diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 4c9ae4faf7233..45fb638e3b49f 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1770,7 +1770,7 @@ extern "C" { pub fn LLVMDisposeMessage(message: *mut c_char); - pub fn LLVMStartMultithreaded() -> Bool; + pub fn LLVMIsMultithreaded() -> Bool; /// Returns a string describing the last error caused by an LLVMRust* call. pub fn LLVMRustGetLastError() -> *const c_char; diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index b15efcd0dc2b1..54767ef683ffe 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -17,35 +17,25 @@ use std::path::Path; use std::ptr; use std::slice; use std::str; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Once; -static POISONED: AtomicBool = AtomicBool::new(false); static INIT: Once = Once::new(); pub(crate) fn init(sess: &Session) { unsafe { // Before we touch LLVM, make sure that multithreading is enabled. + if llvm::LLVMIsMultithreaded() != 1 { + bug!("LLVM compiled without support for threads"); + } INIT.call_once(|| { - if llvm::LLVMStartMultithreaded() != 1 { - // use an extra bool to make sure that all future usage of LLVM - // cannot proceed despite the Once not running more than once. - POISONED.store(true, Ordering::SeqCst); - } - configure_llvm(sess); }); - - if POISONED.load(Ordering::SeqCst) { - bug!("couldn't enable multi-threaded LLVM"); - } } } fn require_inited() { - INIT.call_once(|| bug!("llvm is not initialized")); - if POISONED.load(Ordering::SeqCst) { - bug!("couldn't enable multi-threaded LLVM"); + if !INIT.is_completed() { + bug!("LLVM is not initialized"); } } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 5418f6fc007ca..aaeb1eeb04397 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -46,6 +46,9 @@ pub trait Qualif { /// Whether this `Qualif` is cleared when a local is moved from. const IS_CLEARED_ON_MOVE: bool = false; + /// Whether this `Qualif` might be evaluated after the promotion and can encounter a promoted. + const ALLOW_PROMOTED: bool = false; + /// Extracts the field of `ConstQualifs` that corresponds to this `Qualif`. fn in_qualifs(qualifs: &ConstQualifs) -> bool; @@ -129,6 +132,7 @@ pub struct NeedsNonConstDrop; impl Qualif for NeedsNonConstDrop { const ANALYSIS_NAME: &'static str = "flow_needs_nonconst_drop"; const IS_CLEARED_ON_MOVE: bool = true; + const ALLOW_PROMOTED: bool = true; fn in_qualifs(qualifs: &ConstQualifs) -> bool { qualifs.needs_non_const_drop @@ -310,9 +314,12 @@ where // Check the qualifs of the value of `const` items. if let Some(ct) = constant.literal.const_for_ty() { if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs_: _, promoted }) = ct.val { - assert!(promoted.is_none()); + // Use qualifs of the type for the promoted. Promoteds in MIR body should be possible + // only for `NeedsNonConstDrop` with precise drop checking. This is the only const + // check performed after the promotion. Verify that with an assertion. + assert!(promoted.is_none() || Q::ALLOW_PROMOTED); // Don't peek inside trait associated constants. - if cx.tcx.trait_of_item(def.did).is_none() { + if promoted.is_none() && cx.tcx.trait_of_item(def.did).is_none() { let qualifs = if let Some((did, param_did)) = def.as_const_arg() { cx.tcx.at(constant.span).mir_const_qualif_const_arg((did, param_did)) } else { diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 847b89f0464f6..dd16e3cde75ae 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -130,6 +130,9 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { traits::NonStructuralMatchTy::Opaque => { "opaque types cannot be used in patterns".to_string() } + traits::NonStructuralMatchTy::Closure => { + "closures cannot be used in patterns".to_string() + } traits::NonStructuralMatchTy::Generator => { "generators cannot be used in patterns".to_string() } diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index ac8bab0cf36a7..a398e847b9354 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -17,6 +17,7 @@ pub enum NonStructuralMatchTy<'tcx> { Dynamic, Foreign, Opaque, + Closure, Generator, Projection, } @@ -154,6 +155,9 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> { ty::Projection(..) => { return ControlFlow::Break(NonStructuralMatchTy::Projection); } + ty::Closure(..) => { + return ControlFlow::Break(NonStructuralMatchTy::Closure); + } ty::Generator(..) | ty::GeneratorWitness(..) => { return ControlFlow::Break(NonStructuralMatchTy::Generator); } @@ -197,7 +201,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> { // First check all contained types and then tell the caller to continue searching. return ty.super_visit_with(self); } - ty::Closure(..) | ty::Infer(_) | ty::Placeholder(_) | ty::Bound(..) => { + ty::Infer(_) | ty::Placeholder(_) | ty::Bound(..) => { bug!("unexpected type during structural-match checking: {:?}", ty); } ty::Error(_) => { diff --git a/config.toml.example b/config.toml.example index 2128fdea2eb46..4dd953a495d67 100644 --- a/config.toml.example +++ b/config.toml.example @@ -609,7 +609,11 @@ changelog-seen = 2 # Enable symbol-mangling-version v0. This can be helpful when profiling rustc, # as generics will be preserved in symbols (rather than erased into opaque T). -#new-symbol-mangling = false +# When no setting is given, the new scheme will be used when compiling the +# compiler and its tools and the legacy scheme will be used when compiling the +# standard library. +# If an explicit setting is given, it will be used for all parts of the codebase. +#new-symbol-mangling = true|false (see comment) # ============================================================================= # Options for specific targets diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 9bded6c0f1cf2..d7620c68f2cae 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -162,9 +162,9 @@ use super::SpecExtend; /// item's ordering relative to any other item, as determined by the [`Ord`] /// trait, changes while it is in the heap. This is normally only possible /// through [`Cell`], [`RefCell`], global state, I/O, or unsafe code. The -/// behavior resulting from such a logic error is not specified, but will -/// not result in undefined behavior. This could include panics, incorrect -/// results, aborts, memory leaks, and non-termination. +/// behavior resulting from such a logic error is not specified (it +/// could include panics, incorrect results, aborts, memory leaks, or +/// non-termination) but will not be undefined behavior. /// /// # Examples /// diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index fa86e611565e6..07920a6dba619 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -61,9 +61,9 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; /// It is a logic error for a key to be modified in such a way that the key's ordering relative to /// any other key, as determined by the [`Ord`] trait, changes while it is in the map. This is /// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code. -/// The behavior resulting from such a logic error is not specified, but will not result in -/// undefined behavior. This could include panics, incorrect results, aborts, memory leaks, and -/// non-termination. +/// The behavior resulting from such a logic error is not specified (it could include panics, +/// incorrect results, aborts, memory leaks, or non-termination) but will not be undefined +/// behavior. /// /// [B-Tree]: https://en.wikipedia.org/wiki/B-tree /// [`Cell`]: core::cell::Cell diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index d732f65b0d05f..237e0107f2475 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -23,9 +23,9 @@ use super::Recover; /// It is a logic error for an item to be modified in such a way that the item's ordering relative /// to any other item, as determined by the [`Ord`] trait, changes while it is in the set. This is /// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code. -/// The behavior resulting from such a logic error is not specified, but will not result in -/// undefined behavior. This could include panics, incorrect results, aborts, memory leaks, and -/// non-termination. +/// The behavior resulting from such a logic error is not specified (it could include panics, +/// incorrect results, aborts, memory leaks, or non-termination) but will not be undefined +/// behavior. /// /// [`Ord`]: core::cmp::Ord /// [`Cell`]: core::cell::Cell diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 5a74f39e8bc8b..7114f2d652e54 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -756,7 +756,7 @@ impl Duration { } else if nanos >= MAX_NANOS_F64 { Err(FromSecsError { kind: FromSecsErrorKind::Overflow }) } else if nanos < 0.0 { - Err(FromSecsError { kind: FromSecsErrorKind::Underflow }) + Err(FromSecsError { kind: FromSecsErrorKind::Negative }) } else { let nanos = nanos as u128; Ok(Duration { @@ -818,7 +818,7 @@ impl Duration { } else if nanos >= MAX_NANOS_F32 { Err(FromSecsError { kind: FromSecsErrorKind::Overflow }) } else if nanos < 0.0 { - Err(FromSecsError { kind: FromSecsErrorKind::Underflow }) + Err(FromSecsError { kind: FromSecsErrorKind::Negative }) } else { let nanos = nanos as u128; Ok(Duration { @@ -1274,11 +1274,9 @@ pub struct FromSecsError { impl FromSecsError { const fn description(&self) -> &'static str { match self.kind { - FromSecsErrorKind::NonFinite => { - "got non-finite value when converting float to duration" - } + FromSecsErrorKind::NonFinite => "non-finite value when converting float to duration", FromSecsErrorKind::Overflow => "overflow when converting float to duration", - FromSecsErrorKind::Underflow => "underflow when converting float to duration", + FromSecsErrorKind::Negative => "negative value when converting float to duration", } } } @@ -1292,10 +1290,10 @@ impl fmt::Display for FromSecsError { #[derive(Debug, Clone, PartialEq, Eq)] enum FromSecsErrorKind { - // Value is not a finite value (either infinity or NaN). + // Value is not a finite value (either + or - infinity or NaN). NonFinite, // Value is too large to store in a `Duration`. Overflow, - // Value is less than `0.0`. - Underflow, + // Value is negative. + Negative, } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 5804701892e6e..546c43faecfdc 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -38,8 +38,8 @@ use super::map::{map_try_reserve_error, RandomState}; /// determined by the [`Eq`] trait, changes while it is in the set. This is /// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or /// unsafe code. The behavior resulting from such a logic error is not -/// specified, but will not result in undefined behavior. This could include -/// panics, incorrect results, aborts, memory leaks, and non-termination. +/// specified (it could include panics, incorrect results, aborts, memory +/// leaks, or non-termination) but will not be undefined behavior. /// /// # Examples /// diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index ac1841b691334..d5656f0f37e03 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -972,8 +972,26 @@ impl<'a> Builder<'a> { } } - if self.config.rust_new_symbol_mangling { + let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling { + Some(setting) => { + // If an explicit setting is given, use that + setting + } + None => { + if mode == Mode::Std { + // The standard library defaults to the legacy scheme + false + } else { + // The compiler and tools default to the new scheme + true + } + } + }; + + if use_new_symbol_mangling { rustflags.arg("-Zsymbol-mangling-version=v0"); + } else { + rustflags.arg("-Zsymbol-mangling-version=legacy"); } // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`, diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8d03aade3413a..68e20f90b7fa4 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -141,7 +141,7 @@ pub struct Config { pub rust_verify_llvm_ir: bool, pub rust_thin_lto_import_instr_limit: Option, pub rust_remap_debuginfo: bool, - pub rust_new_symbol_mangling: bool, + pub rust_new_symbol_mangling: Option, pub rust_profile_use: Option, pub rust_profile_generate: Option, pub llvm_profile_use: Option, @@ -874,7 +874,7 @@ impl Config { config.rust_run_dsymutil = rust.run_dsymutil.unwrap_or(false); optimize = rust.optimize; ignore_git = rust.ignore_git; - set(&mut config.rust_new_symbol_mangling, rust.new_symbol_mangling); + config.rust_new_symbol_mangling = rust.new_symbol_mangling; set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.codegen_tests, rust.codegen_tests); set(&mut config.rust_rpath, rust.rpath); diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index e42b4748fdc78..b9b6add99f883 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -70,7 +70,9 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then echo "Attempting to download $url" rm -f /tmp/rustci_docker_cache set +e - retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o /tmp/rustci_docker_cache "$url" + retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \ + -o /tmp/rustci_docker_cache "$url" + echo "Loading images into docker" loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/') set -e echo "Downloaded containers:\n$loaded_images" diff --git a/src/test/ui/const-generics/defaults/default-annotation.rs b/src/test/ui/const-generics/defaults/default-annotation.rs index 2b41dbb58873e..5517bf8ac5fb2 100644 --- a/src/test/ui/const-generics/defaults/default-annotation.rs +++ b/src/test/ui/const-generics/defaults/default-annotation.rs @@ -2,7 +2,7 @@ #![feature(staged_api)] #![feature(const_generics_defaults)] #![allow(incomplete_features)] -// FIXME(const_generics): It seems like we aren't testing the right thing here, +// FIXME(const_generics_defaults): It seems like we aren't testing the right thing here, // I would assume that we want the attributes to apply to the const parameter defaults // themselves. #![stable(feature = "const_default_test", since="none")] diff --git a/src/test/ui/const-generics/defaults/doesnt_infer.rs b/src/test/ui/const-generics/defaults/doesnt_infer.rs new file mode 100644 index 0000000000000..c7f14e47a9d64 --- /dev/null +++ b/src/test/ui/const-generics/defaults/doesnt_infer.rs @@ -0,0 +1,15 @@ +#![feature(const_generics_defaults)] + +// test that defaulted const params are not used to help type inference + +struct Foo; + +impl Foo { + fn foo() -> Self { loop {} } +} + +fn main() { + let foo = Foo::<1>::foo(); + let foo = Foo::foo(); + //~^ error: type annotations needed for `Foo<{_: u32}>` +} diff --git a/src/test/ui/const-generics/defaults/doesnt_infer.stderr b/src/test/ui/const-generics/defaults/doesnt_infer.stderr new file mode 100644 index 0000000000000..b57975e26f290 --- /dev/null +++ b/src/test/ui/const-generics/defaults/doesnt_infer.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed for `Foo<{_: u32}>` + --> $DIR/doesnt_infer.rs:13:15 + | +LL | let foo = Foo::foo(); + | --- ^^^^^^^^ cannot infer the value of const parameter `N` + | | + | consider giving `foo` the explicit type `Foo<{_: u32}>`, where the type parameter `N` is specified + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait.rs b/src/test/ui/const-generics/defaults/rp_impl_trait.rs new file mode 100644 index 0000000000000..1447ebe5348f6 --- /dev/null +++ b/src/test/ui/const-generics/defaults/rp_impl_trait.rs @@ -0,0 +1,31 @@ +// run-pass +#![feature(const_generics_defaults)] + +struct Uwu; + +trait Trait {} +impl Trait for Uwu {} + +fn rawr() -> impl Trait { + Uwu:: +} + +trait Traitor { } + +impl Traitor for u32 {} +impl Traitor<1, 1> for u64 {} + +fn uwu() -> impl Traitor { + 1_u32 +} + +fn owo() -> impl Traitor { + 1_u64 +} + +fn main() { + rawr::<3>(); + rawr::<7>(); + uwu::<{ u8::MAX }>(); + owo(); +} diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs new file mode 100644 index 0000000000000..c989fc8338b90 --- /dev/null +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs @@ -0,0 +1,33 @@ +#![feature(const_generics_defaults)] + +struct Uwu; + +trait Trait {} +impl Trait for Uwu {} + +fn rawr() -> impl Trait { + //~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied + Uwu::<10, 12> +} + +trait Traitor { } + +impl Traitor for u32 {} +impl Traitor<1, 2> for u64 {} + + +fn uwu() -> impl Traitor { + //~^ error: the trait bound `u32: Traitor` is not satisfied + 1_u32 +} + +fn owo() -> impl Traitor { + //~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied + 1_u64 +} + +fn main() { + rawr(); + uwu(); + owo(); +} diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr new file mode 100644 index 0000000000000..cf28932177a7a --- /dev/null +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -0,0 +1,30 @@ +error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied + --> $DIR/rp_impl_trait_fail.rs:8:14 + | +LL | fn rawr() -> impl Trait { + | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` + | + = help: the following implementations were found: + as Trait> + +error[E0277]: the trait bound `u32: Traitor` is not satisfied + --> $DIR/rp_impl_trait_fail.rs:19:26 + | +LL | fn uwu() -> impl Traitor { + | ^^^^^^^^^^^^^^^ the trait `Traitor` is not implemented for `u32` + | + = help: the following implementations were found: + > + +error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied + --> $DIR/rp_impl_trait_fail.rs:24:13 + | +LL | fn owo() -> impl Traitor { + | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` + | + = help: the following implementations were found: + > + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/defaults/trait_objects.rs b/src/test/ui/const-generics/defaults/trait_objects.rs new file mode 100644 index 0000000000000..e36f23fadb272 --- /dev/null +++ b/src/test/ui/const-generics/defaults/trait_objects.rs @@ -0,0 +1,45 @@ +// run-pass +#![feature(const_generics_defaults)] + +trait Trait { + fn uwu(&self) -> u8 { + N + } +} + +impl Trait for u32 {} + +impl Trait<12> for u64 { + fn uwu(&self) -> u8 { + *self as u8 + } +} + +fn foo(arg: &dyn Trait) -> u8 { + arg.uwu() +} + +trait Traitor { + fn owo(&self) -> u8 { + M + } +} + +impl Traitor<2> for bool { } +impl Traitor for u8 { + fn owo(&self) -> u8 { + *self + } +} + +fn bar(arg: &dyn Traitor) -> u8 { + arg.owo() +} + +fn main() { + assert_eq!(foo(&10_u32), 12); + assert_eq!(foo(&3_u64), 3); + + assert_eq!(bar(&true), 2); + assert_eq!(bar(&1_u8), 1); +} diff --git a/src/test/ui/const-generics/defaults/trait_objects_fail.rs b/src/test/ui/const-generics/defaults/trait_objects_fail.rs new file mode 100644 index 0000000000000..09e4265a7a0ef --- /dev/null +++ b/src/test/ui/const-generics/defaults/trait_objects_fail.rs @@ -0,0 +1,32 @@ +#![feature(const_generics_defaults)] + +trait Trait { + fn uwu(&self) -> u8 { + N + } +} + +impl Trait<2> for u32 {} + +fn foo(arg: &dyn Trait) -> u8 { + arg.uwu() +} + +trait Traitor { + fn owo(&self) -> u8 { + M + } +} + +impl Traitor<2, 3> for bool { } + +fn bar(arg: &dyn Traitor) -> u8 { + arg.owo() +} + +fn main() { + foo(&10_u32); + //~^ error: the trait bound `u32: Trait` is not satisfied + bar(&true); + //~^ error: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied +} diff --git a/src/test/ui/const-generics/defaults/trait_objects_fail.stderr b/src/test/ui/const-generics/defaults/trait_objects_fail.stderr new file mode 100644 index 0000000000000..b097c8cd4bae1 --- /dev/null +++ b/src/test/ui/const-generics/defaults/trait_objects_fail.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `u32: Trait` is not satisfied + --> $DIR/trait_objects_fail.rs:28:9 + | +LL | foo(&10_u32); + | --- ^^^^^^^ the trait `Trait` is not implemented for `u32` + | | + | required by a bound introduced by this call + | + = help: the following implementations were found: + > + = note: required for the cast to the object type `dyn Trait` + +error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied + --> $DIR/trait_objects_fail.rs:30:9 + | +LL | bar(&true); + | --- ^^^^^ the trait `Traitor<{_: u8}, {_: u8}>` is not implemented for `bool` + | | + | required by a bound introduced by this call + | + = help: the following implementations were found: + > + = note: required for the cast to the object type `dyn Traitor<{_: u8}, {_: u8}>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/defaults/wfness.rs b/src/test/ui/const-generics/defaults/wfness.rs new file mode 100644 index 0000000000000..c171f292fd698 --- /dev/null +++ b/src/test/ui/const-generics/defaults/wfness.rs @@ -0,0 +1,21 @@ +#![feature(const_generics_defaults)] + +struct Ooopsies; +//~^ error: evaluation of constant value failed + +trait Trait {} +impl Trait<3> for () {} +struct WhereClause where (): Trait; +//~^ error: the trait bound `(): Trait<2_u8>` is not satisfied + +trait Traitor {} +struct WhereClauseTooGeneric(T) where (): Traitor; + +// no error on struct def +struct DependentDefaultWfness>(T); +fn foo() -> DependentDefaultWfness { + //~^ error: the trait bound `(): Trait<1_u8>` is not satisfied + loop {} +} + +fn main() {} diff --git a/src/test/ui/const-generics/defaults/wfness.stderr b/src/test/ui/const-generics/defaults/wfness.stderr new file mode 100644 index 0000000000000..9826af8802a27 --- /dev/null +++ b/src/test/ui/const-generics/defaults/wfness.stderr @@ -0,0 +1,38 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/wfness.rs:3:33 + | +LL | struct Ooopsies; + | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + +error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied + --> $DIR/wfness.rs:8:47 + | +LL | struct WhereClause where (): Trait; + | ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()` + | + = help: the following implementations were found: + <() as Trait<3_u8>> +note: required by `WhereClause` + --> $DIR/wfness.rs:8:1 + | +LL | struct WhereClause where (): Trait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied + --> $DIR/wfness.rs:16:13 + | +LL | fn foo() -> DependentDefaultWfness { + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()` + | + = help: the following implementations were found: + <() as Trait<3_u8>> +note: required by a bound in `WhereClause` + --> $DIR/wfness.rs:8:47 + | +LL | struct WhereClause where (): Trait; + | ^^^^^^^^ required by this bound in `WhereClause` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0080, E0277. +For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/const-generics/defaults/wrong-order.rs b/src/test/ui/const-generics/defaults/wrong-order.rs index 33564a48448a7..94e7367b1fb76 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.rs +++ b/src/test/ui/const-generics/defaults/wrong-order.rs @@ -5,4 +5,7 @@ struct A { arg: T, } +struct Foo(T); +//~^ error: generic parameters with a default must be trailing + fn main() {} diff --git a/src/test/ui/const-generics/defaults/wrong-order.stderr b/src/test/ui/const-generics/defaults/wrong-order.stderr index 47a2c6f3f4193..143ce5c4fea7e 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.stderr +++ b/src/test/ui/const-generics/defaults/wrong-order.stderr @@ -4,5 +4,11 @@ error: generic parameters with a default must be trailing LL | struct A { | ^ -error: aborting due to previous error +error: generic parameters with a default must be trailing + --> $DIR/wrong-order.rs:8:18 + | +LL | struct Foo(T); + | ^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/closure-structural-match-issue-90013.rs b/src/test/ui/consts/closure-structural-match-issue-90013.rs new file mode 100644 index 0000000000000..7853ee41a9009 --- /dev/null +++ b/src/test/ui/consts/closure-structural-match-issue-90013.rs @@ -0,0 +1,8 @@ +// Regression test for issue 90013. +// check-pass +#![allow(incomplete_features)] +#![feature(inline_const)] + +fn main() { + const { || {} }; +} diff --git a/src/test/ui/consts/precise-drop-with-promoted.rs b/src/test/ui/consts/precise-drop-with-promoted.rs new file mode 100644 index 0000000000000..6f2317a5a27a8 --- /dev/null +++ b/src/test/ui/consts/precise-drop-with-promoted.rs @@ -0,0 +1,9 @@ +// Regression test for issue #89938. +// check-pass +// compile-flags: --crate-type=lib +#![feature(const_precise_live_drops)] + +pub const fn f() { + let _: Option = None; + let _: &'static Option = &None; +} diff --git a/src/test/ui/nll/issue-78561.rs b/src/test/ui/nll/issue-78561.rs new file mode 100644 index 0000000000000..55147fcd1bd27 --- /dev/null +++ b/src/test/ui/nll/issue-78561.rs @@ -0,0 +1,23 @@ +// check-pass +#![feature(type_alias_impl_trait)] + +pub trait Trait { + type A; + + fn f() -> Self::A; +} + +pub trait Tr2<'a, 'b> {} + +pub struct A(T); +pub trait Tr { + type B; +} + +impl<'a, 'b, T: Tr>> Trait for A { + type A = impl core::fmt::Debug; + + fn f() -> Self::A {} +} + +fn main() {} diff --git a/src/test/ui/pattern/non-structural-match-types.rs b/src/test/ui/pattern/non-structural-match-types.rs new file mode 100644 index 0000000000000..713418fc5b29a --- /dev/null +++ b/src/test/ui/pattern/non-structural-match-types.rs @@ -0,0 +1,14 @@ +// edition:2021 +#![allow(incomplete_features)] +#![allow(unreachable_code)] +#![feature(const_async_blocks)] +#![feature(inline_const)] + +fn main() { + match loop {} { + const { || {} } => {}, //~ ERROR cannot be used in patterns + } + match loop {} { + const { async {} } => {}, //~ ERROR cannot be used in patterns + } +} diff --git a/src/test/ui/pattern/non-structural-match-types.stderr b/src/test/ui/pattern/non-structural-match-types.stderr new file mode 100644 index 0000000000000..91fed81eaeff6 --- /dev/null +++ b/src/test/ui/pattern/non-structural-match-types.stderr @@ -0,0 +1,14 @@ +error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used in patterns + --> $DIR/non-structural-match-types.rs:9:9 + | +LL | const { || {} } => {}, + | ^^^^^^^^^^^^^^^ + +error: `impl Future` cannot be used in patterns + --> $DIR/non-structural-match-types.rs:12:9 + | +LL | const { async {} } => {}, + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/query-system/issue-83479.rs b/src/test/ui/query-system/issue-83479.rs new file mode 100644 index 0000000000000..32676dfe9c8fa --- /dev/null +++ b/src/test/ui/query-system/issue-83479.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +type PairCoupledTypes: Trait< + //~^ ERROR: bounds on `type`s in this context have no effect + //~| ERROR: cannot find trait `Trait` in this scope + [u32; { + static FOO: usize; //~ ERROR: free static item without body + }], +> = impl Trait< + //~^ ERROR: cannot find trait `Trait` in this scope + [u32; { + static FOO: usize; //~ ERROR: free static item without body + }], +>; + +fn main() {} diff --git a/src/test/ui/query-system/issue-83479.stderr b/src/test/ui/query-system/issue-83479.stderr new file mode 100644 index 0000000000000..7cb41f5cbe51c --- /dev/null +++ b/src/test/ui/query-system/issue-83479.stderr @@ -0,0 +1,44 @@ +error: bounds on `type`s in this context have no effect + --> $DIR/issue-83479.rs:3:24 + | +LL | type PairCoupledTypes: Trait< + | ________________________^ +LL | | +LL | | +LL | | [u32; { +LL | | static FOO: usize; +LL | | }], +LL | | > = impl Trait< + | |_^ + +error: free static item without body + --> $DIR/issue-83479.rs:7:9 + | +LL | static FOO: usize; + | ^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the static: `= ;` + +error: free static item without body + --> $DIR/issue-83479.rs:12:9 + | +LL | static FOO: usize; + | ^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the static: `= ;` + +error[E0405]: cannot find trait `Trait` in this scope + --> $DIR/issue-83479.rs:3:24 + | +LL | type PairCoupledTypes: Trait< + | ^^^^^ not found in this scope + +error[E0405]: cannot find trait `Trait` in this scope + --> $DIR/issue-83479.rs:9:10 + | +LL | > = impl Trait< + | ^^^^^ not found in this scope + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0405`. diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index a341527c84cf0..4afa36502aca1 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,7 +7,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 1330; +const ROOT_ENTRY_LIMIT: usize = 1331; const ISSUES_ENTRY_LIMIT: usize = 2488; fn check_entries(path: &Path, bad: &mut bool) { diff --git a/triagebot.toml b/triagebot.toml index 1e4df4d3fb79a..48c7a00de7830 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -5,8 +5,8 @@ allow-unauthenticated = [ "requires-nightly", "regression-*", "perf-*", - # I-* without I-nominated - "I-*", "!I-nominated", + # I-* without I-*nominated + "I-*", "!I-*nominated", "AsyncAwait-OnDeck", ]