-
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
Rustup to *rustc 1.10.0-nightly (764ef92ae 2016-05-19)* and bump to 0.0.69 #944
Conversation
Don’t know why the tests are failing 😓 |
Some are failing, because there's no way to detect that a for loop was expanded, except to check the HIR for blocks that state that they are for loop expansions. But the HirMap::parent method doesn't give the actual parent if run on anything inside the expansion, but it gives the parent of the for loop. |
ahaa, this probably occurrs because the idents in HIR don't carry information about expansions anymore, but are just names now: rust-lang/rust#33654 |
more info: rust-lang/rust#30145 (comment)
|
|
or even better, it should simply not create a local variable at all |
I know, I linked that in the PR 😄
That local variable is weird, but I can’t update rustc 😅 We might need to rewrite the lint to find that out otherwise but we can’t make it an early-lint because there seem to be no way to get a |
whoops :)
it's there due to some lifetime issues with putting values into the tail expression
Well...
that's not it either |
sure you can 😄 |
We could switch over UsedUnderscoreBinding to use a regular macro check and switch the shadow pass to ignore macros too. |
temporarily? because if permanent, we loose the checks if the name is used in a macro like |
I'm not sure if we do? |
Maybe, but the issue with the for loop won't go away, since it's not from a macro expansion, but from ast -> hir lowering, which isn't recorded. |
With |
@@ -66,7 +66,7 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, block: &Block) { | |||
let mut bindings = Vec::new(); | |||
for arg in &decl.inputs { | |||
if let PatKind::Ident(_, ident, _) = arg.pat.node { | |||
bindings.push((ident.node.unhygienic_name, ident.span)) |
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.
Why isn't unhygienize()
used in this file?
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.
I does now, but the lint still has problems.
ae4adfe
to
8ff4dcc
Compare
fn visit_ident(&mut self, _: Span, ident: Ident) { | ||
if self.name == ident.unhygienic_name { | ||
fn visit_name(&mut self, _: Span, name: Name) { | ||
if self.name == name { |
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.
One more missing unhygienize()
here.
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.
If some lints don't work due to gensyms after proper replacement of all unhygienic_name
s with unhygienize()
, they need to be moved to AST.
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.
Fair point.
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.
One more missing unhygienize() here.
Stupid me. That lint seems ok now. Thanks.
they need to be moved to AST
I would have done that but used_underscore_binding
needs to get the parent of an expression. With hir
that’s in rustc::hir::map::Map
, there does not seem to be an ast
equivalent. I’ll see if we can rewrite the lint to not use that.
3708883
to
c3dc54d
Compare
Another day, another problem: with_vec.unwrap_or(vec![]);
//~^ERROR use of `unwrap_or`
//~|HELP try this
//~|SUGGESTION with_vec.unwrap_or_else(|| vec![]); is now reported as: tests/compile-fail/methods.rs: with_vec.unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] )); This looks to be because of rust-lang/rust#33730 or rust-lang/rust#33712. Looks like |
@jseyfried @nrc Tips on what to use in place of snippet here? |
Am I right in assuming that the broken snippets are the only thing left to fix? In that case, we could temporarily patch the tests and fix this later. |
No, |
We can quick patch that to ignore variables with that name too. |
ac58fcb
to
6d24d2b
Compare
After 3 rustups the tests are finally passing \o/ |
Yep, but file follow-ups for the corners we cut. I'll poke at it later. |
This was caused by #33712, which fixed the span of expanded expressions that are the root of their expansion. These expressions used to have the span of their expansion's invocation (the Note that expanded items have always had the correct span, for example: macro_rules! m {
() => { const fn f() {} } //< This is the span of the expanded item, ...
}
m!(); //< ... not this. The most direct way to fix the fallout here is to compute what the span would have been the change: fn expansion_root_to_call_site(self: &CodeMap, mut span: Span) -> Span {
self.with_expn_info(span.expn_id, |info| info.map(|info| {
if info.callee.span == Some(span) { // Is `span` an expansion root?
span = self.expansion_root_to_call_site(info.call_site); // note the recursion
}
}));
span
} I think you could also just use With expanded spans, |
Ref rust-lang/rust#33654.
Fix #945. Fix #946.