Skip to content

Commit b28ffa5

Browse files
authored
Auto merge of #35743 - jonathandturner:rollup, r=jonathandturner
Rollup of 24 pull requests - Successful merges: #34370, #35415, #35595, #35610, #35613, #35614, #35621, #35660, #35663, #35670, #35671, #35672, #35681, #35686, #35690, #35691, #35695, #35707, #35708, #35713, #35722, #35725, #35726, #35731 - Failed merges: #35395
2 parents d6d0590 + 11be7c0 commit b28ffa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+574
-387
lines changed

mk/main.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
######################################################################
1414

1515
# The version number
16-
CFG_RELEASE_NUM=1.12.0
16+
CFG_RELEASE_NUM=1.13.0
1717

1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release

src/doc/book/associated-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ trait Graph {
6767
Simple enough. Associated types use the `type` keyword, and go inside the body
6868
of the trait, with the functions.
6969

70-
These `type` declarations can have all the same thing as functions do. For example,
70+
These type declarations work the same way as those for functions. For example,
7171
if we wanted our `N` type to implement `Display`, so we can print the nodes out,
7272
we could do this:
7373

src/doc/book/closures.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ the result:
262262

263263
```rust
264264
fn call_with_one<F>(some_closure: F) -> i32
265-
where F : Fn(i32) -> i32 {
265+
where F: Fn(i32) -> i32 {
266266

267267
some_closure(1)
268268
}
@@ -279,7 +279,7 @@ Let’s examine the signature of `call_with_one` in more depth:
279279

280280
```rust
281281
fn call_with_one<F>(some_closure: F) -> i32
282-
# where F : Fn(i32) -> i32 {
282+
# where F: Fn(i32) -> i32 {
283283
# some_closure(1) }
284284
```
285285

@@ -288,7 +288,7 @@ isn’t interesting. The next part is:
288288

289289
```rust
290290
# fn call_with_one<F>(some_closure: F) -> i32
291-
where F : Fn(i32) -> i32 {
291+
where F: Fn(i32) -> i32 {
292292
# some_closure(1) }
293293
```
294294

src/doc/book/lang-items.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ fn main(argc: isize, argv: *const *const u8) -> isize {
5757
0
5858
}
5959
60-
#[lang = "eh_personality"] extern fn eh_personality() {}
61-
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
60+
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
61+
#[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { loop {} }
6262
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
6363
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
6464
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
@@ -73,8 +73,8 @@ Other features provided by lang items include:
7373
`==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
7474
marked with lang items; those specific four are `eq`, `ord`,
7575
`deref`, and `add` respectively.
76-
- stack unwinding and general failure; the `eh_personality`, `fail`
77-
and `fail_bounds_checks` lang items.
76+
- stack unwinding and general failure; the `eh_personality`,
77+
`eh_unwind_resume`, `fail` and `fail_bounds_checks` lang items.
7878
- the traits in `std::marker` used to indicate types of
7979
various kinds; lang items `send`, `sync` and `copy`.
8080
- the marker types and variance indicators found in

src/doc/book/no-stdlib.md

+25-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
5555
// provided by libstd.
5656
#[lang = "eh_personality"]
5757
#[no_mangle]
58-
pub extern fn eh_personality() {
58+
pub extern fn rust_eh_personality() {
59+
}
60+
61+
// This function may be needed based on the compilation target.
62+
#[lang = "eh_unwind_resume"]
63+
#[no_mangle]
64+
pub extern fn rust_eh_unwind_resume() {
5965
}
6066
6167
#[lang = "panic_fmt"]
@@ -87,12 +93,18 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
8793
0
8894
}
8995
90-
// These functions and traits are used by the compiler, but not
96+
// These functions are used by the compiler, but not
9197
// for a bare-bones hello world. These are normally
9298
// provided by libstd.
9399
#[lang = "eh_personality"]
94100
#[no_mangle]
95-
pub extern fn eh_personality() {
101+
pub extern fn rust_eh_personality() {
102+
}
103+
104+
// This function may be needed based on the compilation target.
105+
#[lang = "eh_unwind_resume"]
106+
#[no_mangle]
107+
pub extern fn rust_eh_unwind_resume() {
96108
}
97109
98110
#[lang = "panic_fmt"]
@@ -104,23 +116,28 @@ pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
104116
}
105117
```
106118

107-
## More about the langauge items
119+
## More about the language items
108120

109121
The compiler currently makes a few assumptions about symbols which are
110122
available in the executable to call. Normally these functions are provided by
111123
the standard library, but without it you must define your own. These symbols
112124
are called "language items", and they each have an internal name, and then a
113125
signature that an implementation must conform to.
114126

115-
The first of these two functions, `eh_personality`, is used by the failure
127+
The first of these functions, `rust_eh_personality`, is used by the failure
116128
mechanisms of the compiler. This is often mapped to GCC's personality function
117129
(see the [libstd implementation][unwind] for more information), but crates
118130
which do not trigger a panic can be assured that this function is never
119-
called. Both the language item and the symbol name are `eh_personality`.
120-
131+
called. The language item's name is `eh_personality`.
132+
121133
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
122134

123-
The second function, `panic_fmt`, is also used by the failure mechanisms of the
135+
The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
124136
compiler. When a panic happens, this controls the message that's displayed on
125137
the screen. While the language item's name is `panic_fmt`, the symbol name is
126138
`rust_begin_panic`.
139+
140+
A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
141+
flag is set in the options of the compilation target. It allows customizing the
142+
process of resuming unwind at the end of the landing pads. The language item's name
143+
is `eh_unwind_resume`.

src/doc/grammar.md

+5
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ token : simple_token | ident | literal | symbol | whitespace token ;
172172
Each of these keywords has special meaning in its grammar, and all of them are
173173
excluded from the `ident` rule.
174174

175+
Not all of these keywords are used by the language. Some of them were used
176+
before Rust 1.0, and were left reserved once their implementations were
177+
removed. Some of them were reserved before 1.0 to make space for possible
178+
future features.
179+
175180
### Literals
176181

177182
```antlr

src/libcollections/vec.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,15 @@ pub struct IntoIter<T> {
17131713
end: *const T,
17141714
}
17151715

1716+
#[stable(feature = "vec_intoiter_debug", since = "")]
1717+
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
1718+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1719+
f.debug_tuple("IntoIter")
1720+
.field(&self.as_slice())
1721+
.finish()
1722+
}
1723+
}
1724+
17161725
impl<T> IntoIter<T> {
17171726
/// Returns the remaining items of this iterator as a slice.
17181727
///

src/libcollectionstest/vec.rs

+8
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ fn test_into_iter_as_mut_slice() {
501501
assert_eq!(into_iter.as_slice(), &['y', 'c']);
502502
}
503503

504+
#[test]
505+
fn test_into_iter_debug() {
506+
let vec = vec!['a', 'b', 'c'];
507+
let into_iter = vec.into_iter();
508+
let debug = format!("{:?}", into_iter);
509+
assert_eq!(debug, "IntoIter(['a', 'b', 'c'])");
510+
}
511+
504512
#[test]
505513
fn test_into_iter_count() {
506514
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);

src/libcore/iter/range.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,8 @@ impl<A: Step> ops::Range<A> {
295295
///
296296
/// ```
297297
/// #![feature(step_by)]
298-
///
299-
/// for i in (0..10).step_by(2) {
300-
/// println!("{}", i);
301-
/// }
302-
/// ```
303-
///
304-
/// This prints:
305-
///
306-
/// ```text
307-
/// 0
308-
/// 2
309-
/// 4
310-
/// 6
311-
/// 8
298+
/// let result: Vec<_> = (0..10).step_by(2).collect();
299+
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
312300
/// ```
313301
#[unstable(feature = "step_by", reason = "recent addition",
314302
issue = "27741")]
@@ -650,4 +638,3 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
650638
n
651639
}
652640
}
653-

