-
Notifications
You must be signed in to change notification settings - Fork 13.3k
trait permitting extra members #54665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@nikomatsakis Hi, while playing around with that example I found something interesting: If I add an extern crate salsa; at the top it does error correctly: error[E0407]: method `extra` is not a member of trait `salsa::QueryContext`
--> examples/storage_varieties/implementation.rs:30:5
|
30 | / fn extra(&self) -> u32 {
31 | | 0
32 | | }
| |_____^ not a member of trait `salsa::QueryContext`
So at least this seems to be an issue with the new Rust 2018 module system? |
I think I've got a minimal repro (repro.tar.gz). Considering a Rust 2018 crate with a library and a binary:
pub trait Foo {
fn foo();
}
// Uncomment to make error work:
//extern crate repro;
pub struct Bar;
impl repro::Foo for Bar {
fn foo() {}
// This compiles!
fn extra() {}
}
fn main() {} I can also work around the bug by adding a |
@GabrielMajeri awesome, thanks! |
cc @petrochenkov — any ideas? I'm looking into the code a bit |
The immediate cause of the problem is that rust/src/librustc_resolve/lib.rs Line 2612 in 5472b07
|
We seem to enter this block of code with a successful resolution in rust/src/librustc_resolve/lib.rs Lines 2472 to 2485 in 5472b07
But something goes wrong after that. |
It seems like the problem is that |
Here is the output from some logs I added, showing the value of
|
cc @eddyb also — maybe you or @petrochenkov has some clue what's happening here based on the above output. |
I'll look at this once I'm back from vacation next week (unless it's resolved before that). |
visited for triage. Leaving on RC2 milestone, and thus, leaving at P-high. |
Fixed in #55102 |
resolve: Do not skip extern prelude during speculative resolution Fixes rust-lang#54665
I've been tinkering locally with a crate called salsa. Along the way, I noticed that my impl permits me to add extra members. e.g., I have this trait:
But in my cargo example I can use this impl:
What the heck is going on here? I couldn't easily reproduce this in a smaller example, so I saved the commit. It did reproduce cleanly after
rm -rf target
andcargo clean
, so I guess it's (probably?) not an incremental bug.To reproduce:
36e2b9cdcc01228560f9fb7ffdfadf466d21e60d
.cargo build --example storage_varieties
Marking as T-compiler and P-high. P-high because this could be a very dangerous bug in terms of backwards compat risk! But I'm hoping it's something more bizarre (e.g., not rebuilding when I think it is). I did validate though that adding other weird stuff (e.g., invalid tokens) causes compilation to fail. Assigning to myself to investigate on Monday.
The text was updated successfully, but these errors were encountered: