diff options
Diffstat (limited to 'tests')
15 files changed, 257 insertions, 9 deletions
diff --git a/tests/incremental/track-deps-in-new-solver.rs b/tests/incremental/track-deps-in-new-solver.rs new file mode 100644 index 00000000000..fb013b2b24a --- /dev/null +++ b/tests/incremental/track-deps-in-new-solver.rs @@ -0,0 +1,25 @@ +//@ revisions: cfail1 cfail2 + +//@ compile-flags: -Znext-solver +//@ check-pass + +pub trait Future { + type Error; + fn poll() -> Self::Error; +} + +struct S; +impl Future for S { + type Error = Error; + fn poll() -> Self::Error { + todo!() + } +} + +#[cfg(cfail1)] +pub struct Error(()); + +#[cfg(cfail2)] +pub struct Error(); + +fn main() {} diff --git a/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr index 9c2fcabe5ba..36379429530 100644 --- a/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr +++ b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied because the trait comes from a different crate version +error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied --> foo-current.rs:13:19 | 13 | check_trait::<foo::Struct>(); @@ -23,6 +23,11 @@ note: there are multiple different versions of crate `foo` in the dependency gra | --------------- this is the found trait = note: two types coming from two different versions of the same crate are different types even if they look the same = help: you can use `cargo tree` to explore your dependency tree +note: required by a bound in `check_trait` + --> foo-current.rs:10:19 + | +10 | fn check_trait<T: Trait>() {} + | ^^^^^ required by this bound in `check_trait` error: aborting due to 1 previous error diff --git a/tests/run-make/crate-loading/multiple-dep-versions.stderr b/tests/run-make/crate-loading/multiple-dep-versions.stderr index 7f04b2dd64a..5888aad8f37 100644 --- a/tests/run-make/crate-loading/multiple-dep-versions.stderr +++ b/tests/run-make/crate-loading/multiple-dep-versions.stderr @@ -1,8 +1,10 @@ -error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied because the trait comes from a different crate version +error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied --> replaced | LL | do_something(Type); - | ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type` + | ------------ ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type` + | | + | required by a bound introduced by this call | note: there are multiple different versions of crate `dependency` in the dependency graph --> replaced @@ -27,6 +29,11 @@ LL | pub trait Trait { | --------------- this is the found trait = note: two types coming from two different versions of the same crate are different types even if they look the same = help: you can use `cargo tree` to explore your dependency tree +note: required by a bound in `do_something` + --> replaced + | +LL | pub fn do_something<X: Trait>(_: X) {} + | ^^^^^ required by this bound in `do_something` error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope --> replaced @@ -77,11 +84,13 @@ LL | use dependency::{Trait, do_something}; LL | pub trait Trait { | --------------- this is the trait that was imported -error[E0277]: the trait bound `OtherType: Trait` is not satisfied because the trait comes from a different crate version +error[E0277]: the trait bound `OtherType: Trait` is not satisfied --> replaced | LL | do_something(OtherType); - | ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType` + | ------------ ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType` + | | + | required by a bound introduced by this call | note: there are multiple different versions of crate `dependency` in the dependency graph --> replaced @@ -106,6 +115,11 @@ LL | pub struct OtherType; LL | pub trait Trait { | --------------- this is the found trait = help: you can use `cargo tree` to explore your dependency tree +note: required by a bound in `do_something` + --> replaced + | +LL | pub fn do_something<X: Trait>(_: X) {} + | ^^^^^ required by this bound in `do_something` error: aborting due to 4 previous errors diff --git a/tests/run-make/diagnostics-traits-from-duplicate-crates/minibevy.rs b/tests/run-make/diagnostics-traits-from-duplicate-crates/minibevy.rs new file mode 100644 index 00000000000..1bc8473e08e --- /dev/null +++ b/tests/run-make/diagnostics-traits-from-duplicate-crates/minibevy.rs @@ -0,0 +1,2 @@ +pub trait Resource {} +pub struct Ray2d; diff --git a/tests/run-make/diagnostics-traits-from-duplicate-crates/minirapier.rs b/tests/run-make/diagnostics-traits-from-duplicate-crates/minirapier.rs new file mode 100644 index 00000000000..2b84332aa51 --- /dev/null +++ b/tests/run-make/diagnostics-traits-from-duplicate-crates/minirapier.rs @@ -0,0 +1 @@ +pub type Ray = minibevy::Ray2d; diff --git a/tests/run-make/diagnostics-traits-from-duplicate-crates/repro.rs b/tests/run-make/diagnostics-traits-from-duplicate-crates/repro.rs new file mode 100644 index 00000000000..90a6dfc2e15 --- /dev/null +++ b/tests/run-make/diagnostics-traits-from-duplicate-crates/repro.rs @@ -0,0 +1,14 @@ +extern crate minibevy; +extern crate minirapier; + +use minibevy::Resource; +use minirapier::Ray; + +fn insert_resource<R: Resource>(_resource: R) {} + +struct Res; +impl Resource for Res {} + +fn main() { + insert_resource(Res.into()); +} diff --git a/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs b/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs new file mode 100644 index 00000000000..32c4cf33896 --- /dev/null +++ b/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs @@ -0,0 +1,45 @@ +// Non-regression test for issue #132920 where multiple versions of the same crate are present in +// the dependency graph, and an unexpected error in a dependent crate caused an ICE in the +// unsatisfied bounds diagnostics for traits present in multiple crate versions. +// +// Setup: +// - two versions of the same crate: minibevy_a and minibevy_b +// - minirapier: depends on minibevy_a +// - repro: depends on minirapier and minibevy_b + +use run_make_support::rustc; + +fn main() { + // Prepare dependencies, mimicking a check build with cargo. + rustc() + .input("minibevy.rs") + .crate_name("minibevy") + .crate_type("lib") + .emit("metadata") + .metadata("a") + .extra_filename("-a") + .run(); + rustc() + .input("minibevy.rs") + .crate_name("minibevy") + .crate_type("lib") + .emit("metadata") + .metadata("b") + .extra_filename("-b") + .run(); + rustc() + .input("minirapier.rs") + .crate_name("minirapier") + .crate_type("lib") + .emit("metadata") + .extern_("minibevy", "libminibevy-a.rmeta") + .run(); + + // Building the main crate used to ICE here when printing the `type annotations needed` error. + rustc() + .input("repro.rs") + .extern_("minibevy", "libminibevy-b.rmeta") + .extern_("minirapier", "libminirapier.rmeta") + .run_fail() + .assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug"); +} diff --git a/tests/run-make/llvm-location-discriminator-limit-dummy-span/main.rs b/tests/run-make/llvm-location-discriminator-limit-dummy-span/main.rs new file mode 100644 index 00000000000..421eb4331b3 --- /dev/null +++ b/tests/run-make/llvm-location-discriminator-limit-dummy-span/main.rs @@ -0,0 +1,3 @@ +fn main() { + other::big_function(); +} diff --git a/tests/run-make/llvm-location-discriminator-limit-dummy-span/other.rs b/tests/run-make/llvm-location-discriminator-limit-dummy-span/other.rs new file mode 100644 index 00000000000..a3ff578ebe4 --- /dev/null +++ b/tests/run-make/llvm-location-discriminator-limit-dummy-span/other.rs @@ -0,0 +1 @@ +proc::declare_big_function!(); diff --git a/tests/run-make/llvm-location-discriminator-limit-dummy-span/proc.rs b/tests/run-make/llvm-location-discriminator-limit-dummy-span/proc.rs new file mode 100644 index 00000000000..59d17a9be59 --- /dev/null +++ b/tests/run-make/llvm-location-discriminator-limit-dummy-span/proc.rs @@ -0,0 +1,7 @@ +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro] +pub fn declare_big_function(_input: TokenStream) -> TokenStream { + include_str!("./generated.rs").parse().unwrap() +} diff --git a/tests/run-make/llvm-location-discriminator-limit-dummy-span/rmake.rs b/tests/run-make/llvm-location-discriminator-limit-dummy-span/rmake.rs new file mode 100644 index 00000000000..2727effe818 --- /dev/null +++ b/tests/run-make/llvm-location-discriminator-limit-dummy-span/rmake.rs @@ -0,0 +1,65 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/135332>. +//! +//! We can't simply drop debuginfo location spans when LLVM's location discriminator value limit is +//! reached. Otherwise, with `-Z verify-llvm-ir` and fat LTO, LLVM will report a broken module for +//! +//! ```text +//! inlinable function call in a function with debug info must have a !dbg location +//! ``` + +//@ ignore-cross-compile +//@ needs-dynamic-linking +//@ only-nightly (requires unstable rustc flag) + +#![deny(warnings)] + +use run_make_support::{dynamic_lib_name, rfs, rust_lib_name, rustc}; + +// Synthesize a function that will have a large (`n`) number of functions +// MIR-inlined into it. When combined with a proc-macro, all of these inline +// callsites will have the same span, forcing rustc to use the DWARF +// discriminator to distinguish between them. LLVM's capacity to store that +// discriminator is not infinite (currently it allocates 12 bits for a +// maximum value of 4096) so if this function gets big enough rustc's error +// handling path will be exercised. +fn generate_program(n: u32) -> String { + let mut program = String::from("pub type BigType = Vec<Vec<String>>;\n\n"); + program.push_str("pub fn big_function() -> BigType {\n"); + program.push_str(" vec![\n"); + for i in 1..=n { + program.push_str(&format!("vec![\"string{}\".to_owned()],\n", i)); + } + program.push_str(" ]\n"); + program.push_str("}\n"); + program +} + +fn main() { + // The reported threshold is around 1366 (4096/3), but let's bump it to + // around 1500 to be less sensitive. + rfs::write("generated.rs", generate_program(1500)); + + rustc() + .input("proc.rs") + .crate_type("proc-macro") + .edition("2021") + .arg("-Cdebuginfo=line-tables-only") + .run(); + rustc() + .extern_("proc", dynamic_lib_name("proc")) + .input("other.rs") + .crate_type("rlib") + .edition("2021") + .opt_level("3") + .arg("-Cdebuginfo=line-tables-only") + .run(); + rustc() + .extern_("other", rust_lib_name("other")) + .input("main.rs") + .edition("2021") + .opt_level("3") + .arg("-Cdebuginfo=line-tables-only") + .arg("-Clto=fat") + .arg("-Zverify-llvm-ir") + .run(); +} diff --git a/tests/ui/coherence/occurs-check/associated-type.next.stderr b/tests/ui/coherence/occurs-check/associated-type.next.stderr index 466b991471e..25f9523f4e4 100644 --- a/tests/ui/coherence/occurs-check/associated-type.next.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.next.stderr @@ -1,7 +1,5 @@ WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:32:1 | diff --git a/tests/ui/coherence/occurs-check/associated-type.old.stderr b/tests/ui/coherence/occurs-check/associated-type.old.stderr index 1e0345f4ec0..e091ddcacb2 100644 --- a/tests/ui/coherence/occurs-check/associated-type.old.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.old.stderr @@ -1,7 +1,5 @@ WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:32:1 | diff --git a/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.rs b/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.rs new file mode 100644 index 00000000000..54854b1b8a5 --- /dev/null +++ b/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.rs @@ -0,0 +1,56 @@ +// Computing the ambiguity causes for the overlap ended up +// causing an exponential blowup when recursing into the normalization +// goals for `<Box<?t> as RecursiveSuper>::Assoc`. This test +// takes multiple minutes when doing so and less than a second +// otherwise. + +//@ compile-flags: -Znext-solver=coherence + +trait RecursiveSuper: + Super< + A0 = Self::Assoc, + A1 = Self::Assoc, + A2 = Self::Assoc, + A3 = Self::Assoc, + A4 = Self::Assoc, + A5 = Self::Assoc, + A6 = Self::Assoc, + A7 = Self::Assoc, + A8 = Self::Assoc, + A9 = Self::Assoc, + A10 = Self::Assoc, + A11 = Self::Assoc, + A12 = Self::Assoc, + A13 = Self::Assoc, + A14 = Self::Assoc, + A15 = Self::Assoc, + > +{ + type Assoc; +} + +trait Super { + type A0; + type A1; + type A2; + type A3; + type A4; + type A5; + type A6; + type A7; + type A8; + type A9; + type A10; + type A11; + type A12; + type A13; + type A14; + type A15; +} + +trait Overlap {} +impl<T: RecursiveSuper> Overlap for T {} +impl<T> Overlap for Box<T> {} +//~^ ERROR conflicting implementations of trait `Overlap` for type `Box<_>` + +fn main() {} diff --git a/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.stderr b/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.stderr new file mode 100644 index 00000000000..3731dc5b74e --- /dev/null +++ b/tests/ui/traits/next-solver/coherence/ambiguity-causes-visitor-hang.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `Overlap` for type `Box<_>` + --> $DIR/ambiguity-causes-visitor-hang.rs:53:1 + | +LL | impl<T: RecursiveSuper> Overlap for T {} + | ------------------------------------- first implementation here +LL | impl<T> Overlap for Box<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` + | + = note: downstream crates may implement trait `Super` for type `std::boxed::Box<_>` + = note: downstream crates may implement trait `RecursiveSuper` for type `std::boxed::Box<_>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. |
