about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-05-13 04:19:18 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-08-06 17:54:39 +0000
commitba32673215847a27d4cab381f161a43a59002ee8 (patch)
tree46f662fc4c57adff46a4ba8770c21fd875019e9e /tests
parent4868680ee9156e16a71c3bf197c19bdc59871001 (diff)
downloadrust-ba32673215847a27d4cab381f161a43a59002ee8.tar.gz
rust-ba32673215847a27d4cab381f161a43a59002ee8.zip
Add test for mixing types from two incompatible crate versions
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/crate-loading/auxiliary/dep-2-reexport.rs4
-rw-r--r--tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs7
-rw-r--r--tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs7
-rw-r--r--tests/ui/crate-loading/multiple-dep-versions.rs14
-rw-r--r--tests/ui/crate-loading/multiple-dep-versions.svg101
5 files changed, 133 insertions, 0 deletions
diff --git a/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs b/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs
new file mode 100644
index 00000000000..3a793bbbb10
--- /dev/null
+++ b/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs
@@ -0,0 +1,4 @@
+//@ edition:2021
+//@ aux-build:multiple-dep-versions-2.rs
+extern crate dependency;
+pub use dependency::do_something;
diff --git a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs b/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs
new file mode 100644
index 00000000000..b96bb6d9e64
--- /dev/null
+++ b/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs
@@ -0,0 +1,7 @@
+#![crate_name="dependency"]
+//@ edition:2021
+//@ compile-flags: -C metadata=1 -C extra-filename=-1
+pub struct Type;
+pub trait Trait {}
+impl Trait for Type {}
+pub fn do_something<X: Trait>(_: X) { }
diff --git a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs b/tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs
new file mode 100644
index 00000000000..c79157fa463
--- /dev/null
+++ b/tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs
@@ -0,0 +1,7 @@
+#![crate_name="dependency"]
+//@ edition:2021
+//@ compile-flags: -C metadata=2 -C extra-filename=-2
+pub struct Type(pub i32);
+pub trait Trait {}
+impl Trait for Type {}
+pub fn do_something<X: Trait>(_: X) {}
diff --git a/tests/ui/crate-loading/multiple-dep-versions.rs b/tests/ui/crate-loading/multiple-dep-versions.rs
new file mode 100644
index 00000000000..9e0a5dc5c5d
--- /dev/null
+++ b/tests/ui/crate-loading/multiple-dep-versions.rs
@@ -0,0 +1,14 @@
+//@ aux-build:dep-2-reexport.rs
+//@ aux-build:multiple-dep-versions-1.rs
+//@ edition:2021
+//@ compile-flags: --error-format=human --color=always --crate-type bin --extern dependency={{build-base}}/crate-loading/multiple-dep-versions/auxiliary/libdependency-1.so --extern dep_2_reexport={{build-base}}/crate-loading/multiple-dep-versions/auxiliary/libdep_2_reexport.so
+//@ ignore-windows
+
+extern crate dependency;
+extern crate dep_2_reexport;
+use dependency::Type;
+use dep_2_reexport::do_something;
+
+fn main() {
+    do_something(Type);
+}
diff --git a/tests/ui/crate-loading/multiple-dep-versions.svg b/tests/ui/crate-loading/multiple-dep-versions.svg
new file mode 100644
index 00000000000..6b89ca691e0
--- /dev/null
+++ b/tests/ui/crate-loading/multiple-dep-versions.svg
@@ -0,0 +1,101 @@
+<svg width="1054px" height="686px" xmlns="http://www.w3.org/2000/svg">
+  <style>
+    .fg { fill: #AAAAAA }
+    .bg { background: #000000 }
+    .fg-ansi256-009 { fill: #FF5555 }
+    .fg-ansi256-010 { fill: #55FF55 }
+    .fg-ansi256-012 { fill: #5555FF }
+    .fg-ansi256-014 { fill: #55FFFF }
+    .fg-magenta { fill: #AA00AA }
+    .container {
+      padding: 0 10px;
+      line-height: 18px;
+    }
+    .bold { font-weight: bold; }
+    tspan {
+      font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
+      white-space: pre;
+      line-height: 18px;
+    }
+  </style>
+
+  <rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
+
+  <text xml:space="preserve" class="container fg">
+    <tspan x="10px" y="28px"><tspan class="fg-ansi256-009 bold">error[E0277]</tspan><tspan class="bold">: the trait bound `Type: dependency::Trait` is not satisfied</tspan>
+</tspan>
+    <tspan x="10px" y="46px"><tspan>  </tspan><tspan class="fg-ansi256-012 bold">--&gt; </tspan><tspan>$DIR/multiple-dep-versions.rs:13:18</tspan>
+</tspan>
+    <tspan x="10px" y="64px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="82px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan>     do_something(Type);</tspan>
+</tspan>
+    <tspan x="10px" y="100px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan>     </tspan><tspan class="fg-ansi256-012 bold">------------</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">the trait `dependency::Trait` is not implemented for `Type`</tspan>
+</tspan>
+    <tspan x="10px" y="118px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan>     </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="136px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan>     </tspan><tspan class="fg-ansi256-012 bold">required by a bound introduced by this call</tspan>
+</tspan>
+    <tspan x="10px" y="154px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="172px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you have </tspan><tspan class="fg-magenta bold">multiple different versions</tspan><tspan> of crate `</tspan><tspan class="fg-magenta bold">dependency</tspan><tspan>` in your dependency graph</tspan>
+</tspan>
+    <tspan x="10px" y="190px"><tspan>  </tspan><tspan class="fg-ansi256-012 bold">--&gt; </tspan><tspan>$DIR/multiple-dep-versions.rs:7:1</tspan>
+</tspan>
+    <tspan x="10px" y="208px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="226px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> extern crate dependency;</tspan>
+</tspan>
+    <tspan x="10px" y="244px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-014 bold">^^^^^^^^^^^^^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-014 bold">one version of crate `dependency` is used here, as a direct dependency of the current crate</tspan>
+</tspan>
+    <tspan x="10px" y="262px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> extern crate dep_2_reexport;</tspan>
+</tspan>
+    <tspan x="10px" y="280px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-014 bold">^^^^^^^^^^^^^^^^^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-014 bold">one version of crate `dependency` is used here, as a dependency of crate `dep_2_reexport`</tspan>
+</tspan>
+    <tspan x="10px" y="298px"><tspan class="fg-ansi256-010 bold">note</tspan><tspan>: two types coming from two different versions of the same crate are different types </tspan><tspan class="fg-magenta bold">even if they look the same</tspan>
+</tspan>
+    <tspan x="10px" y="316px"><tspan>  </tspan><tspan class="fg-ansi256-012 bold">--&gt; </tspan><tspan>$DIR/auxiliary/multiple-dep-versions-1.rs:4:1</tspan>
+</tspan>
+    <tspan x="10px" y="334px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="352px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> pub struct Type;</tspan>
+</tspan>
+    <tspan x="10px" y="370px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">^^^^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">this type doesn't implement the required trait</tspan>
+</tspan>
+    <tspan x="10px" y="388px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="406px"><tspan>  </tspan><tspan class="fg-ansi256-012 bold">::: </tspan><tspan>$DIR/auxiliary/multiple-dep-versions-2.rs:4:1</tspan>
+</tspan>
+    <tspan x="10px" y="424px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="442px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> pub struct Type(pub i32);</tspan>
+</tspan>
+    <tspan x="10px" y="460px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">^^^^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">this type implements the required trait</tspan>
+</tspan>
+    <tspan x="10px" y="478px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> pub trait Trait {}</tspan>
+</tspan>
+    <tspan x="10px" y="496px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">this is the required trait</tspan>
+</tspan>
+    <tspan x="10px" y="514px"><tspan class="fg-ansi256-010 bold">note</tspan><tspan>: required by a bound in `dep_2_reexport::do_something`</tspan>
+</tspan>
+    <tspan x="10px" y="532px"><tspan>  </tspan><tspan class="fg-ansi256-012 bold">--&gt; </tspan><tspan>$DIR/auxiliary/multiple-dep-versions-2.rs:7:24</tspan>
+</tspan>
+    <tspan x="10px" y="550px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan>
+</tspan>
+    <tspan x="10px" y="568px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> pub fn do_something&lt;X: Trait&gt;(_: X) {}</tspan>
+</tspan>
+    <tspan x="10px" y="586px"><tspan>   </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan>                        </tspan><tspan class="fg-ansi256-010 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">required by this bound in `do_something`</tspan>
+</tspan>
+    <tspan x="10px" y="604px">
+</tspan>
+    <tspan x="10px" y="622px"><tspan class="fg-ansi256-009 bold">error</tspan><tspan class="bold">: aborting due to 1 previous error</tspan>
+</tspan>
+    <tspan x="10px" y="640px">
+</tspan>
+    <tspan x="10px" y="658px"><tspan class="bold">For more information about this error, try `rustc --explain E0277`.</tspan>
+</tspan>
+    <tspan x="10px" y="676px">
+</tspan>
+  </text>
+
+</svg>