-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Account for trait alias when looking for defid #4430
Conversation
cec16d6
to
89b888d
Compare
Do you think it would be a lot of work to extract a minimal test case? It would be nice to have a test for this |
Do clippy have a way to log the file it is processing? I think this would help extract a testcase. |
Just apply the changes locally and test with your local copy.
|
89b888d
to
dac2509
Compare
Thanks @mikerite. I cannot manage to find a testcase for this but binary |
I can confirm that the bug is where we look up the -- Edit: Realized my fix was the same as this pull request. |
EDIT: rust-lang/rust#29639 // ignore-windows
// ignore-macos
#![feature(no_core, lang_items, start)]
#![no_core]
#[link(name = "c")]
extern {}
#[lang = "sized"]
pub trait Sized {}
#[lang = "copy"]
pub trait Copy {}
#[lang = "freeze"]
pub unsafe trait Freeze {}
#[lang = "start"]
#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
0
} This compiles and does not have |
The example code, that I posted, already passes the test, without your change. You have to adapt this code, so that it matches rust-clippy/clippy_lints/src/methods/mod.rs Lines 1074 to 1086 in b8e5e6f
rust-clippy/clippy_lints/src/methods/mod.rs Lines 1103 to 1107 in b8e5e6f
Where the last line in the second snippet should fail at the IIUC This should just be an |
2c6fd72
to
475a142
Compare
I added it myself. Thanks for your fix! @bors r+ |
📌 Commit 475a142 has been approved by |
Account for trait alias when looking for defid I hit the crash on the `expect` call when running clippy on rustc libcore. Hopefully this will fix it. changelog: none
LL | pub fn as_ref(self) -> &'static str { | ||
| ^^^^ | ||
| | ||
= note: `-D clippy::wrong-self-convention` implied by `-D warnings` |
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.
Fun fact: If you add the &
to self
in a no_core
crate, rustc complains that
error[E0658]: `&A` cannot be used as the type of `self` without the `arbitrary_self_types` feature
--> tests/ui/def_id_nocore.rs:26:19
|
26 | pub fn as_ref(&self) -> &'static str {
| ^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44874
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
I don't think, that we need to adapt the warning though 😄
💔 Test failed - status-appveyor |
475a142
to
c222e7e
Compare
@bors r+ |
📌 Commit c222e7e has been approved by |
Account for trait alias when looking for defid I hit the crash on the `expect` call when running clippy on rustc libcore. Hopefully this will fix it. changelog: none
☀️ Test successful - checks-travis, status-appveyor |
I hit the crash on the
expect
call when running clippy on rustc libcore.Hopefully this will fix it.
changelog: none