src/libcore/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
//! line. It is up to consumers of this core library to define this panic
4343
//! function; it is only required to never return. This requires a `lang`
4444
//! attribute named `panic_fmt`.
45+
//!
46+
//! * `rust_eh_personality` - is used by the failure mechanisms of the
47+
//! compiler. This is often mapped to GCC's personality function, but crates
48+
//! which do not trigger a panic can be assured that this function is never
49+
//! called. The `lang` attribute is called `eh_personality`.
4550
4651
// Since libcore defines many fundamental lang items, all tests live in a
4752
// separate crate, libcoretest, to avoid bizarre issues.

src/libcore/ops.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010

1111
//! Overloadable operators.
1212
//!
13-
//! Implementing these traits allows you to get an effect similar to
14-
//! overloading operators.
13+
//! Implementing these traits allows you to overload certain operators.
1514
//!
1615
//! Some of these traits are imported by the prelude, so they are available in
17-
//! every Rust program.
16+
//! every Rust program. Only operators backed by traits can be overloaded. For
17+
//! example, the addition operator (`+`) can be overloaded through the `Add`
18+
//! trait, but since the assignment operator (`=`) has no backing trait, there
19+
//! is no way of overloading its semantics. Additionally, this module does not
20+
//! provide any mechanism to create new operators. If traitless overloading or
21+
//! custom operators are required, you should look toward macros or compiler
22+
//! plugins to extend Rust's syntax.
1823
//!
1924
//! Many of the operators take their operands by value. In non-generic
2025
//! contexts involving built-in types, this is usually not a problem.

src/librustc_const_eval/check_match.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,12 @@ fn check_irrefutable(cx: &MatchCheckCtxt, pat: &Pat, is_fn_arg: bool) {
10731073
};
10741074

