forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#130275 - compiler-errors:extern-crate, r=lcnr
Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error rust-lang#124944 implemented logic to point out when a trait bound failure involves a *trait* and *type* who come from identically named but different crates. This logic calls the `extern_crate` query which is not valid on `LOCAL_CRATE` cnum, so let's filter that out eagerly. Fixes rust-lang#130272 Fixes rust-lang#129184
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/ui/typeck/auxiliary/foreign_struct_trait_unimplemented.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub struct B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ aux-build:foreign_struct_trait_unimplemented.rs | ||
|
||
extern crate foreign_struct_trait_unimplemented; | ||
|
||
pub trait Test {} | ||
|
||
struct A; | ||
impl Test for A {} | ||
|
||
fn needs_test(_: impl Test) {} | ||
|
||
fn main() { | ||
needs_test(foreign_struct_trait_unimplemented::B); | ||
//~^ ERROR the trait bound `B: Test` is not satisfied | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0277]: the trait bound `B: Test` is not satisfied | ||
--> $DIR/foreign_struct_trait_unimplemented.rs:13:16 | ||
| | ||
LL | needs_test(foreign_struct_trait_unimplemented::B); | ||
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Test` is not implemented for `B` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
help: there are multiple different versions of crate `foreign_struct_trait_unimplemented` in the dependency graph | ||
--> $DIR/foreign_struct_trait_unimplemented.rs:3:1 | ||
| | ||
LL | extern crate foreign_struct_trait_unimplemented; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one version of crate `foreign_struct_trait_unimplemented` is used here, as a direct dependency of the current crate | ||
= help: you can use `cargo tree` to explore your dependency tree | ||
note: required by a bound in `needs_test` | ||
--> $DIR/foreign_struct_trait_unimplemented.rs:10:23 | ||
| | ||
LL | fn needs_test(_: impl Test) {} | ||
| ^^^^ required by this bound in `needs_test` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |