-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add error message for anonymous impl for types not declared in the current module #17321
Conversation
What's the error for something like this? mod Foo {}
impl Foo {} |
It's still
|
I'm a little wary about closing all those issues without seeing tests for them as well. Do any of these error messages improve? pub mod a {
pub struct Foo { a: uint }
}
pub mod b {
use a::Foo;
impl Foo { // ERROR: found value name used as type
fn bar(&self) { }
}
}
pub fn main() { }
impl B {
}
fn main() {
}
pub struct Foo;
mod bar {
use Foo;
impl Foo {
fn baz(&self) {}
}
}
fn main() {}
|
The error from the comments on #7607 you posted changes to "import :/ this is embarrasing: #12729 does not change at all. (An error posted in the comments for that one is fixed, which I think is how it got swept up; but that error was actually a dupe of #7607 I think.) #8767 and #15060 both trigger the improved error message. I'll add compile-fail tests for these. |
It's ok to do them as part of this PR as well |
6d8e3cd
to
1103a9e
Compare
Sorry for the delay, I was out of town. I've updated to fix the remaining error messages, and added compile-fail tests for all of them. |
|
||
pub mod b { | ||
use a::Foo; //~ERROR inherent implementations are only allowed on types | ||
// defined in the current module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the compiletest
runner you can't break up the error message on multiple lines. If the line runs long you can tag the test with `// ignore-tidy-linelength.
Also, how come this error message is on the import rather than the impl itself? would it be possible to be on the impl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the import error is hit first "import conflicts with existing symbol", which I override by checking that the conflict is actually with an impl
. I think if I just suppress the error in this case, it should give the correct error later on when it tries to resolve the impl
and sees there is no struct. But then if there is a struct, so the impl "succeeds" I'm not sure what would happen.
As for broken lines, thanks, I'll fix all of those.
Edit: Oh, obviously I can just switch the spans for the error and the note to put the error on the impl
. Will do this.
1103a9e
to
c2c5618
Compare
New push: puts error messages all on one line in compile-fail tests, also moves errors on |
…he current module Followup to RFC 57. Fixes rust-lang#7607 Fixes rust-lang#8767 Fixes rust-lang#12729 Fixes rust-lang#15060
c2c5618
to
bb58079
Compare
Oops, missed one two-line compile-fail error message, sorry! |
Followup to RFC 57.
Fixes #7607
Fixes #8767
Fixes #12729
Fixes #15060