10751075
is_refutable(cx, pat, |uncovered_pat| {
1076-
span_err!(cx.tcx.sess, pat.span, E0005,
1076+
let pattern_string = pat_to_string(uncovered_pat);
1077+
struct_span_err!(cx.tcx.sess, pat.span, E0005,
10771078
"refutable pattern in {}: `{}` not covered",
10781079
origin,
1079-
pat_to_string(uncovered_pat),
1080-
);
1080+
pattern_string,
1081+
).span_label(pat.span, &format!("pattern `{}` not covered", pattern_string)).emit();
10811082
});
10821083
}
10831084

src/librustc_mir/transform/qualify_consts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
277277
} else {
278278
"cannot refer to statics by value, use a constant instead"
279279
};
280-
span_err!(self.tcx.sess, self.span, E0394, "{}", msg);
280+
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
281+
.span_label(self.span, &format!("referring to another static by value"))
282+
.note(&format!("use the address-of operator or a constant instead"))
283+
.emit();
281284

282285
// Replace STATIC with NOT_CONST to avoid further errors.
283286
self.qualif = self.qualif - Qualif::STATIC;

src/librustc_passes/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
283283
Ok(Ordering::Less) |
284284
Ok(Ordering::Equal) => {}
285285
Ok(Ordering::Greater) => {
286-
span_err!(self.tcx.sess,
287-
start.span,
288-
E0030,
289-
"lower range bound must be less than or equal to upper");
286+
struct_span_err!(self.tcx.sess, start.span, E0030,
287+
"lower range bound must be less than or equal to upper")
288+
.span_label(start.span, &format!("lower bound larger than upper bound"))
289+
.emit();
290290
}
291291
Err(ErrorReported) => {}
292292
}

src/librustc_resolve/lib.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ enum ResolutionError<'a> {
116116
/// error E0408: variable `{}` from pattern #{} is not bound in pattern #{}
117117
VariableNotBoundInPattern(Name, usize, usize),
118118
/// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
119-
VariableBoundWithDifferentMode(Name, usize),
119+
VariableBoundWithDifferentMode(Name, usize, Span),
120120
/// error E0411: use of `Self` outside of an impl or trait
121121
SelfUsedOutsideImplOrTrait,
122122
/// error E0412: use of undeclared
@@ -269,14 +269,19 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
269269
from,
270270
to)
271271
}
272-
ResolutionError::VariableBoundWithDifferentMode(variable_name, pattern_number) => {
273-
struct_span_err!(resolver.session,
272+
ResolutionError::VariableBoundWithDifferentMode(variable_name,
273+
pattern_number,
274+
first_binding_span) => {
275+
let mut err = struct_span_err!(resolver.session,
274276
span,
275277
E0409,
276278
"variable `{}` is bound with different mode in pattern #{} than in \
277279
pattern #1",
278280
variable_name,
279-
pattern_number)
281+
pattern_number);
282+
err.span_label(span, &format!("bound in different ways"));
283+
err.span_label(first_binding_span, &format!("first binding"));
284+
err
280285
}
281286
ResolutionError::SelfUsedOutsideImplOrTrait => {
282287
let mut err = struct_span_err!(resolver.session,
@@ -316,11 +321,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
316321
err
317322
}
318323
ResolutionError::DoesNotNameAStruct(name) => {
319-
struct_span_err!(resolver.session,
324+
let mut err = struct_span_err!(resolver.session,
320325
span,
321326
E0422,
322327
"`{}` does not name a structure",
323-
name)
328+
name);
329+
err.span_label(span, &format!("not a structure"));
330+
err
324331
}
325332
ResolutionError::StructVariantUsedAsFunction(path_name) => {
326333
struct_span_err!(resolver.session,
@@ -2028,8 +2035,10 @@ impl<'a> Resolver<'a> {
20282035
if binding_0.binding_mode != binding_i.binding_mode {
20292036
resolve_error(self,
20302037
binding_i.span,
2031-
ResolutionError::VariableBoundWithDifferentMode(key.name,
2032-
i + 1));
2038+
ResolutionError::VariableBoundWithDifferentMode(
2039+
key.name,
2040+
i + 1,
2041+
binding_0.span));
20332042
}
20342043
}
20352044
}

src/librustc_resolve/resolve_imports.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,12 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
584584
source);
585585
self.session.add_lint(PRIVATE_IN_PUBLIC, directive.id, directive.span, msg);
586586
} else {
587-
let msg = format!("`{}` is private, and cannot be reexported", source);
588-
let note_msg =
589-
format!("consider declaring type or module `{}` with `pub`", source);
590-
struct_span_err!(self.session, directive.span, E0365, "{}", &msg)
591-
.span_note(directive.span, &note_msg)
592-
.emit();
587+
let mut err = struct_span_err!(self.session, directive.span, E0365,
588+
"`{}` is private, and cannot be reexported",
589+
source);
590+
err.span_label(directive.span, &format!("reexport of private `{}`", source));
591+
err.note(&format!("consider declaring type or module `{}` with `pub`", source));
592+
err.emit();
593593
}
594594
}
595595

0 commit comments

Comments
 (0)