diff options
| author | bors <bors@rust-lang.org> | 2023-08-31 06:20:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-31 06:20:39 +0000 |
| commit | 2518c0ffeb112b5ecf409c5ea7825b46bb3db8ec (patch) | |
| tree | c5f0f668af52a644dad21229e18c952893832fb1 /tests | |
| parent | d9c11c65ee93b6dfd0c71f17812c68d316fce183 (diff) | |
| parent | f57b41519dc3bd863650114c344e8e7db7a1cc2d (diff) | |
| download | rust-2518c0ffeb112b5ecf409c5ea7825b46bb3db8ec.tar.gz rust-2518c0ffeb112b5ecf409c5ea7825b46bb3db8ec.zip | |
Auto merge of #3044 - rust-lang:rustup-2023-08-31, r=RalfJung
Automatic sync from rustc
Diffstat (limited to 'tests')
84 files changed, 616 insertions, 174 deletions
diff --git a/tests/debuginfo/regression-bad-location-list-67992.rs b/tests/debuginfo/regression-bad-location-list-67992.rs new file mode 100644 index 00000000000..cc7c4a0d71a --- /dev/null +++ b/tests/debuginfo/regression-bad-location-list-67992.rs @@ -0,0 +1,31 @@ +// compile-flags:-g + +// === GDB TESTS =================================================================================== + +// gdb-command:run + +// gdb-command:print a +// gdb-check:$1 = regression_bad_location_list_67992::Foo {x: [0 <repeats 1024 times>]} + +// === LLDB TESTS ================================================================================== + +// lldb-command:run +// lldb-command:print a +// lldbg-check:(regression_bad_location_list_67992::Foo) $0 = [...] +// lldbr-check:(regression_bad_location_list_67992::Foo) a = [...] + +const ARRAY_SIZE: usize = 1024; + +struct Foo { + x: [u64; ARRAY_SIZE], +} + +fn foo(a: Foo, i: usize) -> u64 { + a.x[i] // #break +} + +fn main() { + println!("Hello, world!"); + + println!("{}", foo(Foo { x: [0; ARRAY_SIZE] }, 42)); +} diff --git a/tests/run-make/pgo-branch-weights/Makefile b/tests/run-make/pgo-branch-weights/Makefile index c60206a1f34..4c9f8b2493a 100644 --- a/tests/run-make/pgo-branch-weights/Makefile +++ b/tests/run-make/pgo-branch-weights/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/pgo-gen-lto/Makefile b/tests/run-make/pgo-gen-lto/Makefile index 3f2f6a838b5..8b647846af3 100644 --- a/tests/run-make/pgo-gen-lto/Makefile +++ b/tests/run-make/pgo-gen-lto/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/pgo-gen/Makefile b/tests/run-make/pgo-gen/Makefile index 4623a74957b..bf32cfdb802 100644 --- a/tests/run-make/pgo-gen/Makefile +++ b/tests/run-make/pgo-gen/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/pgo-indirect-call-promotion/Makefile b/tests/run-make/pgo-indirect-call-promotion/Makefile index 45302215cc6..542eb244d39 100644 --- a/tests/run-make/pgo-indirect-call-promotion/Makefile +++ b/tests/run-make/pgo-indirect-call-promotion/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/pgo-use/Makefile b/tests/run-make/pgo-use/Makefile index 3bac9b77aa3..9f440118dae 100644 --- a/tests/run-make/pgo-use/Makefile +++ b/tests/run-make/pgo-use/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/pointer-auth-link-with-c/Makefile b/tests/run-make/pointer-auth-link-with-c/Makefile index dffbd303582..8fcf10e2096 100644 --- a/tests/run-make/pointer-auth-link-with-c/Makefile +++ b/tests/run-make/pointer-auth-link-with-c/Makefile @@ -1,6 +1,7 @@ include ../tools.mk # only-aarch64 +# ignore-cross-compile all: $(COMPILE_OBJ) $(TMPDIR)/test.o test.c diff --git a/tests/run-make/profile/Makefile b/tests/run-make/profile/Makefile index fffc051adbf..7919b18ba74 100644 --- a/tests/run-make/profile/Makefile +++ b/tests/run-make/profile/Makefile @@ -1,4 +1,5 @@ # needs-profiler-support +# ignore-cross-compile include ../tools.mk diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index f55d7d599f1..00dce3e004e 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -9,18 +9,12 @@ #![feature(rustc_private)] #![feature(assert_matches)] -extern crate rustc_driver; extern crate rustc_hir; -extern crate rustc_interface; extern crate rustc_middle; -extern crate rustc_session; extern crate rustc_smir; -use rustc_driver::{Callbacks, Compilation, RunCompiler}; use rustc_hir::def::DefKind; -use rustc_interface::{interface, Queries}; use rustc_middle::ty::TyCtxt; -use rustc_session::EarlyErrorHandler; use rustc_smir::{rustc_internal, stable_mir}; use std::assert_matches::assert_matches; use std::io::Write; @@ -130,8 +124,8 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// It will invoke the compiler using a custom Callback implementation, which will -/// invoke Stable MIR APIs after the compiler has finished its analysis. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. fn main() { let path = "input.rs"; generate_input(&path).unwrap(); @@ -142,29 +136,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&args, &mut SMirCalls {}).run().unwrap(); - }) - .unwrap(); -} - -struct SMirCalls {} - -impl Callbacks for SMirCalls { - /// Called after analysis. Return value instructs the compiler whether to - /// continue the compilation afterwards (defaults to `Compilation::Continue`) - fn after_analysis<'tcx>( - &mut self, - _handler: &EarlyErrorHandler, - _compiler: &interface::Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - queries.global_ctxt().unwrap().enter(|tcx| { - rustc_smir::rustc_internal::run(tcx, || test_stable_mir(tcx)); - }); - // No need to keep going. - Compilation::Stop - } + rustc_internal::StableMir::new(args, test_stable_mir).run(); } fn generate_input(path: &str) -> std::io::Result<()> { diff --git a/tests/ui/associated-type-bounds/suggest-removing-impl.rs b/tests/ui/associated-type-bounds/suggest-removing-impl.rs new file mode 100644 index 00000000000..242cd85727d --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-removing-impl.rs @@ -0,0 +1,14 @@ +trait Tr { + type Assoc: impl Sized; + //~^ ERROR expected a trait, found type + //~| HELP use the trait bounds directly + + fn fn_with_generics<T>() + where + T: impl Sized + //~^ ERROR expected a trait, found type + //~| HELP use the trait bounds directly + {} +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-removing-impl.stderr b/tests/ui/associated-type-bounds/suggest-removing-impl.stderr new file mode 100644 index 00000000000..875b2db6deb --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-removing-impl.stderr @@ -0,0 +1,26 @@ +error: expected a trait, found type + --> $DIR/suggest-removing-impl.rs:2:17 + | +LL | type Assoc: impl Sized; + | ^^^^^^^^^^ + | +help: use the trait bounds directly + | +LL - type Assoc: impl Sized; +LL + type Assoc: Sized; + | + +error: expected a trait, found type + --> $DIR/suggest-removing-impl.rs:8:12 + | +LL | T: impl Sized + | ^^^^^^^^^^ + | +help: use the trait bounds directly + | +LL - T: impl Sized +LL + T: Sized + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/issues/issue-32323.rs b/tests/ui/associated-types/issue-32323.rs index 5078f5523c9..5078f5523c9 100644 --- a/tests/ui/issues/issue-32323.rs +++ b/tests/ui/associated-types/issue-32323.rs diff --git a/tests/ui/issues/issue-32323.stderr b/tests/ui/associated-types/issue-32323.stderr index 8212c607e11..8212c607e11 100644 --- a/tests/ui/issues/issue-32323.stderr +++ b/tests/ui/associated-types/issue-32323.stderr diff --git a/tests/ui/issues/issue-11873.rs b/tests/ui/closures/issue-11873.rs index d3bd05caf38..d3bd05caf38 100644 --- a/tests/ui/issues/issue-11873.rs +++ b/tests/ui/closures/issue-11873.rs diff --git a/tests/ui/issues/issue-11873.stderr b/tests/ui/closures/issue-11873.stderr index c814eedd226..c814eedd226 100644 --- a/tests/ui/issues/issue-11873.stderr +++ b/tests/ui/closures/issue-11873.stderr diff --git a/tests/ui/issues/issue-25439.rs b/tests/ui/closures/issue-25439.rs index 4f73ff3e38b..4f73ff3e38b 100644 --- a/tests/ui/issues/issue-25439.rs +++ b/tests/ui/closures/issue-25439.rs diff --git a/tests/ui/issues/issue-25439.stderr b/tests/ui/closures/issue-25439.stderr index dadae23fdf3..dadae23fdf3 100644 --- a/tests/ui/issues/issue-25439.stderr +++ b/tests/ui/closures/issue-25439.stderr diff --git a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr index f315ba82130..89289767b83 100644 --- a/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr +++ b/tests/ui/coherence/warn-when-cycle-is-error-in-coherence.stderr @@ -6,13 +6,11 @@ LL | #[derive(PartialEq, Default)] ... LL | impl<T, Q> PartialEq<Q> for Interval<T> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the first impl is here -... -LL | Q: ?Sized + PartialOrd, - | ---------- `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap | = 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 #114040 <https://github.com/rust-lang/rust/issues/114040> = note: impls that are not considered to overlap may be considered to overlap in the future + = note: `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap note: the lint level is defined here --> $DIR/warn-when-cycle-is-error-in-coherence.rs:1:9 | diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.rs b/tests/ui/const-generics/late-bound-vars/in_closure.rs index 4fdf603b05f..6549cad629b 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.rs +++ b/tests/ui/const-generics/late-bound-vars/in_closure.rs @@ -1,4 +1,4 @@ -// failure-status: 101 +// failure-status: 1 // known-bug: unknown // error-pattern:internal compiler error // normalize-stderr-test "internal compiler error.*" -> "" @@ -22,7 +22,10 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] -const fn inner<'a>() -> usize where &'a (): Sized { +const fn inner<'a>() -> usize +where + &'a (): Sized, +{ 3 } diff --git a/tests/ui/error-codes/E0609-private-method.rs b/tests/ui/error-codes/E0609-private-method.rs new file mode 100644 index 00000000000..dfa97ad9a6f --- /dev/null +++ b/tests/ui/error-codes/E0609-private-method.rs @@ -0,0 +1,16 @@ +// This error is an E0609 and *not* an E0615 because the fact that the method exists is not +// relevant. +mod foo { + pub struct Foo { + x: u32, + } + + impl Foo { + fn method(&self) {} + } +} + +fn main() { + let f = foo::Foo { x: 0 }; + f.method; //~ ERROR E0609 +} diff --git a/tests/ui/error-codes/E0609-private-method.stderr b/tests/ui/error-codes/E0609-private-method.stderr new file mode 100644 index 00000000000..d2a11e90627 --- /dev/null +++ b/tests/ui/error-codes/E0609-private-method.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `method` on type `Foo` + --> $DIR/E0609-private-method.rs:15:7 + | +LL | f.method; + | ^^^^^^ unknown field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/impl-trait/issue-108591.rs b/tests/ui/impl-trait/issue-108591.rs index 6b9d14941f2..91ea2e9fb85 100644 --- a/tests/ui/impl-trait/issue-108591.rs +++ b/tests/ui/impl-trait/issue-108591.rs @@ -13,7 +13,8 @@ impl MyTy<'_> { } } -type Opaque<'a> = impl Sized; +type Opaque2 = impl Sized; +type Opaque<'a> = Opaque2; fn define<'a>() -> Opaque<'a> {} fn test<'a>() { diff --git a/tests/ui/impl-trait/issue-108592.rs b/tests/ui/impl-trait/issue-108592.rs index 58a0ed9bf1a..953fffc4898 100644 --- a/tests/ui/impl-trait/issue-108592.rs +++ b/tests/ui/impl-trait/issue-108592.rs @@ -11,7 +11,8 @@ fn test_closure() { closure(&opaque()); } -type Opaque<'a> = impl Sized; +type Opaque2 = impl Sized; +type Opaque<'a> = Opaque2; fn define<'a>() -> Opaque<'a> {} fn test_tait(_: &Opaque<'_>) { diff --git a/tests/ui/impl-trait/issue-86465.rs b/tests/ui/impl-trait/issue-86465.rs index 8c7b41d73b7..a79bb6474d8 100644 --- a/tests/ui/impl-trait/issue-86465.rs +++ b/tests/ui/impl-trait/issue-86465.rs @@ -1,10 +1,6 @@ #![feature(type_alias_impl_trait)] -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type X<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +type X<'a, 'b> = impl std::fmt::Debug; fn f<'t, 'u>(a: &'t u32, b: &'u u32) -> (X<'t, 'u>, X<'u, 't>) { (a, a) diff --git a/tests/ui/impl-trait/issue-86465.stderr b/tests/ui/impl-trait/issue-86465.stderr index b949b2b4245..90d6904ed61 100644 --- a/tests/ui/impl-trait/issue-86465.stderr +++ b/tests/ui/impl-trait/issue-86465.stderr @@ -1,5 +1,5 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/issue-86465.rs:10:5 + --> $DIR/issue-86465.rs:6:5 | LL | (a, a) | ^^^^^^ diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index ea5e1ad9dce..c20a0198ccb 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -117,13 +117,13 @@ error: layout_of(S) = Layout { fields: Arbitrary { offsets: [ Size(0 bytes), - Size(0 bytes), + Size(8 bytes), Size(4 bytes), ], memory_index: [ - 1, 0, 2, + 1, ], }, largest_niche: None, diff --git a/tests/ui/layout/enum.rs b/tests/ui/layout/enum.rs new file mode 100644 index 00000000000..7ac2eaa8600 --- /dev/null +++ b/tests/ui/layout/enum.rs @@ -0,0 +1,18 @@ +// normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN" +//! Various enum layout tests. + +#![feature(rustc_attrs)] +#![feature(never_type)] +#![crate_type = "lib"] + +#[rustc_layout(align)] +enum UninhabitedVariantAlign { //~ERROR: abi: Align(2 bytes) + A([u8; 32]), + B([u16; 0], !), // make sure alignment in uninhabited fields is respected +} + +#[rustc_layout(size)] +enum UninhabitedVariantSpace { //~ERROR: size: Size(16 bytes) + A, + B([u8; 15], !), // make sure there is space being reserved for this field. +} diff --git a/tests/ui/layout/enum.stderr b/tests/ui/layout/enum.stderr new file mode 100644 index 00000000000..d6bc7780ce2 --- /dev/null +++ b/tests/ui/layout/enum.stderr @@ -0,0 +1,14 @@ +error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN } + --> $DIR/enum.rs:9:1 + | +LL | enum UninhabitedVariantAlign { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: size: Size(16 bytes) + --> $DIR/enum.rs:15:1 + | +LL | enum UninhabitedVariantSpace { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/layout/layout-cycle.rs b/tests/ui/layout/layout-cycle.rs new file mode 100644 index 00000000000..85685058e49 --- /dev/null +++ b/tests/ui/layout/layout-cycle.rs @@ -0,0 +1,31 @@ +// build-fail +//~^ ERROR: a cycle occurred during layout computation +//~| ERROR: cycle detected when computing layout of + +// Issue #111176 -- ensure that we do not emit ICE on layout cycles + +use std::mem; + +pub struct S<T: Tr> { + pub f: <T as Tr>::I, +} + +pub trait Tr { + type I: Tr; +} + +impl<T: Tr> Tr for S<T> { + type I = S<S<T>>; +} + +impl Tr for () { + type I = (); +} + +fn foo<T: Tr>() -> usize { + mem::size_of::<S<T>>() +} + +fn main() { + println!("{}", foo::<S<()>>()); +} diff --git a/tests/ui/layout/layout-cycle.stderr b/tests/ui/layout/layout-cycle.stderr new file mode 100644 index 00000000000..a3cdb7edcc2 --- /dev/null +++ b/tests/ui/layout/layout-cycle.stderr @@ -0,0 +1,11 @@ +error[E0391]: cycle detected when computing layout of `S<S<()>>` + | + = note: ...which requires computing layout of `<S<()> as Tr>::I`... + = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle + = 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: failed to get layout for S<S<()>>: a cycle occurred during layout computation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/layout/struct.rs b/tests/ui/layout/struct.rs new file mode 100644 index 00000000000..e74cf5a952b --- /dev/null +++ b/tests/ui/layout/struct.rs @@ -0,0 +1,12 @@ +// normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN" +//! Various struct layout tests. + +#![feature(rustc_attrs)] +#![feature(never_type)] +#![crate_type = "lib"] + +#[rustc_layout(abi)] +struct AlignedZstPreventsScalar(i16, [i32; 0]); //~ERROR: abi: Aggregate + +#[rustc_layout(abi)] +struct AlignedZstButStillScalar(i32, [i16; 0]); //~ERROR: abi: Scalar diff --git a/tests/ui/layout/struct.stderr b/tests/ui/layout/struct.stderr new file mode 100644 index 00000000000..b61c9a99cce --- /dev/null +++ b/tests/ui/layout/struct.stderr @@ -0,0 +1,14 @@ +error: abi: Aggregate { sized: true } + --> $DIR/struct.rs:9:1 + | +LL | struct AlignedZstPreventsScalar(i16, [i32; 0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: abi: Scalar(Initialized { value: Int(I32, true), valid_range: 0..=4294967295 }) + --> $DIR/struct.rs:12:1 + | +LL | struct AlignedZstButStillScalar(i32, [i16; 0]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/issues/issue-69225-SCEVAddExpr-wrap-flag.rs b/tests/ui/loops/issue-69225-SCEVAddExpr-wrap-flag.rs index 6e030f1cc48..6e030f1cc48 100644 --- a/tests/ui/issues/issue-69225-SCEVAddExpr-wrap-flag.rs +++ b/tests/ui/loops/issue-69225-SCEVAddExpr-wrap-flag.rs diff --git a/tests/ui/issues/issue-69225-layout-repeated-checked-add.rs b/tests/ui/loops/issue-69225-layout-repeated-checked-add.rs index 7f43e4d1a51..7f43e4d1a51 100644 --- a/tests/ui/issues/issue-69225-layout-repeated-checked-add.rs +++ b/tests/ui/loops/issue-69225-layout-repeated-checked-add.rs diff --git a/tests/ui/issues/issue-39467.rs b/tests/ui/macros/issue-39467.rs index 397751e4ec3..397751e4ec3 100644 --- a/tests/ui/issues/issue-39467.rs +++ b/tests/ui/macros/issue-39467.rs diff --git a/tests/ui/issues/issue-3707.rs b/tests/ui/methods/issue-3707.rs index 0817c51ee4e..0817c51ee4e 100644 --- a/tests/ui/issues/issue-3707.rs +++ b/tests/ui/methods/issue-3707.rs diff --git a/tests/ui/issues/issue-3707.stderr b/tests/ui/methods/issue-3707.stderr index 07c8101cbc6..07c8101cbc6 100644 --- a/tests/ui/issues/issue-3707.stderr +++ b/tests/ui/methods/issue-3707.stderr diff --git a/tests/ui/mir/mir-inlining/always-encode-mirs.rs b/tests/ui/mir/mir-inlining/always-encode-mirs.rs new file mode 100644 index 00000000000..f3731996cf2 --- /dev/null +++ b/tests/ui/mir/mir-inlining/always-encode-mirs.rs @@ -0,0 +1,12 @@ +// Regression test for MIR inlining with -Zalways-encode-mir enabled in the auxiliary crate. +// Previously we inlined function not eligible for inlining which lead to linking error: +// undefined reference to `internal::S' +// +// aux-build:internal.rs +// build-pass +// compile-flags: -O +extern crate internal; + +fn main() { + println!("{}", internal::f()); +} diff --git a/tests/ui/mir/mir-inlining/auxiliary/internal.rs b/tests/ui/mir/mir-inlining/auxiliary/internal.rs new file mode 100644 index 00000000000..fa0f9c2da41 --- /dev/null +++ b/tests/ui/mir/mir-inlining/auxiliary/internal.rs @@ -0,0 +1,7 @@ +// compile-flags: -Zalways-encode-mir + +static S: usize = 42; + +pub fn f() -> &'static usize { + &S +} diff --git a/tests/ui/issues/issue-13033.rs b/tests/ui/mismatched_types/issue-13033.rs index fdb356e70c5..fdb356e70c5 100644 --- a/tests/ui/issues/issue-13033.rs +++ b/tests/ui/mismatched_types/issue-13033.rs diff --git a/tests/ui/issues/issue-13033.stderr b/tests/ui/mismatched_types/issue-13033.stderr index db2c1189e1e..db2c1189e1e 100644 --- a/tests/ui/issues/issue-13033.stderr +++ b/tests/ui/mismatched_types/issue-13033.stderr diff --git a/tests/ui/issues/issue-34721.fixed b/tests/ui/moves/issue-34721.fixed index f135ad3836e..f135ad3836e 100644 --- a/tests/ui/issues/issue-34721.fixed +++ b/tests/ui/moves/issue-34721.fixed diff --git a/tests/ui/issues/issue-34721.rs b/tests/ui/moves/issue-34721.rs index 14dd01766aa..14dd01766aa 100644 --- a/tests/ui/issues/issue-34721.rs +++ b/tests/ui/moves/issue-34721.rs diff --git a/tests/ui/issues/issue-34721.stderr b/tests/ui/moves/issue-34721.stderr index f2bf22227db..f2bf22227db 100644 --- a/tests/ui/issues/issue-34721.stderr +++ b/tests/ui/moves/issue-34721.stderr diff --git a/tests/ui/parser/macro/macro-expand-to-field.rs b/tests/ui/parser/macro/macro-expand-to-field.rs index 155872f7a5d..533511ecf5a 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.rs +++ b/tests/ui/parser/macro/macro-expand-to-field.rs @@ -1,5 +1,7 @@ // compile-flags: --crate-type=lib +// https://github.com/rust-lang/rust/issues/113766 + macro_rules! field { ($name:ident:$type:ty) => { $name:$type @@ -13,15 +15,14 @@ macro_rules! variant { } struct Struct { + //~^ NOTE while parsing this struct field!(bar:u128), //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` //~| NOTE unexpected token after this a: u32, b: u32, - field!(recovers:()), //~ NOTE macros cannot expand to struct fields - //~^ ERROR unexpected token: `!` - //~^^ NOTE unexpected token after this + field!(recovers:()), } enum EnumVariant { @@ -35,7 +36,7 @@ enum EnumVariant { //~^ NOTE macros cannot expand to enum variants //~| ERROR unexpected token: `!` //~| NOTE unexpected token after this - Data { + Data { //~ NOTE while parsing this struct field!(x:u32), //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` @@ -44,27 +45,35 @@ enum EnumVariant { } enum EnumVariantField { - Named { + Named { //~ NOTE while parsing this struct field!(oopsies:()), //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` //~| unexpected token after this field!(oopsies2:()), - //~^ NOTE macros cannot expand to struct fields - //~| ERROR unexpected token: `!` - //~| unexpected token after this }, } union Union { + //~^ NOTE while parsing this union A: u32, field!(oopsies:()), //~^ NOTE macros cannot expand to union fields //~| ERROR unexpected token: `!` - //~| unexpected token after this + //~| NOTE unexpected token after this B: u32, field!(recovers:()), - //~^ NOTE macros cannot expand to union fields +} + +// https://github.com/rust-lang/rust/issues/114636 + +#[derive(Debug)] +pub struct Lazy { + //~^ NOTE while parsing this struct + unreachable!() + //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` - //~| unexpected token after this + //~| NOTE unexpected token after this } + +fn main() {} diff --git a/tests/ui/parser/macro/macro-expand-to-field.stderr b/tests/ui/parser/macro/macro-expand-to-field.stderr index adcd032f5c0..0bb71800081 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.stderr +++ b/tests/ui/parser/macro/macro-expand-to-field.stderr @@ -1,21 +1,16 @@ error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:16:10 + --> $DIR/macro-expand-to-field.rs:19:10 | +LL | struct Struct { + | ------ while parsing this struct +LL | LL | field!(bar:u128), | ^ unexpected token after this | = note: macros cannot expand to struct fields error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:22:10 - | -LL | field!(recovers:()), - | ^ unexpected token after this - | - = note: macros cannot expand to struct fields - -error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:28:12 + --> $DIR/macro-expand-to-field.rs:29:12 | LL | variant!(whoops), | ^ unexpected token after this @@ -23,7 +18,7 @@ LL | variant!(whoops), = note: macros cannot expand to enum variants error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:34:12 + --> $DIR/macro-expand-to-field.rs:35:12 | LL | variant!(recovers), | ^ unexpected token after this @@ -31,44 +26,46 @@ LL | variant!(recovers), = note: macros cannot expand to enum variants error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:39:14 + --> $DIR/macro-expand-to-field.rs:40:14 | +LL | Data { + | ---- while parsing this struct LL | field!(x:u32), | ^ unexpected token after this | = note: macros cannot expand to struct fields error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:48:14 + --> $DIR/macro-expand-to-field.rs:49:14 | +LL | Named { + | ----- while parsing this struct LL | field!(oopsies:()), | ^ unexpected token after this | = note: macros cannot expand to struct fields error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:52:14 - | -LL | field!(oopsies2:()), - | ^ unexpected token after this - | - = note: macros cannot expand to struct fields - -error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:61:10 + --> $DIR/macro-expand-to-field.rs:60:10 | +LL | union Union { + | ----- while parsing this union +... LL | field!(oopsies:()), | ^ unexpected token after this | = note: macros cannot expand to union fields error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:66:10 + --> $DIR/macro-expand-to-field.rs:73:16 | -LL | field!(recovers:()), - | ^ unexpected token after this +LL | pub struct Lazy { + | ---- while parsing this struct +LL | +LL | unreachable!() + | ^ unexpected token after this | - = note: macros cannot expand to union fields + = note: macros cannot expand to struct fields -error: aborting due to 9 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/print_type_sizes/zero-sized-fields.stdout b/tests/ui/print_type_sizes/zero-sized-fields.stdout index 72f59c4bb57..e4d44241e43 100644 --- a/tests/ui/print_type_sizes/zero-sized-fields.stdout +++ b/tests/ui/print_type_sizes/zero-sized-fields.stdout @@ -1,16 +1,16 @@ print-type-size type: `S5<(), Empty>`: 16 bytes, alignment: 4 bytes +print-type-size field `.w`: 4 bytes +print-type-size field `.x`: 4 bytes +print-type-size field `.y`: 4 bytes +print-type-size field `.z`: 4 bytes print-type-size field `.tagw`: 0 bytes print-type-size field `.unit`: 0 bytes print-type-size field `.void`: 0 bytes print-type-size field `.empty`: 0 bytes print-type-size field `.tagz`: 0 bytes -print-type-size field `.w`: 4 bytes -print-type-size field `.x`: 4 bytes -print-type-size field `.y`: 4 bytes -print-type-size field `.z`: 4 bytes print-type-size type: `S1`: 8 bytes, alignment: 4 bytes -print-type-size field `.tag`: 0 bytes print-type-size field `.x`: 4 bytes print-type-size field `.y`: 4 bytes +print-type-size field `.tag`: 0 bytes print-type-size type: `Empty`: 0 bytes, alignment: 1 bytes print-type-size type: `Void`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/issues/issue-6642.rs b/tests/ui/resolve/issue-6642.rs index f80f6fffe89..f80f6fffe89 100644 --- a/tests/ui/issues/issue-6642.rs +++ b/tests/ui/resolve/issue-6642.rs diff --git a/tests/ui/issues/issue-6642.stderr b/tests/ui/resolve/issue-6642.stderr index 6668108d024..6668108d024 100644 --- a/tests/ui/issues/issue-6642.stderr +++ b/tests/ui/resolve/issue-6642.stderr diff --git a/tests/ui/traits/issue-105231.rs b/tests/ui/traits/issue-105231.rs index bb2b13664ba..74c7afd6b9e 100644 --- a/tests/ui/traits/issue-105231.rs +++ b/tests/ui/traits/issue-105231.rs @@ -1,9 +1,9 @@ +//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send` struct A<T>(B<T>); //~^ ERROR recursive types `A` and `B` have infinite size struct B<T>(A<A<T>>); trait Foo {} impl<T> Foo for T where T: Send {} -//~^ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send` impl Foo for B<u8> {} fn main() {} diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr index 76a71067353..fe20c47c57a 100644 --- a/tests/ui/traits/issue-105231.stderr +++ b/tests/ui/traits/issue-105231.stderr @@ -1,5 +1,5 @@ error[E0072]: recursive types `A` and `B` have infinite size - --> $DIR/issue-105231.rs:1:1 + --> $DIR/issue-105231.rs:2:1 | LL | struct A<T>(B<T>); | ^^^^^^^^^^^ ---- recursive without indirection @@ -15,14 +15,10 @@ LL ~ struct B<T>(Box<A<A<T>>>); | error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send` - --> $DIR/issue-105231.rs:5:28 - | -LL | impl<T> Foo for T where T: Send {} - | ^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`) note: required because it appears within the type `B<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<u8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-105231.rs:3:8 + --> $DIR/issue-105231.rs:4:8 | LL | struct B<T>(A<A<T>>); | ^ diff --git a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.rs b/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.rs new file mode 100644 index 00000000000..539c9614e82 --- /dev/null +++ b/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.rs @@ -0,0 +1,12 @@ +//~ ERROR overflow evaluating the requirement `Self well-formed` +//~| ERROR overflow evaluating the requirement `Self: Trait` + +// This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE. +// compile-flags: -Ztrait-solver=next --crate-type=lib +// check-fail + +#![recursion_limit = "0"] +trait Trait {} +impl Trait for u32 {} +//~^ ERROR overflow evaluating the requirement `u32: Trait` +//~| ERROR overflow evaluating the requirement `u32 well-formed` diff --git a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.stderr b/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.stderr new file mode 100644 index 00000000000..16b25d90ace --- /dev/null +++ b/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.stderr @@ -0,0 +1,27 @@ +error[E0275]: overflow evaluating the requirement `Self: Trait` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`) + +error[E0275]: overflow evaluating the requirement `Self well-formed` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`) + +error[E0275]: overflow evaluating the requirement `u32: Trait` + --> $DIR/recursion-limit-zero-issue-115351.rs:10:16 + | +LL | impl Trait for u32 {} + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`) + +error[E0275]: overflow evaluating the requirement `u32 well-formed` + --> $DIR/recursion-limit-zero-issue-115351.rs:10:16 + | +LL | impl Trait for u32 {} + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs index 206ab07898b..d37943b929a 100644 --- a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs +++ b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs @@ -1,3 +1,4 @@ +//~ ERROR overflow // A regression test for #111729 checking that we correctly // track recursion depth for obligations returned by confirmation. use std::panic::RefUnwindSafe; @@ -14,7 +15,6 @@ struct RootDatabase { } impl<T: RefUnwindSafe> Database for T { - //~^ ERROR overflow type Storage = SalsaStorage; } impl Database for RootDatabase { diff --git a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr index 4123a8199a0..8f9ce3ef1e9 100644 --- a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr +++ b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr @@ -1,17 +1,13 @@ error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe` - --> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:9 - | -LL | impl<T: RefUnwindSafe> Database for T { - | ^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`) note: required because it appears within the type `RootDatabase` - --> $DIR/cycle-via-builtin-auto-trait-impl.rs:12:8 + --> $DIR/cycle-via-builtin-auto-trait-impl.rs:13:8 | LL | struct RootDatabase { | ^^^^^^^^^^^^ note: required for `RootDatabase` to implement `Database` - --> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:24 + --> $DIR/cycle-via-builtin-auto-trait-impl.rs:17:24 | LL | impl<T: RefUnwindSafe> Database for T { | ------------- ^^^^^^^^ ^ diff --git a/tests/ui/issues/issue-32709.rs b/tests/ui/try-trait/issue-32709.rs index c05bfdc4cfd..c05bfdc4cfd 100644 --- a/tests/ui/issues/issue-32709.rs +++ b/tests/ui/try-trait/issue-32709.rs diff --git a/tests/ui/issues/issue-32709.stderr b/tests/ui/try-trait/issue-32709.stderr index 94e8f9295fd..94e8f9295fd 100644 --- a/tests/ui/issues/issue-32709.stderr +++ b/tests/ui/try-trait/issue-32709.stderr diff --git a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs index 5f75fdc716e..4f424b8c665 100644 --- a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs +++ b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs @@ -1,11 +1,7 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type OneLifetime<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +type OneLifetime<'a, 'b> = impl std::fmt::Debug; fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> { a diff --git a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr index 546598e8a5c..0c50a84e894 100644 --- a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr +++ b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr @@ -1,11 +1,11 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/different_lifetimes_defining_uses.rs:15:5 + --> $DIR/different_lifetimes_defining_uses.rs:11:5 | LL | b | ^ expected `&'a u32`, got `&'b u32` | note: previous use here - --> $DIR/different_lifetimes_defining_uses.rs:11:5 + --> $DIR/different_lifetimes_defining_uses.rs:7:5 | LL | a | ^ diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs index 14ced341854..169d4f8d509 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -2,11 +2,7 @@ fn main() {} -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +type Two<'a, 'b> = impl std::fmt::Debug; fn one<'a>(t: &'a ()) -> Two<'a, 'a> { //~^ ERROR non-defining opaque type use diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index 4da69a705c0..b03bf2466e6 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -1,25 +1,25 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_lifetime_param.rs:11:26 + --> $DIR/generic_duplicate_lifetime_param.rs:7:26 | LL | fn one<'a>(t: &'a ()) -> Two<'a, 'a> { | ^^^^^^^^^^^ generic argument `'a` used twice | note: for this opaque type - --> $DIR/generic_duplicate_lifetime_param.rs:9:20 + --> $DIR/generic_duplicate_lifetime_param.rs:5:20 | -LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Two<'a, 'b> = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_lifetime_param.rs:13:5 + --> $DIR/generic_duplicate_lifetime_param.rs:9:5 | LL | t | ^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_lifetime_param.rs:9:10 + --> $DIR/generic_duplicate_lifetime_param.rs:5:10 | -LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +LL | type Two<'a, 'b> = impl std::fmt::Debug; | ^^ ^^ error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index 1e391b55a4f..e3c6f4d874b 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -14,11 +14,7 @@ fn main() {} // test that unused generic parameters are ok type TwoTys<T, U> = impl Debug; -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; +type TwoLifetimes<'a, 'b> = impl Debug; type TwoConsts<const X: usize, const Y: usize> = impl Debug; diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index d8330771d30..495308a6cac 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -1,5 +1,5 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:25:30 + --> $DIR/generic_duplicate_param_use.rs:21:30 | LL | fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> { | ^^^^^^^^^^^^ generic argument `T` used twice @@ -11,7 +11,7 @@ LL | type TwoTys<T, U> = impl Debug; | ^^^^^^^^^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:27:5 + --> $DIR/generic_duplicate_param_use.rs:23:5 | LL | t | ^ @@ -23,49 +23,49 @@ LL | type TwoTys<T, U> = impl Debug; | ^ ^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:31:36 + --> $DIR/generic_duplicate_param_use.rs:27:36 | LL | fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> { | ^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice | note: for this opaque type - --> $DIR/generic_duplicate_param_use.rs:21:29 + --> $DIR/generic_duplicate_param_use.rs:17:29 | -LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type TwoLifetimes<'a, 'b> = impl Debug; + | ^^^^^^^^^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:33:5 + --> $DIR/generic_duplicate_param_use.rs:29:5 | LL | t | ^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_param_use.rs:21:19 + --> $DIR/generic_duplicate_param_use.rs:17:19 | -LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; +LL | type TwoLifetimes<'a, 'b> = impl Debug; | ^^ ^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:37:50 + --> $DIR/generic_duplicate_param_use.rs:33:50 | LL | fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> { | ^^^^^^^^^^^^^^^ generic argument `N` used twice | note: for this opaque type - --> $DIR/generic_duplicate_param_use.rs:23:50 + --> $DIR/generic_duplicate_param_use.rs:19:50 | LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; | ^^^^^^^^^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:39:5 + --> $DIR/generic_duplicate_param_use.rs:35:5 | LL | t | ^ | note: constant used multiple times - --> $DIR/generic_duplicate_param_use.rs:23:16 + --> $DIR/generic_duplicate_param_use.rs:19:16 | LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; | ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs b/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs index 106efefbaf2..e109c38c986 100644 --- a/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs +++ b/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs @@ -1,11 +1,10 @@ -// check-pass +// build-pass (FIXME(62277): could be check-pass?) #![feature(type_alias_impl_trait)] fn main() {} -type Region<'a> = impl std::fmt::Debug + 'a; - +type Region<'a> = impl std::fmt::Debug; fn region<'b>(a: &'b ()) -> Region<'b> { a diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs index 6f9434255a8..469a493b0b3 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] mod test_lifetime_param { - type Ty<'a> = impl Sized + 'a; + type Ty<'a> = impl Sized; fn defining(a: &str) -> Ty<'_> { a } fn assert_static<'a: 'static>() {} fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() } @@ -9,7 +9,7 @@ mod test_lifetime_param { } mod test_higher_kinded_lifetime_param { - type Ty<'a> = impl Sized + 'a; + type Ty<'a> = impl Sized; fn defining(a: &str) -> Ty<'_> { a } fn assert_static<'a: 'static>() {} fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() } diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs index 4f99236f4ea..06c119287d7 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs @@ -1,16 +1,20 @@ // check-pass -#![feature(impl_trait_in_assoc_type)] +#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)] -trait Callable { - type Output; - fn call() -> Self::Output; -} +mod foo { + pub trait Callable { + type Output; + fn call() -> Self::Output; + } -impl<'a> Callable for &'a () { - type Output = impl Sized; - fn call() -> Self::Output {} + pub type OutputHelper = impl Sized; + impl<'a> Callable for &'a () { + type Output = OutputHelper; + fn call() -> Self::Output {} + } } +use foo::*; fn test<'a>() -> impl Sized { <&'a () as Callable>::call() diff --git a/tests/ui/type-alias-impl-trait/issue-89686.rs b/tests/ui/type-alias-impl-trait/issue-89686.rs index 058417bdb80..de070fc9deb 100644 --- a/tests/ui/type-alias-impl-trait/issue-89686.rs +++ b/tests/ui/type-alias-impl-trait/issue-89686.rs @@ -4,7 +4,7 @@ use std::future::Future; -type G<'a, T> = impl Future<Output = ()> + 'a; +type G<'a, T> = impl Future<Output = ()>; trait Trait { type F: Future<Output = ()>; diff --git a/tests/ui/type-alias-impl-trait/issue-89686.stderr b/tests/ui/type-alias-impl-trait/issue-89686.stderr index 3b95a575ac2..b636ada8b75 100644 --- a/tests/ui/type-alias-impl-trait/issue-89686.stderr +++ b/tests/ui/type-alias-impl-trait/issue-89686.stderr @@ -6,7 +6,7 @@ LL | async move { self.f().await } | help: consider restricting type parameter `T` | -LL | type G<'a, T: Trait> = impl Future<Output = ()> + 'a; +LL | type G<'a, T: Trait> = impl Future<Output = ()>; | +++++++ error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs index 01d1f5db132..c584a58cb32 100644 --- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs +++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs @@ -1,7 +1,8 @@ #![feature(type_alias_impl_trait)] -type Opaque<'a, T> = impl Sized; +type Opaque2<T> = impl Sized; +type Opaque<'a, T> = Opaque2<T>; fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } -//~^ ERROR: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds +//~^ ERROR: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds fn main() {} diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr index d666e668d36..6bcae6e5316 100644 --- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr +++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr @@ -1,8 +1,9 @@ -error[E0700]: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds - --> $DIR/missing_lifetime_bound.rs:4:47 +error[E0700]: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds + --> $DIR/missing_lifetime_bound.rs:5:47 | -LL | type Opaque<'a, T> = impl Sized; - | ---------- opaque type defined here +LL | type Opaque2<T> = impl Sized; + | ---------- opaque type defined here +LL | type Opaque<'a, T> = Opaque2<T>; LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } | -- ^ | | diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs index 65eb2952e0f..3f122f10609 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs @@ -1,10 +1,6 @@ #![feature(type_alias_impl_trait)] -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +type Foo<'a, 'b> = impl std::fmt::Debug; fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { (i, i) //~ ERROR concrete type differs from previous diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr index d7676b8e9b1..81e603e2355 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr @@ -1,5 +1,5 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:10:5 + --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 | LL | (i, i) | ^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs index 21fca047a3c..83fd9a1da45 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs @@ -7,11 +7,7 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) (a.clone(), a) } -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} - -type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; +type Foo<'a, 'b> = impl std::fmt::Debug; fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { (i, j) diff --git a/tests/ui/type-alias-impl-trait/self_implication.rs b/tests/ui/type-alias-impl-trait/self_implication.rs index 4e805ee308f..65659a0f3b1 100644 --- a/tests/ui/type-alias-impl-trait/self_implication.rs +++ b/tests/ui/type-alias-impl-trait/self_implication.rs @@ -22,9 +22,9 @@ fn bar() { } // desugared - type FooX<'a> = impl Sized; + type FooX = impl Sized; impl<'a> Foo<'a> { - fn foo(&self) -> FooX<'a> {} + fn foo(&self) -> FooX {} } // use site diff --git a/tests/ui/type-alias-impl-trait/variance.rs b/tests/ui/type-alias-impl-trait/variance.rs new file mode 100644 index 00000000000..eba4816003b --- /dev/null +++ b/tests/ui/type-alias-impl-trait/variance.rs @@ -0,0 +1,50 @@ +#![feature(rustc_attrs, type_alias_impl_trait, impl_trait_in_assoc_type)] +#![allow(internal_features)] +#![rustc_variance_of_opaques] + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +type NotCapturedEarly<'a> = impl Sized; //~ [o] + +type CapturedEarly<'a> = impl Sized + Captures<'a>; //~ [o] + +type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>; //~ [o] + +type CapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'b>>; //~ [o] + +type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a> + Captures<'b>>; //~ [o] + +type Bar<'a, 'b: 'b, T> = impl Sized; //~ ERROR [o, o, o] + +trait Foo<'i> { + type ImplicitCapturedEarly<'a>; + + type ExplicitCaptureEarly<'a>; + + type ImplicitCaptureLate<'a>; + + type ExplicitCaptureLate<'a>; +} + +impl<'i> Foo<'i> for &'i () { + type ImplicitCapturedEarly<'a> = impl Sized; //~ [o, o] + + type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; //~ [o, o] + + type ImplicitCaptureLate<'a> = impl Sized; //~ [o, o] + + type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; //~ [o, o] +} + +impl<'i> Foo<'i> for () { + type ImplicitCapturedEarly<'a> = impl Sized; //~ [o, o] + + type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; //~ [o, o] + + type ImplicitCaptureLate<'a> = impl Sized; //~ [o, o] + + type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; //~ [o, o] +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr new file mode 100644 index 00000000000..f73cf617a4c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/variance.stderr @@ -0,0 +1,86 @@ +error: [o] + --> $DIR/variance.rs:8:29 + | +LL | type NotCapturedEarly<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [o] + --> $DIR/variance.rs:10:26 + | +LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o] + --> $DIR/variance.rs:12:56 + | +LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>; + | ^^^^^^^^^^ + +error: [o] + --> $DIR/variance.rs:14:53 + | +LL | type CapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'b>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o] + --> $DIR/variance.rs:16:49 + | +LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a> + Captures<'b>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, o, o] + --> $DIR/variance.rs:18:27 + | +LL | type Bar<'a, 'b: 'b, T> = impl Sized; + | ^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:31:38 + | +LL | type ImplicitCapturedEarly<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:33:37 + | +LL | type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:35:36 + | +LL | type ImplicitCaptureLate<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:37:36 + | +LL | type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:41:38 + | +LL | type ImplicitCapturedEarly<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:43:37 + | +LL | type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:45:36 + | +LL | type ImplicitCaptureLate<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [o, o] + --> $DIR/variance.rs:47:36 + | +LL | type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 14 previous errors + diff --git a/tests/ui/typeck/issue-114918/const-in-fn-return-type.rs b/tests/ui/typeck/issue-114918/const-in-fn-return-type.rs new file mode 100644 index 00000000000..d939633290e --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-fn-return-type.rs @@ -0,0 +1,10 @@ +// Regression test for #114918 +// Test that a const generic enclosed in a block within a return type +// produces a type mismatch error instead of triggering a const eval cycle + +#[allow(unused_braces)] +fn func() -> [u8; { () } ] { //~ ERROR mismatched types + loop {} +} + +fn main() {} diff --git a/tests/ui/typeck/issue-114918/const-in-fn-return-type.stderr b/tests/ui/typeck/issue-114918/const-in-fn-return-type.stderr new file mode 100644 index 00000000000..88ed96e148c --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-fn-return-type.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/const-in-fn-return-type.rs:6:21 + | +LL | fn func() -> [u8; { () } ] { + | ^^ expected `usize`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs new file mode 100644 index 00000000000..a1b9a7eba4d --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs @@ -0,0 +1,20 @@ +// Regression test for #114918 +// Test that a const generic enclosed in a block within the return type +// of an impl fn produces a type mismatch error instead of triggering +// a const eval cycle + + +trait Trait { + fn func<const N: u32>() -> [ (); N ]; +} + +struct S {} + +#[allow(unused_braces)] +impl Trait for S { + fn func<const N: u32>() -> [ (); { () }] { //~ ERROR mismatched types + N + } +} + +fn main() {} diff --git a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr new file mode 100644 index 00000000000..9843651b1e6 --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/const-in-impl-fn-return-type.rs:15:40 + | +LL | fn func<const N: u32>() -> [ (); { () }] { + | ^^ expected `usize`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-114918/const-in-struct-type-arg.rs b/tests/ui/typeck/issue-114918/const-in-struct-type-arg.rs new file mode 100644 index 00000000000..9eee4ab3d4c --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-struct-type-arg.rs @@ -0,0 +1,12 @@ +// Regression test for #114918 +// Test that a const generic enclosed in a block in a struct's type arg +// produces a type mismatch error instead of triggering a const eval cycle + +#[allow(unused_braces)] +struct S<const N: usize> { + arr: [u8; N] +} + +fn main() { + let s = S::<{ () }> { arr: [5, 6, 7]}; //~ ERROR mismatched types +} diff --git a/tests/ui/typeck/issue-114918/const-in-struct-type-arg.stderr b/tests/ui/typeck/issue-114918/const-in-struct-type-arg.stderr new file mode 100644 index 00000000000..3307e76d957 --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-struct-type-arg.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/const-in-struct-type-arg.rs:11:19 + | +LL | let s = S::<{ () }> { arr: [5, 6, 7]}; + | ^^ expected `usize`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.rs b/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.rs new file mode 100644 index 00000000000..8e2eec34911 --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.rs @@ -0,0 +1,13 @@ +// Regression test for #114918 +// Test that a const generic enclosed in a block within the return type +// of a trait method produces a type mismatch error instead of triggering +// a const eval cycle + +#[allow(unused_braces)] +trait Trait { + fn func<const N: u32>() -> [ (); { () }] { //~ ERROR mismatched types + N + } +} + +fn main() {} diff --git a/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.stderr b/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.stderr new file mode 100644 index 00000000000..6bc0de77a62 --- /dev/null +++ b/tests/ui/typeck/issue-114918/const-in-trait-fn-return-type.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/const-in-trait-fn-return-type.rs:8:40 + | +LL | fn func<const N: u32>() -> [ (); { () }] { + | ^^ expected `usize`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
