Skip to content

Commit 003d8d3

Browse files
committed
Auto merge of rust-lang#89530 - workingjubilee:rollup-ua14iq6, r=workingjubilee
Rollup of 13 pull requests Successful merges: - rust-lang#83655 ([aarch64] add target feature outline-atomics) - rust-lang#87091 (implement advance_(back_)_by on more iterators) - rust-lang#88451 (Fix an ICE caused by type mismatch errors being ignored) - rust-lang#88452 (VecDeque: improve performance for From<[T; N]>) - rust-lang#89400 (Improve wording of `map_or_else` docs) - rust-lang#89407 (Recommend running `cargo clean` in E0514 output) - rust-lang#89443 (Include the length in BTree hashes) - rust-lang#89444 (rustdoc: use slice::contains instead of open-coding it) - rust-lang#89447 (Improve error message for missing angle brackets in `[_]::method`) - rust-lang#89453 (Consistently use 'supertrait'.) - rust-lang#89483 (Practice diagnostic message convention) - rust-lang#89500 (Fix ICE with buffered lint referring to AST node deleted by everybody_loops) - rust-lang#89508 (Stabilize `const_panic`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 175b8db + 9866b09 commit 003d8d3

File tree

174 files changed

+922
-535
lines changed

Some content is hidden

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

174 files changed

+922
-535
lines changed

compiler/rustc_ast/src/ast.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ impl Expr {
12111211
}
12121212
}
12131213

1214+
ExprKind::Underscore => TyKind::Infer,
1215+
12141216
// This expression doesn't look like a type syntactically.
12151217
_ => return None,
12161218
};

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl<'a> AstValidator<'a> {
590590
)
591591
.span_label(self.current_extern_span(), "in this `extern` block")
592592
.note(&format!(
593-
"This limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
593+
"this limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
594594
n, n,
595595
))
596596
.emit();

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![feature(bool_to_option)]
44
#![feature(box_patterns)]
5-
#![feature(const_panic)]
5+
#![cfg_attr(bootstrap, feature(const_panic))]
66
#![feature(crate_visibility_modifier)]
77
#![feature(format_args_capture)]
88
#![feature(in_band_lifetimes)]

compiler/rustc_builtin_macros/src/concat_idents.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn expand_concat_idents<'cx>(
1212
tts: TokenStream,
1313
) -> Box<dyn base::MacResult + 'cx> {
1414
if tts.is_empty() {
15-
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
15+
cx.span_err(sp, "concat_idents! takes 1 or more arguments");
1616
return DummyResult::any(sp);
1717
}
1818

@@ -22,7 +22,7 @@ pub fn expand_concat_idents<'cx>(
2222
match e {
2323
TokenTree::Token(Token { kind: token::Comma, .. }) => {}
2424
_ => {
25-
cx.span_err(sp, "concat_idents! expecting comma.");
25+
cx.span_err(sp, "concat_idents! expecting comma");
2626
return DummyResult::any(sp);
2727
}
2828
}
@@ -34,7 +34,7 @@ pub fn expand_concat_idents<'cx>(
3434
}
3535
}
3636

37-
cx.span_err(sp, "concat_idents! requires ident args.");
37+
cx.span_err(sp, "concat_idents! requires ident args");
3838
return DummyResult::any(sp);
3939
}
4040
}

compiler/rustc_builtin_macros/src/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
382382
.note(
383383
"errors in this attribute were erroneously \
384384
allowed and will become a hard error in a \
385-
future release.",
385+
future release",
386386
)
387387
.emit();
388388
ShouldPanic::Yes(None)

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
416416
// -Ctarget-features
417417
features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));
418418

419+
// FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
420+
if get_version() >= (12, 0, 0) && sess.target.llvm_target.contains("aarch64-unknown-linux") {
421+
features.push("+outline-atomics".to_string());
422+
}
423+
419424
features
420425
}
421426

compiler/rustc_const_eval/src/transform/check_consts/check.rs

-2
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
887887

888888
// At this point, we are calling a function, `callee`, whose `DefId` is known...
889889
if is_lang_panic_fn(tcx, callee) {
890-
self.check_op(ops::Panic);
891-
892890
// `begin_panic` and `panic_display` are generic functions that accept
893891
// types other than str. Check to enforce that only str can be used in
894892
// const-eval.

compiler/rustc_const_eval/src/transform/check_consts/ops.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,6 @@ impl NonConstOp for MutDeref {
368368
}
369369
}
370370

