about summary refs log tree commit diff
path: root/src/librustc/lint
AgeCommit message (Collapse)AuthorLines
2017-01-03Fix lint attributes on non-item nodes.comex-45/+12
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: // 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.
2017-01-03Make is_useful handle empty types properlyAndrew Cann-0/+7
2016-12-28rustc: separate bodies for static/(associated)const and embedded constants.Eduard-Mihai Burtescu-8/+5
2016-12-15Demote most backwards incompatible ambiguity errors from RFC 1560 to warnings.Jeffrey Seyfried-0/+7
2016-12-07remove useless lifetime outlives boundsOliver Schneider-96/+75
2016-12-06annotate stricter lifetimes on LateLintPass methods to allow them to forward ↵Oliver Schneider-76/+129
to a Visitor
2016-11-29revamp `Visitor` with a single method for controlling nested visitsNiko Matsakis-8/+4
2016-11-29Split nested_visit_mode function off from nested_visit_mapFlorian Diebold-4/+8
... and make the latter mandatory to implement.
2016-11-29rustc: replace body exprs by their idsFlorian Diebold-10/+15
2016-11-28rustc: rework stability to be on-demand for type-directed lookup.Eduard Burtescu-1/+8
2016-11-28rustc: desugar `use a::{b,c};` into `use a::b; use a::c;` in HIR.Eduard-Mihai Burtescu-6/+0
2016-11-22Auto merge of #37843 - nikomatsakis:issue-33685-hard-error, r=eddybbors-1/+1
make HR_LIFETIME_IN_ASSOC_TYPE deny-by-default It's time to fix issue #32330. cc #33685 cc @arielb1
2016-11-22Start warning cycle.Jeffrey Seyfried-1/+9
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-13/+7
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-1/+1
2016-11-17make HR_LIFETIME_IN_ASSOC_TYPE deny-by-defaultNiko Matsakis-1/+1
It's time to fix issue #32330. cc #33685
2016-11-16add a `nested_visit_map` methodNiko Matsakis-35/+31
This allows you to enable *all* nested visits in a future-compatible sort of way. Moreover, if you choose to override the `visit_nested` methods yourself, you can "future-proof" against omissions by overriding `nested_visit_map` to panic.
2016-11-16fallout from separating impl-items from implsNiko Matsakis-2/+7
Basically adding `visit_impl_item` in various places and so forth.
2016-11-11Auto merge of #37456 - estebank:unused-imports-verbosity, r=jonathandturnerbors-4/+7
Group unused import warnings per import list Given a file ``` rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ``` nocode warning: unused imports, #[warn(unused_imports)] on by default --> file2.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s. Fixes #16132.
2016-11-10rustc: use an Expr instead of a Block for function bodies.Eduard Burtescu-3/+3
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-6/+6
2016-11-08Group unused import warnings per path listEsteban Küber-4/+7
Given a file ```rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ```nocode warning: unused imports, #[warn(unused_imports)] on by default --> foo.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s.
2016-11-08Replace FnvHasher use with FxHasher.Nicholas Nethercote-11/+11
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-01improve early lint to use multispan from diagnosticNiko Matsakis-35/+16
2016-11-01move early lint over to multispanNiko Matsakis-21/+21
2016-11-01compare-method lintNiko Matsakis-13/+41
2016-11-01retool EarlyLint to track a DiagnosticNiko Matsakis-8/+17
2016-11-01introduce EarlyLint typeNiko Matsakis-11/+52
For now, this type just replaces a tuple, but it will eventually grow the ability to carry more structured information.
2016-10-31Changed most vec! invocations to use square bracesiirelu-5/+5
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-31Auto merge of #37191 - zackmdavis:we_heard_you_the_first_time_really, ↵bors-2/+1
r=nikomatsakis introing one-time diagnostics: only emit "lint level defined here" once This is a revised resubmission of PR #34084 (which was closed due to inactivity on account of time constraints on the author's part). --- We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. This is in the matter of #24690. --- r? @nikomatsakis
2016-10-29Auto merge of #37378 - petrochenkov:nopat, r=eddybbors-1/+8
Prohibit patterns in trait methods without bodies They are not properly type checked ```rust trait Tr { fn f(&a: u8); // <- This compiles } ``` , mostly rejected by the parser already and generally don't make much sense. This PR is kind of a missing part of https://github.com/rust-lang/rust/pull/35015. Given the [statistics from crater](https://github.com/rust-lang/rust/pull/37378#issuecomment-256154994), the effect of this PR is mostly equivalent to improving `unused_mut` lint. cc https://github.com/rust-lang/rust/issues/35078#issuecomment-255707355 https://github.com/rust-lang/rust/pull/35015 https://github.com/rust-lang/rfcs/pull/1685 https://github.com/rust-lang/rust/issues/35203 r? @eddyb
2016-10-27Auto merge of #36894 - petrochenkov:deny, r=nikomatsakisbors-7/+7
Make sufficiently old or low-impact compatibility lints deny-by-default Tracking issues are updated/created when necessary. Needs crater run before proceeding. r? @nikomatsakis
2016-10-27Make sufficiently old or low-impact compatibility lints deny-by-defaultVadim Petrochenkov-7/+7
2016-10-26deduplicate one-time diagnostics on lint ID as well as span and messageZack M. Davis-1/+1
Some lint-level attributes (like `bad-style`, or, more dramatically, `warnings`) can affect more than one lint; it seems fairer to point out the attribute once for each distinct lint affected. Also, a UI test is added. This remains in the matter of #24690.
2016-10-27Add possibility of deprecating attributesNick Cameron-1/+0
2016-10-26Prohibit patterns in trait methods without bodiesVadim Petrochenkov-1/+8
2016-10-15introing one-time diagnostics: only emit "lint level defined here" onceZack M. Davis-2/+1
We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. This is in the matter of #24690.
2016-10-05Turn compatibility lint `match_of_unit_variant_via_paren_dotdot` into a hard ↵Vadim Petrochenkov-7/+0
error
2016-09-14Auto merge of #36270 - petrochenkov:pipwarnagain, r=nikomatsakisbors-1/+1
Make `private_in_public` compatibility lint warn-by-default again More details: https://internals.rust-lang.org/t/regression-report-stable-2016-08-16-vs-beta-2016-08-26/3930/10 r? @nikomatsakis
2016-09-09Issue deprecation warnings for safe accesses to extern staticsVadim Petrochenkov-1/+8
2016-09-05Make `private_in_public` compatibility lint warn-by-default againVadim Petrochenkov-1/+1
2016-09-01turn the RFC1592 warnings into hard errorsAriel Ben-Yehuda-14/+0
The warnings have already reached stable The test rfc1592_deprecated is covered by `bad_sized` and `unsized6`. Fixes #33242 Fixes #33243
2016-08-28Rollup merge of #35917 - jseyfried:remove_attr_ext_traits, r=nrcJeffrey Seyfried-1/+1
syntax: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`
2016-08-28Rollup merge of #35850 - SergioBenitez:master, r=nrcJeffrey Seyfried-7/+5
Implement RFC#1559: allow all literals in attributes Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-27Rollup merge of #35989 - 0xmohit:pr/error-code-E0453, r=jonathandturnerJonathan Turner-2/+3
Update E0453 to new error format Fixes #35929. Part of #35233. r? @jonathandturner
2016-08-26Update E0453 to new error formatMohit Agarwal-2/+3
Fixes #35929. Part of #35233. r? @jonathandturner
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-1/+1
2016-08-25Refactor away `AttrNestedMetaItemMethods`.Jeffrey Seyfried-1/+1
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-7/+5
2016-08-25Auto merge of #34923 - eddyb:deny-fn-item-transmute, r=nikomatsakisbors-1/+1
Deny (by default) transmuting from fn item types to pointer-sized types. This sets the #19925 lint (transmute from zero-sized fn item type) to `deny` by default. Technically a `[breaking-change]`, but will not affect dependent crates because of `--cap-lints`.