about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-16 05:17:39 +0000
committerbors <bors@rust-lang.org>2017-01-16 05:17:39 +0000
commit3dcb28842048ad51394f05473d1f9fb9ed8d143a (patch)
treed99002015cd60aa02249d48beb67bcc4d64c74ca /src/rustllvm/RustWrapper.cpp
parentff591b6dc0e0a107c778d0bb4cf103881527e1a5 (diff)
parent9cfb8b730a473814c2ae090c342abb95e53502db (diff)
downloadrust-3dcb28842048ad51394f05473d1f9fb9ed8d143a.tar.gz
rust-3dcb28842048ad51394f05473d1f9fb9ed8d143a.zip
Auto merge of #38806 - comex:lint-attr-fix, r=nrc
Fix lint attributes on non-item nodes.

Currently, late lint checking uses two HIR visitors: LateContext and
IdVisitor.  IdVisitor only overrides visit_id, and for each node searches
for builtin lints previously added to the session; LateContext overrides
a number of methods, and runs late lints.  When LateContext encounters an
item, it first has IdVisitor walk everything in it except nested items
(OnlyBodies), then recurses into it itself - i.e. there are two separate
walks.

Aside from apparently being unnecessary, this separation prevents lint
attributes (allow/deny/warn) on non-item HIR nodes from working
properly.  Test case:

```rust
// generates warning without this change
fn main() { #[allow(unreachable_code)] loop { break; break; } }
```

LateContext contains logic to merge attributes seen into the current lint
settings while walking (with_lint_attrs), but IdVisitor does not.  So
such attributes will affect late lints (because they are called from
LateContext), and if the node contains any items within it, they will
affect builtin lints within those items (because that IdVisitor is run
while LateContext is within the attributed node), but otherwise the
attributes will be ignored for builtin lints.

This change simply removes IdVisitor and moves its visit_id into
LateContext itself.  Hopefully this doesn't break anything...

Also added walk calls to visit_lifetime and visit_lifetime_def
respectively, so visit_lifetime_def will recurse into the lifetime and
visit_lifetime will recurse into the name.  In principle this could
confuse lint plugins.  This is "necessary" because walk_lifetime calls
visit_id on the lifetime; of course, an alternative would be directly
calling visit_id (which would require manually iterating over the
lifetimes in visit_lifetime_def), but that seems less clean.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions