summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr7
-rw-r--r--tests/run-make/crate-loading/multiple-dep-versions.stderr22
-rw-r--r--tests/run-make/diagnostics-traits-from-duplicate-crates/minibevy.rs2
-rw-r--r--tests/run-make/diagnostics-traits-from-duplicate-crates/minirapier.rs1
-rw-r--r--tests/run-make/diagnostics-traits-from-duplicate-crates/repro.rs14
-rw-r--r--tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs45
-rw-r--r--tests/run-make/llvm-location-discriminator-limit-dummy-span/main.rs3
-rw-r--r--tests/run-make/llvm-location-discriminator-limit-dummy-span/other.rs1
-rw-r--r--tests/run-make/llvm-location-discriminator-limit-dummy-span/proc.rs7
-rw-r--r--tests/run-make/llvm-location-discriminator-limit-dummy-span/rmake.rs65
10 files changed, 162 insertions, 5 deletions
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();
+}