diff options
Diffstat (limited to 'tests')
384 files changed, 3644 insertions, 3597 deletions
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index 267da060240..90073ff3081 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -1,10 +1,10 @@ -//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code #![crate_type = "lib"] #![feature(fn_align)] // CHECK: align 16 -#[no_mangle] +#[unsafe(no_mangle)] #[align(16)] pub fn fn_align() {} @@ -12,12 +12,12 @@ pub struct A; impl A { // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn method_align(self) {} // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn associated_fn() {} } @@ -25,46 +25,94 @@ impl A { trait T: Sized { fn trait_fn() {} - // CHECK: align 32 - #[align(32)] fn trait_method(self) {} + + #[align(8)] + fn trait_method_inherit_low(self); + + #[align(32)] + fn trait_method_inherit_high(self); + + #[align(32)] + fn trait_method_inherit_default(self) {} + + #[align(4)] + #[align(128)] + #[align(8)] + fn inherit_highest(self) {} } impl T for A { - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_fn + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_fn() {} - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_method + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_method(self) {} -} -impl T for () {} + // The prototype's align is ignored because the align here is higher. + // CHECK-LABEL: trait_method_inherit_low + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_low(self) {} + + // The prototype's align is used because it is higher. + // CHECK-LABEL: trait_method_inherit_high + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_high(self) {} + + // The prototype's align inherited. + // CHECK-LABEL: trait_method_inherit_default + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + fn trait_method_inherit_default(self) {} + + // The prototype's highest align inherited. + // CHECK-LABEL: inherit_highest + // CHECK-SAME: align 128 + #[unsafe(no_mangle)] + #[align(32)] + #[align(64)] + fn inherit_highest(self) {} +} -pub fn foo() { - ().trait_method(); +trait HasDefaultImpl: Sized { + // CHECK-LABEL: inherit_from_default_method + // CHECK-LABEL: inherit_from_default_method + // CHECK-SAME: align 32 + #[align(32)] + fn inherit_from_default_method(self) {} } +pub struct InstantiateDefaultMethods; + +impl HasDefaultImpl for InstantiateDefaultMethods {} + // CHECK-LABEL: align_specified_twice_1 // CHECK-SAME: align 64 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(64)] pub fn align_specified_twice_1() {} // CHECK-LABEL: align_specified_twice_2 // CHECK-SAME: align 128 -#[no_mangle] +#[unsafe(no_mangle)] #[align(128)] #[align(32)] pub fn align_specified_twice_2() {} // CHECK-LABEL: align_specified_twice_3 // CHECK-SAME: align 256 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(256)] pub fn align_specified_twice_3() {} diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index f0708a7a109..c8cd8526ae5 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(rustc_attrs)] -#![feature(dyn_star)] #![feature(allocator_api)] use std::marker::PhantomPinned; @@ -277,11 +276,3 @@ pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> { pub fn enum_id_2(x: Option<u8>) -> Option<u8> { x } - -// CHECK: { ptr, {{.+}} } @dyn_star(ptr noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) -// Expect an ABI something like `{ {}*, [3 x i64]* }`, but that's hard to match on generically, -// so do like the `trait_box` test and just match on `{{.+}}` for the vtable. -#[no_mangle] -pub fn dyn_star(x: dyn* Drop) -> dyn* Drop { - x -} diff --git a/tests/crashes/116979.rs b/tests/crashes/116979.rs deleted file mode 100644 index 28bbc972ea3..00000000000 --- a/tests/crashes/116979.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #116979 -//@ compile-flags: -Csymbol-mangling-version=v0 -//@ needs-rustc-debug-assertions - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Display; - -pub fn require_dyn_star_display(_: dyn* Display) {} - -fn main() { - require_dyn_star_display(1usize); -} diff --git a/tests/crashes/119694.rs b/tests/crashes/119694.rs deleted file mode 100644 index f655ea1cd34..00000000000 --- a/tests/crashes/119694.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #119694 -#![feature(dyn_star)] - -trait Trait { - fn foo(self); -} - -impl Trait for usize { - fn foo(self) {} -} - -fn bar(x: dyn* Trait) { - x.foo(); -} - -fn main() { - bar(0usize); -} diff --git a/tests/crashes/132882.rs b/tests/crashes/132882.rs deleted file mode 100644 index 6b5e4dba803..00000000000 --- a/tests/crashes/132882.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #132882 - -use std::ops::Add; - -pub trait Numoid -where - for<N: Numoid> &'a Self: Add<Self>, -{ -} - -pub fn compute<N: Numoid>(a: N) -> N { - &a + a -} diff --git a/tests/incremental/issue-54242.rs b/tests/incremental/issue-54242.rs index 9fa5363e004..17bbd619a8f 100644 --- a/tests/incremental/issue-54242.rs +++ b/tests/incremental/issue-54242.rs @@ -14,7 +14,7 @@ impl Tr for str { type Arr = [u8; 8]; #[cfg(cfail)] type Arr = [u8; Self::C]; - //[cfail]~^ ERROR cycle detected when evaluating type-level constant + //[cfail]~^ ERROR cycle detected when caching mir } fn main() {} diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 483def62fc7..dbe0f692aef 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -5,9 +5,12 @@ // See https://github.com/rust-lang/rust/issues/107910 //@ needs-target-std -//@ ignore-i686-pc-windows-msvc -// Reason: the assert_eq! on line 37 fails, almost seems like it missing debug info? -// Haven't been able to reproduce locally, but it happens on CI. +//@ ignore-windows-msvc +// +// - FIXME(#143198): On `i686-pc-windows-msvc`: the assert_eq! on line 37 fails, almost seems like +// it missing debug info? Haven't been able to reproduce locally, but it happens on CI. +// - FIXME(#143198): On `x86_64-pc-windows-msvc`: full backtrace sometimes do not contain matching +// count of short backtrace markers (e.g. 5x end marker, but 3x start marker). use run_make_support::rustc; diff --git a/tests/rustdoc-json/attrs/link_section_2021.rs b/tests/rustdoc-json/attrs/link_section_2021.rs new file mode 100644 index 00000000000..a1312f4210b --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2021.rs @@ -0,0 +1,6 @@ +//@ edition: 2021 +#![no_std] + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[link_section = ".text"] +pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/link_section_2024.rs b/tests/rustdoc-json/attrs/link_section_2024.rs new file mode 100644 index 00000000000..edb028451a8 --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2024.rs @@ -0,0 +1,9 @@ +//@ edition: 2024 +#![no_std] + +// Since the 2024 edition the link_section attribute must use the unsafe qualification. +// However, the unsafe qualification is not shown by rustdoc. + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[unsafe(link_section = ".text")] +pub extern "C" fn example() {} diff --git a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr index 401020224d6..3e116826c49 100644 --- a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr +++ b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/invalid_infered_static_and_const.rs:1:24 | LL | const FOO: dyn Fn() -> _ = ""; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/invalid_infered_static_and_const.rs:2:25 | LL | static BOO: dyn Fn() -> _ = ""; diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 692c24f0544..64194e72888 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -19,12 +19,6 @@ extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; -use stable_mir::crate_def::CrateDef; -use stable_mir::mir::alloc::GlobalAlloc; -use stable_mir::mir::mono::{Instance, InstanceKind, StaticDef}; -use stable_mir::mir::{Body, TerminatorKind}; -use stable_mir::ty::{Allocation, ConstantKind, RigidTy, TyKind}; -use stable_mir::{CrateItem, CrateItems, ItemKind}; use std::ascii::Char; use std::assert_matches::assert_matches; use std::cmp::{max, min}; @@ -33,6 +27,13 @@ use std::ffi::CStr; use std::io::Write; use std::ops::ControlFlow; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::Body; +use stable_mir::mir::alloc::GlobalAlloc; +use stable_mir::mir::mono::{Instance, StaticDef}; +use stable_mir::ty::{Allocation, ConstantKind}; +use stable_mir::{CrateItem, CrateItems, ItemKind}; + const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. @@ -44,7 +45,6 @@ fn test_stable_mir() -> ControlFlow<()> { check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap()); check_cstr(*get_item(&items, (ItemKind::Static, "C_STR")).unwrap()); check_other_consts(*get_item(&items, (ItemKind::Fn, "other_consts")).unwrap()); - check_type_id(*get_item(&items, (ItemKind::Fn, "check_type_id")).unwrap()); ControlFlow::Continue(()) } @@ -107,7 +107,9 @@ fn check_other_consts(item: CrateItem) { // Instance body will force constant evaluation. let body = Instance::try_from(item).unwrap().body().unwrap(); let assigns = collect_consts(&body); - assert_eq!(assigns.len(), 8); + assert_eq!(assigns.len(), 10); + let mut char_id = None; + let mut bool_id = None; for (name, alloc) in assigns { match name.as_str() { "_max_u128" => { @@ -149,35 +151,21 @@ fn check_other_consts(item: CrateItem) { assert_eq!(max(first, second) as u32, u32::MAX); assert_eq!(min(first, second), 10); } + "_bool_id" => { + bool_id = Some(alloc); + } + "_char_id" => { + char_id = Some(alloc); + } _ => { unreachable!("{name} -- {alloc:?}") } } } -} - -/// Check that we can retrieve the type id of char and bool, and that they have different values. -fn check_type_id(item: CrateItem) { - let body = Instance::try_from(item).unwrap().body().unwrap(); - let mut ids: Vec<u128> = vec![]; - for term in body.blocks.iter().map(|bb| &bb.terminator) { - match &term.kind { - TerminatorKind::Call { func, destination, .. } => { - let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { - unreachable!() - }; - let RigidTy::FnDef(def, args) = ty else { unreachable!() }; - let instance = Instance::resolve(def, &args).unwrap(); - assert_eq!(instance.kind, InstanceKind::Intrinsic); - let dest_ty = destination.ty(body.locals()).unwrap(); - let alloc = instance.try_const_eval(dest_ty).unwrap(); - ids.push(alloc.read_uint().unwrap()); - } - _ => { /* Do nothing */ } - } - } - assert_eq!(ids.len(), 2); - assert_ne!(ids[0], ids[1]); + let bool_id = bool_id.unwrap(); + let char_id = char_id.unwrap(); + // FIXME(stable_mir): add `read_ptr` to `Allocation` + assert_ne!(bool_id, char_id); } /// Collects all the constant assignments. @@ -235,6 +223,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { file, r#" #![feature(core_intrinsics)] + #![expect(internal_features)] use std::intrinsics::type_id; static LEN: usize = 2; @@ -254,11 +243,8 @@ fn generate_input(path: &str) -> std::io::Result<()> { let _ptr = &BAR; let _null_ptr: *const u8 = NULL; let _tuple = TUPLE; - }} - - fn check_type_id() {{ - let _char_id = type_id::<char>(); - let _bool_id = type_id::<bool>(); + let _char_id = const {{ type_id::<char>() }}; + let _bool_id = const {{ type_id::<bool>() }}; }} pub fn main() {{ diff --git a/tests/ui/SUMMARY.md b/tests/ui/SUMMARY.md index 72b673dd50a..8de74d41f39 100644 --- a/tests/ui/SUMMARY.md +++ b/tests/ui/SUMMARY.md @@ -484,10 +484,6 @@ The `dyn` keyword is used to highlight that calls to methods on the associated T See [`dyn` keyword](https://doc.rust-lang.org/std/keyword.dyn.html). -## `tests/ui/dyn-star/`: `dyn*`, Sized `dyn`, `#![feature(dyn_star)]` - -See [Tracking issue for dyn-star #102425](https://github.com/rust-lang/rust/issues/102425). - ## `tests/ui/editions/`: Rust edition-specific peculiarities These tests run in specific Rust editions, such as Rust 2015 or Rust 2018, and check errors and functionality related to specific now-deprecated idioms and features. diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs index a718eb23bed..e583b12b1d7 100644 --- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs +++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs @@ -12,7 +12,7 @@ fn take( K = { () } >, ) {} -//~^^^^^^ ERROR implementation of `Project` is not general enough +//~^^^^^ ERROR implementation of `Project` is not general enough //~^^^^ ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr index 967814c9c3d..42e084f39c0 100644 --- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr +++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr @@ -13,10 +13,14 @@ LL | K = { () } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Project` is not general enough - --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:9:4 + --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:10:13 | -LL | fn take( - | ^^^^ implementation of `Project` is not general enough +LL | _: impl Trait< + | _____________^ +LL | | <<for<'a> fn(&'a str) -> &'a str as Project>::Out as Discard>::Out, +LL | | K = { () } +LL | | >, + | |_____^ implementation of `Project` is not general enough | = note: `Project` would have to be implemented for the type `for<'a> fn(&'a str) -> &'a str` = note: ...but `Project` is actually implemented for the type `fn(&'0 str) -> &'0 str`, for some specific lifetime `'0` diff --git a/tests/ui/associated-inherent-types/issue-111879-0.stderr b/tests/ui/associated-inherent-types/issue-111879-0.stderr index f60fd58c23b..144f6486b3b 100644 --- a/tests/ui/associated-inherent-types/issue-111879-0.stderr +++ b/tests/ui/associated-inherent-types/issue-111879-0.stderr @@ -1,8 +1,8 @@ error: overflow evaluating associated type `Carrier<'b>::Focus<i32>` - --> $DIR/issue-111879-0.rs:9:25 + --> $DIR/issue-111879-0.rs:9:5 | LL | pub type Focus<T> = &'a mut for<'b> fn(Carrier<'b>::Focus<i32>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/normalization-overflow.stderr b/tests/ui/associated-inherent-types/normalization-overflow.stderr index 7f991a53c9b..05aad31c5f4 100644 --- a/tests/ui/associated-inherent-types/normalization-overflow.stderr +++ b/tests/ui/associated-inherent-types/normalization-overflow.stderr @@ -1,8 +1,8 @@ error: overflow evaluating associated type `T::This` - --> $DIR/normalization-overflow.rs:9:17 + --> $DIR/normalization-overflow.rs:9:5 | LL | type This = Self::This; - | ^^^^^^^^^^ + | ^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/regionck-1.stderr b/tests/ui/associated-inherent-types/regionck-1.stderr index 62a00868248..4e0ecc3c80e 100644 --- a/tests/ui/associated-inherent-types/regionck-1.stderr +++ b/tests/ui/associated-inherent-types/regionck-1.stderr @@ -1,10 +1,11 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regionck-1.rs:9:30 + --> $DIR/regionck-1.rs:9:5 | LL | type NoTyOutliv<'a, T> = &'a T; - | -- ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at - | | - | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^^^^^^^--^^^^ + | | | + | | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,10 +13,10 @@ LL | type NoTyOutliv<'a, T: 'a> = &'a T; | ++++ error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references - --> $DIR/regionck-1.rs:10:31 + --> $DIR/regionck-1.rs:10:5 | LL | type NoReOutliv<'a, 'b> = &'a &'b (); - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regionck-1.rs:10:21 diff --git a/tests/ui/associated-types/impl-wf-cycle-4.stderr b/tests/ui/associated-types/impl-wf-cycle-4.stderr index c966579aecf..fac06e64a31 100644 --- a/tests/ui/associated-types/impl-wf-cycle-4.stderr +++ b/tests/ui/associated-types/impl-wf-cycle-4.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` +error[E0391]: cycle detected when computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type --> $DIR/impl-wf-cycle-4.rs:5:1 | LL | / impl<T> Filter for T @@ -6,14 +6,14 @@ LL | | where LL | | T: Fn(Self::ToMatch), | |_________________________^ | -note: ...which requires computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type... +note: ...which requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`... --> $DIR/impl-wf-cycle-4.rs:5:1 | LL | / impl<T> Filter for T LL | | where LL | | T: Fn(Self::ToMatch), | |_________________________^ - = note: ...which again requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`, completing the cycle + = note: ...which again requires computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type, completing the cycle note: cycle used when checking that `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` is well-formed --> $DIR/impl-wf-cycle-4.rs:5:1 | diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs index c9be1369f16..60d3b224a5b 100644 --- a/tests/ui/associated-types/issue-38821.rs +++ b/tests/ui/associated-types/issue-38821.rs @@ -32,16 +32,16 @@ pub trait Column: Expression {} //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied +pub enum ColumnInsertValue<Col, Expr> where +//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied + Col: Column, + Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, +//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied -pub enum ColumnInsertValue<Col, Expr> where -//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - Col: Column, - Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, { Expression(Col, Expr), Default(Col), diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index 8a19142b730..b03a3cf7f47 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:40:1 + --> $DIR/issue-38821.rs:35:1 | LL | pub enum ColumnInsertValue<Col, Expr> where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` @@ -17,16 +17,10 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co | +++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:40:1 + --> $DIR/issue-38821.rs:38:22 | -LL | / pub enum ColumnInsertValue<Col, Expr> where -LL | | -LL | | -LL | | Col: Column, -... | -LL | | Default(Col), -LL | | } - | |_^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -71,11 +65,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider further restricting the associated type - | -LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, - | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:10 @@ -90,12 +79,13 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:10 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -104,7 +94,10 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting the associated type + | +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, + | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:17 @@ -125,10 +118,10 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:17 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -137,7 +130,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting the associated type | LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, @@ -174,11 +166,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider further restricting the associated type - | -LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, - | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:23 @@ -193,12 +180,13 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:23 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -207,7 +195,10 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting the associated type + | +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, + | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:10 @@ -225,10 +216,10 @@ LL | impl<T: NotNull> IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:10 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -237,7 +228,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:23 @@ -255,10 +245,10 @@ LL | impl<T: NotNull> IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:23 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 diff --git a/tests/ui/associated-types/issue-59324.rs b/tests/ui/associated-types/issue-59324.rs index 3abe8473052..9d4c7cb39ae 100644 --- a/tests/ui/associated-types/issue-59324.rs +++ b/tests/ui/associated-types/issue-59324.rs @@ -10,8 +10,8 @@ pub trait Service { pub trait ThriftService<Bug: NotFoo>: //~^ ERROR the trait bound `Bug: Foo` is not satisfied -//~| ERROR the trait bound `Bug: Foo` is not satisfied Service<AssocType = <Bug as Foo>::OnlyFoo> +//~^ ERROR the trait bound `Bug: Foo` is not satisfied { fn get_service( //~^ ERROR the trait bound `Bug: Foo` is not satisfied diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr index f79afc89d10..3e2b0f41889 100644 --- a/tests/ui/associated-types/issue-59324.stderr +++ b/tests/ui/associated-types/issue-59324.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:11:1 | LL | / pub trait ThriftService<Bug: NotFoo>: -... | +LL | | LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> | |______________________________________________^ the trait `Foo` is not implemented for `Bug` | @@ -12,15 +12,10 @@ LL | pub trait ThriftService<Bug: NotFoo + Foo>: | +++++ error[E0277]: the trait bound `Bug: Foo` is not satisfied - --> $DIR/issue-59324.rs:11:1 + --> $DIR/issue-59324.rs:13:13 | -LL | / pub trait ThriftService<Bug: NotFoo>: -LL | | -LL | | -LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> -... | -LL | | } - | |_^ the trait `Foo` is not implemented for `Bug` +LL | Service<AssocType = <Bug as Foo>::OnlyFoo> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug` | help: consider further restricting type parameter `Bug` with trait `Foo` | diff --git a/tests/ui/async-await/async-fn/impl-header.stderr b/tests/ui/async-await/async-fn/impl-header.stderr index 64a98aab17b..2fc7a900a1e 100644 --- a/tests/ui/async-await/async-fn/impl-header.stderr +++ b/tests/ui/async-await/async-fn/impl-header.stderr @@ -22,6 +22,14 @@ LL | impl async Fn<()> for F {} | = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/impl-header.rs:5:1 + | +LL | impl async Fn<()> for F {} + | ^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: ()) -> <Self as FnOnce<()>>::Output { todo!() }` + error[E0277]: expected a `FnMut()` closure, found `F` --> $DIR/impl-header.rs:5:23 | @@ -33,14 +41,6 @@ LL | impl async Fn<()> for F {} note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/impl-header.rs:5:1 - | -LL | impl async Fn<()> for F {} - | ^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: ()) -> <Self as FnOnce<()>>::Output { todo!() }` - error: aborting due to 5 previous errors Some errors have detailed explanations: E0046, E0183, E0277, E0658. diff --git a/tests/ui/attributes/inner-attrs-impl-cfg.rs b/tests/ui/attributes/inner-attrs-impl-cfg.rs new file mode 100644 index 00000000000..e7a5cfa9e2f --- /dev/null +++ b/tests/ui/attributes/inner-attrs-impl-cfg.rs @@ -0,0 +1,36 @@ +//! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions. +//! +//! This test verifies that: +//! - Inner attributes can conditionally exclude entire impl blocks +//! - Regular attributes within impl blocks work independently +//! - Attribute parsing doesn't consume too eagerly + +//@ run-pass + +struct Foo; + +impl Foo { + #![cfg(false)] + + fn method(&self) -> bool { + false + } +} + +impl Foo { + #![cfg(not(FALSE))] + + // Check that we don't eat attributes too eagerly. + #[cfg(false)] + fn method(&self) -> bool { + false + } + + fn method(&self) -> bool { + true + } +} + +pub fn main() { + assert!(Foo.method()); +} diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs new file mode 100644 index 00000000000..64c0d223f83 --- /dev/null +++ b/tests/ui/attributes/malformed-attrs.rs @@ -0,0 +1,221 @@ +// This file contains a bunch of malformed attributes. +// We enable a bunch of features to not get feature-gate errs in this test. +#![feature(rustc_attrs)] +#![feature(rustc_allow_const_fn_unstable)] +#![feature(allow_internal_unstable)] +#![feature(fn_align)] +#![feature(optimize_attribute)] +#![feature(dropck_eyepatch)] +#![feature(export_stable)] +#![allow(incomplete_features)] +#![feature(min_generic_const_args)] +#![feature(ffi_const, ffi_pure)] +#![feature(coverage_attribute)] +#![feature(no_sanitize)] +#![feature(marker_trait_attr)] +#![feature(thread_local)] +#![feature(must_not_suspend)] +#![feature(coroutines)] +#![feature(linkage)] +#![feature(cfi_encoding, extern_types)] +#![feature(patchable_function_entry)] +#![feature(omit_gdb_pretty_printer_section)] +#![feature(fundamental)] + + +#![omit_gdb_pretty_printer_section = 1] +//~^ ERROR malformed `omit_gdb_pretty_printer_section` attribute input + +#![windows_subsystem] +//~^ ERROR malformed + +#[unsafe(export_name)] +//~^ ERROR malformed +#[rustc_allow_const_fn_unstable] +//~^ ERROR `rustc_allow_const_fn_unstable` expects a list of feature names +#[allow_internal_unstable] +//~^ ERROR `allow_internal_unstable` expects a list of feature names +#[rustc_confusables] +//~^ ERROR malformed +#[deprecated = 5] +//~^ ERROR malformed +#[doc] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[rustc_macro_transparency] +//~^ ERROR malformed +#[repr] +//~^ ERROR malformed +#[rustc_as_ptr = 5] +//~^ ERROR malformed +#[inline = 5] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[align] +//~^ ERROR malformed +#[optimize] +//~^ ERROR malformed +#[cold = 1] +//~^ ERROR malformed +#[must_use()] +//~^ ERROR valid forms for the attribute are +#[no_mangle = 1] +//~^ ERROR malformed +#[unsafe(naked())] +//~^ ERROR malformed +#[track_caller()] +//~^ ERROR malformed +#[export_name()] +//~^ ERROR malformed +#[used()] +//~^ ERROR malformed +#[crate_name] +//~^ ERROR malformed +#[doc] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[target_feature] +//~^ ERROR malformed +#[export_stable = 1] +//~^ ERROR malformed +#[link] +//~^ ERROR attribute must be of the form +//~| WARN this was previously accepted by the compiler +#[link_name] +//~^ ERROR malformed +#[link_section] +//~^ ERROR malformed +#[coverage] +//~^ ERROR malformed `coverage` attribute input +#[no_sanitize] +//~^ ERROR malformed +#[ignore()] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[no_implicit_prelude = 23] +//~^ ERROR malformed +#[proc_macro = 18] +//~^ ERROR malformed +//~| ERROR the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type +#[cfg] +//~^ ERROR is not followed by parentheses +#[cfg_attr] +//~^ ERROR malformed +#[instruction_set] +//~^ ERROR malformed +#[patchable_function_entry] +//~^ ERROR malformed +fn test() { + #[coroutine = 63] || {} + //~^ ERROR malformed `coroutine` attribute input + //~| ERROR mismatched types [E0308] +} + +#[proc_macro_attribute = 19] +//~^ ERROR malformed +//~| ERROR the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type +#[must_use = 1] +//~^ ERROR malformed +fn test2() { } + +#[proc_macro_derive] +//~^ ERROR malformed `proc_macro_derive` attribute +//~| ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type +pub fn test3() {} + +#[rustc_layout_scalar_valid_range_start] +//~^ ERROR malformed +#[rustc_layout_scalar_valid_range_end] +//~^ ERROR malformed +#[must_not_suspend()] +//~^ ERROR malformed +#[cfi_encoding] +//~^ ERROR malformed +struct Test; + +#[diagnostic::on_unimplemented] +//~^ WARN missing options for `on_unimplemented` attribute +#[diagnostic::on_unimplemented = 1] +//~^ WARN malformed +trait Hey { + #[type_const = 1] + //~^ ERROR malformed + const HEY: usize = 5; +} + +struct Empty; +#[diagnostic::do_not_recommend()] +//~^ WARN does not expect any arguments +impl Hey for Empty { + +} + +#[marker = 3] +//~^ ERROR malformed +#[fundamental()] +//~^ ERROR malformed +trait EmptyTrait { + +} + + +extern "C" { + #[unsafe(ffi_pure = 1)] + //~^ ERROR malformed + #[link_ordinal] + //~^ ERROR malformed + pub fn baz(); + + #[unsafe(ffi_const = 1)] + //~^ ERROR malformed + #[linkage] + //~^ ERROR malformed + pub fn bar(); +} + +#[allow] +//~^ ERROR malformed +#[expect] +//~^ ERROR malformed +#[warn] +//~^ ERROR malformed +#[deny] +//~^ ERROR malformed +#[forbid] +//~^ ERROR malformed +#[debugger_visualizer] +//~^ ERROR invalid argument +//~| ERROR malformed `debugger_visualizer` attribute input +#[automatically_derived = 18] +//~^ ERROR malformed +mod yooo { + +} + +#[non_exhaustive = 1] +//~^ ERROR malformed +enum Slenum { + +} + +#[thread_local()] +//~^ ERROR malformed +static mut TLS: u8 = 42; + +#[no_link()] +//~^ ERROR malformed +#[macro_use = 1] +//~^ ERROR malformed +extern crate wloop; +//~^ ERROR can't find crate for `wloop` [E0463] + +#[macro_export = 18] +//~^ ERROR malformed `macro_export` attribute input +#[allow_internal_unsafe = 1] +//~^ ERROR malformed +//~| ERROR allow_internal_unsafe side-steps the unsafe_code lint +macro_rules! slump { + () => {} +} + +fn main() {} diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr new file mode 100644 index 00000000000..bf063e8f6e5 --- /dev/null +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -0,0 +1,596 @@ +error: `cfg` is not followed by parentheses + --> $DIR/malformed-attrs.rs:100:1 + | +LL | #[cfg] + | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` + +error: malformed `cfg_attr` attribute input + --> $DIR/malformed-attrs.rs:102:1 + | +LL | #[cfg_attr] + | ^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> +help: missing condition and attribute + | +LL | #[cfg_attr(condition, attribute, other_attribute, ...)] + | ++++++++++++++++++++++++++++++++++++++++++++ + +error[E0463]: can't find crate for `wloop` + --> $DIR/malformed-attrs.rs:209:1 + | +LL | extern crate wloop; + | ^^^^^^^^^^^^^^^^^^^ can't find crate + +error: malformed `omit_gdb_pretty_printer_section` attribute input + --> $DIR/malformed-attrs.rs:26:1 + | +LL | #![omit_gdb_pretty_printer_section = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![omit_gdb_pretty_printer_section]` + +error: malformed `windows_subsystem` attribute input + --> $DIR/malformed-attrs.rs:29:1 + | +LL | #![windows_subsystem] + | ^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![windows_subsystem = "windows|console"]` + +error: malformed `crate_name` attribute input + --> $DIR/malformed-attrs.rs:72:1 + | +LL | #[crate_name] + | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]` + +error: malformed `target_feature` attribute input + --> $DIR/malformed-attrs.rs:77:1 + | +LL | #[target_feature] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` + +error: malformed `export_stable` attribute input + --> $DIR/malformed-attrs.rs:79:1 + | +LL | #[export_stable = 1] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_stable]` + +error: malformed `coverage` attribute input + --> $DIR/malformed-attrs.rs:88:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ + +error: malformed `no_sanitize` attribute input + --> $DIR/malformed-attrs.rs:90:1 + | +LL | #[no_sanitize] + | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]` + +error: malformed `no_implicit_prelude` attribute input + --> $DIR/malformed-attrs.rs:95:1 + | +LL | #[no_implicit_prelude = 23] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[no_implicit_prelude]` + +error: malformed `proc_macro` attribute input + --> $DIR/malformed-attrs.rs:97:1 + | +LL | #[proc_macro = 18] + | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro]` + +error: malformed `instruction_set` attribute input + --> $DIR/malformed-attrs.rs:104:1 + | +LL | #[instruction_set] + | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` + +error: malformed `patchable_function_entry` attribute input + --> $DIR/malformed-attrs.rs:106:1 + | +LL | #[patchable_function_entry] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + +error: malformed `coroutine` attribute input + --> $DIR/malformed-attrs.rs:109:5 + | +LL | #[coroutine = 63] || {} + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[coroutine]` + +error: malformed `proc_macro_attribute` attribute input + --> $DIR/malformed-attrs.rs:114:1 + | +LL | #[proc_macro_attribute = 19] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_attribute]` + +error: malformed `proc_macro_derive` attribute input + --> $DIR/malformed-attrs.rs:121:1 + | +LL | #[proc_macro_derive] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + +error: malformed `must_not_suspend` attribute input + --> $DIR/malformed-attrs.rs:130:1 + | +LL | #[must_not_suspend()] + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[must_not_suspend()] +LL + #[must_not_suspend = "reason"] + | +LL - #[must_not_suspend()] +LL + #[must_not_suspend] + | + +error: malformed `cfi_encoding` attribute input + --> $DIR/malformed-attrs.rs:132:1 + | +LL | #[cfi_encoding] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` + +error: malformed `type_const` attribute input + --> $DIR/malformed-attrs.rs:141:5 + | +LL | #[type_const = 1] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[type_const]` + +error: malformed `marker` attribute input + --> $DIR/malformed-attrs.rs:153:1 + | +LL | #[marker = 3] + | ^^^^^^^^^^^^^ help: must be of the form: `#[marker]` + +error: malformed `fundamental` attribute input + --> $DIR/malformed-attrs.rs:155:1 + | +LL | #[fundamental()] + | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[fundamental]` + +error: malformed `ffi_pure` attribute input + --> $DIR/malformed-attrs.rs:163:5 + | +LL | #[unsafe(ffi_pure = 1)] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[ffi_pure]` + +error: malformed `link_ordinal` attribute input + --> $DIR/malformed-attrs.rs:165:5 + | +LL | #[link_ordinal] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_ordinal(ordinal)]` + +error: malformed `ffi_const` attribute input + --> $DIR/malformed-attrs.rs:169:5 + | +LL | #[unsafe(ffi_const = 1)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[ffi_const]` + +error: malformed `linkage` attribute input + --> $DIR/malformed-attrs.rs:171:5 + | +LL | #[linkage] + | ^^^^^^^^^^ help: must be of the form: `#[linkage = "external|internal|..."]` + +error: malformed `allow` attribute input + --> $DIR/malformed-attrs.rs:176:1 + | +LL | #[allow] + | ^^^^^^^^ help: must be of the form: `#[allow(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `expect` attribute input + --> $DIR/malformed-attrs.rs:178:1 + | +LL | #[expect] + | ^^^^^^^^^ help: must be of the form: `#[expect(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `warn` attribute input + --> $DIR/malformed-attrs.rs:180:1 + | +LL | #[warn] + | ^^^^^^^ help: must be of the form: `#[warn(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `deny` attribute input + --> $DIR/malformed-attrs.rs:182:1 + | +LL | #[deny] + | ^^^^^^^ help: must be of the form: `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `forbid` attribute input + --> $DIR/malformed-attrs.rs:184:1 + | +LL | #[forbid] + | ^^^^^^^^^ help: must be of the form: `#[forbid(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `debugger_visualizer` attribute input + --> $DIR/malformed-attrs.rs:186:1 + | +LL | #[debugger_visualizer] + | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]` + +error: malformed `automatically_derived` attribute input + --> $DIR/malformed-attrs.rs:189:1 + | +LL | #[automatically_derived = 18] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[automatically_derived]` + +error: malformed `non_exhaustive` attribute input + --> $DIR/malformed-attrs.rs:195:1 + | +LL | #[non_exhaustive = 1] + | ^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[non_exhaustive]` + +error: malformed `thread_local` attribute input + --> $DIR/malformed-attrs.rs:201:1 + | +LL | #[thread_local()] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` + +error: malformed `no_link` attribute input + --> $DIR/malformed-attrs.rs:205:1 + | +LL | #[no_link()] + | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` + +error: malformed `macro_use` attribute input + --> $DIR/malformed-attrs.rs:207:1 + | +LL | #[macro_use = 1] + | ^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[macro_use = 1] +LL + #[macro_use(name1, name2, ...)] + | +LL - #[macro_use = 1] +LL + #[macro_use] + | + +error: malformed `macro_export` attribute input + --> $DIR/malformed-attrs.rs:212:1 + | +LL | #[macro_export = 18] + | ^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[macro_export = 18] +LL + #[macro_export(local_inner_macros)] + | +LL - #[macro_export = 18] +LL + #[macro_export] + | + +error: malformed `allow_internal_unsafe` attribute input + --> $DIR/malformed-attrs.rs:214:1 + | +LL | #[allow_internal_unsafe = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[allow_internal_unsafe]` + +error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:97:1 + | +LL | #[proc_macro = 18] + | ^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:114:1 + | +LL | #[proc_macro_attribute = 19] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:121:1 + | +LL | #[proc_macro_derive] + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint + --> $DIR/malformed-attrs.rs:214:1 + | +LL | #[allow_internal_unsafe = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allow_internal_unsafe)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:42:1 + | +LL | #[doc] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:74:1 + | +LL | #[doc] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-attrs.rs:81:1 + | +LL | #[link] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: valid forms for the attribute are `#[ignore]` and `#[ignore = "reason"]` + --> $DIR/malformed-attrs.rs:92:1 + | +LL | #[ignore()] + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: invalid argument + --> $DIR/malformed-attrs.rs:186:1 + | +LL | #[debugger_visualizer] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected: `natvis_file = "..."` + = note: OR + = note: expected: `gdb_script_file = "..."` + +error[E0539]: malformed `export_name` attribute input + --> $DIR/malformed-attrs.rs:32:1 + | +LL | #[unsafe(export_name)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` + +error: `rustc_allow_const_fn_unstable` expects a list of feature names + --> $DIR/malformed-attrs.rs:34:1 + | +LL | #[rustc_allow_const_fn_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `allow_internal_unstable` expects a list of feature names + --> $DIR/malformed-attrs.rs:36:1 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0539]: malformed `rustc_confusables` attribute input + --> $DIR/malformed-attrs.rs:38:1 + | +LL | #[rustc_confusables] + | ^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` + +error[E0539]: malformed `deprecated` attribute input + --> $DIR/malformed-attrs.rs:40:1 + | +LL | #[deprecated = 5] + | ^^^^^^^^^^^^^^^-^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[deprecated = 5] +LL + #[deprecated = "reason"] + | +LL - #[deprecated = 5] +LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] + | +LL - #[deprecated = 5] +LL + #[deprecated] + | + +error[E0539]: malformed `rustc_macro_transparency` attribute input + --> $DIR/malformed-attrs.rs:45:1 + | +LL | #[rustc_macro_transparency] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_macro_transparency = "transparent|semitransparent|opaque"]` + +error[E0539]: malformed `repr` attribute input + --> $DIR/malformed-attrs.rs:47:1 + | +LL | #[repr] + | ^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + +error[E0565]: malformed `rustc_as_ptr` attribute input + --> $DIR/malformed-attrs.rs:49:1 + | +LL | #[rustc_as_ptr = 5] + | ^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_as_ptr]` + +error[E0539]: malformed `align` attribute input + --> $DIR/malformed-attrs.rs:54:1 + | +LL | #[align] + | ^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[align(<alignment in bytes>)]` + +error[E0539]: malformed `optimize` attribute input + --> $DIR/malformed-attrs.rs:56:1 + | +LL | #[optimize] + | ^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[optimize(size|speed|none)]` + +error[E0565]: malformed `cold` attribute input + --> $DIR/malformed-attrs.rs:58:1 + | +LL | #[cold = 1] + | ^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[cold]` + +error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]` + --> $DIR/malformed-attrs.rs:60:1 + | +LL | #[must_use()] + | ^^^^^^^^^^^^^ + +error[E0565]: malformed `no_mangle` attribute input + --> $DIR/malformed-attrs.rs:62:1 + | +LL | #[no_mangle = 1] + | ^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[no_mangle]` + +error[E0565]: malformed `naked` attribute input + --> $DIR/malformed-attrs.rs:64:1 + | +LL | #[unsafe(naked())] + | ^^^^^^^^^^^^^^--^^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[naked]` + +error[E0565]: malformed `track_caller` attribute input + --> $DIR/malformed-attrs.rs:66:1 + | +LL | #[track_caller()] + | ^^^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[track_caller]` + +error[E0539]: malformed `export_name` attribute input + --> $DIR/malformed-attrs.rs:68:1 + | +LL | #[export_name()] + | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` + +error[E0805]: malformed `used` attribute input + --> $DIR/malformed-attrs.rs:70:1 + | +LL | #[used()] + | ^^^^^^--^ + | | + | expected a single argument here + | +help: try changing it to one of the following valid forms of the attribute + | +LL | #[used(compiler|linker)] + | +++++++++++++++ +LL - #[used()] +LL + #[used] + | + +error[E0539]: malformed `link_name` attribute input + --> $DIR/malformed-attrs.rs:84:1 + | +LL | #[link_name] + | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` + +error[E0539]: malformed `link_section` attribute input + --> $DIR/malformed-attrs.rs:86:1 + | +LL | #[link_section] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` + +error[E0539]: malformed `must_use` attribute input + --> $DIR/malformed-attrs.rs:117:1 + | +LL | #[must_use = 1] + | ^^^^^^^^^^^^^-^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[must_use = 1] +LL + #[must_use = "reason"] + | +LL - #[must_use = 1] +LL + #[must_use] + | + +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/malformed-attrs.rs:126:1 + | +LL | #[rustc_layout_scalar_valid_range_start] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` + +error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input + --> $DIR/malformed-attrs.rs:128:1 + | +LL | #[rustc_layout_scalar_valid_range_end] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` + +warning: `#[diagnostic::do_not_recommend]` does not expect any arguments + --> $DIR/malformed-attrs.rs:147:1 + | +LL | #[diagnostic::do_not_recommend()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + +warning: missing options for `on_unimplemented` attribute + --> $DIR/malformed-attrs.rs:136:1 + | +LL | #[diagnostic::on_unimplemented] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: at least one of the `message`, `note` and `label` options are expected + +warning: malformed `on_unimplemented` attribute + --> $DIR/malformed-attrs.rs:138:1 + | +LL | #[diagnostic::on_unimplemented = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here + | + = help: only `message`, `note` and `label` are allowed as options + +error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` + --> $DIR/malformed-attrs.rs:51:1 + | +LL | #[inline = 5] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error[E0308]: mismatched types + --> $DIR/malformed-attrs.rs:109:23 + | +LL | fn test() { + | - help: a return type might be missing here: `-> _` +LL | #[coroutine = 63] || {} + | ^^^^^ expected `()`, found coroutine + | + = note: expected unit type `()` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:109:23: 109:25}` + +error: aborting due to 72 previous errors; 3 warnings emitted + +Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/cast/non-primitive-cast-suggestion.fixed b/tests/ui/cast/non-primitive-cast-suggestion.fixed new file mode 100644 index 00000000000..9a1a3c022c7 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.fixed @@ -0,0 +1,23 @@ +//! Test that casting non-primitive types with `as` is rejected with a helpful suggestion. +//! +//! You can't use `as` to cast between non-primitive types, even if they have +//! `From`/`Into` implementations. The compiler should suggest using `From::from()` +//! or `.into()` instead, and rustfix should be able to apply the suggestion. + +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize, +} + +impl From<Foo> for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + let _ = isize::from(Foo { x: 1 }); + //~^ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.rs b/tests/ui/cast/non-primitive-cast-suggestion.rs new file mode 100644 index 00000000000..79006f4ba26 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.rs @@ -0,0 +1,23 @@ +//! Test that casting non-primitive types with `as` is rejected with a helpful suggestion. +//! +//! You can't use `as` to cast between non-primitive types, even if they have +//! `From`/`Into` implementations. The compiler should suggest using `From::from()` +//! or `.into()` instead, and rustfix should be able to apply the suggestion. + +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize, +} + +impl From<Foo> for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + let _ = Foo { x: 1 } as isize; + //~^ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.stderr b/tests/ui/cast/non-primitive-cast-suggestion.stderr new file mode 100644 index 00000000000..bd35ded15a4 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.stderr @@ -0,0 +1,15 @@ +error[E0605]: non-primitive cast: `Foo` as `isize` + --> $DIR/non-primitive-cast-suggestion.rs:21:13 + | +LL | let _ = Foo { x: 1 } as isize; + | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - let _ = Foo { x: 1 } as isize; +LL + let _ = isize::from(Foo { x: 1 }); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/closures/basic-closure-syntax.rs b/tests/ui/closures/basic-closure-syntax.rs new file mode 100644 index 00000000000..1d968f8cf4a --- /dev/null +++ b/tests/ui/closures/basic-closure-syntax.rs @@ -0,0 +1,35 @@ +//! Test basic closure syntax and usage with generic functions. +//! +//! This test checks that closure syntax works correctly for: +//! - Closures with parameters and return values +//! - Closures without parameters (both expression and block forms) +//! - Integration with generic functions and FnOnce trait bounds + +//@ run-pass + +fn f<F>(i: isize, f: F) -> isize +where + F: FnOnce(isize) -> isize, +{ + f(i) +} + +fn g<G>(_g: G) +where + G: FnOnce(), +{ +} + +pub fn main() { + // Closure with parameter that returns the same value + assert_eq!(f(10, |a| a), 10); + + // Closure without parameters - expression form + g(|| ()); + + // Test closure reuse in generic context + assert_eq!(f(10, |a| a), 10); + + // Closure without parameters - block form + g(|| {}); +} diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.rs b/tests/ui/closures/closure-clone-requires-captured-clone.rs new file mode 100644 index 00000000000..80938e50b67 --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.rs @@ -0,0 +1,19 @@ +//! Test that closures only implement `Clone` if all captured values implement `Clone`. +//! +//! When a closure captures variables from its environment, it can only be cloned +//! if all those captured variables are cloneable. This test makes sure the compiler +//! properly rejects attempts to clone closures that capture non-Clone types. + +//@ compile-flags: --diagnostic-width=300 + +struct NonClone(i32); + +fn main() { + let captured_value = NonClone(5); + let closure = move || { + let _ = captured_value.0; + }; + + closure.clone(); + //~^ ERROR the trait bound `NonClone: Clone` is not satisfied +} diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.stderr b/tests/ui/closures/closure-clone-requires-captured-clone.stderr new file mode 100644 index 00000000000..785cc8a3032 --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}` + --> $DIR/closure-clone-requires-captured-clone.rs:17:13 + | +LL | let closure = move || { + | ------- within this `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}` +... +LL | closure.clone(); + | ^^^^^ within `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}`, the trait `Clone` is not implemented for `NonClone` + | +note: required because it's used within this closure + --> $DIR/closure-clone-requires-captured-clone.rs:13:19 + | +LL | let closure = move || { + | ^^^^^^^ +help: consider annotating `NonClone` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct NonClone(i32); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/missing-body.rs b/tests/ui/closures/missing-body.rs new file mode 100644 index 00000000000..461c2be3ccd --- /dev/null +++ b/tests/ui/closures/missing-body.rs @@ -0,0 +1,7 @@ +// Checks that the compiler complains about the missing closure body and does not +// crash. +// This is a regression test for <https://github.com/rust-lang/rust/issues/143128>. + +fn main() { |b: [str; _]| {}; } +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for closures +//~| ERROR the size for values of type `str` cannot be known at compilation time diff --git a/tests/ui/closures/missing-body.stderr b/tests/ui/closures/missing-body.stderr new file mode 100644 index 00000000000..33580fc2fbd --- /dev/null +++ b/tests/ui/closures/missing-body.stderr @@ -0,0 +1,19 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for closures + --> $DIR/missing-body.rs:5:23 + | +LL | fn main() { |b: [str; _]| {}; } + | ^ not allowed in type signatures + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/missing-body.rs:5:17 + | +LL | fn main() { |b: [str; _]| {}; } + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: slice and array elements must have `Sized` type + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0121, E0277. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs new file mode 100644 index 00000000000..64c31beba28 --- /dev/null +++ b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs @@ -0,0 +1,12 @@ +//! Test that -Z maximal-hir-to-mir-coverage flag is accepted. +//! +//! Original PR: https://github.com/rust-lang/rust/pull/105286 + +//@ compile-flags: -Zmaximal-hir-to-mir-coverage +//@ run-pass + +fn main() { + let x = 1; + let y = x + 1; + println!("{y}"); +} diff --git a/tests/ui/codegen/mono-respects-abi-alignment.rs b/tests/ui/codegen/mono-respects-abi-alignment.rs new file mode 100644 index 00000000000..045d82b761f --- /dev/null +++ b/tests/ui/codegen/mono-respects-abi-alignment.rs @@ -0,0 +1,37 @@ +//! Test that monomorphization correctly distinguishes types with different ABI alignment. +//! +//! On x86_64-linux-gnu and similar platforms, structs get 8-byte "preferred" +//! alignment, but their "ABI" alignment (what actually matters for data layout) +//! is the largest alignment of any field. If monomorphization incorrectly uses +//! "preferred" alignment instead of "ABI" alignment, it might unify types `A` +//! and `B` even though `S<A>` and `S<B>` have field `t` at different offsets, +//! leading to incorrect method dispatch for `unwrap()`. + +//@ run-pass + +#[derive(Copy, Clone)] +struct S<T> { + #[allow(dead_code)] + i: u8, + t: T, +} + +impl<T> S<T> { + fn unwrap(self) -> T { + self.t + } +} + +#[derive(Copy, Clone, PartialEq, Debug)] +struct A((u32, u32)); // Different ABI alignment than B + +#[derive(Copy, Clone, PartialEq, Debug)] +struct B(u64); // Different ABI alignment than A + +pub fn main() { + static CA: S<A> = S { i: 0, t: A((13, 104)) }; + static CB: S<B> = S { i: 0, t: B(31337) }; + + assert_eq!(CA.unwrap(), A((13, 104))); + assert_eq!(CB.unwrap(), B(31337)); +} diff --git a/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs new file mode 100644 index 00000000000..ba97acec822 --- /dev/null +++ b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs @@ -0,0 +1,37 @@ +//! Test that opt-level=z produces correct code on Windows MSVC targets. +//! +//! A previously outdated version of LLVM caused compilation failures and +//! generated invalid code on Windows specifically with optimization level `z`. +//! The bug manifested as corrupted base pointers due to incorrect register +//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables). +//! After updating to a more recent LLVM version, this test ensures that +//! compilation and execution both succeed with opt-level=z. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/45034>. + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ only-windows +// Reason: the observed bug only occurred on Windows MSVC targets +//@ run-pass +//@ compile-flags: -C opt-level=z + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level=z where the base + // pointer gets corrupted due to incorrect register allocation + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr index 033bfee226f..aafedc30b17 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr @@ -1,3 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `eq` + --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1 + | +LL | trait DynIncompatible { fn eq(&self, other: Self); } + | -------------------------- `eq` from trait +LL | impl DynIncompatible for dyn DynIncompatible { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation + error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26 | @@ -14,14 +22,6 @@ LL | trait DynIncompatible { fn eq(&self, other: Self); } | this trait is not dyn compatible... = help: consider moving `eq` to another trait -error[E0046]: not all trait items implemented, missing: `eq` - --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1 - | -LL | trait DynIncompatible { fn eq(&self, other: Self); } - | -------------------------- `eq` from trait -LL | impl DynIncompatible for dyn DynIncompatible { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0046. diff --git a/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr b/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr index 01b6eaf422e..fe28f4ff136 100644 --- a/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr +++ b/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Assoc` + --> $DIR/best-obligation-ICE.rs:10:1 + | +LL | type Assoc; + | ---------- `Assoc` from trait +... +LL | impl<T> Trait for W<W<W<T>>> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation + error[E0277]: the trait bound `W<W<T>>: Trait` is not satisfied --> $DIR/best-obligation-ICE.rs:10:19 | @@ -46,15 +55,6 @@ help: consider restricting type parameter `T` with trait `Trait` LL | impl<T: Trait> Trait for W<W<W<T>>> {} | +++++++ -error[E0046]: not all trait items implemented, missing: `Assoc` - --> $DIR/best-obligation-ICE.rs:10:1 - | -LL | type Assoc; - | ---------- `Assoc` from trait -... -LL | impl<T> Trait for W<W<W<T>>> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation - error[E0119]: conflicting implementations of trait `NoOverlap` for type `W<W<W<W<_>>>>` --> $DIR/best-obligation-ICE.rs:18:1 | diff --git a/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs new file mode 100644 index 00000000000..3a110bdad35 --- /dev/null +++ b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs @@ -0,0 +1,9 @@ +//! Regression test checks UI tests without error annotations are detected as failing. +//! +//! This tests that when we forget to use any `//~ ERROR` comments whatsoever, +//! the test doesn't succeed +//! Originally created in https://github.com/rust-lang/rust/pull/56244 + +//@ should-fail + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs index e5af632da75..478fa3706e8 100644 --- a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs +++ b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs @@ -5,6 +5,7 @@ struct Foo; impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo //~^ ERROR the const parameter `NUM` is not constrained by the impl trait, self type, or predicates +//~| ERROR missing: `Output`, `add` where [(); 1 + 0]: Sized, { diff --git a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr index ade18eb88b9..29bbd23a469 100644 --- a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr +++ b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr @@ -1,5 +1,5 @@ error[E0407]: method `unimplemented` is not a member of trait `std::ops::Add` - --> $DIR/post-analysis-user-facing-param-env.rs:11:5 + --> $DIR/post-analysis-user-facing-param-env.rs:12:5 | LL | / fn unimplemented(self, _: &Foo) -> Self::Output { LL | | @@ -17,6 +17,19 @@ LL | #![feature(generic_const_exprs)] = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = note: `#[warn(incomplete_features)]` on by default +error[E0046]: not all trait items implemented, missing: `Output`, `add` + --> $DIR/post-analysis-user-facing-param-env.rs:6:1 + | +LL | / impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo +LL | | +LL | | +LL | | where +LL | | [(); 1 + 0]: Sized, + | |_______________________^ missing `Output`, `add` in implementation + | + = help: implement the missing item: `type Output = /* Type */;` + = help: implement the missing item: `fn add(self, _: &'a Foo) -> <Self as Add<&'a Foo>>::Output { todo!() }` + error[E0207]: the const parameter `NUM` is not constrained by the impl trait, self type, or predicates --> $DIR/post-analysis-user-facing-param-env.rs:6:10 | @@ -27,7 +40,7 @@ LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo = note: proving the result of expressions other than the parameter are unique is not supported error[E0284]: type annotations needed - --> $DIR/post-analysis-user-facing-param-env.rs:11:40 + --> $DIR/post-analysis-user-facing-param-env.rs:12:40 | LL | fn unimplemented(self, _: &Foo) -> Self::Output { | ^^^^^^^^^^^^ cannot infer the value of const parameter `NUM` @@ -40,7 +53,7 @@ LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo | | | unsatisfied trait bound introduced here -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted -Some errors have detailed explanations: E0207, E0284, E0407. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0046, E0207, E0284, E0407. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr index 7cb67252da5..3b4b5798c80 100644 --- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr @@ -1,11 +1,3 @@ -error: the constant `N` is not of type `usize` - --> $DIR/type_mismatch.rs:8:26 - | -LL | impl<const N: u64> Q for [u8; N] {} - | ^^^^^^^ expected `usize`, found `u64` - | - = note: the length of array `[u8; N]` must be type `usize` - error[E0046]: not all trait items implemented, missing: `ASSOC` --> $DIR/type_mismatch.rs:8:1 | @@ -15,6 +7,14 @@ LL | const ASSOC: usize; LL | impl<const N: u64> Q for [u8; N] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation +error: the constant `N` is not of type `usize` + --> $DIR/type_mismatch.rs:8:26 + | +LL | impl<const N: u64> Q for [u8; N] {} + | ^^^^^^^ expected `usize`, found `u64` + | + = note: the length of array `[u8; N]` must be type `usize` + error: the constant `13` is not of type `u64` --> $DIR/type_mismatch.rs:12:26 | diff --git a/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs b/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs index 126ea667290..34c7a252f11 100644 --- a/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs +++ b/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs @@ -15,6 +15,7 @@ struct ConstChunksExact<'rem, T: 'a, const N: usize> {} impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { //~^ ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates //~^^ ERROR mismatched types +//~| ERROR missing: `next` type Item = &'a [T; N]; } diff --git a/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr b/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr index 3b24808cd16..311caaede09 100644 --- a/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr +++ b/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr @@ -49,6 +49,20 @@ LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {} | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` +error[E0308]: mismatched types + --> $DIR/ice-unexpected-inference-var-122549.rs:15:66 + | +LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^ expected `usize`, found `()` + +error[E0046]: not all trait items implemented, missing: `next` + --> $DIR/ice-unexpected-inference-var-122549.rs:15:1 + | +LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `next` in implementation + | + = help: implement the missing item: `fn next(&mut self) -> Option<<Self as Iterator>::Item> { todo!() }` + error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates --> $DIR/ice-unexpected-inference-var-122549.rs:15:13 | @@ -58,13 +72,7 @@ LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported -error[E0308]: mismatched types - --> $DIR/ice-unexpected-inference-var-122549.rs:15:66 - | -LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { - | ^^ expected `usize`, found `()` - -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0046, E0207, E0261, E0308, E0392. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/issues/issue-71202.stderr b/tests/ui/const-generics/issues/issue-71202.stderr index b7c3db494a5..dd0611a7223 100644 --- a/tests/ui/const-generics/issues/issue-71202.stderr +++ b/tests/ui/const-generics/issues/issue-71202.stderr @@ -7,7 +7,7 @@ LL | | const VALUE: bool = false; ... | LL | | <IsCopy<T>>::VALUE LL | | } as usize] = []; - | |_____________________^ + | |_______________^ | help: try adding a `where` bound | diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs index ba37087135f..9a39ab1ba02 100644 --- a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs @@ -14,5 +14,6 @@ impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T //~^ ERROR mismatched types [E0308] //~| ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates [E0207] type Item = &'a [T; N]; } + //~^ ERROR: `Item` specializes an item from a parent `impl`, but that item is not marked `default` fn main() {} diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr index 1ee68647594..ad89705e1dc 100644 --- a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr @@ -34,6 +34,17 @@ LL | struct ConstChunksExact<'a, T: '_, const assert: usize> {} | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` +error[E0520]: `Item` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/normalizing_with_unconstrained_impl_params.rs:16:5 + | +LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + | ---------------------------------------------------------------------------------------- parent `impl` is here +... +LL | type Item = &'a [T; N]; } + | ^^^^^^^^^ cannot specialize default item `Item` + | + = note: to specialize, `Item` in the parent `impl` must be marked `default` + error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates --> $DIR/normalizing_with_unconstrained_impl_params.rs:13:30 | @@ -54,7 +65,7 @@ LL | fn next(&mut self) -> Option<Self::Item> {} = note: expected enum `Option<_>` found unit type `()` -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0046, E0207, E0308, E0392, E0637. +Some errors have detailed explanations: E0046, E0207, E0308, E0392, E0520, E0637. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr index 42ae012fa55..3612cfad0d4 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -11,7 +11,7 @@ LL | trait Trait<const N: dyn Trait = bar> { | ^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again -note: cycle used when computing explicit predicates of trait `Trait` +note: cycle used when checking that `Trait` is well-formed --> $DIR/not_wf_param_in_rpitit.rs:3:1 | LL | trait Trait<const N: dyn Trait = bar> { diff --git a/tests/ui/consts/array-repeat-expr-not-const.rs b/tests/ui/consts/array-repeat-expr-not-const.rs new file mode 100644 index 00000000000..55aee7336da --- /dev/null +++ b/tests/ui/consts/array-repeat-expr-not-const.rs @@ -0,0 +1,10 @@ +//! Arrays created with `[value; length]` syntax need the length to be known at +//! compile time. This test makes sure the compiler rejects runtime values like +//! function parameters in the length position. + +fn main() { + fn create_array(n: usize) { + let _x = [0; n]; + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + } +} diff --git a/tests/ui/non-constant-expr-for-arr-len.stderr b/tests/ui/consts/array-repeat-expr-not-const.stderr index c9f977fbaa4..f5761545259 100644 --- a/tests/ui/non-constant-expr-for-arr-len.stderr +++ b/tests/ui/consts/array-repeat-expr-not-const.stderr @@ -1,8 +1,8 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/non-constant-expr-for-arr-len.rs:5:22 + --> $DIR/array-repeat-expr-not-const.rs:7:22 | -LL | fn bar(n: usize) { - | - this would need to be a `const` +LL | fn create_array(n: usize) { + | - this would need to be a `const` LL | let _x = [0; n]; | ^ diff --git a/tests/ui/consts/const-fn-type-name.rs b/tests/ui/consts/const-fn-type-name.rs index 5403c26b979..733ab79b7cd 100644 --- a/tests/ui/consts/const-fn-type-name.rs +++ b/tests/ui/consts/const-fn-type-name.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] const fn type_name_wrapper<T>(_: &T) -> &'static str { - core::intrinsics::type_name::<T>() + const { core::intrinsics::type_name::<T>() } } struct Struct<TA, TB, TC> { diff --git a/tests/ui/consts/const-unsized.stderr b/tests/ui/consts/const-unsized.stderr index cee364b33f7..c92fbc17f9c 100644 --- a/tests/ui/consts/const-unsized.stderr +++ b/tests/ui/consts/const-unsized.stderr @@ -17,19 +17,19 @@ LL | const CONST_FOO: str = *"foo"; = note: statics and constants must have a statically known size error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:11:18 + --> $DIR/const-unsized.rs:11:1 | LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); - | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` = note: statics and constants must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:15:20 + --> $DIR/const-unsized.rs:15:1 | LL | static STATIC_BAR: str = *"bar"; - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 3980a7e9b93..1263deebf76 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -24,10 +24,10 @@ LL | static FOO: dyn Sync = AtomicUsize::new(0); | +++ error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time - --> $DIR/const_refs_to_static-ice-121413.rs:8:17 + --> $DIR/const_refs_to_static-ice-121413.rs:8:5 | LL | static FOO: Sync = AtomicUsize::new(0); - | ^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/dont-ctfe-unsized-initializer.stderr b/tests/ui/consts/dont-ctfe-unsized-initializer.stderr index e69790fc182..5b0a0166f31 100644 --- a/tests/ui/consts/dont-ctfe-unsized-initializer.stderr +++ b/tests/ui/consts/dont-ctfe-unsized-initializer.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/dont-ctfe-unsized-initializer.rs:1:11 + --> $DIR/dont-ctfe-unsized-initializer.rs:1:1 | LL | static S: str = todo!(); - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index 1515fa60a5c..adfac02bd0c 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -29,7 +29,7 @@ LL | struct S<const S: (), const S: S = { S }>; | ^ | = note: ...which immediately requires computing type of `S::S` again -note: cycle used when computing explicit predicates of `S` +note: cycle used when checking that `S` is well-formed --> $DIR/issue-103790.rs:4:1 | LL | struct S<const S: (), const S: S = { S }>; diff --git a/tests/ui/auxiliary/noexporttypelib.rs b/tests/ui/cross-crate/auxiliary/unexported-type-error-message.rs index 67889cc5f65..67889cc5f65 100644 --- a/tests/ui/auxiliary/noexporttypelib.rs +++ b/tests/ui/cross-crate/auxiliary/unexported-type-error-message.rs diff --git a/tests/ui/noexporttypeexe.rs b/tests/ui/cross-crate/unexported-type-error-message.rs index 35257b20ccd..5998f0dc6e2 100644 --- a/tests/ui/noexporttypeexe.rs +++ b/tests/ui/cross-crate/unexported-type-error-message.rs @@ -1,13 +1,13 @@ -//@ aux-build:noexporttypelib.rs +//@ aux-build:unexported-type-error-message.rs -extern crate noexporttypelib; +extern crate unexported_type_error_message; fn main() { // Here, the type returned by foo() is not exported. // This used to cause internal errors when serializing // because the def_id associated with the type was // not convertible to a path. - let x: isize = noexporttypelib::foo(); + let x: isize = unexported_type_error_message::foo(); //~^ ERROR mismatched types //~| NOTE expected type `isize` //~| NOTE found enum `Option<isize>` diff --git a/tests/ui/cross-crate/unexported-type-error-message.stderr b/tests/ui/cross-crate/unexported-type-error-message.stderr new file mode 100644 index 00000000000..b468d9839e1 --- /dev/null +++ b/tests/ui/cross-crate/unexported-type-error-message.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/unexported-type-error-message.rs:10:20 + | +LL | let x: isize = unexported_type_error_message::foo(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option<isize>` + | | + | expected due to this + | + = note: expected type `isize` + found enum `Option<isize>` +help: consider using `Option::expect` to unwrap the `Option<isize>` value, panicking if the value is an `Option::None` + | +LL | let x: isize = unexported_type_error_message::foo().expect("REASON"); + | +++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index 2e11a59c3a4..3e5579d2e4a 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -8,10 +8,8 @@ LL | trait Chromosome: Chromosome { note: cycle used when checking that `Chromosome` is well-formed --> $DIR/cycle-trait-supertrait-direct.rs:3:1 | -LL | / trait Chromosome: Chromosome { -LL | | -LL | | } - | |_^ +LL | trait Chromosome: Chromosome { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/cycle-trait/issue-12511.stderr b/tests/ui/cycle-trait/issue-12511.stderr index 0246bf21983..45fc86a7413 100644 --- a/tests/ui/cycle-trait/issue-12511.stderr +++ b/tests/ui/cycle-trait/issue-12511.stderr @@ -13,10 +13,8 @@ LL | trait T2 : T1 { note: cycle used when checking that `T1` is well-formed --> $DIR/issue-12511.rs:1:1 | -LL | / trait T1 : T2 { -LL | | -LL | | } - | |_^ +LL | trait T1 : T2 { + | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/delegation/unsupported.stderr b/tests/ui/delegation/unsupported.stderr index 53d05c3db8c..f69be60133e 100644 --- a/tests/ui/delegation/unsupported.stderr +++ b/tests/ui/delegation/unsupported.stderr @@ -10,11 +10,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>` is well-formed - --> $DIR/unsupported.rs:21:5 +note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:22:25 | -LL | impl ToReuse for u8 { - | ^^^^^^^^^^^^^^^^^^^ +LL | reuse to_reuse::opaque_ret; + | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}` @@ -29,11 +29,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>` is well-formed - --> $DIR/unsupported.rs:24:5 +note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:25:24 | -LL | impl ToReuse for u16 { - | ^^^^^^^^^^^^^^^^^^^^ +LL | reuse ToReuse::opaque_ret; + | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: recursive delegation is not supported yet diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/derive-Debug-enum-variants.rs new file mode 100644 index 00000000000..26f527f7664 --- /dev/null +++ b/tests/ui/derives/derive-Debug-enum-variants.rs @@ -0,0 +1,30 @@ +//! Test that `#[derive(Debug)]` for enums correctly formats variant names. + +//@ run-pass + +#[derive(Debug)] +enum Foo { + A(usize), + C, +} + +#[derive(Debug)] +enum Bar { + D, +} + +pub fn main() { + // Test variant with data + let foo_a = Foo::A(22); + assert_eq!("A(22)".to_string(), format!("{:?}", foo_a)); + + if let Foo::A(value) = foo_a { + println!("Value: {}", value); // This needs to remove #[allow(dead_code)] + } + + // Test unit variant + assert_eq!("C".to_string(), format!("{:?}", Foo::C)); + + // Test unit variant from different enum + assert_eq!("D".to_string(), format!("{:?}", Bar::D)); +} diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr index fe1ce5ad18b..ed6e5c3e0c0 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr @@ -302,7 +302,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | trait P<F> where F: Fn() -> _ { | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/bad-assoc-ty.rs:88:38 | LL | fn foo<F>(_: F) where F: Fn() -> _ {} diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr index 2cf7a150aa2..2ee8ab2760a 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr @@ -284,7 +284,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | trait P<F> where F: Fn() -> _ { | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/bad-assoc-ty.rs:88:38 | LL | fn foo<F>(_: F) where F: Fn() -> _ {} diff --git a/tests/ui/did_you_mean/bad-assoc-ty.rs b/tests/ui/did_you_mean/bad-assoc-ty.rs index 9abda4fd962..39f0a84855a 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.rs +++ b/tests/ui/did_you_mean/bad-assoc-ty.rs @@ -86,7 +86,7 @@ trait P<F> where F: Fn() -> _ { trait Q { fn foo<F>(_: F) where F: Fn() -> _ {} - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions } fn main() {} diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed index db18cf2ad96..0096d3eaea4 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed @@ -7,7 +7,7 @@ trait Foo<T>: Sized { impl Foo<usize> for () { fn bar(i: i32, t: usize, s: &()) -> (usize, i32) { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR type annotations needed (1, 2) } diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs index 1217a96112d..9ebc565b8fd 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs @@ -7,7 +7,7 @@ trait Foo<T>: Sized { impl Foo<usize> for () { fn bar(i: _, t: _, s: _) -> _ { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR type annotations needed (1, 2) } diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr index 6c24a5899ea..3c11ad0cf29 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/replace-impl-infer-ty-from-trait.rs:9:15 | LL | fn bar(i: _, t: _, s: _) -> _ { diff --git a/tests/ui/drop/field-replace-in-struct-with-drop.rs b/tests/ui/drop/field-replace-in-struct-with-drop.rs new file mode 100644 index 00000000000..8c65a4b3ad1 --- /dev/null +++ b/tests/ui/drop/field-replace-in-struct-with-drop.rs @@ -0,0 +1,40 @@ +//! Circa 2016-06-05, `fn inline` below issued an +//! erroneous warning from the elaborate_drops pass about moving out of +//! a field in `Foo`, which has a destructor (and thus cannot have +//! content moved out of it). The reason that the warning is erroneous +//! in this case is that we are doing a *replace*, not a move, of the +//! content in question, and it is okay to replace fields within `Foo`. +//! +//! Another more subtle problem was that the elaborate_drops was +//! creating a separate drop flag for that internally replaced content, +//! even though the compiler should enforce an invariant that any drop +//! flag for such subcontent of `Foo` will always have the same value +//! as the drop flag for `Foo` itself. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/34101>. + +//@ check-pass + +struct Foo(String); + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn test_inline_replacement() { + // dummy variable so `f` gets assigned `var1` in MIR for both functions + let _s = (); + let mut f = Foo(String::from("foo")); + f.0 = String::from("bar"); // This should not warn +} + +fn test_outline_replacement() { + let _s = String::from("foo"); + let mut f = Foo(_s); + f.0 = String::from("bar"); // This should not warn either +} + +fn main() { + test_inline_replacement(); + test_outline_replacement(); +} diff --git a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr index 28d7546d0c9..d898f2f9761 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:27:18 + --> $DIR/explicit-drop-bounds.rs:32:5 | -LL | impl<T> Drop for DropMe<T> - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | fn drop(&mut self) {} + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 @@ -15,10 +15,10 @@ LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply | ++++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:32:5 + --> $DIR/explicit-drop-bounds.rs:27:18 | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr index c363676edea..8155bd4134d 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:38:18 + --> $DIR/explicit-drop-bounds.rs:41:5 | -LL | impl<T> Drop for DropMe<T> - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | fn drop(&mut self) {} + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 @@ -15,10 +15,10 @@ LL | impl<T: std::marker::Copy> Drop for DropMe<T> | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:41:5 + --> $DIR/explicit-drop-bounds.rs:38:18 | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dropck/unconstrained_const_param_on_drop.rs b/tests/ui/dropck/unconstrained_const_param_on_drop.rs index de77fa55fb2..839aca07a6a 100644 --- a/tests/ui/dropck/unconstrained_const_param_on_drop.rs +++ b/tests/ui/dropck/unconstrained_const_param_on_drop.rs @@ -3,5 +3,6 @@ struct Foo {} impl<const UNUSED: usize> Drop for Foo {} //~^ ERROR: `Drop` impl requires `the constant `_` has type `usize`` //~| ERROR: the const parameter `UNUSED` is not constrained by the impl trait, self type, or predicates +//~| ERROR: missing: `drop` fn main() {} diff --git a/tests/ui/dropck/unconstrained_const_param_on_drop.stderr b/tests/ui/dropck/unconstrained_const_param_on_drop.stderr index 851888534ee..515637dd47f 100644 --- a/tests/ui/dropck/unconstrained_const_param_on_drop.stderr +++ b/tests/ui/dropck/unconstrained_const_param_on_drop.stderr @@ -10,6 +10,14 @@ note: the implementor must specify the same requirement LL | struct Foo {} | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unconstrained_const_param_on_drop.rs:3:1 + | +LL | impl<const UNUSED: usize> Drop for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `fn drop(&mut self) { todo!() }` + error[E0207]: the const parameter `UNUSED` is not constrained by the impl trait, self type, or predicates --> $DIR/unconstrained_const_param_on_drop.rs:3:6 | @@ -19,7 +27,7 @@ LL | impl<const UNUSED: usize> Drop for Foo {} = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0367. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0046, E0207, E0367. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/dyn-star/align.normal.stderr b/tests/ui/dyn-star/align.normal.stderr deleted file mode 100644 index d3ee0d3e550..00000000000 --- a/tests/ui/dyn-star/align.normal.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer - --> $DIR/align.rs:14:13 - | -LL | let x = AlignedUsize(12) as dyn* Debug; - | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `AlignedUsize` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.over_aligned.stderr b/tests/ui/dyn-star/align.over_aligned.stderr deleted file mode 100644 index d3ee0d3e550..00000000000 --- a/tests/ui/dyn-star/align.over_aligned.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer - --> $DIR/align.rs:14:13 - | -LL | let x = AlignedUsize(12) as dyn* Debug; - | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `AlignedUsize` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.rs b/tests/ui/dyn-star/align.rs deleted file mode 100644 index f9ef7063231..00000000000 --- a/tests/ui/dyn-star/align.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ revisions: normal over_aligned - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; - -#[cfg_attr(over_aligned, repr(C, align(1024)))] -#[cfg_attr(not(over_aligned), repr(C))] -#[derive(Debug)] -struct AlignedUsize(usize); - -fn main() { - let x = AlignedUsize(12) as dyn* Debug; - //~^ ERROR `AlignedUsize` needs to have the same ABI as a pointer -} diff --git a/tests/ui/dyn-star/async-block-dyn-star.rs b/tests/ui/dyn-star/async-block-dyn-star.rs deleted file mode 100644 index db133d94c91..00000000000 --- a/tests/ui/dyn-star/async-block-dyn-star.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ edition:2018 - -#![feature(dyn_star, const_async_blocks)] -//~^ WARN the feature `dyn_star` is incomplete - -static S: dyn* Send + Sync = async { 42 }; -//~^ ERROR needs to have the same ABI as a pointer - -pub fn main() {} diff --git a/tests/ui/dyn-star/async-block-dyn-star.stderr b/tests/ui/dyn-star/async-block-dyn-star.stderr deleted file mode 100644 index f62c85c0ad2..00000000000 --- a/tests/ui/dyn-star/async-block-dyn-star.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-block-dyn-star.rs:3:12 - | -LL | #![feature(dyn_star, const_async_blocks)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` needs to have the same ABI as a pointer - --> $DIR/async-block-dyn-star.rs:6:30 - | -LL | static S: dyn* Send + Sync = async { 42 }; - | ^^^^^^^^^^^^ `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs b/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs deleted file mode 100644 index ce892088f50..00000000000 --- a/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(dyn_star)] - -use std::fmt::Display; - -pub fn require_dyn_star_display(_: dyn* Display) {} - -fn works_locally() { - require_dyn_star_display(1usize); -} diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs deleted file mode 100644 index f1c9fd1a01e..00000000000 --- a/tests/ui/dyn-star/box.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] compile-flags: -C opt-level=0 -//@[next] compile-flags: -Znext-solver -C opt-level=0 - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Display; - -fn make_dyn_star() -> dyn* Display { - Box::new(42) as dyn* Display -} - -fn main() { - let x = make_dyn_star(); - - println!("{x}"); -} diff --git a/tests/ui/dyn-star/cell.rs b/tests/ui/dyn-star/cell.rs deleted file mode 100644 index f4c7927a39d..00000000000 --- a/tests/ui/dyn-star/cell.rs +++ /dev/null @@ -1,34 +0,0 @@ -// This test with Cell also indirectly exercises UnsafeCell in dyn*. -// -//@ run-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::cell::Cell; - -trait Rw<T> { - fn read(&self) -> T; - fn write(&self, v: T); -} - -impl<T: Copy> Rw<T> for Cell<T> { - fn read(&self) -> T { - self.get() - } - fn write(&self, v: T) { - self.set(v) - } -} - -fn make_dyn_star() -> dyn* Rw<usize> { - Cell::new(42usize) as dyn* Rw<usize> -} - -fn main() { - let x = make_dyn_star(); - - assert_eq!(x.read(), 42); - x.write(24); - assert_eq!(x.read(), 24); -} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr deleted file mode 100644 index a0aff69f396..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 - | -LL | fn polymorphic<T: Debug + ?Sized>(t: &T) { - | - this type parameter needs to be `Sized` -LL | dyn_debug(t); - | ^ `&T` needs to be a pointer-like type - | - = note: required for `&T` to implement `PointerLike` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn polymorphic<T: Debug + ?Sized>(t: &T) { -LL + fn polymorphic<T: Debug>(t: &T) { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr deleted file mode 100644 index a0aff69f396..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 - | -LL | fn polymorphic<T: Debug + ?Sized>(t: &T) { - | - this type parameter needs to be `Sized` -LL | dyn_debug(t); - | ^ `&T` needs to be a pointer-like type - | - = note: required for `&T` to implement `PointerLike` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn polymorphic<T: Debug + ?Sized>(t: &T) { -LL + fn polymorphic<T: Debug>(t: &T) { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs deleted file mode 100644 index acc293a5956..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn dyn_debug(_: (dyn* Debug + '_)) { - -} - -fn polymorphic<T: Debug + ?Sized>(t: &T) { - dyn_debug(t); - //~^ ERROR `&T` needs to have the same ABI as a pointer -} - -fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs deleted file mode 100644 index ceedbafd86b..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn dyn_debug(_: (dyn* Debug + '_)) { - -} - -fn polymorphic<T: Debug>(t: &T) { - dyn_debug(t); -} - -fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast.rs b/tests/ui/dyn-star/check-size-at-cast.rs deleted file mode 100644 index e15e090b529..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn main() { - let i = [1, 2, 3, 4] as dyn* Debug; - //~^ ERROR `[i32; 4]` needs to have the same ABI as a pointer - dbg!(i); -} diff --git a/tests/ui/dyn-star/check-size-at-cast.stderr b/tests/ui/dyn-star/check-size-at-cast.stderr deleted file mode 100644 index b402403ee6f..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `[i32; 4]` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast.rs:7:13 - | -LL | let i = [1, 2, 3, 4] as dyn* Debug; - | ^^^^^^^^^^^^ `[i32; 4]` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `[i32; 4]` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/const-and-static.rs b/tests/ui/dyn-star/const-and-static.rs deleted file mode 100644 index cbb64261a66..00000000000 --- a/tests/ui/dyn-star/const-and-static.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete - -const C: dyn* Send + Sync = &(); - -static S: dyn* Send + Sync = &(); - -fn main() {} diff --git a/tests/ui/dyn-star/const-and-static.stderr b/tests/ui/dyn-star/const-and-static.stderr deleted file mode 100644 index df8f42fb0f5..00000000000 --- a/tests/ui/dyn-star/const-and-static.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/const-and-static.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/const.rs b/tests/ui/dyn-star/const.rs deleted file mode 100644 index 036d678dc02..00000000000 --- a/tests/ui/dyn-star/const.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -#![feature(dyn_star)] -#![allow(unused, incomplete_features)] - -use std::fmt::Debug; - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Debug = i; -} - -fn main() { - make_dyn_star(); -} diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.rs b/tests/ui/dyn-star/dispatch-on-pin-mut.rs deleted file mode 100644 index be40fa30f0d..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ run-pass -//@ edition:2021 -//@ check-run-results - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::future::Future; - -async fn foo(f: dyn* Future<Output = i32>) { - println!("value: {}", f.await); -} - -async fn async_main() { - foo(Box::pin(async { 1 })).await -} - -// ------------------------------------------------------------------------- // -// Implementation Details Below... - -use std::pin::pin; -use std::task::*; - -fn main() { - let mut fut = pin!(async_main()); - - // Poll loop, just to test the future... - let ctx = &mut Context::from_waker(Waker::noop()); - - loop { - match fut.as_mut().poll(ctx) { - Poll::Pending => {} - Poll::Ready(()) => break, - } - } -} diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout b/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout deleted file mode 100644 index 96c5ca6985f..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout +++ /dev/null @@ -1 +0,0 @@ -value: 1 diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.stderr b/tests/ui/dyn-star/dispatch-on-pin-mut.stderr deleted file mode 100644 index cb9c7815814..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dispatch-on-pin-mut.rs:5:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs deleted file mode 100644 index abc66df8b36..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass -//@ check-run-results - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -trait AddOne { - fn add1(&mut self) -> usize; -} - -impl AddOne for usize { - fn add1(&mut self) -> usize { - *self += 1; - *self - } -} - -fn add_one(i: &mut (dyn* AddOne + '_)) -> usize { - i.add1() -} - -fn main() { - let mut x = 42usize as dyn* AddOne; - - println!("{}", add_one(&mut x)); - println!("{}", add_one(&mut x)); -} diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout deleted file mode 100644 index b4db3ed707d..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout +++ /dev/null @@ -1,2 +0,0 @@ -43 -44 diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr deleted file mode 100644 index bcd014f8dc3..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-unsize-coerce-dyn-star.rs:4:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/drop.rs b/tests/ui/dyn-star/drop.rs deleted file mode 100644 index bc746331527..00000000000 --- a/tests/ui/dyn-star/drop.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ run-pass -//@ check-run-results -#![feature(dyn_star, pointer_like_trait)] -#![allow(incomplete_features)] - -use std::fmt::Debug; -use std::marker::PointerLike; - -#[derive(Debug)] -#[repr(transparent)] -struct Foo(#[allow(dead_code)] usize); - -// FIXME(dyn_star): Make this into a derive. -impl PointerLike for Foo {} - -impl Drop for Foo { - fn drop(&mut self) { - println!("destructor called"); - } -} - -fn make_dyn_star(i: Foo) { - let _dyn_i: dyn* Debug = i; -} - -fn main() { - make_dyn_star(Foo(42)); -} diff --git a/tests/ui/dyn-star/drop.run.stdout b/tests/ui/dyn-star/drop.run.stdout deleted file mode 100644 index dadb33ccf3a..00000000000 --- a/tests/ui/dyn-star/drop.run.stdout +++ /dev/null @@ -1 +0,0 @@ -destructor called diff --git a/tests/ui/dyn-star/dyn-async-trait.rs b/tests/ui/dyn-star/dyn-async-trait.rs deleted file mode 100644 index a673b269910..00000000000 --- a/tests/ui/dyn-star/dyn-async-trait.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ check-pass -//@ edition: 2021 - -// This test case is meant to demonstrate how close we can get to async -// functions in dyn traits with the current level of dyn* support. - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::future::Future; - -trait DynAsyncCounter { - fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a; -} - -struct MyCounter { - count: usize, -} - -impl DynAsyncCounter for MyCounter { - fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a { - Box::pin(async { - self.count += 1; - self.count - }) - } -} - -async fn do_counter(counter: &mut dyn DynAsyncCounter) -> usize { - counter.increment().await -} - -fn main() { - let mut counter = MyCounter { count: 0 }; - let _ = do_counter(&mut counter); -} diff --git a/tests/ui/dyn-star/dyn-pointer-like.rs b/tests/ui/dyn-star/dyn-pointer-like.rs deleted file mode 100644 index f26fa90505c..00000000000 --- a/tests/ui/dyn-star/dyn-pointer-like.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Test that `dyn PointerLike` and `dyn* PointerLike` do not implement `PointerLike`. -// This used to ICE during codegen. - -#![crate_type = "lib"] - -#![feature(pointer_like_trait, dyn_star)] -#![feature(unsized_fn_params)] -#![expect(incomplete_features)] -#![expect(internal_features)] - -use std::marker::PointerLike; - -pub fn lol(x: dyn* PointerLike) { - foo(x); //~ ERROR `dyn* PointerLike` needs to have the same ABI as a pointer -} - -pub fn uwu(x: dyn PointerLike) { - foo(x); //~ ERROR `dyn PointerLike` needs to have the same ABI as a pointer -} - -fn foo<T: PointerLike + ?Sized>(x: T) { - let _: dyn* PointerLike = x; -} diff --git a/tests/ui/dyn-star/dyn-pointer-like.stderr b/tests/ui/dyn-star/dyn-pointer-like.stderr deleted file mode 100644 index 4c558e92d3f..00000000000 --- a/tests/ui/dyn-star/dyn-pointer-like.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0277]: `dyn* PointerLike` needs to have the same ABI as a pointer - --> $DIR/dyn-pointer-like.rs:14:9 - | -LL | foo(x); - | --- ^ the trait `PointerLike` is not implemented for `dyn* PointerLike` - | | - | required by a bound introduced by this call - | - = note: the trait bound `dyn* PointerLike: PointerLike` is not satisfied -note: required by a bound in `foo` - --> $DIR/dyn-pointer-like.rs:21:11 - | -LL | fn foo<T: PointerLike + ?Sized>(x: T) { - | ^^^^^^^^^^^ required by this bound in `foo` -help: consider borrowing here - | -LL | foo(&x); - | + -LL | foo(&mut x); - | ++++ - -error[E0277]: `dyn PointerLike` needs to have the same ABI as a pointer - --> $DIR/dyn-pointer-like.rs:18:9 - | -LL | foo(x); - | --- ^ `dyn PointerLike` needs to be a pointer-like type - | | - | required by a bound introduced by this call - | - = help: the trait `PointerLike` is not implemented for `dyn PointerLike` -note: required by a bound in `foo` - --> $DIR/dyn-pointer-like.rs:21:11 - | -LL | fn foo<T: PointerLike + ?Sized>(x: T) { - | ^^^^^^^^^^^ required by this bound in `foo` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.rs b/tests/ui/dyn-star/dyn-star-to-dyn.rs deleted file mode 100644 index 99f673df868..00000000000 --- a/tests/ui/dyn-star/dyn-star-to-dyn.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; - -fn main() { - let x: dyn* Debug = &42; - let x = Box::new(x) as Box<dyn Debug>; - assert_eq!("42", format!("{x:?}")); - - // Also test opposite direction. - let x: Box<dyn Debug> = Box::new(42); - let x = &x as dyn* Debug; - assert_eq!("42", format!("{x:?}")); -} diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.stderr b/tests/ui/dyn-star/dyn-star-to-dyn.stderr deleted file mode 100644 index 03aedf5f797..00000000000 --- a/tests/ui/dyn-star/dyn-star-to-dyn.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dyn-star-to-dyn.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/dyn-to-rigid.rs b/tests/ui/dyn-star/dyn-to-rigid.rs deleted file mode 100644 index dc33e288f24..00000000000 --- a/tests/ui/dyn-star/dyn-to-rigid.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Tr {} - -fn f(x: dyn* Tr) -> usize { - x as usize - //~^ ERROR non-primitive cast: `(dyn* Tr + 'static)` as `usize` -} - -fn main() {} diff --git a/tests/ui/dyn-star/dyn-to-rigid.stderr b/tests/ui/dyn-star/dyn-to-rigid.stderr deleted file mode 100644 index 49b8f268aa4..00000000000 --- a/tests/ui/dyn-star/dyn-to-rigid.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0605]: non-primitive cast: `(dyn* Tr + 'static)` as `usize` - --> $DIR/dyn-to-rigid.rs:7:5 - | -LL | x as usize - | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/dyn-star/enum-cast.rs b/tests/ui/dyn-star/enum-cast.rs deleted file mode 100644 index 3cc7390eb12..00000000000 --- a/tests/ui/dyn-star/enum-cast.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ check-pass - -// This used to ICE, because the compiler confused a pointer-like to dyn* coercion -// with a c-like enum to integer cast. - -#![feature(dyn_star, pointer_like_trait)] -#![expect(incomplete_features)] - -use std::marker::PointerLike; - -#[repr(transparent)] -enum E { - Num(usize), -} - -impl PointerLike for E {} - -trait Trait {} -impl Trait for E {} - -fn main() { - let _ = E::Num(42) as dyn* Trait; -} diff --git a/tests/ui/dyn-star/error.rs b/tests/ui/dyn-star/error.rs deleted file mode 100644 index 1d252d2ce42..00000000000 --- a/tests/ui/dyn-star/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -trait Foo {} - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Foo = i; //~ ERROR trait bound `usize: Foo` is not satisfied -} - -fn main() {} diff --git a/tests/ui/dyn-star/error.stderr b/tests/ui/dyn-star/error.stderr deleted file mode 100644 index 55981c03bac..00000000000 --- a/tests/ui/dyn-star/error.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `usize: Foo` is not satisfied - --> $DIR/error.rs:10:27 - | -LL | let dyn_i: dyn* Foo = i; - | ^ the trait `Foo` is not implemented for `usize` - | -help: this trait has no implementations, consider adding one - --> $DIR/error.rs:6:1 - | -LL | trait Foo {} - | ^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.rs b/tests/ui/dyn-star/feature-gate-dyn_star.rs deleted file mode 100644 index b12fd7755be..00000000000 --- a/tests/ui/dyn-star/feature-gate-dyn_star.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Feature gate test for dyn_star - -/// dyn* is not necessarily the final surface syntax (if we have one at all), -/// but for now we will support it to aid in writing tests independently. -pub fn dyn_star_parameter(_: &dyn* Send) { - //~^ ERROR `dyn*` trait objects are experimental -} - -fn main() {} diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.stderr b/tests/ui/dyn-star/feature-gate-dyn_star.stderr deleted file mode 100644 index c3e99b20d06..00000000000 --- a/tests/ui/dyn-star/feature-gate-dyn_star.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/feature-gate-dyn_star.rs:5:31 - | -LL | pub fn dyn_star_parameter(_: &dyn* Send) { - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/dyn-star/float-as-dyn-star.rs b/tests/ui/dyn-star/float-as-dyn-star.rs deleted file mode 100644 index 1b629c64c25..00000000000 --- a/tests/ui/dyn-star/float-as-dyn-star.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ only-x86_64 - -#![feature(dyn_star, pointer_like_trait)] -//~^ WARN the feature `dyn_star` is incomplete - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star() -> dyn* Debug + 'static { - f32::from_bits(0x1) as f64 - //~^ ERROR `f64` needs to have the same ABI as a pointer -} - -fn main() { - println!("{:?}", make_dyn_star()); -} diff --git a/tests/ui/dyn-star/float-as-dyn-star.stderr b/tests/ui/dyn-star/float-as-dyn-star.stderr deleted file mode 100644 index 06071a27afc..00000000000 --- a/tests/ui/dyn-star/float-as-dyn-star.stderr +++ /dev/null @@ -1,23 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/float-as-dyn-star.rs:3:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `f64` needs to have the same ABI as a pointer - --> $DIR/float-as-dyn-star.rs:10:5 - | -LL | f32::from_bits(0x1) as f64 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `f64` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `f64` - = help: the following other types implement trait `PointerLike`: - isize - usize - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/gated-span.rs b/tests/ui/dyn-star/gated-span.rs deleted file mode 100644 index a747987bd24..00000000000 --- a/tests/ui/dyn-star/gated-span.rs +++ /dev/null @@ -1,8 +0,0 @@ -macro_rules! t { - ($t:ty) => {} -} - -t!(dyn* Send); -//~^ ERROR `dyn*` trait objects are experimental - -fn main() {} diff --git a/tests/ui/dyn-star/gated-span.stderr b/tests/ui/dyn-star/gated-span.stderr deleted file mode 100644 index 8ba6d7969fc..00000000000 --- a/tests/ui/dyn-star/gated-span.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/gated-span.rs:5:4 - | -LL | t!(dyn* Send); - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/dyn-star/illegal.rs b/tests/ui/dyn-star/illegal.rs deleted file mode 100644 index ce0d784fcd2..00000000000 --- a/tests/ui/dyn-star/illegal.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete - -trait Foo {} - -pub fn lol(x: dyn* Foo + Send) { - x as dyn* Foo; - //~^ ERROR casting `(dyn* Foo + Send + 'static)` as `dyn* Foo` is invalid -} - -fn lol2(x: &dyn Foo) { - *x as dyn* Foo; - //~^ ERROR `dyn Foo` needs to have the same ABI as a pointer -} - -fn main() {} diff --git a/tests/ui/dyn-star/illegal.stderr b/tests/ui/dyn-star/illegal.stderr deleted file mode 100644 index fdf3c813a23..00000000000 --- a/tests/ui/dyn-star/illegal.stderr +++ /dev/null @@ -1,27 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/illegal.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0606]: casting `(dyn* Foo + Send + 'static)` as `dyn* Foo` is invalid - --> $DIR/illegal.rs:7:5 - | -LL | x as dyn* Foo; - | ^^^^^^^^^^^^^ - -error[E0277]: `dyn Foo` needs to have the same ABI as a pointer - --> $DIR/illegal.rs:12:5 - | -LL | *x as dyn* Foo; - | ^^ `dyn Foo` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn Foo` - -error: aborting due to 2 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0277, E0606. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/issue-102430.rs b/tests/ui/dyn-star/issue-102430.rs deleted file mode 100644 index 4e48d5e2f5d..00000000000 --- a/tests/ui/dyn-star/issue-102430.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait AddOne { - fn add1(&mut self) -> usize; -} - -impl AddOne for usize { - fn add1(&mut self) -> usize { - *self += 1; - *self - } -} - -impl AddOne for &mut usize { - fn add1(&mut self) -> usize { - (*self).add1() - } -} - -fn add_one(mut i: dyn* AddOne + '_) -> usize { - i.add1() -} - -fn main() { - let mut x = 42usize; - let y = &mut x as (dyn* AddOne + '_); - - println!("{}", add_one(y)); -} diff --git a/tests/ui/dyn-star/make-dyn-star.rs b/tests/ui/dyn-star/make-dyn-star.rs deleted file mode 100644 index 24004335f06..00000000000 --- a/tests/ui/dyn-star/make-dyn-star.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-pass -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn make_dyn_star(i: usize) { - let _dyn_i: dyn* Debug = i; -} - -fn make_dyn_star_explicit(i: usize) { - let _dyn_i: dyn* Debug = i as dyn* Debug; -} - -fn main() { - make_dyn_star(42); - make_dyn_star_explicit(42); -} diff --git a/tests/ui/dyn-star/method.rs b/tests/ui/dyn-star/method.rs deleted file mode 100644 index 0d0855eec7f..00000000000 --- a/tests/ui/dyn-star/method.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Foo { - fn get(&self) -> usize; -} - -impl Foo for usize { - fn get(&self) -> usize { - *self - } -} - -fn invoke_dyn_star(i: dyn* Foo) -> usize { - i.get() -} - -fn make_and_invoke_dyn_star(i: usize) -> usize { - let dyn_i: dyn* Foo = i; - invoke_dyn_star(dyn_i) -} - -fn main() { - println!("{}", make_and_invoke_dyn_star(42)); -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs b/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs deleted file mode 100644 index 2d28f516ab5..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::fmt::Debug; - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Debug = i as dyn* Debug; - //~^ ERROR casting `usize` as `dyn* Debug` is invalid - //~| ERROR `dyn*` trait objects are experimental - //~| ERROR `dyn*` trait objects are experimental -} - -fn main() { - make_dyn_star(); -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr b/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr deleted file mode 100644 index bb4c612cedd..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/no-explicit-dyn-star-cast.rs:5:16 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/no-explicit-dyn-star-cast.rs:5:34 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0606]: casting `usize` as `dyn* Debug` is invalid - --> $DIR/no-explicit-dyn-star-cast.rs:5:29 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0606, E0658. -For more information about an error, try `rustc --explain E0606`. diff --git a/tests/ui/dyn-star/no-explicit-dyn-star.rs b/tests/ui/dyn-star/no-explicit-dyn-star.rs deleted file mode 100644 index 0847597450e..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:dyn-star-foreign.rs - -extern crate dyn_star_foreign; - -fn main() { - dyn_star_foreign::require_dyn_star_display(1usize as _); - //~^ ERROR casting `usize` as `dyn* std::fmt::Display` is invalid -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star.stderr b/tests/ui/dyn-star/no-explicit-dyn-star.stderr deleted file mode 100644 index 641404aa09e..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0606]: casting `usize` as `dyn* std::fmt::Display` is invalid - --> $DIR/no-explicit-dyn-star.rs:6:48 - | -LL | dyn_star_foreign::require_dyn_star_display(1usize as _); - | ^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/dyn-star/no-implicit-dyn-star.rs b/tests/ui/dyn-star/no-implicit-dyn-star.rs deleted file mode 100644 index 7af3f9a734b..00000000000 --- a/tests/ui/dyn-star/no-implicit-dyn-star.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:dyn-star-foreign.rs - -extern crate dyn_star_foreign; - -fn main() { - dyn_star_foreign::require_dyn_star_display(1usize); - //~^ ERROR mismatched types -} diff --git a/tests/ui/dyn-star/no-implicit-dyn-star.stderr b/tests/ui/dyn-star/no-implicit-dyn-star.stderr deleted file mode 100644 index d1d3da9ca70..00000000000 --- a/tests/ui/dyn-star/no-implicit-dyn-star.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/no-implicit-dyn-star.rs:6:48 - | -LL | dyn_star_foreign::require_dyn_star_display(1usize); - | ------------------------------------------ ^^^^^^ expected `dyn Display`, found `usize` - | | - | arguments to this function are incorrect - | - = note: expected trait object `(dyn* std::fmt::Display + 'static)` - found type `usize` - = help: `usize` implements `Display`, `#[feature(dyn_star)]` is likely not enabled; that feature it is currently incomplete -note: function defined here - --> $DIR/auxiliary/dyn-star-foreign.rs:5:8 - | -LL | pub fn require_dyn_star_display(_: dyn* Display) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs deleted file mode 100644 index 1702fc1ed49..00000000000 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![expect(incomplete_features)] -#![feature(dyn_star)] - -trait A: B {} -trait B {} -impl A for usize {} -impl B for usize {} - -fn main() { - let x: Box<dyn* A> = Box::new(1usize as dyn* A); - let y: Box<dyn* B> = x; - //~^ ERROR mismatched types -} diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr deleted file mode 100644 index 289d85072e6..00000000000 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 - | -LL | let y: Box<dyn* B> = x; - | ----------- ^ expected trait `B`, found trait `A` - | | - | expected due to this - | - = note: expected struct `Box<dyn* B>` - found struct `Box<dyn* A>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr deleted file mode 100644 index 6e464c17014..00000000000 --- a/tests/ui/dyn-star/param-env-region-infer.current.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/param-env-region-infer.rs:20:10 - | -LL | t as _ - | ^ cannot infer type - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs deleted file mode 100644 index 842964ad284..00000000000 --- a/tests/ui/dyn-star/param-env-region-infer.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ revisions: current -//@ incremental - -// FIXME(-Znext-solver): This currently results in unstable query results: -// `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)` -// once the hidden type of the opaque is already defined to be itself. -//@ unused-revision-names: next - -// checks that we don't ICE if there are region inference variables in the environment -// when computing `PointerLike` builtin candidates. - -#![feature(dyn_star, pointer_like_trait)] -#![allow(incomplete_features)] - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - //[next]~^ ERROR cycle detected when computing - t as _ - //[current]~^ ERROR type annotations needed -} - -fn main() {} diff --git a/tests/ui/dyn-star/pointer-like-impl-rules.rs b/tests/ui/dyn-star/pointer-like-impl-rules.rs deleted file mode 100644 index c234e86e09a..00000000000 --- a/tests/ui/dyn-star/pointer-like-impl-rules.rs +++ /dev/null @@ -1,82 +0,0 @@ -//@ check-fail - -#![feature(extern_types)] -#![feature(pointer_like_trait)] - -use std::marker::PointerLike; - -struct NotReprTransparent; -impl PointerLike for NotReprTransparent {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the struct `NotReprTransparent` is not `repr(transparent)` - -#[repr(transparent)] -struct FieldIsPl(usize); -impl PointerLike for FieldIsPl {} - -#[repr(transparent)] -struct FieldIsPlAndHasOtherField(usize, ()); -impl PointerLike for FieldIsPlAndHasOtherField {} - -#[repr(transparent)] -struct FieldIsNotPl(u8); -impl PointerLike for FieldIsNotPl {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the field `0` of struct `FieldIsNotPl` does not implement `PointerLike` - -#[repr(transparent)] -struct GenericFieldIsNotPl<T>(T); -impl<T> PointerLike for GenericFieldIsNotPl<T> {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the field `0` of struct `GenericFieldIsNotPl<T>` does not implement `PointerLike` - -#[repr(transparent)] -struct GenericFieldIsPl<T>(T); -impl<T: PointerLike> PointerLike for GenericFieldIsPl<T> {} - -#[repr(transparent)] -struct IsZeroSized(()); -impl PointerLike for IsZeroSized {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the struct `IsZeroSized` is `repr(transparent)`, but does not have a non-trivial field - -trait SomeTrait {} -impl PointerLike for dyn SomeTrait {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: types of dynamic or unknown size - -extern "C" { - type ExternType; -} -impl PointerLike for ExternType {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: types of dynamic or unknown size - -struct LocalSizedType(&'static str); -struct LocalUnsizedType(str); - -// This is not a special error but a normal coherence error, -// which should still happen. -impl PointerLike for &LocalSizedType {} -//~^ ERROR: conflicting implementations of trait `PointerLike` -//~| NOTE: conflicting implementation in crate `core` - -impl PointerLike for &LocalUnsizedType {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: references to dynamically-sized types are too large to be `PointerLike` - -impl PointerLike for Box<LocalSizedType> {} -//~^ ERROR: conflicting implementations of trait `PointerLike` -//~| NOTE: conflicting implementation in crate `alloc` - -impl PointerLike for Box<LocalUnsizedType> {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: boxes of dynamically-sized types are too large to be `PointerLike` - -fn expects_pointer_like(x: impl PointerLike) {} - -fn main() { - expects_pointer_like(FieldIsPl(1usize)); - expects_pointer_like(FieldIsPlAndHasOtherField(1usize, ())); - expects_pointer_like(GenericFieldIsPl(1usize)); -} diff --git a/tests/ui/dyn-star/pointer-like-impl-rules.stderr b/tests/ui/dyn-star/pointer-like-impl-rules.stderr deleted file mode 100644 index 39f08f442c4..00000000000 --- a/tests/ui/dyn-star/pointer-like-impl-rules.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0119]: conflicting implementations of trait `PointerLike` for type `&LocalSizedType` - --> $DIR/pointer-like-impl-rules.rs:60:1 - | -LL | impl PointerLike for &LocalSizedType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `core`: - - impl<T> PointerLike for &T; - -error[E0119]: conflicting implementations of trait `PointerLike` for type `Box<LocalSizedType>` - --> $DIR/pointer-like-impl-rules.rs:68:1 - | -LL | impl PointerLike for Box<LocalSizedType> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `alloc`: - - impl<T> PointerLike for Box<T>; - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:9:1 - | -LL | impl PointerLike for NotReprTransparent {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the struct `NotReprTransparent` is not `repr(transparent)` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:23:1 - | -LL | impl PointerLike for FieldIsNotPl {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the field `0` of struct `FieldIsNotPl` does not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:29:1 - | -LL | impl<T> PointerLike for GenericFieldIsNotPl<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the field `0` of struct `GenericFieldIsNotPl<T>` does not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:39:1 - | -LL | impl PointerLike for IsZeroSized {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the struct `IsZeroSized` is `repr(transparent)`, but does not have a non-trivial field (it is zero-sized) - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:44:1 - | -LL | impl PointerLike for dyn SomeTrait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: types of dynamic or unknown size may not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:51:1 - | -LL | impl PointerLike for ExternType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: types of dynamic or unknown size may not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:64:1 - | -LL | impl PointerLike for &LocalUnsizedType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: references to dynamically-sized types are too large to be `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:72:1 - | -LL | impl PointerLike for Box<LocalUnsizedType> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: boxes of dynamically-sized types are too large to be `PointerLike` - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/dyn-star/return.rs b/tests/ui/dyn-star/return.rs deleted file mode 100644 index 47d95d1d643..00000000000 --- a/tests/ui/dyn-star/return.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -fn _foo() -> dyn* Unpin { - 4usize -} - -fn main() {} diff --git a/tests/ui/dyn-star/return.stderr b/tests/ui/dyn-star/return.stderr deleted file mode 100644 index 9c265682904..00000000000 --- a/tests/ui/dyn-star/return.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/syntax.rs b/tests/ui/dyn-star/syntax.rs deleted file mode 100644 index d4983404de2..00000000000 --- a/tests/ui/dyn-star/syntax.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Make sure we can parse the `dyn* Trait` syntax -// -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -pub fn dyn_star_parameter(_: dyn* Send) { -} - -fn main() {} diff --git a/tests/ui/dyn-star/thin.next.stderr b/tests/ui/dyn-star/thin.next.stderr deleted file mode 100644 index ef251062afc..00000000000 --- a/tests/ui/dyn-star/thin.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/thin.rs:6:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/thin.old.stderr b/tests/ui/dyn-star/thin.old.stderr deleted file mode 100644 index ef251062afc..00000000000 --- a/tests/ui/dyn-star/thin.old.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/thin.rs:6:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/thin.rs b/tests/ui/dyn-star/thin.rs deleted file mode 100644 index 6df70f560de..00000000000 --- a/tests/ui/dyn-star/thin.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@check-pass -//@revisions: old next -//@[next] compile-flags: -Znext-solver - -#![feature(ptr_metadata)] -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; -use std::ptr::Thin; - -fn check_thin<T: ?Sized + Thin>() {} - -fn main() { - check_thin::<dyn* Debug>(); -} diff --git a/tests/ui/dyn-star/union.rs b/tests/ui/dyn-star/union.rs deleted file mode 100644 index ad3a85a937a..00000000000 --- a/tests/ui/dyn-star/union.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -union Union { - x: usize, -} - -trait Trait {} -impl Trait for Union {} - -fn bar(_: dyn* Trait) {} - -fn main() { - bar(Union { x: 0usize }); - //~^ ERROR `Union` needs to have the same ABI as a pointer -} diff --git a/tests/ui/dyn-star/union.stderr b/tests/ui/dyn-star/union.stderr deleted file mode 100644 index 906eb4f5163..00000000000 --- a/tests/ui/dyn-star/union.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/union.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `Union` needs to have the same ABI as a pointer - --> $DIR/union.rs:14:9 - | -LL | bar(Union { x: 0usize }); - | ^^^^^^^^^^^^^^^^^^^ `Union` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `Union` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs b/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs deleted file mode 100644 index 1e8cafe1561..00000000000 --- a/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn main() { - let i = 42 as &dyn* Debug; - //~^ ERROR non-primitive cast: `i32` as `&dyn* Debug` -} diff --git a/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr b/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr deleted file mode 100644 index b3274580afe..00000000000 --- a/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0605]: non-primitive cast: `i32` as `&dyn* Debug` - --> $DIR/unsize-into-ref-dyn-star.rs:7:13 - | -LL | let i = 42 as &dyn* Debug; - | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/dyn-star/upcast.rs b/tests/ui/dyn-star/upcast.rs deleted file mode 100644 index 01e1b94f87e..00000000000 --- a/tests/ui/dyn-star/upcast.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ known-bug: #104800 - -#![feature(dyn_star)] - -trait Foo: Bar { - fn hello(&self); -} - -trait Bar { - fn world(&self); -} - -struct W(usize); - -impl Foo for W { - fn hello(&self) { - println!("hello!"); - } -} - -impl Bar for W { - fn world(&self) { - println!("world!"); - } -} - -fn main() { - let w: dyn* Foo = W(0); - w.hello(); - let w: dyn* Bar = w; - w.world(); -} diff --git a/tests/ui/dyn-star/upcast.stderr b/tests/ui/dyn-star/upcast.stderr deleted file mode 100644 index 3f244d4b6ae..00000000000 --- a/tests/ui/dyn-star/upcast.stderr +++ /dev/null @@ -1,28 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/upcast.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `W` needs to have the same ABI as a pointer - --> $DIR/upcast.rs:28:23 - | -LL | let w: dyn* Foo = W(0); - | ^^^^ `W` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `W` - -error[E0277]: `dyn* Foo` needs to have the same ABI as a pointer - --> $DIR/upcast.rs:30:23 - | -LL | let w: dyn* Bar = w; - | ^ `dyn* Foo` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn* Foo` - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index c29d258a90b..77449656ea6 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -15,6 +15,18 @@ LL | | A LL | | } | |_- not a struct or union +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/eval-error.rs:2:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop<str>, + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/eval-error.rs:2:8 | @@ -33,18 +45,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | a: Box<str>, | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/eval-error.rs:2:5 - | -LL | a: str, - | ^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | a: std::mem::ManuallyDrop<str>, - | +++++++++++++++++++++++ + - error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | diff --git a/tests/ui/extern/issue-36122-accessing-externed-dst.stderr b/tests/ui/extern/issue-36122-accessing-externed-dst.stderr index 6f805aec1df..8007c3f13e5 100644 --- a/tests/ui/extern/issue-36122-accessing-externed-dst.stderr +++ b/tests/ui/extern/issue-36122-accessing-externed-dst.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[usize]` cannot be known at compilation time - --> $DIR/issue-36122-accessing-externed-dst.rs:3:24 + --> $DIR/issue-36122-accessing-externed-dst.rs:3:9 | LL | static symbol: [usize]; - | ^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[usize]` = note: statics and constants must have a statically known size diff --git a/tests/ui/extern/issue-47725.rs b/tests/ui/extern/issue-47725.rs index 012673b9159..60d0cd62347 100644 --- a/tests/ui/extern/issue-47725.rs +++ b/tests/ui/extern/issue-47725.rs @@ -17,7 +17,6 @@ extern "C" { #[link_name] //~^ ERROR malformed `link_name` attribute input //~| HELP must be of the form -//~| NOTE expected this to be of the form `link_name = "..." extern "C" { fn bar() -> u32; } diff --git a/tests/ui/extern/issue-47725.stderr b/tests/ui/extern/issue-47725.stderr index 53d6b4927f8..4fd02a1778b 100644 --- a/tests/ui/extern/issue-47725.stderr +++ b/tests/ui/extern/issue-47725.stderr @@ -2,10 +2,7 @@ error[E0539]: malformed `link_name` attribute input --> $DIR/issue-47725.rs:17:1 | LL | #[link_name] - | ^^^^^^^^^^^^ - | | - | expected this to be of the form `link_name = "..."` - | help: must be of the form: `#[link_name = "name"]` + | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` warning: attribute should be applied to a foreign function or static --> $DIR/issue-47725.rs:3:1 diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 7768c25bd2c..334bc63b7ee 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -56,6 +56,19 @@ LL | impl Fn<()> for Foo { | = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable +error[E0053]: method `call` has an incompatible type for trait + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 + | +LL | extern "rust-call" fn call(self, args: ()) -> () {} + | ^^^^ expected `&Foo`, found `Foo` + | + = note: expected signature `extern "rust-call" fn(&Foo, ()) -> _` + found signature `extern "rust-call" fn(Foo, ()) -> ()` +help: change the self-receiver type to match the trait + | +LL | extern "rust-call" fn call(&self, args: ()) -> () {} + | + + error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:6 | @@ -85,19 +98,6 @@ LL | impl Fn<()> for Foo { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0053]: method `call` has an incompatible type for trait - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 - | -LL | extern "rust-call" fn call(self, args: ()) -> () {} - | ^^^^ expected `&Foo`, found `Foo` - | - = note: expected signature `extern "rust-call" fn(&Foo, ()) -> _` - found signature `extern "rust-call" fn(Foo, ()) -> ()` -help: change the self-receiver type to match the trait - | -LL | extern "rust-call" fn call(&self, args: ()) -> () {} - | + - error[E0183]: manual implementations of `FnOnce` are experimental --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:18:6 | @@ -144,17 +144,6 @@ LL | impl FnOnce() for Foo1 { | = help: implement the missing item: `type Output = /* Type */;` -error[E0277]: expected a `FnOnce()` closure, found `Bar` - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:20 - | -LL | impl FnMut<()> for Bar { - | ^^^ expected an `FnOnce()` closure, found `Bar` - | - = help: the trait `FnOnce()` is not implemented for `Bar` - = note: wrap the `Bar` in a closure with no arguments: `|| { /* code */ }` -note: required by a bound in `FnMut` - --> $SRC_DIR/core/src/ops/function.rs:LL:COL - error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36 | @@ -168,6 +157,17 @@ help: change the self-receiver type to match the trait LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {} | +++ +error[E0277]: expected a `FnOnce()` closure, found `Bar` + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:20 + | +LL | impl FnMut<()> for Bar { + | ^^^ expected an `FnOnce()` closure, found `Bar` + | + = help: the trait `FnOnce()` is not implemented for `Bar` + = note: wrap the `Bar` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `FnMut` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + error[E0046]: not all trait items implemented, missing: `Output` --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:1 | diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 1243ed5d8f4..02b9e2f06ee 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -387,14 +387,6 @@ LL | #![link()] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 - | -LL | #![link_section = "1800"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - warning: attribute should be applied to a function definition --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 | @@ -411,6 +403,14 @@ LL | #![link_name = "1900"] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 + | +LL | #![link_section = "1800"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + warning: `#[must_use]` has no effect when applied to a module --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 | diff --git a/tests/ui/logging-only-prints-once.rs b/tests/ui/fmt/debug-single-call.rs index bb8c29694b5..b59a766c71a 100644 --- a/tests/ui/logging-only-prints-once.rs +++ b/tests/ui/fmt/debug-single-call.rs @@ -1,9 +1,12 @@ +//! Test that Debug::fmt is called exactly once during formatting. +//! +//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715 + //@ run-pass //@ needs-threads use std::cell::Cell; -use std::fmt; -use std::thread; +use std::{fmt, thread}; struct Foo(Cell<isize>); diff --git a/tests/ui/fn/error-recovery-mismatch.stderr b/tests/ui/fn/error-recovery-mismatch.stderr index c046302cb91..10dab3052be 100644 --- a/tests/ui/fn/error-recovery-mismatch.stderr +++ b/tests/ui/fn/error-recovery-mismatch.stderr @@ -29,7 +29,7 @@ LL | fn fold<T>(&self, _: T, &self._) {} = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> = note: `#[warn(anonymous_parameters)]` on by default -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/error-recovery-mismatch.rs:11:35 | LL | fn fold<T>(&self, _: T, &self._) {} diff --git a/tests/ui/fn/issue-39259.stderr b/tests/ui/fn/issue-39259.stderr index a923d7b26ef..90e305ca17a 100644 --- a/tests/ui/fn/issue-39259.stderr +++ b/tests/ui/fn/issue-39259.stderr @@ -10,6 +10,14 @@ help: parenthesized trait syntax expands to `Fn<(u32,), Output=u32>` LL | impl Fn(u32) -> u32 for S { | ^^^^^^^^^^^^^^ +error[E0050]: method `call` has 1 parameter but the declaration in trait `call` has 2 + --> $DIR/issue-39259.rs:9:13 + | +LL | fn call(&self) -> u32 { + | ^^^^^ expected 2 parameters, found 1 + | + = note: `call` from trait: `extern "rust-call" fn(&Self, Args) -> <Self as FnOnce<Args>>::Output` + error[E0277]: expected a `FnMut(u32)` closure, found `S` --> $DIR/issue-39259.rs:6:25 | @@ -20,14 +28,6 @@ LL | impl Fn(u32) -> u32 for S { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0050]: method `call` has 1 parameter but the declaration in trait `call` has 2 - --> $DIR/issue-39259.rs:9:13 - | -LL | fn call(&self) -> u32 { - | ^^^^^ expected 2 parameters, found 1 - | - = note: `call` from trait: `extern "rust-call" fn(&Self, Args) -> <Self as FnOnce<Args>>::Output` - error: aborting due to 3 previous errors Some errors have detailed explanations: E0050, E0229, E0277. diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.stderr b/tests/ui/generic-associated-types/bugs/issue-87735.stderr index 1b955431363..c3f4f7a73f3 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-87735.stderr @@ -5,12 +5,13 @@ LL | impl<'b, T, U> AsRef2 for Foo<T> | ^ unconstrained type parameter error[E0309]: the parameter type `U` may not live long enough - --> $DIR/issue-87735.rs:34:21 + --> $DIR/issue-87735.rs:34:3 | LL | type Output<'a> = FooRef<'a, U> where Self: 'a; - | -- ^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds... - | | - | the parameter type `U` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^^^--^ + | | | + | | the parameter type `U` must be valid for the lifetime `'a` as defined here... + | ...so that the type `U` will meet its required lifetime bounds... | note: ...that is required by this bound --> $DIR/issue-87735.rs:23:22 diff --git a/tests/ui/generic-associated-types/bugs/issue-88526.stderr b/tests/ui/generic-associated-types/bugs/issue-88526.stderr index 5da3e3ff64a..5e39eb7a6b9 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88526.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-88526.stderr @@ -5,12 +5,13 @@ LL | impl<'q, Q, I, F> A for TestB<Q, F> | ^ unconstrained type parameter error[E0309]: the parameter type `F` may not live long enough - --> $DIR/issue-88526.rs:16:18 + --> $DIR/issue-88526.rs:16:5 | LL | type I<'a> = &'a F; - | -- ^^^^^ ...so that the reference type `&'a F` does not outlive the data it points at - | | - | the parameter type `F` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^--^ + | | | + | | the parameter type `F` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a F` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs index d00c036fbd5..81e2db182bc 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs +++ b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs @@ -9,6 +9,7 @@ impl <T, T1> Foo for T { type F<T1> = &[u8]; //~^ ERROR: the name `T1` is already used for //~| ERROR: `&` without an explicit lifetime name cannot be used here + //~| ERROR: has 1 type parameter but its trait declaration has 0 type parameters } fn main() {} diff --git a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr index cb2b9f32bfe..42aa83c8f43 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr @@ -13,13 +13,22 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here LL | type F<T1> = &[u8]; | ^ explicit lifetime name needed here +error[E0049]: associated type `F` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/gat-trait-path-generic-type-arg.rs:9:12 + | +LL | type F<'a>; + | -- expected 0 type parameters +... +LL | type F<T1> = &[u8]; + | ^^ found 1 type parameter + error[E0207]: the type parameter `T1` is not constrained by the impl trait, self type, or predicates --> $DIR/gat-trait-path-generic-type-arg.rs:7:10 | LL | impl <T, T1> Foo for T { | ^^ unconstrained type parameter -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0207, E0403, E0637. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0049, E0207, E0403, E0637. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-associated-types/issue-84931.stderr b/tests/ui/generic-associated-types/issue-84931.stderr index 71d112277a3..01819481108 100644 --- a/tests/ui/generic-associated-types/issue-84931.stderr +++ b/tests/ui/generic-associated-types/issue-84931.stderr @@ -18,12 +18,13 @@ LL | type Item<'a> = &'a mut T where Self: 'a; | ++++++++++++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-84931.rs:14:21 + --> $DIR/issue-84931.rs:14:5 | LL | type Item<'a> = &'a mut T; - | -- ^^^^^^^^^ ...so that the reference type `&'a mut T` does not outlive the data it points at - | | - | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^--^ + | | | + | | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a mut T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr b/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr index 7d985a9013f..786aa00350c 100644 --- a/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr +++ b/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr @@ -82,6 +82,14 @@ help: consider adding an explicit lifetime bound LL | struct Far<T: 'static | +++++++++ +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/static-lifetime-tip-with-default-type.rs:22:10 + | +LL | struct S<'a, K: 'a = i32>(&'static K); + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + error[E0310]: the parameter type `K` may not live long enough --> $DIR/static-lifetime-tip-with-default-type.rs:22:27 | @@ -96,14 +104,6 @@ help: consider adding an explicit lifetime bound LL | struct S<'a, K: 'a + 'static = i32>(&'static K); | +++++++++ -error[E0392]: lifetime parameter `'a` is never used - --> $DIR/static-lifetime-tip-with-default-type.rs:22:10 - | -LL | struct S<'a, K: 'a = i32>(&'static K); - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - error: aborting due to 8 previous errors Some errors have detailed explanations: E0310, E0392. diff --git a/tests/ui/generic-const-items/evaluatable-bounds.stderr b/tests/ui/generic-const-items/evaluatable-bounds.stderr index ca26d633658..8bc4a3d236f 100644 --- a/tests/ui/generic-const-items/evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/evaluatable-bounds.stderr @@ -2,7 +2,7 @@ error: unconstrained generic constant --> $DIR/evaluatable-bounds.rs:14:5 | LL | const ARRAY: [i32; Self::LEN]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | diff --git a/tests/ui/generics/newtype-with-generics.rs b/tests/ui/generics/newtype-with-generics.rs new file mode 100644 index 00000000000..c5e200e4bc4 --- /dev/null +++ b/tests/ui/generics/newtype-with-generics.rs @@ -0,0 +1,32 @@ +//! Test newtype pattern with generic parameters. + +//@ run-pass + +#[derive(Clone)] +struct MyVec<T>(Vec<T>); + +fn extract_inner_vec<T: Clone>(wrapper: MyVec<T>) -> Vec<T> { + let MyVec(inner_vec) = wrapper; + inner_vec.clone() +} + +fn get_first_element<T>(wrapper: MyVec<T>) -> T { + let MyVec(inner_vec) = wrapper; + inner_vec.into_iter().next().unwrap() +} + +pub fn main() { + let my_vec = MyVec(vec![1, 2, 3]); + let cloned_vec = my_vec.clone(); + + // Test extracting inner vector + let extracted = extract_inner_vec(cloned_vec); + assert_eq!(extracted[1], 2); + + // Test getting first element + assert_eq!(get_first_element(my_vec.clone()), 1); + + // Test direct destructuring + let MyVec(inner) = my_vec; + assert_eq!(inner[2], 3); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr index 7fe803550bd..5ded3a5e76c 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr @@ -53,10 +53,10 @@ LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:22:20 + --> $DIR/issue-89118.rs:22:5 | LL | type Handler = Ctx<C::Dispatcher>; - | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` + | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` | help: this trait has no implementations, consider adding one --> $DIR/issue-89118.rs:1:1 diff --git a/tests/ui/new-impl-syntax.rs b/tests/ui/impl-trait/basic-trait-impl.rs index 124d604e6a8..2706c9c1798 100644 --- a/tests/ui/new-impl-syntax.rs +++ b/tests/ui/impl-trait/basic-trait-impl.rs @@ -1,10 +1,12 @@ +//! Test basic trait implementation syntax for both simple and generic types. + //@ run-pass use std::fmt; struct Thingy { x: isize, - y: isize + y: isize, } impl fmt::Debug for Thingy { @@ -14,10 +16,10 @@ impl fmt::Debug for Thingy { } struct PolymorphicThingy<T> { - x: T + x: T, } -impl<T:fmt::Debug> fmt::Debug for PolymorphicThingy<T> { +impl<T: fmt::Debug> fmt::Debug for PolymorphicThingy<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.x) } diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr index b6e7e02f331..2351b18fdfc 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr @@ -19,11 +19,14 @@ help: consider further restricting type parameter `F` with trait `MyFn` LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ -error[E0277]: the trait bound `F: Callback<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:42:12 +error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied + --> $DIR/false-positive-predicate-entailment-error.rs:36:5 | -LL | F: Callback<Self::CallbackArg>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` +LL | / fn autobatch<F>(self) -> impl Trait +... | +LL | | where +LL | | F: Callback<Self::CallbackArg>, + | |_______________________________________^ the trait `MyFn<i32>` is not implemented for `F` | note: required for `F` to implement `Callback<i32>` --> $DIR/false-positive-predicate-entailment-error.rs:14:21 @@ -32,27 +35,17 @@ LL | impl<A, F: MyFn<A>> Callback<A> for F { | ------- ^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method - --> $DIR/false-positive-predicate-entailment-error.rs:25:8 - | -LL | trait ChannelSender { - | ------------- in this trait -... -LL | fn autobatch<F>(self) -> impl Trait - | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ -error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:36:5 +error[E0277]: the trait bound `F: Callback<i32>` is not satisfied + --> $DIR/false-positive-predicate-entailment-error.rs:42:12 | -LL | / fn autobatch<F>(self) -> impl Trait -... | -LL | | where -LL | | F: Callback<Self::CallbackArg>, - | |_______________________________________^ the trait `MyFn<i32>` is not implemented for `F` +LL | F: Callback<Self::CallbackArg>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` | note: required for `F` to implement `Callback<i32>` --> $DIR/false-positive-predicate-entailment-error.rs:14:21 @@ -61,7 +54,14 @@ LL | impl<A, F: MyFn<A>> Callback<A> for F { | ------- ^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method + --> $DIR/false-positive-predicate-entailment-error.rs:25:8 + | +LL | trait ChannelSender { + | ------------- in this trait +... +LL | fn autobatch<F>(self) -> impl Trait + | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback<Self::CallbackArg> + MyFn<i32>, diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr index 5d651245746..ff3a726477e 100644 --- a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr +++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr @@ -46,11 +46,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr index 4bbba62bd71..f0a20367a4a 100644 --- a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr +++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr @@ -50,11 +50,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}` @@ -109,11 +109,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs index 894f592d9e2..8433fb72b5e 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs @@ -9,6 +9,7 @@ pub trait Mirror { impl<T: ?Sized> Mirror for () { //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR the size for values of type `T` cannot be known at compilation time } pub trait First { diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr index 10ebad2a7d5..fd53c9fef44 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Mirror for () { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/refine-resolution-errors.rs:11:18 + | +LL | impl<T: ?Sized> Mirror for () { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Mirror::Assoc` + --> $DIR/refine-resolution-errors.rs:7:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Mirror::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Mirror for () { +LL + impl<T> Mirror for () { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr index eaa320455bb..f95f6fab413 100644 --- a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr +++ b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr @@ -1,3 +1,15 @@ +error[E0195]: lifetime parameters or bounds on associated type `Item` do not match the trait declaration + --> $DIR/span-bug-issue-121457.rs:10:14 + | +LL | type Item<'a> + | ---- lifetimes in impl do not match this associated type in trait +LL | where +LL | Self: 'a; + | -- this bound might be missing in the impl +... +LL | type Item = u32; + | ^ lifetimes do not match associated type in trait + error[E0582]: binding for associated type `Item` references lifetime `'missing`, which does not appear in the trait input types --> $DIR/span-bug-issue-121457.rs:13:51 | @@ -12,18 +24,6 @@ LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missin | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0195]: lifetime parameters or bounds on associated type `Item` do not match the trait declaration - --> $DIR/span-bug-issue-121457.rs:10:14 - | -LL | type Item<'a> - | ---- lifetimes in impl do not match this associated type in trait -LL | where -LL | Self: 'a; - | -- this bound might be missing in the impl -... -LL | type Item = u32; - | ^ lifetimes do not match associated type in trait - error[E0277]: `()` is not an iterator --> $DIR/span-bug-issue-121457.rs:13:23 | diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs index ff3753de5a2..12e0a4263f5 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs @@ -6,6 +6,7 @@ impl<'a, T> Foo for T { //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates fn test() -> &'a () { + //~^ WARN: does not match trait method signature &() } } diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr index 4c5a42c0b4b..27340c5b362 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr @@ -1,9 +1,27 @@ +warning: impl trait in impl method signature does not match trait method signature + --> $DIR/unconstrained-lt.rs:8:18 + | +LL | fn test() -> impl Sized; + | ---------- return type from trait method defined here +... +LL | fn test() -> &'a () { + | ^^^^^^ + | + = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate + = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information + = note: `#[warn(refining_impl_trait_internal)]` on by default +help: replace the return type so that it matches the trait + | +LL - fn test() -> &'a () { +LL + fn test() -> impl Sized { + | + error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates --> $DIR/unconstrained-lt.rs:5:6 | LL | impl<'a, T> Foo for T { | ^^ unconstrained lifetime parameter -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr b/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr index 07cb0aecda8..dcb68fbf2cd 100644 --- a/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr +++ b/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references - --> $DIR/impl-header-unnormalized-types.rs:15:18 + --> $DIR/impl-header-unnormalized-types.rs:15:5 | LL | type Assoc = &'a &'b (); - | ^^^^^^^^^^ + | ^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/impl-header-unnormalized-types.rs:14:6 diff --git a/tests/ui/integral-indexing.rs b/tests/ui/indexing/indexing-integral-types.rs index e20553af8a2..a91696a6fd5 100644 --- a/tests/ui/integral-indexing.rs +++ b/tests/ui/indexing/indexing-integral-types.rs @@ -1,16 +1,20 @@ +//! Test that only usize can be used for indexing arrays and slices. + pub fn main() { let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5]; let s: String = "abcdef".to_string(); + + // Valid indexing with usize v[3_usize]; v[3]; - v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` - v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` + v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` + v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32` v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32` s.as_bytes()[3_usize]; s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` - s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` + s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` + s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32` s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32` } diff --git a/tests/ui/integral-indexing.stderr b/tests/ui/indexing/indexing-integral-types.stderr index 26253e078cb..b63991ec2c4 100644 --- a/tests/ui/integral-indexing.stderr +++ b/tests/ui/indexing/indexing-integral-types.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `[isize]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:6:7 + --> $DIR/indexing-integral-types.rs:10:7 | LL | v[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -11,7 +11,7 @@ LL | v[3u8]; = note: required for `Vec<isize>` to implement `Index<u8>` error[E0277]: the type `[isize]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:7:7 + --> $DIR/indexing-integral-types.rs:11:7 | LL | v[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -23,7 +23,7 @@ LL | v[3i8]; = note: required for `Vec<isize>` to implement `Index<i8>` error[E0277]: the type `[isize]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:8:7 + --> $DIR/indexing-integral-types.rs:12:7 | LL | v[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -35,7 +35,7 @@ LL | v[3u32]; = note: required for `Vec<isize>` to implement `Index<u32>` error[E0277]: the type `[isize]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:9:7 + --> $DIR/indexing-integral-types.rs:13:7 | LL | v[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -47,7 +47,7 @@ LL | v[3i32]; = note: required for `Vec<isize>` to implement `Index<i32>` error[E0277]: the type `[u8]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:12:18 + --> $DIR/indexing-integral-types.rs:16:18 | LL | s.as_bytes()[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -59,7 +59,7 @@ LL | s.as_bytes()[3u8]; = note: required for `[u8]` to implement `Index<u8>` error[E0277]: the type `[u8]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:13:18 + --> $DIR/indexing-integral-types.rs:17:18 | LL | s.as_bytes()[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -71,7 +71,7 @@ LL | s.as_bytes()[3i8]; = note: required for `[u8]` to implement `Index<i8>` error[E0277]: the type `[u8]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:14:18 + --> $DIR/indexing-integral-types.rs:18:18 | LL | s.as_bytes()[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -83,7 +83,7 @@ LL | s.as_bytes()[3u32]; = note: required for `[u8]` to implement `Index<u32>` error[E0277]: the type `[u8]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:15:18 + --> $DIR/indexing-integral-types.rs:19:18 | LL | s.as_bytes()[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.stderr b/tests/ui/infinite/infinite-trait-alias-recursion.stderr index 5b0cbd58231..fa51914415d 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.stderr +++ b/tests/ui/infinite/infinite-trait-alias-recursion.stderr @@ -20,7 +20,7 @@ note: cycle used when checking that `T1` is well-formed --> $DIR/infinite-trait-alias-recursion.rs:3:1 | LL | trait T1 = T2; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr index 3dec2c3084f..e586248f5d2 100644 --- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr @@ -1,24 +1,24 @@ error[E0275]: overflow normalizing the type alias `X2` - --> $DIR/infinite-type-alias-mutual-recursion.rs:6:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:6:1 | LL | type X1 = X2; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `X3` - --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:1 | LL | type X2 = X3; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `X1` - --> $DIR/infinite-type-alias-mutual-recursion.rs:11:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:11:1 | LL | type X3 = X1; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr index 5c8d50341c1..3e07a46ea26 100644 --- a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr +++ b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow normalizing the type alias `X` - --> $DIR/infinite-vec-type-recursion.rs:6:10 + --> $DIR/infinite-vec-type-recursion.rs:6:1 | LL | type X = Vec<X>; - | ^^^^^^ + | ^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/inner-attrs-on-impl.rs b/tests/ui/inner-attrs-on-impl.rs deleted file mode 100644 index 1dce1cdd261..00000000000 --- a/tests/ui/inner-attrs-on-impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass - -struct Foo; - -impl Foo { - #![cfg(false)] - - fn method(&self) -> bool { false } -} - -impl Foo { - #![cfg(not(FALSE))] - - // check that we don't eat attributes too eagerly. - #[cfg(false)] - fn method(&self) -> bool { false } - - fn method(&self) -> bool { true } -} - - -pub fn main() { - assert!(Foo.method()); -} diff --git a/tests/ui/inner-module.rs b/tests/ui/inner-module.rs deleted file mode 100644 index 111f2cab857..00000000000 --- a/tests/ui/inner-module.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -mod inner { - pub mod inner2 { - pub fn hello() { println!("hello, modular world"); } - } - pub fn hello() { inner2::hello(); } -} - -pub fn main() { inner::hello(); inner::inner2::hello(); } diff --git a/tests/ui/inner-static-type-parameter.rs b/tests/ui/inner-static-type-parameter.rs deleted file mode 100644 index a1994e7529c..00000000000 --- a/tests/ui/inner-static-type-parameter.rs +++ /dev/null @@ -1,11 +0,0 @@ -// see #9186 - -enum Bar<T> { What } //~ ERROR parameter `T` is never used - -fn foo<T>() { - static a: Bar<T> = Bar::What; -//~^ ERROR can't use generic parameters from outer item -} - -fn main() { -} diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr index 7879e7358c0..8b9ad78db37 100644 --- a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr +++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr @@ -1,20 +1,38 @@ -error: expected exactly one integer literal argument +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:3:1 | LL | #[rustc_layout_scalar_valid_range_start(u32::MAX)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` -error: expected exactly one integer literal argument +error[E0805]: malformed `rustc_layout_scalar_valid_range_end` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:6:1 | LL | #[rustc_layout_scalar_valid_range_end(1, 2)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^ + | | | + | | expected a single argument here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` -error: expected exactly one integer literal argument +error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:9:1 | LL | #[rustc_layout_scalar_valid_range_end(a = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` + +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1 + | +LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` error: attribute should be applied to a struct --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1 @@ -27,11 +45,7 @@ LL | | Y = 14, LL | | } | |_- not a struct -error: expected exactly one integer literal argument - --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1 - | -LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 5 previous errors +Some errors have detailed explanations: E0539, E0805. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/issues/issue-54410.stderr b/tests/ui/issues/issue-54410.stderr index 2cd5a2a49ef..cb68ada7e13 100644 --- a/tests/ui/issues/issue-54410.stderr +++ b/tests/ui/issues/issue-54410.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[i8]` cannot be known at compilation time - --> $DIR/issue-54410.rs:2:28 + --> $DIR/issue-54410.rs:2:5 | LL | pub static mut symbol: [i8]; - | ^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i8]` = note: statics and constants must have a statically known size diff --git a/tests/ui/issues/issue-7364.stderr b/tests/ui/issues/issue-7364.stderr index a47a90c90ce..e07f88b806c 100644 --- a/tests/ui/issues/issue-7364.stderr +++ b/tests/ui/issues/issue-7364.stderr @@ -1,8 +1,8 @@ error[E0277]: `RefCell<isize>` cannot be shared between threads safely - --> $DIR/issue-7364.rs:4:15 + --> $DIR/issue-7364.rs:4:1 | LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); - | ^^^^^^^^^^^^^^^^^^^ `RefCell<isize>` cannot be shared between threads safely + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `RefCell<isize>` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `RefCell<isize>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead diff --git a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr index 626be7ac283..b0ea655fc67 100644 --- a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr +++ b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr @@ -70,6 +70,18 @@ help: the `Box` type always has a statically known size and allocates its conten LL | field2: Box<str>, // Unsized | ++++ + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:5 + | +LL | field2: str, // Unsized + | ^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | field2: std::mem::ManuallyDrop<str>, // Unsized + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:13 | @@ -88,18 +100,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | field2: Box<str>, // Unsized | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:5 - | -LL | field2: str, // Unsized - | ^^^^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | field2: std::mem::ManuallyDrop<str>, // Unsized - | +++++++++++++++++++++++ + - error: aborting due to 6 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr b/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr index 32a564e466b..75ee936d9e8 100644 --- a/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr +++ b/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr @@ -1,4 +1,17 @@ error[E0059]: type parameter to bare `FnOnce` trait must be a tuple + --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 + | +LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` + | +note: required by a bound in `FnOnce` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL +help: consider further restricting type parameter `A` with unstable trait `Tuple` + | +LL | A: Eq + Hash + Clone + std::marker::Tuple, + | ++++++++++++++++++++ + +error[E0059]: type parameter to bare `FnOnce` trait must be a tuple --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:24:12 | LL | impl<A, B> FnOnce<A> for CachedFun<A, B> @@ -12,9 +25,9 @@ LL | A: Eq + Hash + Clone + std::marker::Tuple, | ++++++++++++++++++++ error[E0059]: type parameter to bare `FnOnce` trait must be a tuple - --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 + --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:45:5 | -LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { +LL | extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` | note: required by a bound in `FnOnce` @@ -37,19 +50,6 @@ help: consider further restricting type parameter `A` with unstable trait `Tuple LL | A: Eq + Hash + Clone + std::marker::Tuple, | ++++++++++++++++++++ -error[E0059]: type parameter to bare `FnOnce` trait must be a tuple - --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:45:5 - | -LL | extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` - | -note: required by a bound in `FnOnce` - --> $SRC_DIR/core/src/ops/function.rs:LL:COL -help: consider further restricting type parameter `A` with unstable trait `Tuple` - | -LL | A: Eq + Hash + Clone + std::marker::Tuple, - | ++++++++++++++++++++ - error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 | diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr index 85ac98f4050..e91946066bd 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow normalizing the type alias `Loop` - --> $DIR/inherent-impls-overflow.rs:8:13 + --> $DIR/inherent-impls-overflow.rs:8:1 | LL | type Loop = Loop; - | ^^^^ + | ^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead @@ -15,18 +15,18 @@ LL | impl Loop {} = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:17:17 + --> $DIR/inherent-impls-overflow.rs:17:1 | LL | type Poly0<T> = Poly1<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:21:17 + --> $DIR/inherent-impls-overflow.rs:21:1 | LL | type Poly1<T> = Poly0<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr index e94f29de44f..62ed6e8e513 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving `Loop normalizes-to _` - --> $DIR/inherent-impls-overflow.rs:8:13 + --> $DIR/inherent-impls-overflow.rs:8:1 | LL | type Loop = Loop; - | ^^^^ types differ + | ^^^^^^^^^ types differ error[E0271]: type mismatch resolving `Loop normalizes-to _` --> $DIR/inherent-impls-overflow.rs:12:1 @@ -17,10 +17,10 @@ LL | impl Loop {} | ^^^^ types differ error[E0275]: overflow evaluating the requirement `Poly1<(T,)> == _` - --> $DIR/inherent-impls-overflow.rs:17:17 + --> $DIR/inherent-impls-overflow.rs:17:1 | LL | type Poly0<T> = Poly1<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) @@ -36,10 +36,10 @@ LL | type Poly0<T> = Poly1<(T,)>; = note: all type parameters must be used in a non-recursive way in order to constrain their variance error[E0275]: overflow evaluating the requirement `Poly0<(T,)> == _` - --> $DIR/inherent-impls-overflow.rs:21:17 + --> $DIR/inherent-impls-overflow.rs:21:1 | LL | type Poly1<T> = Poly0<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) diff --git a/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr index bcffa02ddd4..d8270a0abdd 100644 --- a/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr @@ -5,10 +5,10 @@ LL | impl<T> Loop<T> {} | ^ unconstrained type parameter error[E0275]: overflow normalizing the type alias `Loop<T>` - --> $DIR/unconstrained-params-in-impl-due-to-overflow.rs:6:16 + --> $DIR/unconstrained-params-in-impl-due-to-overflow.rs:6:1 | LL | type Loop<T> = Loop<T>; - | ^^^^^^^ + | ^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr index 534ba933ba5..4bfbe0eeff7 100644 --- a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr +++ b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr @@ -7,12 +7,6 @@ LL | beta: [(); foo::<&'a ()>()], = note: lifetime parameters may not be used in const expressions = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/issue-64173-unused-lifetimes.rs:4:28 - | -LL | array: [(); size_of::<&Self>()], - | ^^^^ - error[E0392]: lifetime parameter `'s` is never used --> $DIR/issue-64173-unused-lifetimes.rs:3:12 | @@ -21,6 +15,12 @@ LL | struct Foo<'s> { | = help: consider removing `'s`, referring to it in a field, or using a marker such as `PhantomData` +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-64173-unused-lifetimes.rs:4:28 + | +LL | array: [(); size_of::<&Self>()], + | ^^^^ + error[E0392]: lifetime parameter `'a` is never used --> $DIR/issue-64173-unused-lifetimes.rs:15:12 | diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs index eab436fa341..d6fda129e36 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs @@ -7,10 +7,12 @@ async fn wrapper<F>(f: F) //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` -//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` where F:, for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, +//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` +//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` +//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` { //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` let mut i = 41; diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr index 90572fed0ed..945d38d17f6 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -10,10 +10,26 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:6:10 + --> $DIR/issue-76168-hr-outlives-3.rs:12:50 | -LL | async fn wrapper<F>(f: F) - | ^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` + | + = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` + +error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:12:57 + | +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` + | + = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` + +error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:12:72 + | +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` @@ -41,7 +57,7 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:14:1 + --> $DIR/issue-76168-hr-outlives-3.rs:16:1 | LL | / { LL | | @@ -52,6 +68,6 @@ LL | | } | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lifetimes/issue-95023.stderr b/tests/ui/lifetimes/issue-95023.stderr index cbc0eeebee1..dffa033fb17 100644 --- a/tests/ui/lifetimes/issue-95023.stderr +++ b/tests/ui/lifetimes/issue-95023.stderr @@ -32,6 +32,14 @@ help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/issue-95023.rs:3:1 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` + error[E0277]: expected a `FnMut(&isize)` closure, found `Error` --> $DIR/issue-95023.rs:3:21 | @@ -42,14 +50,6 @@ LL | impl Fn(&isize) for Error { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/issue-95023.rs:3:1 - | -LL | impl Fn(&isize) for Error { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` - error[E0220]: associated type `B` not found for `Self` --> $DIR/issue-95023.rs:8:44 | diff --git a/tests/ui/auxiliary/msvc-data-only-lib.rs b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs index b8a8f905e8b..b8a8f905e8b 100644 --- a/tests/ui/auxiliary/msvc-data-only-lib.rs +++ b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs diff --git a/tests/ui/link-section.rs b/tests/ui/linkage-attr/link-section-placement.rs index a8de8c2e1e7..6a143bfedb4 100644 --- a/tests/ui/link-section.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -1,8 +1,9 @@ +//! Test placement of functions and statics in custom link sections + //@ run-pass // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] - #![allow(non_upper_case_globals)] #[cfg(not(target_vendor = "apple"))] #[link_section = ".moretext"] diff --git a/tests/ui/linkage-attr/msvc-static-data-import.rs b/tests/ui/linkage-attr/msvc-static-data-import.rs new file mode 100644 index 00000000000..e53eb404ef6 --- /dev/null +++ b/tests/ui/linkage-attr/msvc-static-data-import.rs @@ -0,0 +1,18 @@ +//! Test that static data from external crates can be imported on MSVC targets. +//! +//! On Windows MSVC targets, static data from external rlibs must be imported +//! through `__imp_<symbol>` stubs to ensure proper linking. Without this, +//! the linker would fail with "unresolved external symbol" errors when trying +//! to reference static data from another crate. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/26591>. +//! Fixed in <https://github.com/rust-lang/rust/pull/28646>. + +//@ run-pass +//@ aux-build:msvc-static-data-import-lib.rs + +extern crate msvc_static_data_import_lib; + +fn main() { + println!("The answer is {}!", msvc_static_data_import_lib::FOO); +} diff --git a/tests/ui/missing_debug_impls.rs b/tests/ui/lint/missing-debug-implementations-lint.rs index 3abc0706887..8a93f052f9c 100644 --- a/tests/ui/missing_debug_impls.rs +++ b/tests/ui/lint/missing-debug-implementations-lint.rs @@ -1,3 +1,7 @@ +//! Test the `missing_debug_implementations` lint that warns about public types without Debug. +//! +//! See https://github.com/rust-lang/rust/issues/20855 + //@ compile-flags: --crate-type lib #![deny(missing_debug_implementations)] #![allow(unused)] @@ -10,7 +14,6 @@ pub enum A {} //~ ERROR type does not implement `Debug` pub enum B {} pub enum C {} - impl fmt::Debug for C { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) @@ -23,15 +26,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug` pub struct Bar; pub struct Baz; - impl fmt::Debug for Baz { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) } } +// Private types should not trigger the lint struct PrivateStruct; - enum PrivateEnum {} #[derive(Debug)] diff --git a/tests/ui/missing_debug_impls.stderr b/tests/ui/lint/missing-debug-implementations-lint.stderr index 0538f207b44..288ab981034 100644 --- a/tests/ui/missing_debug_impls.stderr +++ b/tests/ui/lint/missing-debug-implementations-lint.stderr @@ -1,17 +1,17 @@ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:7:1 + --> $DIR/missing-debug-implementations-lint.rs:11:1 | LL | pub enum A {} | ^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/missing_debug_impls.rs:2:9 + --> $DIR/missing-debug-implementations-lint.rs:6:9 | LL | #![deny(missing_debug_implementations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:20:1 + --> $DIR/missing-debug-implementations-lint.rs:23:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/unused-attr-duplicate.rs b/tests/ui/lint/unused/unused-attr-duplicate.rs index 407af40654e..bf94a42f6e0 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.rs +++ b/tests/ui/lint/unused/unused-attr-duplicate.rs @@ -102,4 +102,10 @@ pub fn no_mangle_test() {} #[used] //~ ERROR unused attribute static FOO: u32 = 0; +#[link_section = ".text"] +//~^ ERROR unused attribute +//~| WARN this was previously accepted +#[link_section = ".bss"] +pub extern "C" fn example() {} + fn main() {} diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index e8452465efc..feae8528cf7 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -289,5 +289,18 @@ note: attribute also specified here LL | #[used] | ^^^^^^^ -error: aborting due to 23 previous errors +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:105:1 + | +LL | #[link_section = ".text"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:108:1 + | +LL | #[link_section = ".bss"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: aborting due to 24 previous errors diff --git a/tests/ui/log-err-phi.rs b/tests/ui/log-err-phi.rs deleted file mode 100644 index 1bb97758782..00000000000 --- a/tests/ui/log-err-phi.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - if false { - println!("{}", "foobar"); - } -} diff --git a/tests/ui/log-knows-the-names-of-variants.rs b/tests/ui/log-knows-the-names-of-variants.rs deleted file mode 100644 index cb82cb4878a..00000000000 --- a/tests/ui/log-knows-the-names-of-variants.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#[derive(Debug)] -enum foo { - a(usize), - b(String), - c, -} - -#[derive(Debug)] -enum bar { - d, e, f -} - -pub fn main() { - assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22))); - assert_eq!("c".to_string(), format!("{:?}", foo::c)); - assert_eq!("d".to_string(), format!("{:?}", bar::d)); -} diff --git a/tests/ui/loud_ui.rs b/tests/ui/loud_ui.rs deleted file mode 100644 index 2a73e49e172..00000000000 --- a/tests/ui/loud_ui.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ should-fail - -// this test ensures that when we forget to use -// any `//~ ERROR` comments whatsoever, that the test doesn't succeed - -fn main() {} diff --git a/tests/ui/lowering/issue-121108.stderr b/tests/ui/lowering/issue-121108.stderr index e4942e8cb07..f68655a7002 100644 --- a/tests/ui/lowering/issue-121108.stderr +++ b/tests/ui/lowering/issue-121108.stderr @@ -5,7 +5,7 @@ LL | #![derive(Clone, Copy)] | ^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | use std::ptr::addr_of; - | ------- the inner attribute doesn't annotate this `use` import + | ------- the inner attribute doesn't annotate this import | help: perhaps you meant to use an outer attribute | diff --git a/tests/ui/macros/macro-span-issue-116502.stderr b/tests/ui/macros/macro-span-issue-116502.stderr index 68f8874f5d6..024656e685f 100644 --- a/tests/ui/macros/macro-span-issue-116502.stderr +++ b/tests/ui/macros/macro-span-issue-116502.stderr @@ -4,7 +4,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | _ | ^ not allowed in type signatures ... -LL | T: Trait<m!()>; +LL | struct S<T = m!()>(m!(), T) | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -15,8 +15,8 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | _ | ^ not allowed in type signatures ... -LL | struct S<T = m!()>(m!(), T) - | ---- in this macro invocation +LL | T: Trait<m!()>; + | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -27,7 +27,7 @@ LL | _ | ^ not allowed in type signatures ... LL | struct S<T = m!()>(m!(), T) - | ---- in this macro invocation + | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/macros/macro-metavar-expr-concat/allowed-operations.rs b/tests/ui/macros/metavar-expressions/concat-allowed-operations.rs index 695a752fe17..695a752fe17 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/allowed-operations.rs +++ b/tests/ui/macros/metavar-expressions/concat-allowed-operations.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/hygiene.rs b/tests/ui/macros/metavar-expressions/concat-hygiene.rs index 24b0e36498a..24b0e36498a 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/hygiene.rs +++ b/tests/ui/macros/metavar-expressions/concat-hygiene.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/hygiene.stderr b/tests/ui/macros/metavar-expressions/concat-hygiene.stderr index ef2326dce85..f3150d385ee 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/hygiene.stderr +++ b/tests/ui/macros/metavar-expressions/concat-hygiene.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `abcdef` in this scope - --> $DIR/hygiene.rs:5:10 + --> $DIR/concat-hygiene.rs:5:10 | LL | ${concat($lhs, $rhs)} | ^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.rs b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.rs index b1cb2141cc4..b1cb2141cc4 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.rs +++ b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.stderr b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.stderr index 4e11e20acc5..7abab6a5103 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.stderr +++ b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.stderr @@ -1,47 +1,47 @@ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:28:22 + --> $DIR/concat-raw-identifiers.rs:28:22 | LL | let ${concat(r#abc, abc)}: () = (); | ^^^^^ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:32:27 + --> $DIR/concat-raw-identifiers.rs:32:27 | LL | let ${concat(abc, r#abc)}: () = (); | ^^^^^ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:35:22 + --> $DIR/concat-raw-identifiers.rs:35:22 | LL | let ${concat(r#abc, r#abc)}: () = (); | ^^^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:5:28 + --> $DIR/concat-raw-identifiers.rs:5:28 | LL | let ${concat(abc, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:12:23 + --> $DIR/concat-raw-identifiers.rs:12:23 | LL | let ${concat($lhs, abc)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:23 + --> $DIR/concat-raw-identifiers.rs:19:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:29 + --> $DIR/concat-raw-identifiers.rs:19:29 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:23 + --> $DIR/concat-raw-identifiers.rs:19:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ @@ -49,31 +49,31 @@ LL | let ${concat($lhs, $rhs)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:42:28 + --> $DIR/concat-raw-identifiers.rs:42:28 | LL | let ${concat(abc, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:49:23 + --> $DIR/concat-raw-identifiers.rs:49:23 | LL | let ${concat($lhs, abc)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:23 + --> $DIR/concat-raw-identifiers.rs:56:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:29 + --> $DIR/concat-raw-identifiers.rs:56:29 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:23 + --> $DIR/concat-raw-identifiers.rs:56:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ @@ -81,7 +81,7 @@ LL | let ${concat($lhs, $rhs)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected pattern, found `$` - --> $DIR/raw-identifiers.rs:28:13 + --> $DIR/concat-raw-identifiers.rs:28:13 | LL | let ${concat(r#abc, abc)}: () = (); | ^ expected pattern diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs b/tests/ui/macros/metavar-expressions/concat-repetitions.rs index 52a7d5cd8a7..52a7d5cd8a7 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs +++ b/tests/ui/macros/metavar-expressions/concat-repetitions.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr b/tests/ui/macros/metavar-expressions/concat-repetitions.stderr index c3006c4be5d..18b0a90c1c8 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr +++ b/tests/ui/macros/metavar-expressions/concat-repetitions.stderr @@ -1,17 +1,17 @@ error: invalid syntax - --> $DIR/repetitions.rs:14:20 + --> $DIR/concat-repetitions.rs:14:20 | LL | const ${concat($a, Z)}: i32 = 3; | ^^^^^^^^^^^^^^^ error: invalid syntax - --> $DIR/repetitions.rs:22:17 + --> $DIR/concat-repetitions.rs:22:17 | LL | read::<${concat($t, $en)}>() | ^^^^^^^^^^^^^^^^^ error: invalid syntax - --> $DIR/repetitions.rs:22:17 + --> $DIR/concat-repetitions.rs:22:17 | LL | read::<${concat($t, $en)}>() | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/macros/metavar-expressions/concat-trace-errors.rs b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs new file mode 100644 index 00000000000..45407f5e86d --- /dev/null +++ b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs @@ -0,0 +1,33 @@ +// Our diagnostics should be able to point to a specific input that caused an invalid +// identifier. + +#![feature(macro_metavar_expr_concat)] + +// See what we can do without expanding anything +macro_rules! pre_expansion { + ($a:ident) => { + ${concat("hi", " bye ")}; + ${concat("hi", "-", "bye")}; + ${concat($a, "-")}; + } +} + +macro_rules! post_expansion { + ($a:literal) => { + const _: () = ${concat("hi", $a, "bye")}; + //~^ ERROR is not generating a valid identifier + } +} + +post_expansion!("!"); + +macro_rules! post_expansion_many { + ($a:ident, $b:ident, $c:ident, $d:literal, $e:ident) => { + const _: () = ${concat($a, $b, $c, $d, $e)}; + //~^ ERROR is not generating a valid identifier + } +} + +post_expansion_many!(a, b, c, ".d", e); + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr b/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr new file mode 100644 index 00000000000..dac8b58a15c --- /dev/null +++ b/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr @@ -0,0 +1,24 @@ +error: `${concat(..)}` is not generating a valid identifier + --> $DIR/concat-trace-errors.rs:17:24 + | +LL | const _: () = ${concat("hi", $a, "bye")}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | post_expansion!("!"); + | -------------------- in this macro invocation + | + = note: this error originates in the macro `post_expansion` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `${concat(..)}` is not generating a valid identifier + --> $DIR/concat-trace-errors.rs:26:24 + | +LL | const _: () = ${concat($a, $b, $c, $d, $e)}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | post_expansion_many!(a, b, c, ".d", e); + | -------------------------------------- in this macro invocation + | + = note: this error originates in the macro `post_expansion_many` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/macro-metavar-expr-concat/unicode-expansion.rs b/tests/ui/macros/metavar-expressions/concat-unicode-expansion.rs index 4eeb2384deb..4eeb2384deb 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/unicode-expansion.rs +++ b/tests/ui/macros/metavar-expressions/concat-unicode-expansion.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.rs b/tests/ui/macros/metavar-expressions/concat-usage-errors.rs index 7673bd3200f..7d8756de9e2 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.rs +++ b/tests/ui/macros/metavar-expressions/concat-usage-errors.rs @@ -1,6 +1,8 @@ +//@ edition: 2021 + #![feature(macro_metavar_expr_concat)] -macro_rules! wrong_concat_declarations { +macro_rules! syntax_errors { ($ex:expr) => { ${concat()} //~^ ERROR expected identifier @@ -90,11 +92,31 @@ macro_rules! unsupported_literals { //~| ERROR expected pattern let ${concat(_a, 1)}: () = (); //~^ ERROR expected identifier or string literal + let ${concat(_a, 1.5)}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, c"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b'b')}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b'b')}: () = (); + //~^ ERROR expected identifier or string literal let ${concat($ident, 'b')}: () = (); //~^ ERROR expected identifier or string literal let ${concat($ident, 1)}: () = (); //~^ ERROR expected identifier or string literal + let ${concat($ident, 1.5)}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, c"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b'b')}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b'b')}: () = (); + //~^ ERROR expected identifier or string literal }}; } @@ -132,7 +154,7 @@ macro_rules! bad_tt_literal { } fn main() { - wrong_concat_declarations!(1); + syntax_errors!(1); dollar_sign_without_referenced_ident!(VAR); diff --git a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.stderr b/tests/ui/macros/metavar-expressions/concat-usage-errors.stderr index 2de6d2b3ce3..8be3e792ec3 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.stderr +++ b/tests/ui/macros/metavar-expressions/concat-usage-errors.stderr @@ -1,71 +1,131 @@ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:5:10 + --> $DIR/concat-usage-errors.rs:7:10 | LL | ${concat()} | ^^^^^^^^^^ error: `concat` must have at least two elements - --> $DIR/syntax-errors.rs:8:11 + --> $DIR/concat-usage-errors.rs:10:11 | LL | ${concat(aaaa)} | ^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:11:10 + --> $DIR/concat-usage-errors.rs:13:10 | LL | ${concat(aaaa,)} | ^^^^^^^^^^^^^^^ error: expected comma - --> $DIR/syntax-errors.rs:16:10 + --> $DIR/concat-usage-errors.rs:18:10 | LL | ${concat(aaaa aaaa)} | ^^^^^^^^^^^^^^^^^^^ error: `concat` must have at least two elements - --> $DIR/syntax-errors.rs:19:11 + --> $DIR/concat-usage-errors.rs:21:11 | LL | ${concat($ex)} | ^^^^^^ error: expected comma - --> $DIR/syntax-errors.rs:25:10 + --> $DIR/concat-usage-errors.rs:27:10 | LL | ${concat($ex, aaaa 123)} | ^^^^^^^^^^^^^^^^^^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:28:10 + --> $DIR/concat-usage-errors.rs:30:10 | LL | ${concat($ex, aaaa,)} | ^^^^^^^^^^^^^^^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:88:26 + --> $DIR/concat-usage-errors.rs:90:26 | LL | let ${concat(_a, 'b')}: () = (); | ^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:91:26 + --> $DIR/concat-usage-errors.rs:93:26 | LL | let ${concat(_a, 1)}: () = (); | ^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:94:30 + --> $DIR/concat-usage-errors.rs:95:26 + | +LL | let ${concat(_a, 1.5)}: () = (); + | ^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:97:26 + | +LL | let ${concat(_a, c"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:99:26 + | +LL | let ${concat(_a, b"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:101:26 + | +LL | let ${concat(_a, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:103:26 + | +LL | let ${concat(_a, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:106:30 | LL | let ${concat($ident, 'b')}: () = (); | ^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:96:30 + --> $DIR/concat-usage-errors.rs:108:30 | LL | let ${concat($ident, 1)}: () = (); | ^ +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:110:30 + | +LL | let ${concat($ident, 1.5)}: () = (); + | ^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:112:30 + | +LL | let ${concat($ident, c"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:114:30 + | +LL | let ${concat($ident, b"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:116:30 + | +LL | let ${concat($ident, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:118:30 + | +LL | let ${concat($ident, b'b')}: () = (); + | ^^^^ + error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:22:19 + --> $DIR/concat-usage-errors.rs:24:19 | LL | ${concat($ex, aaaa)} | ^^ @@ -73,13 +133,13 @@ LL | ${concat($ex, aaaa)} = note: currently only string literals are supported error: variable `foo` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:35:30 + --> $DIR/concat-usage-errors.rs:37:30 | LL | const ${concat(FOO, $foo)}: i32 = 2; | ^^^ error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:42:14 + --> $DIR/concat-usage-errors.rs:44:14 | LL | let ${concat("1", $ident)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +150,7 @@ LL | starting_number!(_abc); = note: this error originates in the macro `starting_number` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:55:14 + --> $DIR/concat-usage-errors.rs:57:14 | LL | let ${concat("\u{00BD}", $ident)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +161,7 @@ LL | starting_invalid_unicode!(_abc); = note: this error originates in the macro `starting_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:74:14 + --> $DIR/concat-usage-errors.rs:76:14 | LL | let ${concat($ident, "\u{00BD}")}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +172,7 @@ LL | ending_invalid_unicode!(_abc); = note: this error originates in the macro `ending_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected pattern, found `$` - --> $DIR/syntax-errors.rs:88:13 + --> $DIR/concat-usage-errors.rs:90:13 | LL | let ${concat(_a, 'b')}: () = (); | ^ expected pattern @@ -123,7 +183,7 @@ LL | unsupported_literals!(_abc); = note: this error originates in the macro `unsupported_literals` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:81:14 + --> $DIR/concat-usage-errors.rs:83:14 | LL | let ${concat("", "")}: () = (); | ^^^^^^^^^^^^^^^^ @@ -134,7 +194,7 @@ LL | empty!(); = note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +205,7 @@ LL | bad_literal_string!("\u{00BD}"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +216,7 @@ LL | bad_literal_string!("\x41"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +227,7 @@ LL | bad_literal_string!("🤷"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +238,7 @@ LL | bad_literal_string!("d[-_-]b"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +249,7 @@ LL | bad_literal_string!("-1"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -200,7 +260,7 @@ LL | bad_literal_string!("1.0"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +271,7 @@ LL | bad_literal_string!("'1'"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -219,7 +279,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: currently only string literals are supported error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -228,7 +288,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -237,7 +297,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -246,7 +306,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -255,7 +315,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -263,7 +323,7 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: currently only string literals are supported error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -272,7 +332,7 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -280,5 +340,5 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: currently only string literals are supported = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 33 previous errors +error: aborting due to 43 previous errors diff --git a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs b/tests/ui/macros/metavar-expressions/count-and-length-are-distinct.rs index 8ca453273cd..8ca453273cd 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs +++ b/tests/ui/macros/metavar-expressions/count-and-length-are-distinct.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs b/tests/ui/macros/metavar-expressions/count-empty-index-arg.rs index 3000bfed6a8..69880ee7fa9 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs +++ b/tests/ui/macros/metavar-expressions/count-empty-index-arg.rs @@ -1,3 +1,6 @@ +// Issue: https://github.com/rust-lang/rust/issues/111904 +// Ensure that a trailing `,` is not interpreted as a `0`. + #![feature(macro_metavar_expr)] macro_rules! foo { @@ -10,5 +13,4 @@ fn test() { foo!(a, a; b, b); } -fn main() { -} +fn main() {} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr b/tests/ui/macros/metavar-expressions/count-empty-index-arg.stderr index fd53c1686cf..e1f9d020b7f 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr +++ b/tests/ui/macros/metavar-expressions/count-empty-index-arg.stderr @@ -1,11 +1,11 @@ error: `count` followed by a comma must have an associated index indicating its depth - --> $DIR/issue-111904.rs:4:37 + --> $DIR/count-empty-index-arg.rs:7:37 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^^^^^ error: expected expression, found `$` - --> $DIR/issue-111904.rs:4:35 + --> $DIR/count-empty-index-arg.rs:7:35 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^ expected expression diff --git a/tests/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs b/tests/ui/macros/metavar-expressions/dollar-dollar-has-correct-behavior.rs index 9b8e3216a68..9b8e3216a68 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs +++ b/tests/ui/macros/metavar-expressions/dollar-dollar-has-correct-behavior.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs b/tests/ui/macros/metavar-expressions/feature-gate-macro_metavar_expr.rs index 51445221c57..51445221c57 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs +++ b/tests/ui/macros/metavar-expressions/feature-gate-macro_metavar_expr.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs b/tests/ui/macros/metavar-expressions/macro-expansion.rs index 1d34275874b..1d34275874b 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs +++ b/tests/ui/macros/metavar-expressions/macro-expansion.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.rs index 0caa3ea89e4..0caa3ea89e4 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs +++ b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.stderr index 0b441cad083..0b441cad083 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr +++ b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.stderr diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs b/tests/ui/macros/metavar-expressions/required-feature.rs index 77c165e3855..77c165e3855 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs +++ b/tests/ui/macros/metavar-expressions/required-feature.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr b/tests/ui/macros/metavar-expressions/required-feature.stderr index f28f822a058..f28f822a058 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr +++ b/tests/ui/macros/metavar-expressions/required-feature.stderr diff --git a/tests/ui/macros/metavar-expressions/syntax-errors.rs b/tests/ui/macros/metavar-expressions/syntax-errors.rs new file mode 100644 index 00000000000..8fc76a74baa --- /dev/null +++ b/tests/ui/macros/metavar-expressions/syntax-errors.rs @@ -0,0 +1,117 @@ +// General syntax errors that apply to all matavariable expressions +// +// We don't invoke the macros here to ensure code gets rejected at the definition rather than +// only when expanded. + +#![feature(macro_metavar_expr)] + +macro_rules! dollar_dollar_in_the_lhs { + ( $$ $a:ident ) => { + //~^ ERROR unexpected token: $ + }; +} + +macro_rules! metavar_in_the_lhs { + ( ${ len() } ) => { + //~^ ERROR unexpected token: { + //~| ERROR expected one of: `*`, `+`, or `?` + }; +} + +macro_rules! metavar_token_without_ident { + ( $( $i:ident ),* ) => { ${ ignore() } }; + //~^ ERROR meta-variable expressions must be referenced using a dollar sign +} + +macro_rules! metavar_with_literal_suffix { + ( $( $i:ident ),* ) => { ${ index(1u32) } }; + //~^ ERROR only unsuffixes integer literals are supported in meta-variable expressions +} + +macro_rules! mve_without_parens { + ( $( $i:ident ),* ) => { ${ count } }; + //~^ ERROR meta-variable expression parameter must be wrapped in parentheses +} + +#[rustfmt::skip] +macro_rules! empty_expression { + () => { ${} }; + //~^ ERROR expected identifier or string literal +} + +#[rustfmt::skip] +macro_rules! open_brackets_with_lit { + () => { ${ "hi" } }; + //~^ ERROR expected identifier + } + +macro_rules! mve_wrong_delim { + ( $( $i:ident ),* ) => { ${ count{i} } }; + //~^ ERROR meta-variable expression parameter must be wrapped in parentheses +} + +macro_rules! invalid_metavar { + () => { ${ignore($123)} } + //~^ ERROR expected identifier, found `123` +} + +#[rustfmt::skip] +macro_rules! open_brackets_with_group { + ( $( $i:ident ),* ) => { ${ {} } }; + //~^ ERROR expected identifier +} + +macro_rules! extra_garbage_after_metavar { + ( $( $i:ident ),* ) => { + ${count() a b c} + //~^ ERROR unexpected token: a + ${count($i a b c)} + //~^ ERROR unexpected token: a + ${count($i, 1 a b c)} + //~^ ERROR unexpected token: a + ${count($i) a b c} + //~^ ERROR unexpected token: a + + ${ignore($i) a b c} + //~^ ERROR unexpected token: a + ${ignore($i a b c)} + //~^ ERROR unexpected token: a + + ${index() a b c} + //~^ ERROR unexpected token: a + ${index(1 a b c)} + //~^ ERROR unexpected token: a + + ${index() a b c} + //~^ ERROR unexpected token: a + ${index(1 a b c)} + //~^ ERROR unexpected token: a + }; +} + +const IDX: usize = 1; +macro_rules! metavar_depth_is_not_literal { + ( $( $i:ident ),* ) => { ${ index(IDX) } }; + //~^ ERROR meta-variable expression depth must be a literal +} + +macro_rules! unknown_count_ident { + ( $( $i:ident )* ) => { + ${count(foo)} + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + }; +} + +macro_rules! unknown_ignore_ident { + ( $( $i:ident )* ) => { + ${ignore(bar)} + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + }; +} + +macro_rules! unknown_metavar { + ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; + //~^ ERROR unrecognized meta-variable expression +} + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/syntax-errors.stderr b/tests/ui/macros/metavar-expressions/syntax-errors.stderr new file mode 100644 index 00000000000..20d2358facc --- /dev/null +++ b/tests/ui/macros/metavar-expressions/syntax-errors.stderr @@ -0,0 +1,224 @@ +error: unexpected token: $ + --> $DIR/syntax-errors.rs:9:8 + | +LL | ( $$ $a:ident ) => { + | ^ + +note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions + --> $DIR/syntax-errors.rs:9:8 + | +LL | ( $$ $a:ident ) => { + | ^ + +error: unexpected token: { + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +error: expected one of: `*`, `+`, or `?` + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:22:33 + | +LL | ( $( $i:ident ),* ) => { ${ ignore() } }; + | ^^^^^^ + +error: only unsuffixes integer literals are supported in meta-variable expressions + --> $DIR/syntax-errors.rs:27:33 + | +LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; + | ^^^^^ + +error: meta-variable expression parameter must be wrapped in parentheses + --> $DIR/syntax-errors.rs:32:33 + | +LL | ( $( $i:ident ),* ) => { ${ count } }; + | ^^^^^ + +error: meta-variable expression parameter must be wrapped in parentheses + --> $DIR/syntax-errors.rs:49:33 + | +LL | ( $( $i:ident ),* ) => { ${ count{i} } }; + | ^^^^^ + +error: expected identifier, found `123` + --> $DIR/syntax-errors.rs:54:23 + | +LL | () => { ${ignore($123)} } + | ^^^ help: try removing `123` + +error: unexpected token: a + --> $DIR/syntax-errors.rs:66:19 + | +LL | ${count() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:66:19 + | +LL | ${count() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:68:20 + | +LL | ${count($i a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:68:20 + | +LL | ${count($i a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:70:23 + | +LL | ${count($i, 1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:70:23 + | +LL | ${count($i, 1 a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:72:21 + | +LL | ${count($i) a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:72:21 + | +LL | ${count($i) a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:75:22 + | +LL | ${ignore($i) a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:75:22 + | +LL | ${ignore($i) a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:77:21 + | +LL | ${ignore($i a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:77:21 + | +LL | ${ignore($i a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:80:19 + | +LL | ${index() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:80:19 + | +LL | ${index() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:82:19 + | +LL | ${index(1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:82:19 + | +LL | ${index(1 a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:85:19 + | +LL | ${index() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:85:19 + | +LL | ${index() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:87:19 + | +LL | ${index(1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:87:19 + | +LL | ${index(1 a b c)} + | ^ + +error: meta-variable expression depth must be a literal + --> $DIR/syntax-errors.rs:94:33 + | +LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; + | ^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:100:11 + | +LL | ${count(foo)} + | ^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:107:11 + | +LL | ${ignore(bar)} + | ^^^^^^ + +error: unrecognized meta-variable expression + --> $DIR/syntax-errors.rs:113:33 + | +LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; + | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and len + +error: expected identifier or string literal + --> $DIR/syntax-errors.rs:38:14 + | +LL | () => { ${} }; + | ^^ + +error: expected identifier, found `"hi"` + --> $DIR/syntax-errors.rs:44:17 + | +LL | () => { ${ "hi" } }; + | ^^^^ help: try removing `"hi"` + +error: expected identifier or string literal + --> $DIR/syntax-errors.rs:60:33 + | +LL | ( $( $i:ident ),* ) => { ${ {} } }; + | ^^ + +error: aborting due to 25 previous errors + diff --git a/tests/ui/macros/metavar-expressions/usage-errors.rs b/tests/ui/macros/metavar-expressions/usage-errors.rs new file mode 100644 index 00000000000..feff02e2ce4 --- /dev/null +++ b/tests/ui/macros/metavar-expressions/usage-errors.rs @@ -0,0 +1,55 @@ +// Errors for the `count` and `length` metavariable expressions + +#![feature(macro_metavar_expr)] + +// `curly` = Right hand side curly brackets +// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" +// `round` = Left hand side round brackets + +macro_rules! curly__no_rhs_dollar__round { + ( $( $i:ident ),* ) => { ${ count($i) } }; +} +const _: u32 = curly__no_rhs_dollar__round!(a, b, c); + +macro_rules! curly__no_rhs_dollar__no_round { + ( $i:ident ) => { ${ count($i) } }; + //~^ ERROR `count` can not be placed inside the innermost repetition +} +curly__no_rhs_dollar__no_round!(a); + +macro_rules! curly__rhs_dollar__no_round { + ( $i:ident ) => { ${ count($i) } }; + //~^ ERROR `count` can not be placed inside the innermost repetition +} +curly__rhs_dollar__no_round !(a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__no_rhs_dollar__round { + ( $( $i:ident ),* ) => { count(i) }; + //~^ ERROR missing `fn` or `struct` for function or struct definition +} +no_curly__no_rhs_dollar__round !(a, b, c); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__no_rhs_dollar__no_round { + ( $i:ident ) => { count(i) }; + //~^ ERROR missing `fn` or `struct` for function or struct definition +} +no_curly__no_rhs_dollar__no_round !(a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__rhs_dollar__round { + ( $( $i:ident ),* ) => { count($i) }; + //~^ ERROR variable `i` is still repeating at this depth +} +no_curly__rhs_dollar__round! (a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__rhs_dollar__no_round { + ( $i:ident ) => { count($i) }; + //~^ ERROR cannot find function `count` in this scope +} +const _: u32 = no_curly__rhs_dollar__no_round! (a); +//~^ ERROR cannot find value `a` in this scope + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/usage-errors.stderr b/tests/ui/macros/metavar-expressions/usage-errors.stderr new file mode 100644 index 00000000000..f66f522e23b --- /dev/null +++ b/tests/ui/macros/metavar-expressions/usage-errors.stderr @@ -0,0 +1,71 @@ +error: `count` can not be placed inside the innermost repetition + --> $DIR/usage-errors.rs:15:24 + | +LL | ( $i:ident ) => { ${ count($i) } }; + | ^^^^^^^^^^^^^ + +error: `count` can not be placed inside the innermost repetition + --> $DIR/usage-errors.rs:21:24 + | +LL | ( $i:ident ) => { ${ count($i) } }; + | ^^^^^^^^^^^^^ + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/usage-errors.rs:28:30 + | +LL | ( $( $i:ident ),* ) => { count(i) }; + | ^^^^^ +... +LL | no_curly__no_rhs_dollar__round !(a, b, c); + | ----------------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if you meant to call a macro, try + | +LL | ( $( $i:ident ),* ) => { count!(i) }; + | + + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/usage-errors.rs:35:23 + | +LL | ( $i:ident ) => { count(i) }; + | ^^^^^ +... +LL | no_curly__no_rhs_dollar__no_round !(a); + | -------------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if you meant to call a macro, try + | +LL | ( $i:ident ) => { count!(i) }; + | + + +error: variable `i` is still repeating at this depth + --> $DIR/usage-errors.rs:42:36 + | +LL | ( $( $i:ident ),* ) => { count($i) }; + | ^^ + +error[E0425]: cannot find value `a` in this scope + --> $DIR/usage-errors.rs:52:49 + | +LL | ( $i:ident ) => { count($i) }; + | -- due to this macro variable +... +LL | const _: u32 = no_curly__rhs_dollar__no_round! (a); + | ^ not found in this scope + +error[E0425]: cannot find function `count` in this scope + --> $DIR/usage-errors.rs:49:23 + | +LL | ( $i:ident ) => { count($i) }; + | ^^^^^ not found in this scope +... +LL | const _: u32 = no_curly__rhs_dollar__no_round! (a); + | ----------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs deleted file mode 100644 index 78cede92526..00000000000 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs +++ /dev/null @@ -1,164 +0,0 @@ -#![feature(macro_metavar_expr)] - -// `curly` = Right hand side curly brackets -// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" -// `round` = Left hand side round brackets - -macro_rules! curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count($i) } }; -} - -macro_rules! curly__no_rhs_dollar__no_round { - ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR `count` can not be placed inside the innermost repetition -} - -macro_rules! curly__rhs_dollar__no_round { - ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR `count` can not be placed inside the innermost repetition -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__no_rhs_dollar__no_round { - ( $i:ident ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__rhs_dollar__round { - ( $( $i:ident ),* ) => { count($i) }; - //~^ ERROR variable `i` is still repeating at this depth -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__rhs_dollar__no_round { - ( $i:ident ) => { count($i) }; - //~^ ERROR cannot find function `count` in this scope -} - -// Other scenarios - -macro_rules! dollar_dollar_in_the_lhs { - ( $$ $a:ident ) => { - //~^ ERROR unexpected token: $ - }; -} - -macro_rules! extra_garbage_after_metavar { - ( $( $i:ident ),* ) => { - ${count() a b c} - //~^ ERROR unexpected token: a - //~| ERROR expected expression, found `$` - ${count($i a b c)} - //~^ ERROR unexpected token: a - ${count($i, 1 a b c)} - //~^ ERROR unexpected token: a - ${count($i) a b c} - //~^ ERROR unexpected token: a - - ${ignore($i) a b c} - //~^ ERROR unexpected token: a - ${ignore($i a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - }; -} - -const IDX: usize = 1; -macro_rules! metavar_depth_is_not_literal { - ( $( $i:ident ),* ) => { ${ index(IDX) } }; - //~^ ERROR meta-variable expression depth must be a literal - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_in_the_lhs { - ( ${ len() } ) => { - //~^ ERROR unexpected token: { - //~| ERROR expected one of: `*`, `+`, or `?` - }; -} - -macro_rules! metavar_token_without_ident { - ( $( $i:ident ),* ) => { ${ ignore() } }; - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression -} - -macro_rules! metavar_with_literal_suffix { - ( $( $i:ident ),* ) => { ${ index(1u32) } }; - //~^ ERROR only unsuffixes integer literals are supported in meta-variable expressions - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_without_parens { - ( $( $i:ident ),* ) => { ${ count{i} } }; - //~^ ERROR meta-variable expression parameter must be wrapped in parentheses - //~| ERROR expected expression, found `$` -} - -#[rustfmt::skip] -macro_rules! open_brackets_without_tokens { - ( $( $i:ident ),* ) => { ${ {} } }; - //~^ ERROR expected expression, found `$` - //~| ERROR expected identifier -} - -macro_rules! unknown_count_ident { - ( $( $i:ident )* ) => { - ${count(foo)} - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression - }; -} - -macro_rules! unknown_ignore_ident { - ( $( $i:ident )* ) => { - ${ignore(bar)} - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression - }; -} - -macro_rules! unknown_metavar { - ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - //~^ ERROR unrecognized meta-variable expression - //~| ERROR expected expression -} - -fn main() { - curly__no_rhs_dollar__round!(a, b, c); - curly__no_rhs_dollar__no_round!(a); - curly__rhs_dollar__no_round!(a); - no_curly__no_rhs_dollar__round!(a, b, c); - no_curly__no_rhs_dollar__no_round!(a); - no_curly__rhs_dollar__round!(a, b, c); - no_curly__rhs_dollar__no_round!(a); - //~^ ERROR cannot find value `a` in this scope - - extra_garbage_after_metavar!(a); - metavar_depth_is_not_literal!(a); - metavar_token_without_ident!(a); - metavar_with_literal_suffix!(a); - metavar_without_parens!(a); - open_brackets_without_tokens!(a); - unknown_count_ident!(a); - unknown_ignore_ident!(a); - unknown_metavar!(a); -} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr deleted file mode 100644 index d9646760cea..00000000000 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr +++ /dev/null @@ -1,382 +0,0 @@ -error: unexpected token: $ - --> $DIR/syntax-errors.rs:50:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:50:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:57:19 - | -LL | ${count() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:57:19 - | -LL | ${count() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:60:20 - | -LL | ${count($i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:60:20 - | -LL | ${count($i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:62:23 - | -LL | ${count($i, 1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:62:23 - | -LL | ${count($i, 1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:64:21 - | -LL | ${count($i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:64:21 - | -LL | ${count($i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:67:22 - | -LL | ${ignore($i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:67:22 - | -LL | ${ignore($i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:69:21 - | -LL | ${ignore($i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:69:21 - | -LL | ${ignore($i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:72:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:72:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:74:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:74:19 - | -LL | ${index(1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:79:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:79:19 - | -LL | ${index(1 a b c)} - | ^ - -error: meta-variable expression depth must be a literal - --> $DIR/syntax-errors.rs:86:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^^^^^ - -error: unexpected token: { - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -error: expected one of: `*`, `+`, or `?` - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:99:33 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^^^^^^ - -error: only unsuffixes integer literals are supported in meta-variable expressions - --> $DIR/syntax-errors.rs:105:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^^^^^ - -error: meta-variable expression parameter must be wrapped in parentheses - --> $DIR/syntax-errors.rs:111:33 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:125:11 - | -LL | ${count(foo)} - | ^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:133:11 - | -LL | ${ignore(bar)} - | ^^^^^^ - -error: unrecognized meta-variable expression - --> $DIR/syntax-errors.rs:140:33 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and len - -error: expected identifier or string literal - --> $DIR/syntax-errors.rs:118:33 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^^ - -error: `count` can not be placed inside the innermost repetition - --> $DIR/syntax-errors.rs:12:24 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^^^^^^^^^ - -error: `count` can not be placed inside the innermost repetition - --> $DIR/syntax-errors.rs:17:24 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^^^^^^^^^ - -error: variable `i` is still repeating at this depth - --> $DIR/syntax-errors.rs:37:36 - | -LL | ( $( $i:ident ),* ) => { count($i) }; - | ^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:57:9 - | -LL | ${count() a b c} - | ^ expected expression -... -LL | extra_garbage_after_metavar!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `extra_garbage_after_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:86:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^ expected expression -... -LL | metavar_depth_is_not_literal!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_depth_is_not_literal` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:99:30 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^ expected expression -... -LL | metavar_token_without_ident!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_token_without_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:105:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^ expected expression -... -LL | metavar_with_literal_suffix!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_with_literal_suffix` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:111:30 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^ expected expression -... -LL | metavar_without_parens!(a); - | -------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_without_parens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:118:30 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^ expected expression -... -LL | open_brackets_without_tokens!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `open_brackets_without_tokens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:125:9 - | -LL | ${count(foo)} - | ^ expected expression -... -LL | unknown_count_ident!(a); - | ----------------------- in this macro invocation - | - = note: this error originates in the macro `unknown_count_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:133:9 - | -LL | ${ignore(bar)} - | ^ expected expression -... -LL | unknown_ignore_ident!(a); - | ------------------------ in this macro invocation - | - = note: this error originates in the macro `unknown_ignore_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:140:30 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^ expected expression -... -LL | unknown_metavar!(a); - | ------------------- in this macro invocation - | - = note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:23:36 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:30:29 - | -LL | ( $i:ident ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `a` in this scope - --> $DIR/syntax-errors.rs:152:37 - | -LL | ( $i:ident ) => { count($i) }; - | -- due to this macro variable -... -LL | no_curly__rhs_dollar__no_round!(a); - | ^ not found in this scope - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:23:30 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:30:23 - | -LL | ( $i:ident ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:43:23 - | -LL | ( $i:ident ) => { count($i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__rhs_dollar__no_round!(a); - | ---------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 39 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/maximal_mir_to_hir_coverage.rs b/tests/ui/maximal_mir_to_hir_coverage.rs deleted file mode 100644 index e57c83d007e..00000000000 --- a/tests/ui/maximal_mir_to_hir_coverage.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Zmaximal-hir-to-mir-coverage -//@ run-pass - -// Just making sure this flag is accepted and doesn't crash the compiler - -fn main() { - let x = 1; - let y = x + 1; - println!("{y}"); -} diff --git a/tests/ui/maybe-bounds.rs b/tests/ui/maybe-bounds.rs deleted file mode 100644 index 02ed45c656f..00000000000 --- a/tests/ui/maybe-bounds.rs +++ /dev/null @@ -1,9 +0,0 @@ -trait Tr: ?Sized {} -//~^ ERROR `?Trait` is not permitted in supertraits - -type A1 = dyn Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types -type A2 = dyn for<'a> Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types - -fn main() {} diff --git a/tests/ui/method-output-diff-issue-127263.rs b/tests/ui/method-output-diff-issue-127263.rs deleted file mode 100644 index 85a903e2453..00000000000 --- a/tests/ui/method-output-diff-issue-127263.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn bar() {} -fn foo(x: i32) -> u32 { - 0 -} -fn main() { - let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] - let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] -} diff --git a/tests/ui/methods/filter-relevant-fn-bounds.rs b/tests/ui/methods/filter-relevant-fn-bounds.rs index 76ececf7baa..6233c9db53a 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.rs +++ b/tests/ui/methods/filter-relevant-fn-bounds.rs @@ -7,11 +7,10 @@ struct Wrapper; impl Wrapper { fn do_something_wrapper<O, F>(self, _: F) //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied where F: for<'a> FnOnce(<F as Output<'a>>::Type), - //~^ ERROR the trait bound `F: Output<'_>` is not satisfied - //~| ERROR the trait bound `F: Output<'_>` is not satisfied + //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied + //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied { } } diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 0e00adf6ea6..82103e62ddf 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -3,7 +3,6 @@ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied | LL | / fn do_something_wrapper<O, F>(self, _: F) LL | | -LL | | LL | | where LL | | F: for<'a> FnOnce(<F as Output<'a>>::Type), | |___________________________________________________^ the trait `for<'a> Output<'a>` is not implemented for `F` @@ -14,54 +13,43 @@ LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:8:8 + --> $DIR/filter-relevant-fn-bounds.rs:11:12 | -LL | fn do_something_wrapper<O, F>(self, _: F) - | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` +LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` | help: consider further restricting type parameter `F` with trait `Output` | LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ -error[E0277]: the trait bound `F: Output<'_>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:12:12 - | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F` - | -help: consider further restricting type parameter `F` with trait `Output` - | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>, - | ++++++++++++ - -error[E0277]: the trait bound `F: Output<'_>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:12:20 +error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied + --> $DIR/filter-relevant-fn-bounds.rs:11:20 | LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` | help: consider further restricting type parameter `F` with trait `Output` | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>, - | ++++++++++++ +LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, + | ++++++++++++++++++++ -error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` - --> $DIR/filter-relevant-fn-bounds.rs:21:34 +error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` + --> $DIR/filter-relevant-fn-bounds.rs:20:34 | LL | wrapper.do_something_wrapper(|value| ()); - | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` help: this trait has no implementations, consider adding one --> $DIR/filter-relevant-fn-bounds.rs:1:1 | LL | trait Output<'a> { | ^^^^^^^^^^^^^^^^ note: required by a bound in `Wrapper::do_something_wrapper` - --> $DIR/filter-relevant-fn-bounds.rs:12:12 + --> $DIR/filter-relevant-fn-bounds.rs:11:12 | LL | fn do_something_wrapper<O, F>(self, _: F) | -------------------- required by a bound in this associated function @@ -69,6 +57,6 @@ LL | fn do_something_wrapper<O, F>(self, _: F) LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs new file mode 100644 index 00000000000..e28ca3e55b5 --- /dev/null +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs @@ -0,0 +1,16 @@ +//! This test checks that when there's a type mismatch between a function item and +//! a function pointer, the error message focuses on the actual type difference +//! (return types, argument types) rather than the confusing "pointer vs item" distinction. +//! +//! See https://github.com/rust-lang/rust/issues/127263 + +fn bar() {} + +fn foo(x: i32) -> u32 { + 0 +} + +fn main() { + let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] + let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] +} diff --git a/tests/ui/method-output-diff-issue-127263.stderr b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr index 35b86114f16..8d63f2ea2d3 100644 --- a/tests/ui/method-output-diff-issue-127263.stderr +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:6:26 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:14:26 | LL | let b: fn() -> u32 = bar; | ----------- ^^^ expected fn pointer, found fn item @@ -10,7 +10,7 @@ LL | let b: fn() -> u32 = bar; found fn item `fn() -> () {bar}` error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:7:22 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:15:22 | LL | let f: fn(i32) = foo; | ------- ^^^ expected fn pointer, found fn item diff --git a/tests/ui/integral-variable-unification-error.rs b/tests/ui/mismatched_types/int-float-type-mismatch.rs index 8d1621321e8..b45d02730d9 100644 --- a/tests/ui/integral-variable-unification-error.rs +++ b/tests/ui/mismatched_types/int-float-type-mismatch.rs @@ -1,3 +1,6 @@ +//! Check that a type mismatch error is reported when trying +//! to unify a {float} value assignment to an {integer} variable. + fn main() { let mut x //~ NOTE expected due to the type of this binding = diff --git a/tests/ui/integral-variable-unification-error.stderr b/tests/ui/mismatched_types/int-float-type-mismatch.stderr index 1caa6042fd2..43b8609a49d 100644 --- a/tests/ui/integral-variable-unification-error.stderr +++ b/tests/ui/mismatched_types/int-float-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/integral-variable-unification-error.rs:5:9 + --> $DIR/int-float-type-mismatch.rs:8:9 | LL | let mut x | ----- expected due to the type of this binding diff --git a/tests/ui/mod-subitem-as-enum-variant.rs b/tests/ui/mod-subitem-as-enum-variant.rs deleted file mode 100644 index 959024c46f4..00000000000 --- a/tests/ui/mod-subitem-as-enum-variant.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod Mod { - pub struct FakeVariant<T>(pub T); -} - -fn main() { - Mod::FakeVariant::<i32>(0); - Mod::<i32>::FakeVariant(0); - //~^ ERROR type arguments are not allowed on module `Mod` [E0109] -} diff --git a/tests/ui/modules/nested-modules-basic.rs b/tests/ui/modules/nested-modules-basic.rs new file mode 100644 index 00000000000..12eccec2808 --- /dev/null +++ b/tests/ui/modules/nested-modules-basic.rs @@ -0,0 +1,19 @@ +//! Basic test for nested module functionality and path resolution + +//@ run-pass + +mod inner { + pub mod inner2 { + pub fn hello() { + println!("hello, modular world"); + } + } + pub fn hello() { + inner2::hello(); + } +} + +pub fn main() { + inner::hello(); + inner::inner2::hello(); +} diff --git a/tests/ui/monomorphize-abi-alignment.rs b/tests/ui/monomorphize-abi-alignment.rs deleted file mode 100644 index 62df1aca357..00000000000 --- a/tests/ui/monomorphize-abi-alignment.rs +++ /dev/null @@ -1,35 +0,0 @@ -//@ run-pass - -#![allow(non_upper_case_globals)] -#![allow(dead_code)] -/*! - * On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment, - * but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment - * of any field. (Also, `u64` has 8-byte ABI alignment; this is not always true). - * - * On such platforms, if monomorphize uses the "preferred" alignment, then it will unify - * `A` and `B`, even though `S<A>` and `S<B>` have the field `t` at different offsets, - * and apply the wrong instance of the method `unwrap`. - */ - -#[derive(Copy, Clone)] -struct S<T> { i:u8, t:T } - -impl<T> S<T> { - fn unwrap(self) -> T { - self.t - } -} - -#[derive(Copy, Clone, PartialEq, Debug)] -struct A((u32, u32)); - -#[derive(Copy, Clone, PartialEq, Debug)] -struct B(u64); - -pub fn main() { - static Ca: S<A> = S { i: 0, t: A((13, 104)) }; - static Cb: S<B> = S { i: 0, t: B(31337) }; - assert_eq!(Ca.unwrap(), A((13, 104))); - assert_eq!(Cb.unwrap(), B(31337)); -} diff --git a/tests/ui/msvc-data-only.rs b/tests/ui/msvc-data-only.rs deleted file mode 100644 index 15d799085fe..00000000000 --- a/tests/ui/msvc-data-only.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:msvc-data-only-lib.rs - -extern crate msvc_data_only_lib; - -fn main() { - println!("The answer is {} !", msvc_data_only_lib::FOO); -} diff --git a/tests/ui/msvc-opt-minsize.rs b/tests/ui/msvc-opt-minsize.rs deleted file mode 100644 index c1be168a05d..00000000000 --- a/tests/ui/msvc-opt-minsize.rs +++ /dev/null @@ -1,31 +0,0 @@ -// A previously outdated version of LLVM caused compilation failures on Windows -// specifically with optimization level `z`. After the update to a more recent LLVM -// version, this test checks that compilation and execution both succeed. -// See https://github.com/rust-lang/rust/issues/45034 - -//@ ignore-cross-compile -// Reason: the compiled binary is executed -//@ only-windows -// Reason: the observed bug only occurs on Windows -//@ run-pass -//@ compile-flags: -C opt-level=z - -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/tests/ui/multibyte.rs b/tests/ui/multibyte.rs deleted file mode 100644 index d585a791fb9..00000000000 --- a/tests/ui/multibyte.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -// - -// Test that multibyte characters don't crash the compiler -pub fn main() { - println!("마이너스 사인이 없으면"); -} diff --git a/tests/ui/multiline-comment.rs b/tests/ui/multiline-comment.rs deleted file mode 100644 index 98174882032..00000000000 --- a/tests/ui/multiline-comment.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -/* - * This is a multi-line oldcomment. - */ -pub fn main() { } diff --git a/tests/ui/new-import-syntax.rs b/tests/ui/new-import-syntax.rs deleted file mode 100644 index 547900fab61..00000000000 --- a/tests/ui/new-import-syntax.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass - -pub fn main() { - println!("Hello world!"); -} diff --git a/tests/ui/new-style-constants.rs b/tests/ui/new-style-constants.rs deleted file mode 100644 index e33a2da3878..00000000000 --- a/tests/ui/new-style-constants.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -static FOO: isize = 3; - -pub fn main() { - println!("{}", FOO); -} diff --git a/tests/ui/newlambdas.rs b/tests/ui/newlambdas.rs deleted file mode 100644 index 75e851fb73a..00000000000 --- a/tests/ui/newlambdas.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -// Tests for the new |args| expr lambda syntax - - -fn f<F>(i: isize, f: F) -> isize where F: FnOnce(isize) -> isize { f(i) } - -fn g<G>(_g: G) where G: FnOnce() { } - -pub fn main() { - assert_eq!(f(10, |a| a), 10); - g(||()); - assert_eq!(f(10, |a| a), 10); - g(||{}); -} diff --git a/tests/ui/newtype-polymorphic.rs b/tests/ui/newtype-polymorphic.rs deleted file mode 100644 index 146d49fdf68..00000000000 --- a/tests/ui/newtype-polymorphic.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] - - -#[derive(Clone)] -struct myvec<X>(Vec<X> ); - -fn myvec_deref<X:Clone>(mv: myvec<X>) -> Vec<X> { - let myvec(v) = mv; - return v.clone(); -} - -fn myvec_elt<X>(mv: myvec<X>) -> X { - let myvec(v) = mv; - return v.into_iter().next().unwrap(); -} - -pub fn main() { - let mv = myvec(vec![1, 2, 3]); - let mv_clone = mv.clone(); - let mv_clone = myvec_deref(mv_clone); - assert_eq!(mv_clone[1], 2); - assert_eq!(myvec_elt(mv.clone()), 1); - let myvec(v) = mv; - assert_eq!(v[2], 3); -} diff --git a/tests/ui/newtype.rs b/tests/ui/newtype.rs deleted file mode 100644 index 8a07c67eb4f..00000000000 --- a/tests/ui/newtype.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#[derive(Copy, Clone)] -struct mytype(Mytype); - -#[derive(Copy, Clone)] -struct Mytype { - compute: fn(mytype) -> isize, - val: isize, -} - -fn compute(i: mytype) -> isize { - let mytype(m) = i; - return m.val + 20; -} - -pub fn main() { - let myval = mytype(Mytype{compute: compute, val: 30}); - println!("{}", compute(myval)); - let mytype(m) = myval; - assert_eq!((m.compute)(myval), 50); -} diff --git a/tests/ui/no-core-1.rs b/tests/ui/no-core-1.rs deleted file mode 100644 index d6d2ba60445..00000000000 --- a/tests/ui/no-core-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(no_core, core)] -#![no_core] - -extern crate std; -extern crate core; - -use std::option::Option::Some; - -fn main() { - let a = Some("foo"); - a.unwrap(); -} diff --git a/tests/ui/no-core-2.rs b/tests/ui/no-core-2.rs deleted file mode 100644 index 2f55365bdd0..00000000000 --- a/tests/ui/no-core-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -#![allow(dead_code, unused_imports)] -#![feature(no_core)] -#![no_core] -//@ edition:2018 - -extern crate std; -extern crate core; -use core::{prelude::v1::*, *}; - -fn foo() { - for _ in &[()] {} -} - -fn bar() -> Option<()> { - None? -} - -fn main() {} diff --git a/tests/ui/no-warn-on-field-replace-issue-34101.rs b/tests/ui/no-warn-on-field-replace-issue-34101.rs deleted file mode 100644 index e1d5e9c5268..00000000000 --- a/tests/ui/no-warn-on-field-replace-issue-34101.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Issue 34101: Circa 2016-06-05, `fn inline` below issued an -// erroneous warning from the elaborate_drops pass about moving out of -// a field in `Foo`, which has a destructor (and thus cannot have -// content moved out of it). The reason that the warning is erroneous -// in this case is that we are doing a *replace*, not a move, of the -// content in question, and it is okay to replace fields within `Foo`. -// -// Another more subtle problem was that the elaborate_drops was -// creating a separate drop flag for that internally replaced content, -// even though the compiler should enforce an invariant that any drop -// flag for such subcontent of `Foo` will always have the same value -// as the drop flag for `Foo` itself. - - - - - - - - -//@ check-pass - -struct Foo(String); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn inline() { - // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) - let _s = (); - let mut f = Foo(String::from("foo")); - f.0 = String::from("bar"); -} - -fn outline() { - let _s = String::from("foo"); - let mut f = Foo(_s); - f.0 = String::from("bar"); -} - - -fn main() { - inline(); - outline(); -} diff --git a/tests/ui/no_send-enum.rs b/tests/ui/no_send-enum.rs deleted file mode 100644 index bd560649b99..00000000000 --- a/tests/ui/no_send-enum.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Send; - -struct NoSend; -impl !Send for NoSend {} - -enum Foo { - A(NoSend) -} - -fn bar<T: Send>(_: T) {} - -fn main() { - let x = Foo::A(NoSend); - bar(x); - //~^ ERROR `NoSend` cannot be sent between threads safely -} diff --git a/tests/ui/no_send-enum.stderr b/tests/ui/no_send-enum.stderr deleted file mode 100644 index 3b66c7db545..00000000000 --- a/tests/ui/no_send-enum.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: `NoSend` cannot be sent between threads safely - --> $DIR/no_send-enum.rs:16:9 - | -LL | bar(x); - | --- ^ `NoSend` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: within `Foo`, the trait `Send` is not implemented for `NoSend` -note: required because it appears within the type `Foo` - --> $DIR/no_send-enum.rs:8:6 - | -LL | enum Foo { - | ^^^ -note: required by a bound in `bar` - --> $DIR/no_send-enum.rs:12:11 - | -LL | fn bar<T: Send>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_send-rc.rs b/tests/ui/no_send-rc.rs deleted file mode 100644 index f31db15ef2e..00000000000 --- a/tests/ui/no_send-rc.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::rc::Rc; - -fn bar<T: Send>(_: T) {} - -fn main() { - let x = Rc::new(5); - bar(x); - //~^ ERROR `Rc<{integer}>` cannot be sent between threads safely -} diff --git a/tests/ui/no_send-rc.stderr b/tests/ui/no_send-rc.stderr deleted file mode 100644 index 1430a7a29ea..00000000000 --- a/tests/ui/no_send-rc.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: `Rc<{integer}>` cannot be sent between threads safely - --> $DIR/no_send-rc.rs:7:9 - | -LL | bar(x); - | --- ^ `Rc<{integer}>` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Send` is not implemented for `Rc<{integer}>` -note: required by a bound in `bar` - --> $DIR/no_send-rc.rs:3:11 - | -LL | fn bar<T: Send>(_: T) {} - | ^^^^ required by this bound in `bar` -help: consider dereferencing here - | -LL | bar(*x); - | + - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_share-enum.rs b/tests/ui/no_share-enum.rs deleted file mode 100644 index 44bf1913e7a..00000000000 --- a/tests/ui/no_share-enum.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Sync; - -struct NoSync; -impl !Sync for NoSync {} - -enum Foo { A(NoSync) } - -fn bar<T: Sync>(_: T) {} - -fn main() { - let x = Foo::A(NoSync); - bar(x); - //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] -} diff --git a/tests/ui/no_share-enum.stderr b/tests/ui/no_share-enum.stderr deleted file mode 100644 index 89939216d5b..00000000000 --- a/tests/ui/no_share-enum.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: `NoSync` cannot be shared between threads safely - --> $DIR/no_share-enum.rs:14:9 - | -LL | bar(x); - | --- ^ `NoSync` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: within `Foo`, the trait `Sync` is not implemented for `NoSync` -note: required because it appears within the type `Foo` - --> $DIR/no_share-enum.rs:8:6 - | -LL | enum Foo { A(NoSync) } - | ^^^ -note: required by a bound in `bar` - --> $DIR/no_share-enum.rs:10:11 - | -LL | fn bar<T: Sync>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_share-struct.rs b/tests/ui/no_share-struct.rs deleted file mode 100644 index 7d8a36a76f2..00000000000 --- a/tests/ui/no_share-struct.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Sync; - -struct Foo { a: isize } -impl !Sync for Foo {} - -fn bar<T: Sync>(_: T) {} - -fn main() { - let x = Foo { a: 5 }; - bar(x); - //~^ ERROR `Foo` cannot be shared between threads safely [E0277] -} diff --git a/tests/ui/no_share-struct.stderr b/tests/ui/no_share-struct.stderr deleted file mode 100644 index 9c7a921b8d8..00000000000 --- a/tests/ui/no_share-struct.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `Foo` cannot be shared between threads safely - --> $DIR/no_share-struct.rs:12:9 - | -LL | bar(x); - | --- ^ `Foo` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `Foo` -note: required by a bound in `bar` - --> $DIR/no_share-struct.rs:8:11 - | -LL | fn bar<T: Sync>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_std/no-core-edition2018-syntax.rs b/tests/ui/no_std/no-core-edition2018-syntax.rs new file mode 100644 index 00000000000..9a327e4c8e3 --- /dev/null +++ b/tests/ui/no_std/no-core-edition2018-syntax.rs @@ -0,0 +1,28 @@ +//! Test that `#![no_core]` doesn't break modern Rust syntax in edition 2018. +//! +//! When you use `#![no_core]`, you lose the automatic prelude, but you can still +//! get everything back by manually importing `use core::{prelude::v1::*, *}`. +//! This test makes sure that after doing that, things like `for` loops and the +//! `?` operator still work as expected. + +//@ run-pass +//@ edition:2018 + +#![allow(dead_code, unused_imports)] +#![feature(no_core)] +#![no_core] + +extern crate core; +extern crate std; +use core::prelude::v1::*; +use core::*; + +fn test_for_loop() { + for _ in &[()] {} +} + +fn test_question_mark_operator() -> Option<()> { + None? +} + +fn main() {} diff --git a/tests/ui/no_std/no-core-with-explicit-std-core.rs b/tests/ui/no_std/no-core-with-explicit-std-core.rs new file mode 100644 index 00000000000..3940bcb3aa4 --- /dev/null +++ b/tests/ui/no_std/no-core-with-explicit-std-core.rs @@ -0,0 +1,21 @@ +//! Test that you can use `#![no_core]` and still import std and core manually. +//! +//! The `#![no_core]` attribute disables the automatic core prelude, but you should +//! still be able to explicitly import both `std` and `core` crates and use types +//! like `Option` normally. + +//@ run-pass + +#![allow(stable_features)] +#![feature(no_core, core)] +#![no_core] + +extern crate core; +extern crate std; + +use std::option::Option::Some; + +fn main() { + let a = Some("foo"); + a.unwrap(); +} diff --git a/tests/ui/noexporttypeexe.stderr b/tests/ui/noexporttypeexe.stderr deleted file mode 100644 index 59759b696c7..00000000000 --- a/tests/ui/noexporttypeexe.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/noexporttypeexe.rs:10:18 - | -LL | let x: isize = noexporttypelib::foo(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option<isize>` - | | - | expected due to this - | - = note: expected type `isize` - found enum `Option<isize>` -help: consider using `Option::expect` to unwrap the `Option<isize>` value, panicking if the value is an `Option::None` - | -LL | let x: isize = noexporttypelib::foo().expect("REASON"); - | +++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/non-constant-expr-for-arr-len.rs b/tests/ui/non-constant-expr-for-arr-len.rs deleted file mode 100644 index 1b101d3233f..00000000000 --- a/tests/ui/non-constant-expr-for-arr-len.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Check that non constant exprs fail for array repeat syntax - -fn main() { - fn bar(n: usize) { - let _x = [0; n]; - //~^ ERROR attempt to use a non-constant value in a constant [E0435] - } -} diff --git a/tests/ui/nonscalar-cast.fixed b/tests/ui/nonscalar-cast.fixed deleted file mode 100644 index cb5591dbb9d..00000000000 --- a/tests/ui/nonscalar-cast.fixed +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From<Foo> for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", isize::from(Foo { x: 1 })); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.rs b/tests/ui/nonscalar-cast.rs deleted file mode 100644 index 27429b44cd0..00000000000 --- a/tests/ui/nonscalar-cast.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From<Foo> for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", Foo { x: 1 } as isize); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.stderr b/tests/ui/nonscalar-cast.stderr deleted file mode 100644 index 834d4ea241c..00000000000 --- a/tests/ui/nonscalar-cast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0605]: non-primitive cast: `Foo` as `isize` - --> $DIR/nonscalar-cast.rs:15:20 - | -LL | println!("{}", Foo { x: 1 } as isize); - | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - | -help: consider using the `From` trait instead - | -LL - println!("{}", Foo { x: 1 } as isize); -LL + println!("{}", isize::from(Foo { x: 1 })); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/not-clone-closure.rs b/tests/ui/not-clone-closure.rs deleted file mode 100644 index 976e3b9e81c..00000000000 --- a/tests/ui/not-clone-closure.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@compile-flags: --diagnostic-width=300 -// Check that closures do not implement `Clone` if their environment is not `Clone`. - -struct S(i32); - -fn main() { - let a = S(5); - let hello = move || { - println!("Hello {}", a.0); - }; - - let hello = hello.clone(); //~ ERROR the trait bound `S: Clone` is not satisfied -} diff --git a/tests/ui/not-clone-closure.stderr b/tests/ui/not-clone-closure.stderr deleted file mode 100644 index 0c95a99d0c0..00000000000 --- a/tests/ui/not-clone-closure.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` - --> $DIR/not-clone-closure.rs:12:23 - | -LL | let hello = move || { - | ------- within this `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` -... -LL | let hello = hello.clone(); - | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}`, the trait `Clone` is not implemented for `S` - | -note: required because it's used within this closure - --> $DIR/not-clone-closure.rs:8:17 - | -LL | let hello = move || { - | ^^^^^^^ -help: consider annotating `S` with `#[derive(Clone)]` - | -LL + #[derive(Clone)] -LL | struct S(i32); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index 4e8edf4d46e..0a01bb84f01 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -33,6 +33,7 @@ fn f() {} #[must_use = "string"suffix] //~^ ERROR suffixes on string literals are invalid +//~| ERROR malformed `must_use` attribute input fn g() {} #[link(name = "string"suffix)] @@ -41,4 +42,5 @@ extern "C" {} #[rustc_layout_scalar_valid_range_start(0suffix)] //~^ ERROR invalid suffix `suffix` for number literal +//~| ERROR malformed `rustc_layout_scalar_valid_range_start` attribute input struct S; diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 416143e496a..7876d75c5a4 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -23,13 +23,13 @@ LL | #[must_use = "string"suffix] | ^^^^^^^^^^^^^^ invalid suffix `suffix` error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:38:15 + --> $DIR/bad-lit-suffixes.rs:39:15 | LL | #[link(name = "string"suffix)] | ^^^^^^^^^^^^^^ invalid suffix `suffix` error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:42:41 + --> $DIR/bad-lit-suffixes.rs:43:41 | LL | #[rustc_layout_scalar_valid_range_start(0suffix)] | ^^^^^^^ invalid suffix `suffix` @@ -150,5 +150,33 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: aborting due to 20 previous errors; 2 warnings emitted +error[E0539]: malformed `must_use` attribute input + --> $DIR/bad-lit-suffixes.rs:34:1 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^--------------^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[must_use = "string"suffix] +LL + #[must_use = "reason"] + | +LL - #[must_use = "string"suffix] +LL + #[must_use] + | + +error[E0805]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/bad-lit-suffixes.rs:43:1 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^ + | | | + | | expected a single argument here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` + +error: aborting due to 22 previous errors; 2 warnings emitted +Some errors have detailed explanations: E0539, E0805. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/parser/multiline-comments-basic.rs b/tests/ui/parser/multiline-comments-basic.rs new file mode 100644 index 00000000000..1aa2a531f5c --- /dev/null +++ b/tests/ui/parser/multiline-comments-basic.rs @@ -0,0 +1,10 @@ +//! Test that basic multiline comments are parsed correctly. +//! +//! Feature implementation test for <https://github.com/rust-lang/rust/issues/66>. + +//@ run-pass + +/* + * This is a multi-line comment. + */ +pub fn main() {} diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs index 1cbd2ff1bdf..2c75840bc0a 100644 --- a/tests/ui/parser/trait-object-delimiters.rs +++ b/tests/ui/parser/trait-object-delimiters.rs @@ -8,7 +8,7 @@ fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around t fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{` -//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` +//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` //~| ERROR at least one trait is required for an object type fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<` diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr index 16d5392eec8..a2c9161cfbe 100644 --- a/tests/ui/parser/trait-object-delimiters.stderr +++ b/tests/ui/parser/trait-object-delimiters.stderr @@ -39,11 +39,11 @@ error: expected parameter name, found `{` LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} | ^ expected parameter name -error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` +error: expected one of `!`, `(`, `)`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` --> $DIR/trait-object-delimiters.rs:10:17 | LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} - | -^ expected one of 14 possible tokens + | -^ expected one of 13 possible tokens | | | help: missing `,` diff --git a/tests/ui/new-unicode-escapes.rs b/tests/ui/parser/unicode-escape-sequences.rs index 867a50da081..8b084866f19 100644 --- a/tests/ui/new-unicode-escapes.rs +++ b/tests/ui/parser/unicode-escape-sequences.rs @@ -1,6 +1,12 @@ +//! Test ES6-style Unicode escape sequences in string literals. +//! +//! Regression test for RFC 446 implementation. +//! See <https://github.com/rust-lang/rust/pull/19480>. + //@ run-pass pub fn main() { + // Basic Unicode escape - snowman character let s = "\u{2603}"; assert_eq!(s, "☃"); diff --git a/tests/ui/parser/unicode-multibyte-chars-no-ice.rs b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs new file mode 100644 index 00000000000..b1bb0c66ae2 --- /dev/null +++ b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs @@ -0,0 +1,9 @@ +//! Test that multibyte Unicode characters don't crash the compiler. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/4780>. + +//@ run-pass + +pub fn main() { + println!("마이너스 사인이 없으면"); +} diff --git a/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr b/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr index 9f1315070eb..e94074548e9 100644 --- a/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr +++ b/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied - --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:16 + --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:5 | LL | type Bar = BarImpl<'a, 'b, T>; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:6 diff --git a/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index b15d2affeea..e2a5027e710 100644 --- a/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -4,6 +4,14 @@ error[E0226]: only a single explicit lifetime bound is permitted LL | z: Box<dyn Is<'a>+'b+'c>, | ^^ +error[E0392]: lifetime parameter `'c` is never used + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 + | +LL | struct Foo<'a,'b,'c> { + | ^^ unused lifetime parameter + | + = help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData` + error[E0478]: lifetime bound not satisfied --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:8 | @@ -21,14 +29,6 @@ note: but lifetime parameter must outlive the lifetime `'a` as defined here LL | struct Foo<'a,'b,'c> { | ^^ -error[E0392]: lifetime parameter `'c` is never used - --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 - | -LL | struct Foo<'a,'b,'c> { - | ^^ unused lifetime parameter - | - = help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData` - error: aborting due to 3 previous errors Some errors have detailed explanations: E0226, E0392, E0478. diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.rs b/tests/ui/regions/regions-normalize-in-where-clause-list.rs index 389f82e794b..9b046e6baed 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.rs +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.rs @@ -22,9 +22,9 @@ where // Here we get an error: we need `'a: 'b`. fn bar<'a, 'b>() -//~^ ERROR cannot infer where <() as Project<'a, 'b>>::Item: Eq, + //~^ ERROR cannot infer { } diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr index ca9ceeeeff3..9a5c9ae53de 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr @@ -1,8 +1,8 @@ error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-normalize-in-where-clause-list.rs:24:4 + --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 | -LL | fn bar<'a, 'b>() - | ^^^ +LL | <() as Project<'a, 'b>>::Item: Eq, + | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... --> $DIR/regions-normalize-in-where-clause-list.rs:24:8 @@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he LL | fn bar<'a, 'b>() | ^^ note: ...so that the types are compatible - --> $DIR/regions-normalize-in-where-clause-list.rs:24:4 + --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 | -LL | fn bar<'a, 'b>() - | ^^^ +LL | <() as Project<'a, 'b>>::Item: Eq, + | ^^ = note: expected `Project<'a, 'b>` found `Project<'_, '_>` diff --git a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr index a9b45a18af3..f53e9e3b478 100644 --- a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr +++ b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr @@ -2,6 +2,7 @@ error[E0259]: the name `std` is defined multiple times | = note: `std` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import + --> $DIR/resolve-conflict-extern-crate-vs-extern-crate.rs:1:17 | LL | extern crate std as other_std; | ++++++++++++ diff --git a/tests/ui/max-min-classes.rs b/tests/ui/resolve/struct-function-same-name.rs index 338a3156a9a..bb2837d7ca6 100644 --- a/tests/ui/max-min-classes.rs +++ b/tests/ui/resolve/struct-function-same-name.rs @@ -1,3 +1,5 @@ +//! Test that a struct and function can have the same name +//! //@ run-pass #![allow(non_snake_case)] @@ -23,7 +25,7 @@ impl Product for Foo { } fn Foo(x: isize, y: isize) -> Foo { - Foo { x: x, y: y } + Foo { x, y } } pub fn main() { diff --git a/tests/ui/lexical-scoping.rs b/tests/ui/resolve/type-param-local-var-shadowing.rs index f858369f7ce..e08379e2acf 100644 --- a/tests/ui/lexical-scoping.rs +++ b/tests/ui/resolve/type-param-local-var-shadowing.rs @@ -1,8 +1,13 @@ +//! Test that items in subscopes correctly shadow type parameters and local variables +//! +//! Regression test for https://github.com/rust-lang/rust/issues/23880 + //@ run-pass -// Tests that items in subscopes can shadow type parameters and local variables (see issue #23880). #![allow(unused)] -struct Foo<X> { x: Box<X> } +struct Foo<X> { + x: Box<X>, +} impl<Bar> Foo<Bar> { fn foo(&self) { type Bar = i32; diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr index 591585c88f5..01a3f528359 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:9 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr index 0404b52d9ef..ff4c5f07284 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region.rs:17:20 + --> $DIR/regions-outlives-nominal-type-region.rs:17:9 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-region.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr index 62415e250ec..a0ede2aeada 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:9 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr index 464d7968b74..23d3f4ac606 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type.rs:17:20 + --> $DIR/regions-outlives-nominal-type-type.rs:17:9 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-type.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr index eb17ce736f7..73c0bbc44fb 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:13:16 + --> $DIR/regions-struct-not-wf.rs:13:5 | LL | impl<'a, T> Trait<'a, T> for usize { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a T; - | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,12 +12,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for usize { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:21:16 + --> $DIR/regions-struct-not-wf.rs:21:5 | LL | impl<'a, T> Trait<'a, T> for u32 { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound --> $DIR/regions-struct-not-wf.rs:16:20 @@ -30,10 +30,10 @@ LL | impl<'a, T: 'a> Trait<'a, T> for u32 { | ++++ error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:25:16 + --> $DIR/regions-struct-not-wf.rs:25:5 | LL | type Out = &'a &'b T; - | ^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-struct-not-wf.rs:24:6 diff --git a/tests/ui/self/self-infer.rs b/tests/ui/self/self-infer.rs index 9839b8880e9..d6f6d8bfa06 100644 --- a/tests/ui/self/self-infer.rs +++ b/tests/ui/self/self-infer.rs @@ -1,8 +1,8 @@ struct S; impl S { - fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions - fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions + fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods + fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods } fn main() {} diff --git a/tests/ui/self/self-infer.stderr b/tests/ui/self/self-infer.stderr index f9db559390f..13d803d9559 100644 --- a/tests/ui/self/self-infer.stderr +++ b/tests/ui/self/self-infer.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/self-infer.rs:4:16 | LL | fn f(self: _) {} | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/self-infer.rs:5:17 | LL | fn g(self: &_) {} diff --git a/tests/ui/simd/array-trait.stderr b/tests/ui/simd/array-trait.stderr index 299f0ad96ae..47f395044ff 100644 --- a/tests/ui/simd/array-trait.stderr +++ b/tests/ui/simd/array-trait.stderr @@ -1,3 +1,9 @@ +error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type + --> $DIR/array-trait.rs:22:1 + | +LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); + | ^^^^^^^^^^^^^^^^^^^^^ + error: unconstrained generic constant --> $DIR/array-trait.rs:22:23 | @@ -9,12 +15,6 @@ help: try adding a `where` bound LL | pub struct T<S: Simd>([S::Lane; S::SIZE]) where [(); S::SIZE]:; | ++++++++++++++++++++ -error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/array-trait.rs:22:1 - | -LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); - | ^^^^^^^^^^^^^^^^^^^^^ - error: unconstrained generic constant --> $DIR/array-trait.rs:22:23 | diff --git a/tests/ui/sized-hierarchy/impls.rs b/tests/ui/sized-hierarchy/impls.rs index 46697e47c4b..643f7bc7c46 100644 --- a/tests/ui/sized-hierarchy/impls.rs +++ b/tests/ui/sized-hierarchy/impls.rs @@ -3,7 +3,7 @@ #![allow(incomplete_features, internal_features)] #![feature(sized_hierarchy)] -#![feature(coroutines, dyn_star, extern_types, f16, never_type, unsized_fn_params)] +#![feature(coroutines, extern_types, f16, never_type, unsized_fn_params)] use std::fmt::Debug; use std::marker::{MetaSized, PointeeSized}; @@ -151,11 +151,6 @@ fn main() { needs_metasized::<!>(); needs_pointeesized::<!>(); - // `dyn*` - needs_sized::<dyn* Debug>(); - needs_metasized::<dyn* Debug>(); - needs_pointeesized::<dyn* Debug>(); - // `str` needs_sized::<str>(); //~^ ERROR the size for values of type `str` cannot be known at compilation time diff --git a/tests/ui/sized-hierarchy/impls.stderr b/tests/ui/sized-hierarchy/impls.stderr index eebe4e0d706..ca70822aad2 100644 --- a/tests/ui/sized-hierarchy/impls.stderr +++ b/tests/ui/sized-hierarchy/impls.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:240:42 + --> $DIR/impls.rs:235:42 | LL | struct StructAllFieldsMetaSized { x: [u8], y: [u8] } | ^^^^ doesn't have a size known at compile-time @@ -17,7 +17,7 @@ LL | struct StructAllFieldsMetaSized { x: Box<[u8]>, y: [u8] } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:248:40 + --> $DIR/impls.rs:243:40 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^ doesn't have a size known at compile-time @@ -35,7 +35,7 @@ LL | struct StructAllFieldsUnsized { x: Box<Foo>, y: Foo } | ++++ + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:284:44 + --> $DIR/impls.rs:279:44 | LL | enum EnumAllFieldsMetaSized { Qux { x: [u8], y: [u8] } } | ^^^^ doesn't have a size known at compile-time @@ -53,7 +53,7 @@ LL | enum EnumAllFieldsMetaSized { Qux { x: Box<[u8]>, y: [u8] } } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:291:42 + --> $DIR/impls.rs:286:42 | LL | enum EnumAllFieldsUnsized { Qux { x: Foo, y: Foo } } | ^^^ doesn't have a size known at compile-time @@ -71,7 +71,7 @@ LL | enum EnumAllFieldsUnsized { Qux { x: Box<Foo>, y: Foo } } | ++++ + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:298:52 + --> $DIR/impls.rs:293:52 | LL | enum EnumLastFieldMetaSized { Qux { x: u32, y: [u8] } } | ^^^^ doesn't have a size known at compile-time @@ -89,7 +89,7 @@ LL | enum EnumLastFieldMetaSized { Qux { x: u32, y: Box<[u8]> } } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:305:50 + --> $DIR/impls.rs:300:50 | LL | enum EnumLastFieldUnsized { Qux { x: u32, y: Foo } } | ^^^ doesn't have a size known at compile-time @@ -107,7 +107,7 @@ LL | enum EnumLastFieldUnsized { Qux { x: u32, y: Box<Foo> } } | ++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/impls.rs:160:19 + --> $DIR/impls.rs:155:19 | LL | needs_sized::<str>(); | ^^^ doesn't have a size known at compile-time @@ -120,7 +120,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:166:19 + --> $DIR/impls.rs:161:19 | LL | needs_sized::<[u8]>(); | ^^^^ doesn't have a size known at compile-time @@ -133,7 +133,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/impls.rs:172:19 + --> $DIR/impls.rs:167:19 | LL | needs_sized::<dyn Debug>(); | ^^^^^^^^^ doesn't have a size known at compile-time @@ -146,7 +146,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:181:19 + --> $DIR/impls.rs:176:19 | LL | needs_sized::<Foo>(); | ^^^ doesn't have a size known at compile-time @@ -159,7 +159,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:183:23 + --> $DIR/impls.rs:178:23 | LL | needs_metasized::<Foo>(); | ^^^ doesn't have a known size @@ -172,7 +172,7 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:198:19 + --> $DIR/impls.rs:193:19 | LL | needs_sized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -181,7 +181,7 @@ LL | needs_sized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:200:23 + --> $DIR/impls.rs:195:23 | LL | needs_metasized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -190,7 +190,7 @@ LL | needs_metasized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:202:26 + --> $DIR/impls.rs:197:26 | LL | needs_pointeesized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -199,7 +199,7 @@ LL | needs_pointeesized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:206:19 + --> $DIR/impls.rs:201:19 | LL | needs_sized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -208,7 +208,7 @@ LL | needs_sized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:208:23 + --> $DIR/impls.rs:203:23 | LL | needs_metasized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -217,7 +217,7 @@ LL | needs_metasized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:208:23 + --> $DIR/impls.rs:203:23 | LL | needs_metasized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a known size @@ -231,7 +231,7 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:211:26 + --> $DIR/impls.rs:206:26 | LL | needs_pointeesized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -240,7 +240,7 @@ LL | needs_pointeesized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:215:19 + --> $DIR/impls.rs:210:19 | LL | needs_sized::<(u32, [u8])>(); | ^^^^^^^^^^^ doesn't have a size known at compile-time @@ -254,7 +254,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:221:19 + --> $DIR/impls.rs:216:19 | LL | needs_sized::<(u32, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -268,7 +268,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:223:23 + --> $DIR/impls.rs:218:23 | LL | needs_metasized::<(u32, Foo)>(); | ^^^^^^^^^^ doesn't have a known size @@ -282,14 +282,14 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:242:19 + --> $DIR/impls.rs:237:19 | LL | needs_sized::<StructAllFieldsMetaSized>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructAllFieldsMetaSized`, the trait `Sized` is not implemented for `[u8]` note: required because it appears within the type `StructAllFieldsMetaSized` - --> $DIR/impls.rs:240:12 + --> $DIR/impls.rs:235:12 | LL | struct StructAllFieldsMetaSized { x: [u8], y: [u8] } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,14 +300,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:250:19 + --> $DIR/impls.rs:245:19 | LL | needs_sized::<StructAllFieldsUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructAllFieldsUnsized`, the trait `Sized` is not implemented for `main::Foo` note: required because it appears within the type `StructAllFieldsUnsized` - --> $DIR/impls.rs:248:12 + --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -318,14 +318,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:252:23 + --> $DIR/impls.rs:247:23 | LL | needs_metasized::<StructAllFieldsUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size | = help: within `StructAllFieldsUnsized`, the trait `MetaSized` is not implemented for `main::Foo` note: required because it appears within the type `StructAllFieldsUnsized` - --> $DIR/impls.rs:248:12 + --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -336,14 +336,14 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:258:19 + --> $DIR/impls.rs:253:19 | LL | needs_sized::<StructLastFieldMetaSized>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructLastFieldMetaSized`, the trait `Sized` is not implemented for `[u8]` note: required because it appears within the type `StructLastFieldMetaSized` - --> $DIR/impls.rs:257:12 + --> $DIR/impls.rs:252:12 | LL | struct StructLastFieldMetaSized { x: u32, y: [u8] } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -354,14 +354,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:265:19 + --> $DIR/impls.rs:260:19 | LL | needs_sized::<StructLastFieldUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructLastFieldUnsized`, the trait `Sized` is not implemented for `main::Foo` note: required because it appears within the type `StructLastFieldUnsized` - --> $DIR/impls.rs:264:12 + --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -372,14 +372,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:267:23 + --> $DIR/impls.rs:262:23 | LL | needs_metasized::<StructLastFieldUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size | = help: within `StructLastFieldUnsized`, the trait `MetaSized` is not implemented for `main::Foo` note: required because it appears within the type `StructLastFieldUnsized` - --> $DIR/impls.rs:264:12 + --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/specialization/defaultimpl/validation.stderr b/tests/ui/specialization/defaultimpl/validation.stderr index d034386b842..82a33bf9cdc 100644 --- a/tests/ui/specialization/defaultimpl/validation.stderr +++ b/tests/ui/specialization/defaultimpl/validation.stderr @@ -18,14 +18,6 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error: impls of auto traits cannot be default - --> $DIR/validation.rs:9:21 - | -LL | default unsafe impl Send for S {} - | ------- ^^^^ auto trait - | | - | default because of this - error[E0367]: `!Send` impl requires `Z: Send` but the struct it is implemented for does not --> $DIR/validation.rs:12:1 | @@ -39,6 +31,14 @@ LL | struct Z; | ^^^^^^^^ error: impls of auto traits cannot be default + --> $DIR/validation.rs:9:21 + | +LL | default unsafe impl Send for S {} + | ------- ^^^^ auto trait + | | + | default because of this + +error: impls of auto traits cannot be default --> $DIR/validation.rs:12:15 | LL | default impl !Send for Z {} diff --git a/tests/ui/specialization/issue-51892.stderr b/tests/ui/specialization/issue-51892.stderr index b1cabc0ac0e..f327f10438d 100644 --- a/tests/ui/specialization/issue-51892.stderr +++ b/tests/ui/specialization/issue-51892.stderr @@ -1,8 +1,8 @@ error: unconstrained generic constant - --> $DIR/issue-51892.rs:14:17 + --> $DIR/issue-51892.rs:14:5 | LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | help: try adding a `where` bound | diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr index 2ed614f1857..9b6c931f909 100644 --- a/tests/ui/specialization/min_specialization/issue-79224.stderr +++ b/tests/ui/specialization/min_specialization/issue-79224.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:28:29 + --> $DIR/issue-79224.rs:30:5 | -LL | impl<B: ?Sized> Display for Cow<'_, B> { - | ^^^^^^^^^^ the trait `Clone` is not implemented for `B` +LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting type parameter `B` with trait `Clone` @@ -11,10 +11,10 @@ LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> { | +++++++++++++++++++ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:30:5 + --> $DIR/issue-79224.rs:28:29 | -LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `B` +LL | impl<B: ?Sized> Display for Cow<'_, B> { + | ^^^^^^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting type parameter `B` with trait `Clone` diff --git a/tests/ui/static/issue-24446.stderr b/tests/ui/static/issue-24446.stderr index 0e6e338c5ef..6e35db7cc4a 100644 --- a/tests/ui/static/issue-24446.stderr +++ b/tests/ui/static/issue-24446.stderr @@ -1,17 +1,17 @@ error[E0277]: `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely - --> $DIR/issue-24446.rs:2:17 + --> $DIR/issue-24446.rs:2:5 | LL | static foo: dyn Fn() -> u32 = || -> u32 { - | ^^^^^^^^^^^^^^^ `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `(dyn Fn() -> u32 + 'static)` = note: shared static variables must have a type that implements `Sync` error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time - --> $DIR/issue-24446.rs:2:17 + --> $DIR/issue-24446.rs:2:5 | LL | static foo: dyn Fn() -> u32 = || -> u32 { - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` = note: statics and constants must have a statically known size diff --git a/tests/ui/statics/issue-17718-static-sync.stderr b/tests/ui/statics/issue-17718-static-sync.stderr index 96f894146c5..d49dbd947c5 100644 --- a/tests/ui/statics/issue-17718-static-sync.stderr +++ b/tests/ui/statics/issue-17718-static-sync.stderr @@ -1,8 +1,8 @@ error[E0277]: `Foo` cannot be shared between threads safely - --> $DIR/issue-17718-static-sync.rs:9:13 + --> $DIR/issue-17718-static-sync.rs:9:1 | LL | static BAR: Foo = Foo; - | ^^^ `Foo` cannot be shared between threads safely + | ^^^^^^^^^^^^^^^ `Foo` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `Foo` = note: shared static variables must have a type that implements `Sync` diff --git a/tests/ui/statics/static-generic-param-soundness.rs b/tests/ui/statics/static-generic-param-soundness.rs new file mode 100644 index 00000000000..aabcca514d3 --- /dev/null +++ b/tests/ui/statics/static-generic-param-soundness.rs @@ -0,0 +1,20 @@ +//! Originally, inner statics in generic functions were generated only once, causing the same +//! static to be shared across all generic instantiations. This created a soundness hole where +//! different types could be coerced through thread-local storage in safe code. +//! +//! This test checks that generic parameters from outer scopes cannot be used in inner statics, +//! preventing this soundness issue. +//! +//! See https://github.com/rust-lang/rust/issues/9186 + +enum Bar<T> { + //~^ ERROR parameter `T` is never used + What, +} + +fn foo<T>() { + static a: Bar<T> = Bar::What; + //~^ ERROR can't use generic parameters from outer item +} + +fn main() {} diff --git a/tests/ui/inner-static-type-parameter.stderr b/tests/ui/statics/static-generic-param-soundness.stderr index 88d33b44c59..47554c7fcb0 100644 --- a/tests/ui/inner-static-type-parameter.stderr +++ b/tests/ui/statics/static-generic-param-soundness.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/inner-static-type-parameter.rs:6:19 + --> $DIR/static-generic-param-soundness.rs:16:19 | LL | fn foo<T>() { | - type parameter from outer item @@ -9,9 +9,9 @@ LL | static a: Bar<T> = Bar::What; = note: a `static` is a separate item from the item that contains it error[E0392]: type parameter `T` is never used - --> $DIR/inner-static-type-parameter.rs:3:10 + --> $DIR/static-generic-param-soundness.rs:10:10 | -LL | enum Bar<T> { What } +LL | enum Bar<T> { | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index f799a82f139..a0f9ad6772d 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -1,8 +1,8 @@ error: static of uninhabited type - --> $DIR/uninhabited-static.rs:6:5 + --> $DIR/uninhabited-static.rs:12:1 | -LL | static VOID: Void; - | ^^^^^^^^^^^^^^^^^ +LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> @@ -14,30 +14,30 @@ LL | #![deny(uninhabited_static)] | ^^^^^^^^^^^^^^^^^^ error: static of uninhabited type - --> $DIR/uninhabited-static.rs:8:5 + --> $DIR/uninhabited-static.rs:15:1 | -LL | static NEVER: !; - | ^^^^^^^^^^^^^^^ +LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> = note: uninhabited statics cannot be initialized, and any access would be an immediate error error: static of uninhabited type - --> $DIR/uninhabited-static.rs:12:1 + --> $DIR/uninhabited-static.rs:6:5 | -LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^ +LL | static VOID: Void; + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> = note: uninhabited statics cannot be initialized, and any access would be an immediate error error: static of uninhabited type - --> $DIR/uninhabited-static.rs:15:1 + --> $DIR/uninhabited-static.rs:8:5 | -LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^ +LL | static NEVER: !; + | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> diff --git a/tests/ui/statics/unsized_type2.stderr b/tests/ui/statics/unsized_type2.stderr index 3f9b0879c16..293df7554e9 100644 --- a/tests/ui/statics/unsized_type2.stderr +++ b/tests/ui/statics/unsized_type2.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized_type2.rs:14:24 + --> $DIR/unsized_type2.rs:14:1 | LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `Sized` is not implemented for `str` note: required because it appears within the type `Foo` diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr index e401277a020..8a19207c5d7 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr @@ -22,10 +22,10 @@ LL | fn bar() -> i32 where Self: Sized; | +++++++++++++++++ error[E0277]: `(dyn Qux + 'static)` cannot be shared between threads safely - --> $DIR/unsizing-wfcheck-issue-127299.rs:12:13 + --> $DIR/unsizing-wfcheck-issue-127299.rs:12:1 | LL | static FOO: &Lint = &Lint { desc: "desc" }; - | ^^^^^ `(dyn Qux + 'static)` cannot be shared between threads safely + | ^^^^^^^^^^^^^^^^^ `(dyn Qux + 'static)` cannot be shared between threads safely | = help: within `&'static Lint`, the trait `Sync` is not implemented for `(dyn Qux + 'static)` = note: required because it appears within the type `&'static (dyn Qux + 'static)` diff --git a/tests/ui/stats/macro-stats.rs b/tests/ui/stats/macro-stats.rs index ee265d682fd..d986904ddd6 100644 --- a/tests/ui/stats/macro-stats.rs +++ b/tests/ui/stats/macro-stats.rs @@ -49,12 +49,17 @@ fn opt(x: Option<u32>) { } } -macro_rules! this_is_a_really_really_long_macro_name { +macro_rules! long_name_that_fits_on_a_single_line { + () => {} +} +long_name_that_fits_on_a_single_line!(); + +macro_rules! long_name_that_doesnt_fit_on_one_line { ($t:ty) => { fn f(_: $t) {} } } -this_is_a_really_really_long_macro_name!(u32!()); // AstFragmentKind::{Items,Ty} +long_name_that_doesnt_fit_on_one_line!(u32!()); // AstFragmentKind::{Items,Ty} macro_rules! trait_tys { () => { diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index 00c6b55c6a2..8d0fdb8958a 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -15,12 +15,13 @@ macro-stats #[derive(Copy)] 1 2 2.0 macro-stats p! 1 3 3.0 32 32.0 macro-stats trait_impl_tys! 1 2 2.0 28 28.0 macro-stats foreign_item! 1 1 1.0 21 21.0 -macro-stats this_is_a_really_really_long_macro_name! +macro-stats long_name_that_doesnt_fit_on_one_line! macro-stats 1 1 1.0 18 18.0 macro-stats impl_const! 1 1 1.0 17 17.0 macro-stats trait_tys! 1 2 2.0 15 15.0 macro-stats n99! 2 2 1.0 4 2.0 macro-stats none! 1 1 1.0 4 4.0 macro-stats u32! 1 1 1.0 3 3.0 +macro-stats long_name_that_fits_on_a_single_line! 1 1 1.0 0 0.0 macro-stats #[test] 1 1 1.0 0 0.0 macro-stats =================================================================================== diff --git a/tests/ui/structs/basic-newtype-pattern.rs b/tests/ui/structs/basic-newtype-pattern.rs new file mode 100644 index 00000000000..38ccd0ea8e0 --- /dev/null +++ b/tests/ui/structs/basic-newtype-pattern.rs @@ -0,0 +1,25 @@ +//! Test basic newtype pattern functionality. + +//@ run-pass + +#[derive(Copy, Clone)] +struct Counter(CounterData); + +#[derive(Copy, Clone)] +struct CounterData { + compute: fn(Counter) -> isize, + val: isize, +} + +fn compute_value(counter: Counter) -> isize { + let Counter(data) = counter; + data.val + 20 +} + +pub fn main() { + let my_counter = Counter(CounterData { compute: compute_value, val: 30 }); + + // Test destructuring and function pointer call + let Counter(data) = my_counter; + assert_eq!((data.compute)(my_counter), 50); +} diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.rs b/tests/ui/suggestions/bad-infer-in-trait-impl.rs index f38b168037b..db6fc9319e1 100644 --- a/tests/ui/suggestions/bad-infer-in-trait-impl.rs +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.rs @@ -4,7 +4,7 @@ trait Foo { impl Foo for () { fn bar(s: _) {} - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR has 1 parameter but the declaration in trait `Foo::bar` has 0 } diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr index 8b7d67ac041..5aa46545943 100644 --- a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/bad-infer-in-trait-impl.rs:6:15 | LL | fn bar(s: _) {} diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs index 6a273997ee6..2ee6ad91056 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs @@ -1,5 +1,3 @@ -#![feature(dyn_star)] //~ WARNING the feature `dyn_star` is incomplete - use std::future::Future; pub fn dyn_func<T>( @@ -8,12 +6,6 @@ pub fn dyn_func<T>( Box::new(executor) //~ ERROR may not live long enough } -pub fn dyn_star_func<T>( - executor: impl FnOnce(T) -> dyn* Future<Output = ()>, -) -> Box<dyn FnOnce(T) -> dyn* Future<Output = ()>> { - Box::new(executor) //~ ERROR may not live long enough -} - trait Trait { fn method(&self) {} } diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr index 1fb3e7d211e..62943616e3a 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr @@ -1,14 +1,5 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0599]: no method named `method` found for type parameter `T` in the current scope - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:24:7 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:16:7 | LL | pub fn in_ty_param<T: Fn() -> dyn std::fmt::Debug> (t: T) { | - method `method` not found for this type parameter @@ -22,7 +13,7 @@ LL | pub fn in_ty_param<T: Fn() -> (dyn std::fmt::Debug) + Trait> (t: T) { | + +++++++++ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:29:21 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:21:21 | LL | fn with_sized<T: Fn() -> &'static (dyn std::fmt::Debug) + ?Sized>() { | - this type parameter needs to be `Sized` @@ -30,7 +21,7 @@ LL | without_sized::<T>(); | ^ doesn't have a size known at compile-time | note: required by an implicit `Sized` bound in `without_sized` - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:33:18 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:25:18 | LL | fn without_sized<T: Fn() -> &'static dyn std::fmt::Debug>() {} | ^ required by the implicit `Sized` requirement on this type parameter in `without_sized` @@ -45,7 +36,7 @@ LL | fn without_sized<T: Fn() -> &'static (dyn std::fmt::Debug) + ?Sized>() {} | + ++++++++++ error[E0310]: the parameter type `impl FnOnce(T) -> dyn Future<Output = ()>` may not live long enough - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:8:5 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:6:5 | LL | Box::new(executor) | ^^^^^^^^^^^^^^^^^^ @@ -58,21 +49,7 @@ help: consider adding an explicit lifetime bound LL | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ -error[E0310]: the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` may not live long enough - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:14:5 - | -LL | Box::new(executor) - | ^^^^^^^^^^^^^^^^^^ - | | - | the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` must be valid for the static lifetime... - | ...so that the type `impl FnOnce(T) -> dyn* Future<Output = ()>` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound - | -LL | executor: impl FnOnce(T) -> (dyn* Future<Output = ()>) + 'static, - | + +++++++++++ - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0310, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/no-send-res-ports.rs b/tests/ui/threads-sendsync/rc-is-not-send.rs index 1bac5868e73..dd562e9e8f3 100644 --- a/tests/ui/no-send-res-ports.rs +++ b/tests/ui/threads-sendsync/rc-is-not-send.rs @@ -1,28 +1,28 @@ -use std::thread; +//! Test that `Rc<T>` cannot be sent between threads. + use std::rc::Rc; +use std::thread; #[derive(Debug)] struct Port<T>(Rc<T>); -fn main() { - #[derive(Debug)] - struct Foo { - _x: Port<()>, - } +#[derive(Debug)] +struct Foo { + _x: Port<()>, +} - impl Drop for Foo { - fn drop(&mut self) {} - } +impl Drop for Foo { + fn drop(&mut self) {} +} - fn foo(x: Port<()>) -> Foo { - Foo { - _x: x - } - } +fn foo(x: Port<()>) -> Foo { + Foo { _x: x } +} +fn main() { let x = foo(Port(Rc::new(()))); - thread::spawn(move|| { + thread::spawn(move || { //~^ ERROR `Rc<()>` cannot be sent between threads safely let y = x; println!("{:?}", y); diff --git a/tests/ui/no-send-res-ports.stderr b/tests/ui/threads-sendsync/rc-is-not-send.stderr index 9c30261e5cb..a06b683f729 100644 --- a/tests/ui/no-send-res-ports.stderr +++ b/tests/ui/threads-sendsync/rc-is-not-send.stderr @@ -1,10 +1,10 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/no-send-res-ports.rs:25:19 + --> $DIR/rc-is-not-send.rs:25:19 | -LL | thread::spawn(move|| { - | ------------- ^----- +LL | thread::spawn(move || { + | ------------- ^------ | | | - | _____|_____________within this `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}` + | _____|_____________within this `{closure@$DIR/rc-is-not-send.rs:25:19: 25:26}` | | | | | required by a bound introduced by this call LL | | @@ -13,22 +13,22 @@ LL | | println!("{:?}", y); LL | | }); | |_____^ `Rc<()>` cannot be sent between threads safely | - = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}`, the trait `Send` is not implemented for `Rc<()>` + = help: within `{closure@$DIR/rc-is-not-send.rs:25:19: 25:26}`, the trait `Send` is not implemented for `Rc<()>` note: required because it appears within the type `Port<()>` - --> $DIR/no-send-res-ports.rs:5:8 + --> $DIR/rc-is-not-send.rs:7:8 | LL | struct Port<T>(Rc<T>); | ^^^^ note: required because it appears within the type `Foo` - --> $DIR/no-send-res-ports.rs:9:12 + --> $DIR/rc-is-not-send.rs:10:8 | -LL | struct Foo { - | ^^^ +LL | struct Foo { + | ^^^ note: required because it's used within this closure - --> $DIR/no-send-res-ports.rs:25:19 + --> $DIR/rc-is-not-send.rs:25:19 | -LL | thread::spawn(move|| { - | ^^^^^^ +LL | thread::spawn(move || { + | ^^^^^^^ note: required by a bound in `spawn` --> $SRC_DIR/std/src/thread/mod.rs:LL:COL diff --git a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr index eedaae43f9a..54c0cf8ebee 100644 --- a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr +++ b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr @@ -1,9 +1,3 @@ -error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates - --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:9:9 - | -LL | impl<T, S> Trait<T> for i32 { - | ^ unconstrained type parameter - error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:15:12 | @@ -16,6 +10,12 @@ note: trait defined here, with 1 generic parameter: `T` LL | pub trait Trait<T> { | ^^^^^ - +error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates + --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:9:9 + | +LL | impl<T, S> Trait<T> for i32 { + | ^ unconstrained type parameter + error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:19:12 | diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index c6e0c699520..a165ef12060 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr @@ -16,7 +16,7 @@ LL | impl<T> const FromResidual for T { = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/ice-119717-constant-lifetime.rs:9:31 | LL | fn from_residual(t: T) -> _ { diff --git a/tests/ui/traits/constrained-type-params-trait-impl.stderr b/tests/ui/traits/constrained-type-params-trait-impl.stderr index 2175129a8df..e59fad6e72d 100644 --- a/tests/ui/traits/constrained-type-params-trait-impl.stderr +++ b/tests/ui/traits/constrained-type-params-trait-impl.stderr @@ -35,6 +35,17 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self LL | impl<T, U> Foo<T> for [isize; 1] { | ^ unconstrained type parameter +error[E0119]: conflicting implementations of trait `Bar` + --> $DIR/constrained-type-params-trait-impl.rs:48:1 + | +LL | impl<T, U> Bar for T { + | -------------------- first implementation here +... +LL | / impl<T, U> Bar for T +LL | | where +LL | | T: Bar<Out = U>, + | |____________________^ conflicting implementation + error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/constrained-type-params-trait-impl.rs:42:9 | @@ -59,17 +70,6 @@ error[E0207]: the type parameter `V` is not constrained by the impl trait, self LL | impl<T, U, V> Foo<T> for T | ^ unconstrained type parameter -error[E0119]: conflicting implementations of trait `Bar` - --> $DIR/constrained-type-params-trait-impl.rs:48:1 - | -LL | impl<T, U> Bar for T { - | -------------------- first implementation here -... -LL | / impl<T, U> Bar for T -LL | | where -LL | | T: Bar<Out = U>, - | |____________________^ conflicting implementation - error: aborting due to 9 previous errors Some errors have detailed explanations: E0119, E0207. diff --git a/tests/ui/traits/deep-norm-pending.rs b/tests/ui/traits/deep-norm-pending.rs index f56c3cfa3ea..d6c498dcf2b 100644 --- a/tests/ui/traits/deep-norm-pending.rs +++ b/tests/ui/traits/deep-norm-pending.rs @@ -8,9 +8,10 @@ trait Bar { } impl<T> Bar for T //~^ ERROR the trait bound `T: Foo` is not satisfied -//~| ERROR the trait bound `T: Foo` is not satisfied where <T as Foo>::Assoc: Sized, + //~^ ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied { fn method() {} //~^ ERROR the trait bound `T: Foo` is not satisfied @@ -18,7 +19,6 @@ where //~| ERROR the trait bound `T: Foo` is not satisfied //~| ERROR the trait bound `T: Foo` is not satisfied //~| ERROR the trait bound `T: Foo` is not satisfied - //~| ERROR the trait bound `T: Foo` is not satisfied } fn main() {} diff --git a/tests/ui/traits/deep-norm-pending.stderr b/tests/ui/traits/deep-norm-pending.stderr index b95b9d7f4ae..c1d6120c390 100644 --- a/tests/ui/traits/deep-norm-pending.stderr +++ b/tests/ui/traits/deep-norm-pending.stderr @@ -1,20 +1,8 @@ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 - | -LL | fn method() {} - | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` - | -help: consider further restricting type parameter `T` with trait `Foo` - | -LL | <T as Foo>::Assoc: Sized, T: Foo - | ++++++ - -error[E0277]: the trait bound `T: Foo` is not satisfied --> $DIR/deep-norm-pending.rs:9:1 | LL | / impl<T> Bar for T LL | | -LL | | LL | | where LL | | <T as Foo>::Assoc: Sized, | |_____________________________^ the trait `Foo` is not implemented for `T` @@ -25,15 +13,10 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:9:1 + --> $DIR/deep-norm-pending.rs:16:5 | -LL | / impl<T> Bar for T -LL | | -LL | | -LL | | where -... | -LL | | } - | |_^ the trait `Foo` is not implemented for `T` +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` | help: consider further restricting type parameter `T` with trait `Foo` | @@ -41,7 +24,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -53,7 +36,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -72,7 +55,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -103,7 +86,18 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:12:24 + | +LL | <T as Foo>::Assoc: Sized, + | ^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | <T as Foo>::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -115,11 +109,12 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:8 + --> $DIR/deep-norm-pending.rs:12:24 | -LL | fn method() {} - | ^^^^^^ the trait `Foo` is not implemented for `T` +LL | <T as Foo>::Assoc: Sized, + | ^^^^^ the trait `Foo` is not implemented for `T` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `T` with trait `Foo` | LL | <T as Foo>::Assoc: Sized, T: Foo diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.rs b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs index b1d4b261bab..f5f66ca69cf 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.rs +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs @@ -1,20 +1,30 @@ +//! Test various invalid implementations of DispatchFromDyn trait. +//! +//! DispatchFromDyn is a special trait used by the compiler for dyn-compatible dynamic dispatch. +//! This checks that the compiler correctly rejects invalid implementations: +//! - Structs with extra non-coercible fields +//! - Structs with multiple pointer fields +//! - Structs with no coercible fields +//! - Structs with repr(C) or other incompatible representations +//! - Structs with over-aligned fields + #![feature(unsize, dispatch_from_dyn)] -use std::{ - ops::DispatchFromDyn, - marker::{Unsize, PhantomData}, -}; +use std::marker::{PhantomData, Unsize}; +use std::ops::DispatchFromDyn; +// Extra field prevents DispatchFromDyn struct WrapperWithExtraField<T>(T, i32); impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> //~^ ERROR [E0378] where - T: DispatchFromDyn<U>, -{} - + T: DispatchFromDyn<U> +{ +} -struct MultiplePointers<T: ?Sized>{ +// Multiple pointer fields create ambiguous coercion +struct MultiplePointers<T: ?Sized> { ptr1: *const T, ptr2: *const T, } @@ -22,10 +32,11 @@ struct MultiplePointers<T: ?Sized>{ impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> //~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced where - T: Unsize<U>, -{} - + T: Unsize<U> +{ +} +// No coercible fields (only PhantomData) struct NothingToCoerce<T: ?Sized> { data: PhantomData<T>, } @@ -33,23 +44,28 @@ struct NothingToCoerce<T: ?Sized> { impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} //~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced +// repr(C) is incompatible with DispatchFromDyn #[repr(C)] struct HasReprC<T: ?Sized>(Box<T>); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> //~^ ERROR [E0378] where - T: Unsize<U>, -{} + T: Unsize<U> +{ +} +// Over-aligned fields are incompatible #[repr(align(64))] struct OverAlignedZst; + struct OverAligned<T: ?Sized>(Box<T>, OverAlignedZst); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> //~^ ERROR [E0378] - where - T: Unsize<U>, -{} +where + T: Unsize<U> +{ +} fn main() {} diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr index 93ec6bbe089..676da0ce81f 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr @@ -1,25 +1,25 @@ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else - --> $DIR/invalid_dispatch_from_dyn_impls.rs:10:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:19:1 | LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> LL | | LL | | where -LL | | T: DispatchFromDyn<U>, - | |__________________________^ +LL | | T: DispatchFromDyn<U> + | |_________________________^ | = note: extra field `1` of type `i32` is not allowed error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:22:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:32:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +LL | | T: Unsize<U> + | |________________^ | note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:18:5 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:28:5 | LL | ptr1: *const T, | ^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | ptr2: *const T, | ^^^^^^^^^^^^^^ error[E0374]: implementing `DispatchFromDyn` requires a field to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:33:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:44:1 | LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,22 +35,22 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingT = note: expected a single field to be coerced, none found error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]` - --> $DIR/invalid_dispatch_from_dyn_impls.rs:39:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:51:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +LL | | T: Unsize<U> + | |________________^ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else - --> $DIR/invalid_dispatch_from_dyn_impls.rs:49:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:64:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> LL | | -LL | | where -LL | | T: Unsize<U>, - | |_____________________^ +LL | | where +LL | | T: Unsize<U> + | |________________^ | = note: extra field `1` of type `OverAlignedZst` is not allowed diff --git a/tests/ui/traits/dyn-star-drop-principal.rs b/tests/ui/traits/dyn-star-drop-principal.rs deleted file mode 100644 index 1ad99070339..00000000000 --- a/tests/ui/traits/dyn-star-drop-principal.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Trait {} -impl Trait for usize {} - -fn main() { - // We allow &dyn Trait + Send -> &dyn Send (i.e. dropping principal), - // but we don't (currently?) allow the same for dyn* - let x: dyn* Trait + Send = 1usize; - x as dyn* Send; //~ error: `dyn* Trait + Send` needs to have the same ABI as a pointer -} diff --git a/tests/ui/traits/dyn-star-drop-principal.stderr b/tests/ui/traits/dyn-star-drop-principal.stderr deleted file mode 100644 index 721ae7e191e..00000000000 --- a/tests/ui/traits/dyn-star-drop-principal.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `dyn* Trait + Send` needs to have the same ABI as a pointer - --> $DIR/dyn-star-drop-principal.rs:11:5 - | -LL | x as dyn* Send; - | ^ `dyn* Trait + Send` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn* Trait + Send` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issue-11881.rs b/tests/ui/traits/encoder-trait-bounds-regression.rs index 1abe0797203..292b921cdf7 100644 --- a/tests/ui/issue-11881.rs +++ b/tests/ui/traits/encoder-trait-bounds-regression.rs @@ -1,14 +1,23 @@ +//! Regression test for issue #11881 +//! +//! Originally, the compiler would ICE when trying to parameterize on certain encoder types +//! due to issues with higher-ranked trait bounds and lifetime inference. This test checks +//! that various encoder patterns work correctly: +//! - Generic encoders with associated error types +//! - Higher-ranked trait bounds (for<'r> Encodable<JsonEncoder<'r>>) +//! - Multiple encoder implementations for the same type +//! - Polymorphic encoding functions + //@ run-pass #![allow(unused_must_use)] #![allow(dead_code)] #![allow(unused_imports)] -use std::fmt; -use std::io::prelude::*; use std::io::Cursor; -use std::slice; +use std::io::prelude::*; use std::marker::PhantomData; +use std::{fmt, slice}; trait Encoder { type Error; @@ -45,7 +54,6 @@ impl Encoder for OpaqueEncoder { type Error = (); } - struct Foo { baz: bool, } @@ -69,7 +77,6 @@ impl<S: Encoder> Encodable<S> for Bar { enum WireProtocol { JSON, Opaque, - // ... } fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) { diff --git a/tests/ui/traits/enum-negative-send-impl.rs b/tests/ui/traits/enum-negative-send-impl.rs new file mode 100644 index 00000000000..6bff42e9999 --- /dev/null +++ b/tests/ui/traits/enum-negative-send-impl.rs @@ -0,0 +1,22 @@ +//! Test that enums inherit Send/!Send properties from their variants. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send. + +#![feature(negative_impls)] + +use std::marker::Send; + +struct NoSend; +impl !Send for NoSend {} + +enum Container { + WithNoSend(NoSend), +} + +fn requires_send<T: Send>(_: T) {} + +fn main() { + let container = Container::WithNoSend(NoSend); + requires_send(container); + //~^ ERROR `NoSend` cannot be sent between threads safely +} diff --git a/tests/ui/traits/enum-negative-send-impl.stderr b/tests/ui/traits/enum-negative-send-impl.stderr new file mode 100644 index 00000000000..1992becccf4 --- /dev/null +++ b/tests/ui/traits/enum-negative-send-impl.stderr @@ -0,0 +1,23 @@ +error[E0277]: `NoSend` cannot be sent between threads safely + --> $DIR/enum-negative-send-impl.rs:20:19 + | +LL | requires_send(container); + | ------------- ^^^^^^^^^ `NoSend` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + = help: within `Container`, the trait `Send` is not implemented for `NoSend` +note: required because it appears within the type `Container` + --> $DIR/enum-negative-send-impl.rs:12:6 + | +LL | enum Container { + | ^^^^^^^^^ +note: required by a bound in `requires_send` + --> $DIR/enum-negative-send-impl.rs:16:21 + | +LL | fn requires_send<T: Send>(_: T) {} + | ^^^^ required by this bound in `requires_send` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/enum-negative-sync-impl.rs b/tests/ui/traits/enum-negative-sync-impl.rs new file mode 100644 index 00000000000..aa81a9fbbf9 --- /dev/null +++ b/tests/ui/traits/enum-negative-sync-impl.rs @@ -0,0 +1,22 @@ +//! Test that enums inherit Sync/!Sync properties from their variants. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync. + +#![feature(negative_impls)] + +use std::marker::Sync; + +struct NoSync; +impl !Sync for NoSync {} + +enum Container { + WithNoSync(NoSync), +} + +fn requires_sync<T: Sync>(_: T) {} + +fn main() { + let container = Container::WithNoSync(NoSync); + requires_sync(container); + //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] +} diff --git a/tests/ui/traits/enum-negative-sync-impl.stderr b/tests/ui/traits/enum-negative-sync-impl.stderr new file mode 100644 index 00000000000..a97b7a36a7b --- /dev/null +++ b/tests/ui/traits/enum-negative-sync-impl.stderr @@ -0,0 +1,23 @@ +error[E0277]: `NoSync` cannot be shared between threads safely + --> $DIR/enum-negative-sync-impl.rs:20:19 + | +LL | requires_sync(container); + | ------------- ^^^^^^^^^ `NoSync` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: within `Container`, the trait `Sync` is not implemented for `NoSync` +note: required because it appears within the type `Container` + --> $DIR/enum-negative-sync-impl.rs:12:6 + | +LL | enum Container { + | ^^^^^^^^^ +note: required by a bound in `requires_sync` + --> $DIR/enum-negative-sync-impl.rs:16:21 + | +LL | fn requires_sync<T: Sync>(_: T) {} + | ^^^^ required by this bound in `requires_sync` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/eval-caching-error-region.rs b/tests/ui/traits/eval-caching-error-region.rs new file mode 100644 index 00000000000..831b5ab80c1 --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.rs @@ -0,0 +1,23 @@ +// Regression test for #132882. + +use std::ops::Add; + +pub trait Numoid: Sized +where + &'missing Self: Add<Self>, + //~^ ERROR use of undeclared lifetime name `'missing` +{ +} + +// Proving `N: Numoid`'s well-formedness causes us to have to prove `&'missing N: Add<N>`. +// Since `'missing` is a region error, that will lead to us consider the predicate to hold, +// since it references errors. Since the freshener turns error regions into fresh regions, +// this means that subsequent lookups of `&'?0 N: Add<N>` will also hit this cache entry +// even if candidate assembly can't assemble anything for `&'?0 N: Add<?1>` anyways. This +// led to an ICE. +pub fn compute<N: Numoid>(a: N) { + let _ = &a + a; + //~^ ERROR cannot add `N` to `&N` +} + +fn main() {} diff --git a/tests/ui/traits/eval-caching-error-region.stderr b/tests/ui/traits/eval-caching-error-region.stderr new file mode 100644 index 00000000000..6365d242d2e --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/eval-caching-error-region.rs:7:6 + | +LL | &'missing Self: Add<Self>, + | ^^^^^^^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'missing` lifetime + | +LL | for<'missing> &'missing Self: Add<Self>, + | +++++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | pub trait Numoid<'missing>: Sized + | ++++++++++ + +error[E0369]: cannot add `N` to `&N` + --> $DIR/eval-caching-error-region.rs:19:16 + | +LL | let _ = &a + a; + | -- ^ - N + | | + | &N + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | pub fn compute<N: Numoid>(a: N) where &N: Add<N> { + | ++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0261, E0369. +For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr index e113f8382b2..b048548018a 100644 --- a/tests/ui/traits/issue-105231.stderr +++ b/tests/ui/traits/issue-105231.stderr @@ -1,3 +1,14 @@ +error: type parameter `T` is only used recursively + --> $DIR/issue-105231.rs:1:15 + | +LL | struct A<T>(B<T>); + | - ^ + | | + | type parameter must be used non-recursively in the definition + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = note: all type parameters must be used in a non-recursive way in order to constrain their variance + error[E0072]: recursive types `A` and `B` have infinite size --> $DIR/issue-105231.rs:1:1 | @@ -16,17 +27,6 @@ LL ~ struct B<T>(Box<A<A<T>>>); | error: type parameter `T` is only used recursively - --> $DIR/issue-105231.rs:1:15 - | -LL | struct A<T>(B<T>); - | - ^ - | | - | type parameter must be used non-recursively in the definition - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = note: all type parameters must be used in a non-recursive way in order to constrain their variance - -error: type parameter `T` is only used recursively --> $DIR/issue-105231.rs:4:17 | LL | struct B<T>(A<A<T>>); diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr index fbc60ce5d83..a1c772f58e1 100644 --- a/tests/ui/traits/issue-78372.stderr +++ b/tests/ui/traits/issue-78372.stderr @@ -56,6 +56,12 @@ LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} = help: add `#![feature(dispatch_from_dyn)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures + --> $DIR/issue-78372.rs:3:1 + | +LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0307]: invalid `self` parameter type: `Smaht<Self, T>` --> $DIR/issue-78372.rs:9:18 | @@ -65,12 +71,6 @@ LL | fn foo(self: Smaht<Self, T>); = note: type of `self` must be `Self` or a type that dereferences to it = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) -error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures - --> $DIR/issue-78372.rs:3:1 - | -LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 7 previous errors Some errors have detailed explanations: E0307, E0377, E0412, E0658. diff --git a/tests/ui/traits/issue-87558.stderr b/tests/ui/traits/issue-87558.stderr index 4cc3ec2ea8b..dc5bd6ece36 100644 --- a/tests/ui/traits/issue-87558.stderr +++ b/tests/ui/traits/issue-87558.stderr @@ -24,6 +24,14 @@ help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/issue-87558.rs:3:1 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` + error[E0277]: expected a `FnMut(&isize)` closure, found `Error` --> $DIR/issue-87558.rs:3:21 | @@ -34,14 +42,6 @@ LL | impl Fn(&isize) for Error { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/issue-87558.rs:3:1 - | -LL | impl Fn(&isize) for Error { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` - error: aborting due to 5 previous errors Some errors have detailed explanations: E0046, E0183, E0229, E0277, E0407. diff --git a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs new file mode 100644 index 00000000000..04963c98765 --- /dev/null +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs @@ -0,0 +1,18 @@ +//! Test that ?Trait bounds are forbidden in supertraits and trait object types. +//! +//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses, +//! they are explicitly forbidden in certain syntactic positions: +//! - As supertraits in trait definitions +//! - In trait object type expressions +//! +//! See https://github.com/rust-lang/rust/issues/20503 + +trait Tr: ?Sized {} +//~^ ERROR `?Trait` is not permitted in supertraits + +type A1 = dyn Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types +type A2 = dyn for<'a> Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types + +fn main() {} diff --git a/tests/ui/maybe-bounds.stderr b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr index 230d11fd0ae..bd0baa580bd 100644 --- a/tests/ui/maybe-bounds.stderr +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr @@ -1,5 +1,5 @@ error[E0658]: `?Trait` is not permitted in supertraits - --> $DIR/maybe-bounds.rs:1:11 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11 | LL | trait Tr: ?Sized {} | ^^^^^^ @@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:4:20 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20 | LL | type A1 = dyn Tr + (?Sized); | ^^^^^^^^ @@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:6:28 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28 | LL | type A2 = dyn for<'a> Tr + (?Sized); | ^^^^^^^^ diff --git a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr index d535c39639f..6472ac7363b 100644 --- a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr +++ b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:23 | LL | fn deserialize(s: _) {} diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index 45fa33dff52..391272b8d3b 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -14,10 +14,10 @@ LL | #![feature(lazy_type_alias)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied - --> $DIR/issue-118950-root-region.rs:14:21 + --> $DIR/issue-118950-root-region.rs:14:1 | LL | type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` + | ^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` | help: this trait has no implementations, consider adding one --> $DIR/issue-118950-root-region.rs:8:1 diff --git a/tests/ui/traits/rc-not-send.rs b/tests/ui/traits/rc-not-send.rs new file mode 100644 index 00000000000..83084c6173a --- /dev/null +++ b/tests/ui/traits/rc-not-send.rs @@ -0,0 +1,11 @@ +//! Test that `Rc<T>` does not implement `Send`. + +use std::rc::Rc; + +fn requires_send<T: Send>(_: T) {} + +fn main() { + let rc_value = Rc::new(5); + requires_send(rc_value); + //~^ ERROR `Rc<{integer}>` cannot be sent between threads safely +} diff --git a/tests/ui/traits/rc-not-send.stderr b/tests/ui/traits/rc-not-send.stderr new file mode 100644 index 00000000000..d6171a39ad0 --- /dev/null +++ b/tests/ui/traits/rc-not-send.stderr @@ -0,0 +1,22 @@ +error[E0277]: `Rc<{integer}>` cannot be sent between threads safely + --> $DIR/rc-not-send.rs:9:19 + | +LL | requires_send(rc_value); + | ------------- ^^^^^^^^ `Rc<{integer}>` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Send` is not implemented for `Rc<{integer}>` +note: required by a bound in `requires_send` + --> $DIR/rc-not-send.rs:5:21 + | +LL | fn requires_send<T: Send>(_: T) {} + | ^^^^ required by this bound in `requires_send` +help: consider dereferencing here + | +LL | requires_send(*rc_value); + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/struct-negative-sync-impl.rs b/tests/ui/traits/struct-negative-sync-impl.rs new file mode 100644 index 00000000000..d32846276f6 --- /dev/null +++ b/tests/ui/traits/struct-negative-sync-impl.rs @@ -0,0 +1,21 @@ +//! Test negative Sync implementation on structs. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync. + +#![feature(negative_impls)] + +use std::marker::Sync; + +struct NotSync { + value: isize, +} + +impl !Sync for NotSync {} + +fn requires_sync<T: Sync>(_: T) {} + +fn main() { + let not_sync = NotSync { value: 5 }; + requires_sync(not_sync); + //~^ ERROR `NotSync` cannot be shared between threads safely [E0277] +} diff --git a/tests/ui/traits/struct-negative-sync-impl.stderr b/tests/ui/traits/struct-negative-sync-impl.stderr new file mode 100644 index 00000000000..c5fd13f42e5 --- /dev/null +++ b/tests/ui/traits/struct-negative-sync-impl.stderr @@ -0,0 +1,18 @@ +error[E0277]: `NotSync` cannot be shared between threads safely + --> $DIR/struct-negative-sync-impl.rs:19:19 + | +LL | requires_sync(not_sync); + | ------------- ^^^^^^^^ `NotSync` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `NotSync` +note: required by a bound in `requires_sync` + --> $DIR/struct-negative-sync-impl.rs:15:21 + | +LL | fn requires_sync<T: Sync>(_: T) {} + | ^^^^ required by this bound in `requires_sync` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr index b9988e2e6d3..4264f2688ac 100644 --- a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr +++ b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr @@ -9,7 +9,7 @@ note: cycle used when checking that `A` is well-formed --> $DIR/cyclic-trait-resolution.rs:1:1 | LL | trait A: B + A {} - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing the implied predicates of `A` diff --git a/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs b/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs deleted file mode 100644 index 5936c93efad..00000000000 --- a/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs +++ /dev/null @@ -1,19 +0,0 @@ -// While somewhat nonsensical, this is a cast from a wide pointer to a thin pointer. -// Thus, we don't need to check an unsize goal here; there isn't any vtable casting -// happening at all. - -// Regression test for <https://github.com/rust-lang/rust/issues/137579>. - -//@ check-pass - -#![allow(incomplete_features)] -#![feature(dyn_star)] - -trait Foo {} -trait Bar {} - -fn cast(x: *const dyn Foo) { - x as *const dyn* Bar; -} - -fn main() {} diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr index 2bb389c6ec1..9ce0e8d957d 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization-2.rs:16:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization-2.rs:12:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr index 3eacab33e46..2da655afa93 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr @@ -4,13 +4,37 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization-2.rs:16:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization-2.rs:12:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + error[E0282]: type annotations needed - --> $DIR/unconstrained-projection-normalization-2.rs:19:11 + --> $DIR/unconstrained-projection-normalization-2.rs:20:11 | LL | fn foo(_: <Thing as Every>::Assoc) {} | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `<Thing as Every>::Assoc` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0282. +Some errors have detailed explanations: E0207, E0277, E0282. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs index 9d95c73eea7..899d67571e7 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.rs +++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs @@ -12,8 +12,9 @@ pub trait Every { type Assoc; } impl<T: ?Sized> Every for Thing { -//~^ ERROR the type parameter `T` is not constrained + //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR: the size for values of type `T` cannot be known at compilation time } fn foo(_: <Thing as Every>::Assoc) {} diff --git a/tests/ui/traits/unconstrained-projection-normalization.current.stderr b/tests/ui/traits/unconstrained-projection-normalization.current.stderr index 991f0e8ba66..c52e8dd68aa 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.current.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization.current.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization.rs:15:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization.rs:11:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.next.stderr b/tests/ui/traits/unconstrained-projection-normalization.next.stderr index 991f0e8ba66..c52e8dd68aa 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.next.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization.next.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization.rs:15:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization.rs:11:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.rs b/tests/ui/traits/unconstrained-projection-normalization.rs index fa4ab7fec4c..8e9444533a8 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.rs +++ b/tests/ui/traits/unconstrained-projection-normalization.rs @@ -11,8 +11,9 @@ pub trait Every { type Assoc; } impl<T: ?Sized> Every for Thing { -//~^ ERROR the type parameter `T` is not constrained + //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR: the size for values of type `T` cannot be known at compilation time } static I: <Thing as Every>::Assoc = 3; diff --git a/tests/ui/type-alias-enum-variants/module-type-args-error.rs b/tests/ui/type-alias-enum-variants/module-type-args-error.rs new file mode 100644 index 00000000000..9f7dae4f4f5 --- /dev/null +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.rs @@ -0,0 +1,16 @@ +//! Test that type arguments are properly rejected on modules. +//! +//! Related PR: https://github.com/rust-lang/rust/pull/56225 (RFC 2338 implementation) + +mod Mod { + pub struct FakeVariant<T>(pub T); +} + +fn main() { + // This should work fine - normal generic struct constructor + Mod::FakeVariant::<i32>(0); + + // This should error - type arguments not allowed on modules + Mod::<i32>::FakeVariant(0); + //~^ ERROR type arguments are not allowed on module `Mod` [E0109] +} diff --git a/tests/ui/mod-subitem-as-enum-variant.stderr b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr index 92d972eba42..4c59d19eaa7 100644 --- a/tests/ui/mod-subitem-as-enum-variant.stderr +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr @@ -1,5 +1,5 @@ error[E0109]: type arguments are not allowed on module `Mod` - --> $DIR/mod-subitem-as-enum-variant.rs:7:11 + --> $DIR/module-type-args-error.rs:14:11 | LL | Mod::<i32>::FakeVariant(0); | --- ^^^ type argument not allowed diff --git a/tests/ui/typeck/issue-13853-5.rs b/tests/ui/typeck/issue-13853-5.rs index fc97c6c67d6..47596aa4927 100644 --- a/tests/ui/typeck/issue-13853-5.rs +++ b/tests/ui/typeck/issue-13853-5.rs @@ -1,4 +1,4 @@ -trait Deserializer<'a> { } +trait Deserializer<'a> {} trait Deserializable { fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; @@ -8,6 +8,7 @@ impl<'a, T: Deserializable> Deserializable for &'a str { //~^ ERROR type parameter `T` is not constrained fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { //~^ ERROR mismatched types + //~| ERROR do not match the trait declaration } } diff --git a/tests/ui/typeck/issue-13853-5.stderr b/tests/ui/typeck/issue-13853-5.stderr index 4e483a0a58e..bb967b07b81 100644 --- a/tests/ui/typeck/issue-13853-5.stderr +++ b/tests/ui/typeck/issue-13853-5.stderr @@ -1,3 +1,12 @@ +error[E0195]: lifetime parameters or bounds on associated function `deserialize_token` do not match the trait declaration + --> $DIR/issue-13853-5.rs:9:25 + | +LL | fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; + | ------------------------- lifetimes in impl do not match this associated function in trait +... +LL | fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { + | ^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match associated function in trait + error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-13853-5.rs:7:10 | @@ -19,7 +28,7 @@ LL ~ _y LL ~ | -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0308. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0195, E0207, E0308. +For more information about an error, try `rustc --explain E0195`. diff --git a/tests/ui/typeck/issue-74086.rs b/tests/ui/typeck/issue-74086.rs index 1993cc7db35..c00ba81f551 100644 --- a/tests/ui/typeck/issue-74086.rs +++ b/tests/ui/typeck/issue-74086.rs @@ -1,4 +1,4 @@ fn main() { static BUG: fn(_) -> u8 = |_| 8; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static items + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for statics } diff --git a/tests/ui/typeck/issue-74086.stderr b/tests/ui/typeck/issue-74086.stderr index 25f454ac0c3..02c48201918 100644 --- a/tests/ui/typeck/issue-74086.stderr +++ b/tests/ui/typeck/issue-74086.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-74086.rs:2:20 | LL | static BUG: fn(_) -> u8 = |_| 8; diff --git a/tests/ui/typeck/issue-75889.stderr b/tests/ui/typeck/issue-75889.stderr index 1438f481ec7..c76f7c60b2e 100644 --- a/tests/ui/typeck/issue-75889.stderr +++ b/tests/ui/typeck/issue-75889.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-75889.rs:3:24 | LL | const FOO: dyn Fn() -> _ = ""; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-75889.rs:4:25 | LL | static BOO: dyn Fn() -> _ = ""; diff --git a/tests/ui/typeck/issue-81885.rs b/tests/ui/typeck/issue-81885.rs index d73c77b8f3a..d675231d898 100644 --- a/tests/ui/typeck/issue-81885.rs +++ b/tests/ui/typeck/issue-81885.rs @@ -1,7 +1,7 @@ const TEST4: fn() -> _ = 42; -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants fn main() { const TEST5: fn() -> _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants } diff --git a/tests/ui/typeck/issue-81885.stderr b/tests/ui/typeck/issue-81885.stderr index 25a6bb632ef..414fe548883 100644 --- a/tests/ui/typeck/issue-81885.stderr +++ b/tests/ui/typeck/issue-81885.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-81885.rs:1:22 | LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-81885.rs:5:26 | LL | const TEST5: fn() -> _ = 42; diff --git a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr index a4cb53025e3..c4a5c0dea6e 100644 --- a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr +++ b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15 | LL | static x: _; diff --git a/tests/ui/typeck/issue-88643.rs b/tests/ui/typeck/issue-88643.rs index 4435cba0207..e562f3e55ac 100644 --- a/tests/ui/typeck/issue-88643.rs +++ b/tests/ui/typeck/issue-88643.rs @@ -8,12 +8,12 @@ use std::collections::HashMap; pub trait T {} static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] static CALLBACKS3: Option<dyn Fn(& _)> = None; -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] fn main() {} diff --git a/tests/ui/typeck/issue-88643.stderr b/tests/ui/typeck/issue-88643.stderr index d5d596b6f42..ad11c3ea8e0 100644 --- a/tests/ui/typeck/issue-88643.stderr +++ b/tests/ui/typeck/issue-88643.stderr @@ -1,16 +1,16 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:10:56 | LL | static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:13:33 | LL | static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:16:36 | LL | static CALLBACKS3: Option<dyn Fn(& _)> = None; diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index dc790361919..48547c019d6 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -41,7 +41,7 @@ impl Test9 { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn test10(&self, _x : _) { } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } fn test11(x: &usize) -> &_ { @@ -56,10 +56,10 @@ unsafe fn test12(x: *const usize) -> *const *const _ { impl Clone for Test9 { fn clone(&self) -> _ { Test9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn clone_from(&mut self, other: _) { *self = Test9; } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } struct Test10 { @@ -108,15 +108,15 @@ pub fn main() { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn fn_test10(&self, _x : _) { } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } impl Clone for FnTest9 { fn clone(&self) -> _ { FnTest9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn clone_from(&mut self, other: _) { *self = FnTest9; } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } struct FnTest10 { @@ -140,19 +140,19 @@ pub fn main() { trait T { fn method_test1(&self, x: _); - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn method_test2(&self, x: _) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - //~| ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods + //~| ERROR the placeholder `_` is not allowed within types on item signatures for methods fn method_test3(&self) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn assoc_fn_test1(x: _); - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions fn assoc_fn_test2(x: _) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - //~| ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions + //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated functions fn assoc_fn_test3() -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions } struct BadStruct<_>(_); diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 53476f6c807..87750ee6dc1 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -203,7 +203,7 @@ LL | unsafe fn test12(x: *const usize) -> *const *const _ { | | not allowed in type signatures | help: replace with the correct return type: `*const *const usize` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:58:24 | LL | fn clone(&self) -> _ { Test9 } @@ -215,7 +215,7 @@ LL - fn clone(&self) -> _ { Test9 } LL + fn clone(&self) -> Test9 { Test9 } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:61:37 | LL | fn clone_from(&mut self, other: _) { *self = Test9; } @@ -332,7 +332,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | fn fn_test8(_f: fn() -> _) { } | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:115:28 | LL | fn clone(&self) -> _ { FnTest9 } @@ -344,7 +344,7 @@ LL - fn clone(&self) -> _ { FnTest9 } LL + fn clone(&self) -> FnTest9 { FnTest9 } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:118:41 | LL | fn clone_from(&mut self, other: _) { *self = FnTest9; } @@ -389,49 +389,49 @@ LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } | | not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:142:31 | LL | fn method_test1(&self, x: _); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:144:31 | LL | fn method_test2(&self, x: _) -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:144:37 | LL | fn method_test2(&self, x: _) -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:147:31 | LL | fn method_test3(&self) -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/typeck_type_placeholder_item.rs:149:26 | LL | fn assoc_fn_test1(x: _); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/typeck_type_placeholder_item.rs:151:26 | LL | fn assoc_fn_test2(x: _) -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/typeck_type_placeholder_item.rs:151:32 | LL | fn assoc_fn_test2(x: _) -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/typeck_type_placeholder_item.rs:154:28 | LL | fn assoc_fn_test3() -> _; @@ -575,7 +575,7 @@ LL | fn test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:43:27 | LL | fn test10(&self, _x : _) { } @@ -590,7 +590,7 @@ LL | fn fn_test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:110:34 | LL | fn fn_test10(&self, _x : _) { } diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.rs b/tests/ui/typeck/typeck_type_placeholder_item_help.rs index ab433aaaf16..758b94f9854 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.rs @@ -11,7 +11,7 @@ const TEST3: _ = Some(42); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const TEST4: fn() -> _ = 42; -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants trait Test5 { const TEST5: _ = 42; diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr index 5066e2eaa52..2fce00e7a8e 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -31,7 +31,7 @@ LL - const TEST3: _ = Some(42); LL + const TEST3: Option<i32> = Some(42); | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:13:22 | LL | const TEST4: fn() -> _ = 42; diff --git a/tests/ui/union/issue-81199.stderr b/tests/ui/union/issue-81199.stderr index 8b78ddcf4a5..7deba88fc80 100644 --- a/tests/ui/union/issue-81199.stderr +++ b/tests/ui/union/issue-81199.stderr @@ -1,3 +1,15 @@ +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/issue-81199.rs:5:5 + | +LL | components: PtrComponents<T>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | components: std::mem::ManuallyDrop<PtrComponents<T>>, + | +++++++++++++++++++++++ + + error[E0277]: the trait bound `T: Pointee` is not satisfied --> $DIR/issue-81199.rs:5:17 | @@ -14,18 +26,6 @@ help: consider further restricting type parameter `T` with trait `Pointee` LL | union PtrRepr<T: ?Sized + Pointee> { | +++++++++ -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/issue-81199.rs:5:5 - | -LL | components: PtrComponents<T>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | components: std::mem::ManuallyDrop<PtrComponents<T>>, - | +++++++++++++++++++++++ + - error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/union/union-unsized.stderr b/tests/ui/union/union-unsized.stderr index 851ad8939d4..89ab716071a 100644 --- a/tests/ui/union/union-unsized.stderr +++ b/tests/ui/union/union-unsized.stderr @@ -1,3 +1,15 @@ +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:2:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop<str>, + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/union-unsized.rs:2:8 | @@ -17,15 +29,15 @@ LL | a: Box<str>, | ++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-unsized.rs:2:5 + --> $DIR/union-unsized.rs:11:5 | -LL | a: str, +LL | b: str, | ^^^^^^ | = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` help: wrap the field type in `ManuallyDrop<...>` | -LL | a: std::mem::ManuallyDrop<str>, +LL | b: std::mem::ManuallyDrop<str>, | +++++++++++++++++++++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -46,18 +58,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | b: Box<str>, | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-unsized.rs:11:5 - | -LL | b: str, - | ^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | b: std::mem::ManuallyDrop<str>, - | +++++++++++++++++++++++ + - error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index 9df027b69b2..53ca3c8e391 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -15,7 +15,6 @@ #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -596,7 +595,6 @@ mod types { let _: dyn Send + 'static; let _: dyn 'static + Send; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait const fn ty_impl_trait() { diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr index ac8079ae089..aa411ce81eb 100644 --- a/tests/ui/unpretty/exhaustive.hir.stderr +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -1,17 +1,17 @@ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:210:9 + --> $DIR/exhaustive.rs:209:9 | LL | static || value; | ^^^^^^^^^ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:211:9 + --> $DIR/exhaustive.rs:210:9 | LL | static move || value; | ^^^^^^^^^^^^^^ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/exhaustive.rs:240:13 + --> $DIR/exhaustive.rs:239:13 | LL | fn expr_await() { | --------------- this is not `async` @@ -20,19 +20,19 @@ LL | fut.await; | ^^^^^ only allowed inside `async` functions and blocks error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/exhaustive.rs:289:9 + --> $DIR/exhaustive.rs:288:9 | LL | _; | ^ `_` not allowed here error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:299:9 + --> $DIR/exhaustive.rs:298:9 | LL | x::(); | ^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:300:9 + --> $DIR/exhaustive.rs:299:9 | LL | x::(T, T) -> T; | ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses @@ -44,31 +44,31 @@ LL + x::<T, T> -> T; | error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:301:9 + --> $DIR/exhaustive.rs:300:9 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:301:26 + --> $DIR/exhaustive.rs:300:26 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:304:9 + --> $DIR/exhaustive.rs:303:9 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:304:19 + --> $DIR/exhaustive.rs:303:19 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^^^ only `Fn` traits may use parentheses error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks - --> $DIR/exhaustive.rs:391:9 + --> $DIR/exhaustive.rs:390:9 | LL | yield; | ^^^^^ @@ -79,7 +79,7 @@ LL | #[coroutine] fn expr_yield() { | ++++++++++++ error[E0703]: invalid ABI: found `C++` - --> $DIR/exhaustive.rs:471:23 + --> $DIR/exhaustive.rs:470:23 | LL | unsafe extern "C++" {} | ^^^^^ invalid ABI @@ -87,7 +87,7 @@ LL | unsafe extern "C++" {} = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions error: `..` patterns are not allowed here - --> $DIR/exhaustive.rs:678:13 + --> $DIR/exhaustive.rs:677:13 | LL | let ..; | ^^ @@ -95,13 +95,13 @@ LL | let ..; = note: only allowed in tuple, tuple struct, and slice patterns error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:793:16 + --> $DIR/exhaustive.rs:792:16 | LL | let _: T() -> !; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:808:16 + --> $DIR/exhaustive.rs:806:16 | LL | let _: impl Send; | ^^^^^^^^^ @@ -112,7 +112,7 @@ LL | let _: impl Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:809:16 + --> $DIR/exhaustive.rs:807:16 | LL | let _: impl Send + 'static; | ^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ LL | let _: impl Send + 'static; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:810:16 + --> $DIR/exhaustive.rs:808:16 | LL | let _: impl 'static + Send; | ^^^^^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | let _: impl 'static + Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:811:16 + --> $DIR/exhaustive.rs:809:16 | LL | let _: impl ?Sized; | ^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | let _: impl ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:812:16 + --> $DIR/exhaustive.rs:810:16 | LL | let _: impl [const] Clone; | ^^^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ LL | let _: impl [const] Clone; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:813:16 + --> $DIR/exhaustive.rs:811:16 | LL | let _: impl for<'a> Send; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 2d347ec6e88..2b8f3b21396 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -14,7 +14,6 @@ #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -661,7 +660,6 @@ mod types { let _: dyn Send + 'static; let _: dyn Send + 'static; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait const fn ty_impl_trait() { diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 5bf1118058c..5292ddad4f6 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -14,7 +14,6 @@ #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -800,7 +799,6 @@ mod types { let _: dyn Send + 'static; let _: dyn 'static + Send; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait diff --git a/tests/ui/unsized-locals/yote.stderr b/tests/ui/unsized-locals/yote.stderr index 8e7da64038a..f08a0b4aa60 100644 --- a/tests/ui/unsized-locals/yote.stderr +++ b/tests/ui/unsized-locals/yote.stderr @@ -4,7 +4,7 @@ error[E0557]: feature has been removed LL | #![feature(unsized_locals)] | ^^^^^^^^^^^^^^ feature has been removed | - = note: removed in CURRENT_RUSTC_VERSION + = note: removed in 1.89.0 = note: removed due to implementation concerns; see https://github.com/rust-lang/rust/issues/111942 error: aborting due to 1 previous error diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.stderr b/tests/ui/unsized/unsized-trait-impl-self-type.stderr index 3b684193b4a..61165d49b2d 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-trait-impl-self-type.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-self-type.rs:10:1 + | +LL | fn foo(&self, z: &Z); + | --------------------- `foo` from trait +... +LL | impl<X: ?Sized> T3<X> for S5<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized-trait-impl-self-type.rs:10:27 | @@ -24,15 +33,6 @@ LL - impl<X: ?Sized> T3<X> for S5<X> { LL + impl<X> T3<X> for S5<X> { | -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/unsized-trait-impl-self-type.rs:10:1 - | -LL | fn foo(&self, z: &Z); - | --------------------- `foo` from trait -... -LL | impl<X: ?Sized> T3<X> for S5<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr index 79fc9567dae..f46a6f678a9 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 + | +LL | fn foo(&self, z: Z); + | -------------------- `foo` from trait +... +LL | impl<X: ?Sized> T2<X> for S4<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized-trait-impl-trait-arg.rs:8:17 | @@ -21,15 +30,6 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T2<Z: ?Sized> { | ++++++++ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 - | -LL | fn foo(&self, z: Z); - | -------------------- `foo` from trait -... -LL | impl<X: ?Sized> T2<X> for S4<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/unsized/unsized7.stderr b/tests/ui/unsized/unsized7.stderr index 6e9c052a070..2e65c8c3357 100644 --- a/tests/ui/unsized/unsized7.stderr +++ b/tests/ui/unsized/unsized7.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `dummy` + --> $DIR/unsized7.rs:12:1 + | +LL | fn dummy(&self) -> Z; + | --------------------- `dummy` from trait +... +LL | impl<X: ?Sized + T> T1<X> for S3<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized7.rs:12:21 | @@ -21,15 +30,6 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T1<Z: T + ?Sized> { | ++++++++ -error[E0046]: not all trait items implemented, missing: `dummy` - --> $DIR/unsized7.rs:12:1 - | -LL | fn dummy(&self) -> Z; - | --------------------- `dummy` from trait -... -LL | impl<X: ?Sized + T> T1<X> for S3<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/variance/variance-regions-unused-indirect.stderr b/tests/ui/variance/variance-regions-unused-indirect.stderr index 8cdbb3c0f5e..f942c51b05b 100644 --- a/tests/ui/variance/variance-regions-unused-indirect.stderr +++ b/tests/ui/variance/variance-regions-unused-indirect.stderr @@ -1,3 +1,11 @@ +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/variance-regions-unused-indirect.rs:3:10 + | +LL | enum Foo<'a> { + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + error[E0072]: recursive types `Foo` and `Bar` have infinite size --> $DIR/variance-regions-unused-indirect.rs:3:1 | @@ -22,14 +30,6 @@ LL ~ Bar1(Box<Foo<'a>>) | error[E0392]: lifetime parameter `'a` is never used - --> $DIR/variance-regions-unused-indirect.rs:3:10 - | -LL | enum Foo<'a> { - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - -error[E0392]: lifetime parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:8:10 | LL | enum Bar<'a> { diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr index e4d48bf82c0..07304cd448e 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.stderr +++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr @@ -11,10 +11,10 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:7:21 + --> $DIR/hir-wf-check-erase-regions.rs:7:5 | LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator + | ^^^^^^^^^^^^^ `&'a T` is not an iterator | = help: the trait `Iterator` is not implemented for `&'a T` = help: the trait `Iterator` is implemented for `&mut I` diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index e10bb98c134..dc5a1cf3485 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -32,7 +32,7 @@ LL | trait Trait<const N: dyn Trait = bar> { | ^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again -note: cycle used when computing explicit predicates of trait `Trait` +note: cycle used when checking that `Trait` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1 | LL | trait Trait<const N: dyn Trait = bar> { diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index a381f2acdce..a99728f4b66 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -37,7 +37,7 @@ note: ...which requires computing type of `Bar::M`... LL | trait Bar<const M: Foo<2>> {} | ^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `Foo::N`, completing the cycle -note: cycle used when computing explicit predicates of trait `Foo` +note: cycle used when checking that `Foo` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | LL | trait Foo<const N: Bar<2>> { @@ -56,7 +56,7 @@ note: ...which requires computing type of `Bar::M`... LL | trait Bar<const M: Foo<2>> {} | ^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `Foo::N`, completing the cycle -note: cycle used when computing explicit predicates of trait `Foo` +note: cycle used when checking that `Foo` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | LL | trait Foo<const N: Bar<2>> { diff --git a/tests/ui/wf/wf-impl-associated-type-region.stderr b/tests/ui/wf/wf-impl-associated-type-region.stderr index f17d33474f4..86e35b86fb1 100644 --- a/tests/ui/wf/wf-impl-associated-type-region.stderr +++ b/tests/ui/wf/wf-impl-associated-type-region.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-impl-associated-type-region.rs:10:16 + --> $DIR/wf-impl-associated-type-region.rs:10:5 | LL | impl<'a, T> Foo<'a> for T { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Bar = &'a T; - | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index e0cf42fd10c..f2989ae97b5 100644 --- a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:16 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:5 | LL | impl<'a, T> Trait<'a, T> for usize { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a fn(T); - | ^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,12 +12,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for usize { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:16 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | LL | impl<'a, T> Trait<'a, T> for u32 { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a dyn Baz<T>; - | ^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/wf/wf-trait-associated-type-region.stderr b/tests/ui/wf/wf-trait-associated-type-region.stderr index d6647b2cb96..9589e1d7853 100644 --- a/tests/ui/wf/wf-trait-associated-type-region.stderr +++ b/tests/ui/wf/wf-trait-associated-type-region.stderr @@ -1,11 +1,11 @@ error[E0309]: the associated type `<Self as SomeTrait<'a>>::Type1` may not live long enough - --> $DIR/wf-trait-associated-type-region.rs:9:18 + --> $DIR/wf-trait-associated-type-region.rs:9:5 | LL | trait SomeTrait<'a> { | -- the associated type `<Self as SomeTrait<'a>>::Type1` must be valid for the lifetime `'a` as defined here... LL | type Type1; LL | type Type2 = &'a Self::Type1; - | ^^^^^^^^^^^^^^^ ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at + | ^^^^^^^^^^ ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at | help: consider adding an explicit lifetime bound | |
