Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #89530

Merged
merged 30 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dec7fc3
Fix an ICE caused by type mismatch errors being ignored
theo-lw Aug 29, 2021
2ab73cf
add benchmark for From<[T; N]> in VecDeque
xu-cheng Aug 29, 2021
c3cff0a
VecDeque: improve performance for From<[T; N]>
xu-cheng Aug 29, 2021
09d55d5
Remove special checks to is_assign_to_bool
theo-lw Sep 17, 2021
35b0015
Improve wording of `map_or_else` docs
Nitepone Sep 30, 2021
7ed75ce
Recommend running `cargo clean` in E0514 output
pierwill Sep 30, 2021
2c6e671
implement advance_(back_)_by on more iterators
the8472 Jul 12, 2021
6654a0b
from review: code style
the8472 Jul 13, 2021
ffd7ade
fix issues pointed out in review
the8472 Jul 13, 2021
0f9f241
[aarch64] add target feature outline-atomics
Apr 5, 2021
d6fde80
Include the length in BTree hashes
cuviper Oct 1, 2021
d92c683
Improve error message for missing angle brackets in `[_]::method`
FabianWolff Oct 1, 2021
277a018
rustdoc: use slice::contains instead of open-coding it
notriddle Oct 1, 2021
058a21d
Consistently use 'supertrait'.
waywardmonkeys Oct 2, 2021
3818981
Practice diagnostic message convention
hkmatsumoto Oct 3, 2021
a28a78f
Fix ICE with buffered lint referring to AST node deleted by everybody…
FabianWolff Oct 3, 2021
bce8621
Stabilize `const_panic`
jhpratt Oct 4, 2021
4e9cf04
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
workingjubilee Oct 4, 2021
ca8a108
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
workingjubilee Oct 4, 2021
a2c6075
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
workingjubilee Oct 4, 2021
19d9a14
Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se
workingjubilee Oct 4, 2021
9e387cf
Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay
workingjubilee Oct 4, 2021
9381d7a
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
workingjubilee Oct 4, 2021
e1478d6
Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay
workingjubilee Oct 4, 2021
b115a16
Rollup merge of #89444 - notriddle:notriddle/contains-str, r=jyn514
workingjubilee Oct 4, 2021
08dd414
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
workingjubilee Oct 4, 2021
2bc89ce
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, …
workingjubilee Oct 4, 2021
5352e17
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
workingjubilee Oct 4, 2021
3d4467d
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
workingjubilee Oct 4, 2021
9866b09
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
workingjubilee Oct 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@ impl Expr {
}
}

ExprKind::Underscore => TyKind::Infer,

// This expression doesn't look like a type syntactically.
_ => return None,
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ impl<'a> AstValidator<'a> {
)
.span_label(self.current_extern_span(), "in this `extern` block")
.note(&format!(
"This limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
"this limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
n, n,
))
.emit();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(crate_visibility_modifier)]
#![feature(format_args_capture)]
#![feature(in_band_lifetimes)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn expand_concat_idents<'cx>(
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
if tts.is_empty() {
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
cx.span_err(sp, "concat_idents! takes 1 or more arguments");
return DummyResult::any(sp);
}

Expand All @@ -22,7 +22,7 @@ pub fn expand_concat_idents<'cx>(
match e {
TokenTree::Token(Token { kind: token::Comma, .. }) => {}
_ => {
cx.span_err(sp, "concat_idents! expecting comma.");
cx.span_err(sp, "concat_idents! expecting comma");
return DummyResult::any(sp);
}
}
Expand All @@ -34,7 +34,7 @@ pub fn expand_concat_idents<'cx>(
}
}

cx.span_err(sp, "concat_idents! requires ident args.");
cx.span_err(sp, "concat_idents! requires ident args");
return DummyResult::any(sp);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
.note(
"errors in this attribute were erroneously \
allowed and will become a hard error in a \
future release.",
future release",
)
.emit();
ShouldPanic::Yes(None)
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
// -Ctarget-features
features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));

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

