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 14 pull requests #89525

Closed
wants to merge 35 commits into from
Closed
Changes from all commits
Commits
Show all changes
35 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
18c14ad
Add a `try_clone()` function to `OwnedFd`.
sunfishcode Sep 9, 2021
622dfcc
Fix Windows compilation errors.
sunfishcode Sep 9, 2021
c986c6b
Fix more Windows compilation errors.
sunfishcode Sep 9, 2021
2d6a4c8
Fix another Windows compilation error.
sunfishcode Sep 9, 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
02d1f83
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
Manishearth Oct 4, 2021
6a00ed9
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
Manishearth Oct 4, 2021
7b1ad3e
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Manishearth Oct 4, 2021
fe0759f
Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se
Manishearth Oct 4, 2021
b5301d8
Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtri…
Manishearth Oct 4, 2021
fd4974b
Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay
Manishearth Oct 4, 2021
54f9a67
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
Manishearth Oct 4, 2021
337ad5b
Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay
Manishearth Oct 4, 2021
dd925cc
Rollup merge of #89444 - notriddle:notriddle/contains-str, r=jyn514
Manishearth Oct 4, 2021
9d081ce
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
Manishearth Oct 4, 2021
e122009
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, …
Manishearth Oct 4, 2021
e11685f
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Manishearth Oct 4, 2021
ecd5bb8
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
Manishearth Oct 4, 2021
2914d1d
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Manishearth 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
@@ -1211,6 +1211,8 @@ impl Expr {
}
}

ExprKind::Underscore => TyKind::Infer,

// This expression doesn't look like a type syntactically.
_ => return None,
};
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/concat_idents.rs
Original file line number Diff line number Diff line change
@@ -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);
}

@@ -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);
}
}
@@ -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);
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
@@ -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
}

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
@@ -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.
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
@@ -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;
@@ -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",
@@ -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",
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
4 changes: 2 additions & 2 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
@@ -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;
}

@@ -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;
}

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
@@ -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.
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
@@ -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),

8 changes: 6 additions & 2 deletions compiler/rustc_index/src/vec.rs
Original file line number Diff line number Diff line change
@@ -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)
@@ -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)
18 changes: 12 additions & 6 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
@@ -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(
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -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
7 changes: 3 additions & 4 deletions compiler/rustc_lint/src/non_ascii_idents.rs
Original file line number Diff line number Diff line change
@@ -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()
});
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
@@ -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();
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
@@ -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
));
}
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
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)]
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
@@ -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));
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion compiler/rustc_save_analysis/src/dump_visitor.rs
Original file line number Diff line number Diff line change
@@ -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, _) => (
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
@@ -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`",
);
}
Loading