Skip to content

Commit 852b7cb

Browse files
committed
Auto merge of #42165 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests - Successful merges: #42016, #42122, #42144, #42145, #42151, #42152, #42160, #42163 - Failed merges:
2 parents 2e91391 + aa7762f commit 852b7cb

File tree

23 files changed

+319
-186
lines changed

23 files changed

+319
-186
lines changed

src/doc/unstable-book/src/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
- [link_llvm_intrinsics](language-features/link-llvm-intrinsics.md)
5050
- [linkage](language-features/linkage.md)
5151
- [log_syntax](language-features/log-syntax.md)
52-
- [loop_break_value](language-features/loop-break-value.md)
5352
- [macro_reexport](language-features/macro-reexport.md)
5453
- [macro_vis_matcher](language-features/macro-vis-matcher.md)
5554
- [main](language-features/main.md)

src/doc/unstable-book/src/language-features/attr-literals.md

+20
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,25 @@ The tracking issue for this feature is: [#34981]
66

77
------------------------
88

9+
At present, literals are only accepted as the value of a key-value pair in
10+
attributes. What's more, only _string_ literals are accepted. This means that
11+
literals can only appear in forms of `#[attr(name = "value")]` or
12+
`#[attr = "value"]`.
913

14+
The `attr_literals` unstable feature allows other types of literals to be used
15+
in attributes. Here are some examples of attributes that can now be used with
16+
this feature enabled:
17+
18+
+```rust,ignore
19+
+#[attr]
20+
+#[attr(true)]
21+
+#[attr(ident)]
22+
+#[attr(ident, 100, true, "true", ident = 100, ident = "hello", ident(100))]
23+
+#[attr(100)]
24+
+#[attr(enabled = true)]
25+
+#[enabled(true)]
26+
+#[attr("hello")]
27+
+#[repr(C, align = 4)]
28+
+#[repr(C, align(4))]
29+
+```
1030

src/doc/unstable-book/src/language-features/catch-expr.md

+23
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,26 @@ The tracking issue for this feature is: [#31436]
55
[#31436]: https://github.com/rust-lang/rust/issues/31436
66

77
------------------------
8+
9+
The `catch_expr` feature adds support for a `catch` expression. The `catch`
10+
expression creates a new scope one can use the `?` operator in.
11+
12+
```rust
13+
#![feature(catch_expr)]
14+
15+
use std::num::ParseIntError;
16+
17+
let result: Result<i32, ParseIntError> = do catch {
18+
Ok("1".parse::<i32>()?
19+
+ "2".parse::<i32>()?
20+
+ "3".parse::<i32>()?)
21+
};
22+
assert_eq!(result, Ok(6));
23+
24+
let result: Result<i32, ParseIntError> = do catch {
25+
Ok("1".parse::<i32>()?
26+
+ "foo".parse::<i32>()?
27+
+ "3".parse::<i32>()?)
28+
};
29+
assert!(result.is_err());
30+
```

src/doc/unstable-book/src/language-features/loop-break-value.md

-83
This file was deleted.

src/doc/unstable-book/src/language-features/on-unimplemented.md

+37
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,42 @@ The tracking issue for this feature is: [#29628]
66

77
------------------------
88

9+
The `on_unimplemented` feature provides the `#[rustc_on_unimplemented]`
10+
attribute, which allows trait definitions to add specialized notes to error
11+
messages when an implementation was expected but not found.
912

13+
For example:
14+
15+
```rust,compile_fail
16+
#![feature(on_unimplemented)]
17+
18+
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an \
19+
iterator over elements of type `{A}`"]
20+
trait MyIterator<A> {
21+
fn next(&mut self) -> A;
22+
}
23+
24+
fn iterate_chars<I: MyIterator<char>>(i: I) {
25+
// ...
26+
}
27+
28+
fn main() {
29+
iterate_chars(&[1, 2, 3][..]);
30+
}
31+
```
32+
33+
When the user compiles this, they will see the following;
34+
35+
```txt
36+
error[E0277]: the trait bound `&[{integer}]: MyIterator<char>` is not satisfied
37+
--> <anon>:14:5
38+
|
39+
14 | iterate_chars(&[1, 2, 3][..]);
40+
| ^^^^^^^^^^^^^ the trait `MyIterator<char>` is not implemented for `&[{integer}]`
41+
|
42+
= note: a collection of type `&[{integer}]` cannot be built from an iterator over elements of type `char`
43+
= note: required by `iterate_chars`
44+
45+
error: aborting due to previous error
46+
```
1047

src/libcollections/slice.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,9 @@ impl<T> [T] {
14101410

14111411
/// Converts `self` into a vector without clones or allocation.
14121412
///
1413+
/// The resulting vector can be converted back into a box via
1414+
/// `Vec<T>`'s `into_boxed_slice` method.
1415+
///
14131416
/// # Examples
14141417
///
14151418
/// ```

0 commit comments

Comments
 (0)