Detect stability attributes on methods.#10990
Conversation
src/librustc/middle/ty.rs
Outdated
There was a problem hiding this comment.
Not sure if this is completely correct. I essentially copied what's done here: https://github.com/mozilla/rust/blob/master/src/librustc/middle/typeck/check/method.rs#L500-L503
There was a problem hiding this comment.
Doesn't this need to copy that logic exactly? i.e. also ignore trait methods without a self (e.g. both bar and baz in trait Foo { fn bar(n: uint) -> Self; fn baz() -> uint; }) (that's what the != sty_static is checking).
There was a problem hiding this comment.
I still don't understand why it ignores trait methods without self. Is it possible for the name to overlap still? And can't you implement a static trait method?
There was a problem hiding this comment.
Oh, I guess the name can't overlap. shrugs
There was a problem hiding this comment.
Well, I'll leave it as is. If some bug comes up, at least I'll know what it's for. :D
There was a problem hiding this comment.
This can be
trait_methods.iter()
.position(|m| m.ident.name == name)
.map(|idx| ty::trait_method(tcx, trait_did, idx).def_id)(Copying my commit comment here so it's preserved post-rebase/update.)
|
r? @huonw |
|
r? @huonw. I updated the comment to |
src/librustc/middle/lint.rs
Outdated
There was a problem hiding this comment.
Oh, this could be ty::trait_method_of_method(cx.tcx, def_id).unwrap_or(def_id).
(Copying my commit comment here so it's preserved post-rebase/update.)
|
r=me after the two option-matching style nits are fixed. (Thanks so much for this!) |
|
Very glad to see work on this! |
If it's a trait method, this checks the stability attribute of the method inside the trait definition. Otherwise, it checks the method implementation itself.
|
@brson you and me both :). I have an experiment for which this will be perfect. |
If it's a trait method, this checks the stability attribute of the method inside the trait definition. Otherwise, it checks the method implementation itself. Close #8961.
…dnet [`single_match`]: don't lint if block contains comments Fixes rust-lang#8634 It now ignores matches with a comment in the "else" arm changelog: [`single_match`]: don't lint if block contains comments
If it's a trait method, this checks the stability attribute of the
method inside the trait definition. Otherwise, it checks the method
implementation itself.
Close #8961.