features
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_const_eval/src/transform/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {

// At this point, we are calling a function, `callee`, whose `DefId` is known...
if is_lang_panic_fn(tcx, callee) {
self.check_op(ops::Panic);

// `begin_panic` and `panic_display` are generic functions that accept
// types other than str. Check to enforce that only str can be used in
// const-eval.
Expand Down
21 changes: 2 additions & 19 deletions compiler/rustc_const_eval/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,23 +368,6 @@ impl NonConstOp for MutDeref {
}
}

#[derive(Debug)]
pub struct Panic;
impl NonConstOp for Panic {
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
Status::Unstable(sym::const_panic)
}

fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_panic,
span,
&format!("panicking in {}s is unstable", ccx.const_kind()),
)
}
}

/// A call to a `panic()` lang item where the first argument is _not_ a `&str`.
#[derive(Debug)]
pub struct PanicNonStr;
Expand All @@ -407,7 +390,7 @@ impl NonConstOp for RawPtrComparison {
let mut err = ccx
.tcx
.sess
.struct_span_err(span, "pointers cannot be reliably compared during const eval.");
.struct_span_err(span, "pointers cannot be reliably compared during const eval");
err.note(
"see issue #53020 <https://github.com/rust-lang/rust/issues/53020> \
for more information",
Expand Down Expand Up @@ -443,7 +426,7 @@ impl NonConstOp for RawPtrToIntCast {
let mut err = ccx
.tcx
.sess
.struct_span_err(span, "pointers cannot be cast to integers during const eval.");
.struct_span_err(span, "pointers cannot be cast to integers during const eval");
err.note("at compile-time, pointers do not have an integer value");
err.note(
"avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![feature(associated_type_bounds)]
#![feature(auto_traits)]
#![feature(bool_to_option)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(control_flow_enum)]
#![feature(core_intrinsics)]
#![feature(extend_one)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ trait PrinterSupport: pprust::PpAnn {
/// Produces the pretty-print annotation object.
///
/// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.)
/// an object for one of its supertraits.)
fn pp_ann(&self) -> &dyn pprust::PpAnn;
}

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

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0222.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub trait BoxCar : Box + Vehicle {}
fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {} // Invalid constraint
```

In this example, `BoxCar` has two super-traits: `Vehicle` and `Box`. Both of
In this example, `BoxCar` has two supertraits: `Vehicle` and `Box`. Both of
these traits define an associated type `Color`. `BoxCar` inherits two types
with that name from both super-traits. Because of this, we need to use the
with that name from both supertraits. Because of this, we need to use the
fully qualified path syntax to refer to the appropriate `Color` associated
type, either `<BoxCar as Vehicle>::Color` or `<BoxCar as Box>::Color`, but this
syntax is not allowed to be used in a function signature.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ declare_features! (
(accepted, arbitrary_enum_discriminant, "1.56.0", Some(60553), None),
/// Allows macro attributes to observe output of `#[derive]`.
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
/// Allows panicking during const eval (producing compile-time errors).
(accepted, const_panic, "1.57.0", Some(51999), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,6 @@ declare_features! (
/// Allows using the `amdgpu-kernel` ABI.
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),

/// Allows panicking during const eval (producing compile-time errors).
(active, const_panic, "1.30.0", Some(51999), None),

/// Allows `#[marker]` on certain traits allowing overlapping implementations.
(active, marker_trait_attr, "1.30.0", Some(29864), None),

Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_index/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ macro_rules! newtype_index {

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

#[inline]
$v const fn from_u32(value: u32) -> Self {
// FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
#[cfg(not(bootstrap))]
assert!(value <= $max);
#[cfg(bootstrap)]
[()][(value > $max) as usize];
unsafe {
Self::from_u32_unchecked(value)
Expand Down
18 changes: 12 additions & 6 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,18 @@ pub fn configure_and_expand(
});

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

Ok(krate)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
let mut diag = lint.build(&format!(
"this method call resolves to `<&{} as IntoIterator>::into_iter` \
(due to backwards compatibility), \
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.",
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021",
target, target,
));
diag.span_suggestion(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ impl EarlyLintPass for AnonymousParameters {

lint.build(
"anonymous parameters are deprecated and will be \
removed in the next edition.",
removed in the next edition",
)
.span_suggestion(
arg.pat.span,
Expand Down Expand Up @@ -1629,9 +1629,9 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
let predicates = cx.tcx.predicates_of(item.def_id);
for &(predicate, span) in predicates.predicates {
let predicate_kind_name = match predicate.kind().skip_binder() {
Trait(..) => "Trait",
Trait(..) => "trait",
TypeOutlives(..) |
RegionOutlives(..) => "Lifetime",
RegionOutlives(..) => "lifetime",

// Ignore projections, as they can only be global
// if the trait bound is global
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_lint/src/non_ascii_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,17 @@ impl EarlyLintPass for NonAsciiIdents {
for ((sp, ch_list), script_set) in lint_reports {
cx.struct_span_lint(MIXED_SCRIPT_CONFUSABLES, sp, |lint| {
let message = format!(
"The usage of Script Group `{}` in this crate consists solely of mixed script confusables",
"the usage of Script Group `{}` in this crate consists solely of mixed script confusables",
script_set);
let mut note = "The usage includes ".to_string();
let mut note = "the usage includes ".to_string();
for (idx, ch) in ch_list.into_iter().enumerate() {
if idx != 0 {
note += ", ";
}
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
note += &char_info;
}
note += ".";
lint.build(&message).note(&note).note("Please recheck to make sure their usages are indeed what you want.").emit()
lint.build(&message).note(&note).note("please recheck to make sure their usages are indeed what you want").emit()
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ impl<'a> CrateLoader<'a> {
"no global memory allocator found but one is \
required; link to std or \
add `#[global_allocator]` to a static item \
that implements the GlobalAlloc trait.",
that implements the GlobalAlloc trait",
);
}
self.cstore.allocator_kind = Some(AllocatorKind::Default);
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,8 @@ impl CrateError {
add,
);
err.help(&format!(
"please recompile that crate using this compiler ({})",
"please recompile that crate using this compiler ({}) \
(consider running `cargo clean` first)",
rustc_version(),
));
let mismatches = locator.crate_rejections.via_version.iter();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ impl Collector<'tcx> {
self.tcx.sess.err(&format!(
"renaming of the library `{}` was specified, \
however this crate contains no `#[link(...)]` \
attributes referencing this library.",
attributes referencing this library",
lib.name
));
} else if !renames.insert(&lib.name) {
self.tcx.sess.err(&format!(
"multiple renamings were \
specified for library `{}` .",
specified for library `{}`",
lib.name
));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,7 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

/// Computes the def-ids of the transitive super-traits of `trait_def_id`. This (intentionally)
/// Computes the def-ids of the transitive supertraits of `trait_def_id`. This (intentionally)
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
/// to identify which traits may define a given associated type to help avoid cycle errors.
/// Returns a `DefId` iterator.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ impl<'tcx> Predicate<'tcx> {
// where both `'x` and `'b` would have a DB index of 1.
// The substitution from the input trait-ref is therefore going to be
// `'a => 'x` (where `'x` has a DB index of 1).
// - The super-trait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
// - The supertrait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
// early-bound parameter and `'b' is a late-bound parameter with a
// DB index of 1.
// - If we replace `'a` with `'x` from the input, it too will have
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(exact_size_is_empty)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(map_try_insert)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
tcx.sess.err("`#[panic_handler]` function required, but not found");
} else if item == LangItem::Oom {
if !tcx.features().default_alloc_error_handler {
tcx.sess.err("`#[alloc_error_handler]` function required, but not found.");
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler.");
tcx.sess.err("`#[alloc_error_handler]` function required, but not found");
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler");
}
} else {
tcx.sess.err(&format!("language item required, but not found: `{}`", name));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
};

if module.is_trait() {
self.r.session.span_err(import.span, "items in traits are not importable.");
self.r.session.span_err(import.span, "items in traits are not importable");
return;
} else if ptr::eq(module, import.parent_scope.module) {
return;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_save_analysis/src/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ impl<'tcx> DumpVisitor<'tcx> {
);
}

// super-traits
// supertraits
for super_bound in trait_refs.iter() {
let (def_id, sub_span) = match *super_bound {
hir::GenericBound::Trait(ref trait_ref, _) => (
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
// Cannot enable crt-static with sanitizers on Linux
if sess.crt_static(None) && !sess.opts.debugging_opts.sanitizer.is_empty() {
sess.err(
"Sanitizer is incompatible with statically linked libc, \
"sanitizer is incompatible with statically linked libc, \
disable it using `-C target-feature=-crt-static`",
);
}
Expand Down
Loading