mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Add test for mixing types from two incompatible crate versions
This commit is contained in:
parent
4868680ee9
commit
ba32673215
4
tests/ui/crate-loading/auxiliary/dep-2-reexport.rs
Normal file
4
tests/ui/crate-loading/auxiliary/dep-2-reexport.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//@ edition:2021
|
||||
//@ aux-build:multiple-dep-versions-2.rs
|
||||
extern crate dependency;
|
||||
pub use dependency::do_something;
|
@ -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) { }
|
@ -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) {}
|
14
tests/ui/crate-loading/multiple-dep-versions.rs
Normal file
14
tests/ui/crate-loading/multiple-dep-versions.rs
Normal file
@ -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);
|
||||
}
|
101
tests/ui/crate-loading/multiple-dep-versions.svg
Normal file
101
tests/ui/crate-loading/multiple-dep-versions.svg
Normal file
@ -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">--> </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">--> </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">--> </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">--> </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<X: Trait>(_: 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>
|
After Width: | Height: | Size: 7.2 KiB |
Loading…
Reference in New Issue
Block a user