371-
#[derive(Debug)]
372-
pub struct Panic;
373-
impl NonConstOp for Panic {
374-
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
375-
Status::Unstable(sym::const_panic)
376-
}
377-
378-
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
379-
feature_err(
380-
&ccx.tcx.sess.parse_sess,
381-
sym::const_panic,
382-
span,
383-
&format!("panicking in {}s is unstable", ccx.const_kind()),
384-
)
385-
}
386-
}
387-
388371
/// A call to a `panic()` lang item where the first argument is _not_ a `&str`.
389372
#[derive(Debug)]
390373
pub struct PanicNonStr;
@@ -407,7 +390,7 @@ impl NonConstOp for RawPtrComparison {
407390
let mut err = ccx
408391
.tcx
409392
.sess
410-
.struct_span_err(span, "pointers cannot be reliably compared during const eval.");
393+
.struct_span_err(span, "pointers cannot be reliably compared during const eval");
411394
err.note(
412395
"see issue #53020 <https://github.com/rust-lang/rust/issues/53020> \
413396
for more information",
@@ -443,7 +426,7 @@ impl NonConstOp for RawPtrToIntCast {
443426
let mut err = ccx
444427
.tcx
445428
.sess
446-
.struct_span_err(span, "pointers cannot be cast to integers during const eval.");
429+
.struct_span_err(span, "pointers cannot be cast to integers during const eval");
447430
err.note("at compile-time, pointers do not have an integer value");
448431
err.note(
449432
"avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior",

compiler/rustc_data_structures/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![feature(associated_type_bounds)]
1212
#![feature(auto_traits)]
1313
#![feature(bool_to_option)]
14-
#![feature(const_panic)]
14+
#![cfg_attr(bootstrap, feature(const_panic))]
1515
#![feature(control_flow_enum)]
1616
#![feature(core_intrinsics)]
1717
#![feature(extend_one)]

compiler/rustc_driver/src/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ trait PrinterSupport: pprust::PpAnn {
8888
/// Produces the pretty-print annotation object.
8989
///
9090
/// (Rust does not yet support upcasting from a trait object to
91-
/// an object for one of its super-traits.)
91+
/// an object for one of its supertraits.)
9292
fn pp_ann(&self) -> &dyn pprust::PpAnn;
9393
}
9494

@@ -104,7 +104,7 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
104104
/// Produces the pretty-print annotation object.
105105
///
106106
/// (Rust does not yet support upcasting from a trait object to
107-
/// an object for one of its super-traits.)
107+
/// an object for one of its supertraits.)
108108
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn;
109109
}
110110

compiler/rustc_error_codes/src/error_codes/E0222.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub trait BoxCar : Box + Vehicle {}
1616
fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {} // Invalid constraint
1717
```
1818

19-
In this example, `BoxCar` has two super-traits: `Vehicle` and `Box`. Both of
19+
In this example, `BoxCar` has two supertraits: `Vehicle` and `Box`. Both of
2020
these traits define an associated type `Color`. `BoxCar` inherits two types
21-
with that name from both super-traits. Because of this, we need to use the
21+
with that name from both supertraits. Because of this, we need to use the
2222
fully qualified path syntax to refer to the appropriate `Color` associated
2323
type, either `<BoxCar as Vehicle>::Color` or `<BoxCar as Box>::Color`, but this
2424
syntax is not allowed to be used in a function signature.

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ declare_features! (
297297
(accepted, arbitrary_enum_discriminant, "1.56.0", Some(60553), None),
298298
/// Allows macro attributes to observe output of `#[derive]`.
299299
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
300+
/// Allows panicking during const eval (producing compile-time errors).
301+
(accepted, const_panic, "1.57.0", Some(51999), None),
300302

301303
// -------------------------------------------------------------------------
302304
// feature-group-end: accepted features

compiler/rustc_feature/src/active.rs

-3
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ declare_features! (
425425
/// Allows using the `amdgpu-kernel` ABI.
426426
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
427427

428-
/// Allows panicking during const eval (producing compile-time errors).
429-
(active, const_panic, "1.30.0", Some(51999), None),
430-
431428
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
432429
(active, marker_trait_attr, "1.30.0", Some(29864), None),
433430

compiler/rustc_index/src/vec.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ macro_rules! newtype_index {
124124

125125
#[inline]
126126
$v const fn from_usize(value: usize) -> Self {
127-
// FIXME: replace with `assert!(value <= ($max as usize));` once `const_panic` is stable
127+
#[cfg(not(bootstrap))]
128+
assert!(value <= ($max as usize));
129+
#[cfg(bootstrap)]
128130
[()][(value > ($max as usize)) as usize];
129131
unsafe {
130132
Self::from_u32_unchecked(value as u32)
@@ -133,7 +135,9 @@ macro_rules! newtype_index {
133135

134136
#[inline]
135137
$v const fn from_u32(value: u32) -> Self {
136-
// FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
138+
#[cfg(not(bootstrap))]
139+
assert!(value <= $max);
140+
#[cfg(bootstrap)]
137141
[()][(value > $max) as usize];
138142
unsafe {
139143
Self::from_u32_unchecked(value)

compiler/rustc_interface/src/passes.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,18 @@ pub fn configure_and_expand(
437437
});
438438

439439
// Add all buffered lints from the `ParseSess` to the `Session`.
440-
sess.parse_sess.buffered_lints.with_lock(|buffered_lints| {
441-
info!("{} parse sess buffered_lints", buffered_lints.len());
442-
for early_lint in buffered_lints.drain(..) {
443-
resolver.lint_buffer().add_early_lint(early_lint);
444-
}
445-
});
440+
// The ReplaceBodyWithLoop pass may have deleted some AST nodes, potentially
441+
// causing a delay_span_bug later if a buffered lint refers to such a deleted
442+
// AST node (issue #87308). Since everybody_loops is for pretty-printing only,
443+
// anyway, we simply skip all buffered lints here.
444+
if !matches!(sess.opts.pretty, Some(PpMode::Source(PpSourceMode::EveryBodyLoops))) {
445+
sess.parse_sess.buffered_lints.with_lock(|buffered_lints| {
446+
info!("{} parse sess buffered_lints", buffered_lints.len());
447+
for early_lint in buffered_lints.drain(..) {
448+
resolver.lint_buffer().add_early_lint(early_lint);
449+
}
450+
});
451+
}
446452

447453
Ok(krate)
448454
}

compiler/rustc_lint/src/array_into_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
124124
let mut diag = lint.build(&format!(
125125
"this method call resolves to `<&{} as IntoIterator>::into_iter` \
126126
(due to backwards compatibility), \
127-
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.",
127+
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021",
128128
target, target,
129129
));
130130
diag.span_suggestion(

compiler/rustc_lint/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ impl EarlyLintPass for AnonymousParameters {
918918

919919
lint.build(
920920
"anonymous parameters are deprecated and will be \
921-
removed in the next edition.",
921+
removed in the next edition",
922922
)
923923
.span_suggestion(
924924
arg.pat.span,
@@ -1629,9 +1629,9 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
16291629
let predicates = cx.tcx.predicates_of(item.def_id);
16301630
for &(predicate, span) in predicates.predicates {
16311631
let predicate_kind_name = match predicate.kind().skip_binder() {
1632-
Trait(..) => "Trait",
1632+
Trait(..) => "trait",
16331633
TypeOutlives(..) |
1634-
RegionOutlives(..) => "Lifetime",
1634+
RegionOutlives(..) => "lifetime",
16351635

16361636
// Ignore projections, as they can only be global
16371637
// if the trait bound is global

compiler/rustc_lint/src/non_ascii_idents.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,17 @@ impl EarlyLintPass for NonAsciiIdents {
331331
for ((sp, ch_list), script_set) in lint_reports {
332332
cx.struct_span_lint(MIXED_SCRIPT_CONFUSABLES, sp, |lint| {
333333
let message = format!(
334-
"The usage of Script Group `{}` in this crate consists solely of mixed script confusables",
334+
"the usage of Script Group `{}` in this crate consists solely of mixed script confusables",
335335
script_set);
336-
let mut note = "The usage includes ".to_string();
336+
let mut note = "the usage includes ".to_string();
337337
for (idx, ch) in ch_list.into_iter().enumerate() {
338338
if idx != 0 {
339339
note += ", ";
340340
}
341341
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
342342
note += &char_info;
343343
}
344-
note += ".";
345-
lint.build(&message).note(&note).note("Please recheck to make sure their usages are indeed what you want.").emit()
344+
lint.build(&message).note(&note).note("please recheck to make sure their usages are indeed what you want").emit()
346345
});
347346
}
348347
}

compiler/rustc_metadata/src/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ impl<'a> CrateLoader<'a> {
878878
"no global memory allocator found but one is \
879879
required; link to std or \
880880
add `#[global_allocator]` to a static item \
881-
that implements the GlobalAlloc trait.",
881+
that implements the GlobalAlloc trait",
882882
);
883883
}
884884
self.cstore.allocator_kind = Some(AllocatorKind::Default);

compiler/rustc_metadata/src/locator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,8 @@ impl CrateError {
10301030
add,
10311031
);
10321032
err.help(&format!(
1033-
"please recompile that crate using this compiler ({})",
1033+
"please recompile that crate using this compiler ({}) \
1034+
(consider running `cargo clean` first)",
10341035
rustc_version(),
10351036
));
10361037
let mismatches = locator.crate_rejections.via_version.iter();

compiler/rustc_metadata/src/native_libs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ impl Collector<'tcx> {
319319
self.tcx.sess.err(&format!(
320320
"renaming of the library `{}` was specified, \
321321
however this crate contains no `#[link(...)]` \
322-
attributes referencing this library.",
322+
attributes referencing this library",
323323
lib.name
324324
));
325325
} else if !renames.insert(&lib.name) {
326326
self.tcx.sess.err(&format!(
327327
"multiple renamings were \
328-
specified for library `{}` .",
328+
specified for library `{}`",
329329
lib.name
330330
));
331331
}

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,7 @@ impl<'tcx> TyCtxt<'tcx> {
21172117
})
21182118
}
21192119

2120-
/// Computes the def-ids of the transitive super-traits of `trait_def_id`. This (intentionally)
2120+
/// Computes the def-ids of the transitive supertraits of `trait_def_id`. This (intentionally)
21212121
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
21222122
/// to identify which traits may define a given associated type to help avoid cycle errors.
21232123
/// Returns a `DefId` iterator.

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl<'tcx> Predicate<'tcx> {
599599
// where both `'x` and `'b` would have a DB index of 1.
600600
// The substitution from the input trait-ref is therefore going to be
601601
// `'a => 'x` (where `'x` has a DB index of 1).
602-
// - The super-trait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
602+
// - The supertrait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
603603
// early-bound parameter and `'b' is a late-bound parameter with a
604604
// DB index of 1.
605605
// - If we replace `'a` with `'x` from the input, it too will have

compiler/rustc_mir_dataflow/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(bool_to_option)]
33
#![feature(box_patterns)]
44
#![feature(box_syntax)]
5-
#![feature(const_panic)]
5+
#![cfg_attr(bootstrap, feature(const_panic))]
66
#![feature(exact_size_is_empty)]
77
#![feature(in_band_lifetimes)]
88
#![feature(iter_zip)]

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(box_patterns)]
22
#![feature(box_syntax)]
33
#![feature(crate_visibility_modifier)]
4-
#![feature(const_panic)]
4+
#![cfg_attr(bootstrap, feature(const_panic))]
55
#![feature(in_band_lifetimes)]
66
#![feature(iter_zip)]
77
#![feature(map_try_insert)]

compiler/rustc_passes/src/weak_lang_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
6666
tcx.sess.err("`#[panic_handler]` function required, but not found");
6767
} else if item == LangItem::Oom {
6868
if !tcx.features().default_alloc_error_handler {
69-
tcx.sess.err("`#[alloc_error_handler]` function required, but not found.");
70-
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler.");
69+
tcx.sess.err("`#[alloc_error_handler]` function required, but not found");
70+
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler");
7171
}
7272
} else {
7373
tcx.sess.err(&format!("language item required, but not found: `{}`", name));

compiler/rustc_resolve/src/imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13391339
};
13401340

13411341
if module.is_trait() {
1342-
self.r.session.span_err(import.span, "items in traits are not importable.");
1342+
self.r.session.span_err(import.span, "items in traits are not importable");
13431343
return;
13441344
} else if ptr::eq(module, import.parent_scope.module) {
13451345
return;

compiler/rustc_save_analysis/src/dump_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl<'tcx> DumpVisitor<'tcx> {
682682
);
683683
}
684684

685-
// super-traits
685+
// supertraits
686686
for super_bound in trait_refs.iter() {
687687
let (def_id, sub_span) = match *super_bound {
688688
hir::GenericBound::Trait(ref trait_ref, _) => (

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13841384
// Cannot enable crt-static with sanitizers on Linux
13851385
if sess.crt_static(None) && !sess.opts.debugging_opts.sanitizer.is_empty() {
13861386
sess.err(
1387-
"Sanitizer is incompatible with statically linked libc, \
1387+
"sanitizer is incompatible with statically linked libc, \
13881388
disable it using `-C target-feature=-crt-static`",
13891389
);
13901390
}

0 commit comments

Comments
 (0)