summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2021-07-21Rename force-warns to force-warnRyan Levick-1/+1
2021-07-20Auto merge of #84959 - camsteffen:lint-suggest-group, r=estebankbors-7/+7
Suggest lint groups Fixes rust-lang/rust-clippy#6986
2021-07-19Auto merge of #86970 - inquisitivecrystal:force-warn, r=davidtwcobors-19/+5
Make `--force-warns` a normal lint level option Now that `ForceWarn` is a lint level, there's no reason `--force-warns` should be treated differently from other options that set lint levels. This merges the `ForceWarn` handling in with the other lint level command line options. It also unifies all of the relevant selection logic in `compiler/rustc_lint/src/levels.rs`, rather than having some of it weirdly elsewhere. Fixes #86958, which arose from the special-cased handling of `ForceWarn` having had an error in it.
2021-07-19Auto merge of #87146 - Aaron1011:better-macro-lint, r=petrochenkovbors-4/+18
Compute a better `lint_node_id` during expansion When we need to emit a lint at a macro invocation, we currently use the `NodeId` of its parent definition (e.g. the enclosing function). This means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the macro (e.g. on an enclosing block or statement) will have no effect. This commit computes a better `lint_node_id` in `InvocationCollector`. When we visit/flat_map an AST node, we assign it a `NodeId` (earlier than we normally would), and store than `NodeId` in current `ExpansionData`. When we collect a macro invocation, the current `lint_node_id` gets cloned along with our `ExpansionData`, allowing it to be used if we need to emit a lint later on. This improves the handling of `#[allow]` / `#[deny]` for `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints. The 'legacy derive helpers' lint retains its current behavior (I've inlined the now-removed `lint_node_id` function), since there isn't an `ExpansionData` readily available.
2021-07-18feat(rustc_lint): add `dyn_drop`Michael Howell-1/+62
Based on the conversation in #86747. Explanation ----------- A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended. `Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted. To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation. ```rust trait Placeholder {} impl<T> Placeholder for T {} fn foo(_x: Box<dyn Placeholder>) {} ```
2021-07-17Make `--force-warns` a normal lint level optioninquisitivecrystal-19/+5
2021-07-17Add additional missing lint handling logicAaron Hill-2/+4
2021-07-17Add missing `visit_expr_field`Aaron Hill-2/+14
2021-07-16Make GATs no longer incompleteJack Huey-1/+1
2021-07-13Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obkbors-44/+39
Fix internal `default_hash_types` lint to use resolved path I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-20/+5
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-10Auto merge of #86968 - inquisitivecrystal:missing-docs-v2, r=oli-obkbors-0/+6
Remove `missing_docs` lint on private 2.0 macros https://github.com/rust-lang/rust/blob/798baebde1fe77e5a660490ec64e727a5d79970d/compiler/rustc_lint/src/builtin.rs#L573-L584 This code is the source of #57569. The problem is subtle, so let me point it out. This code makes the mistake of assuming that all of the macros in `krate.exported_macros` are exported. ...Yeah. For some historical reason, all `macro` macros are marked as exported, regardless of whether they actually are, which is dreadfully confusing. It would be more accurate to say that `exported_macros` currently contains only macros that have paths. This PR renames `exported_macros` to `importable_macros`, since these macros can be imported with `use` while others cannot. It also fixes the code above to no longer lint on private `macro` macros, since the `missing_docs` lint should only appear on exported items. Fixes #57569.
2021-07-09Fix default_hash_types to use resolved pathCameron Steffen-44/+39
2021-07-08Improve handing of `missing_docs` for macrosinquisitivecrystal-2/+3
2021-07-08Remove `missing_docs` lint on private 2.0 macrosinquisitivecrystal-0/+5
2021-07-08Update to last upstream versionGuillaume Gomez-4/+6
2021-07-08Rollup merge of #86639 - eholk:lint-tool, r=petrochenkovYuki Okushi-34/+101
Support lint tool names in rustc command line options When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue. Note that we discovered this issue while discussing https://github.com/rust-lang/cargo/issues/5034. Fixes #86628.
2021-07-07Cleanup: unify lint name checkingEric Holk-21/+14
This change merges `check_lint_and_tool_name` into `check_lint_name` in order to avoid having two very similar functions. Also adds the `.stderr` file back for the test case, since apparently it is still needed.
2021-07-06Unify lint tool and lint name checkingEric Holk-36/+69
This shares a little more code between checking command line and attribute lint specifications.
2021-07-06Parse tool name for command line lint optionsEric Holk-3/+44
2021-07-06Add s to non_fmt_panicRyan Levick-6/+7
2021-07-06Change or_patterns_back_compat lint to rust_2021_incompatible_or_patternsRyan Levick-0/+1
2021-07-06Rename lintRyan Levick-0/+1
2021-07-06Auto merge of #82985 - cjgillot:lint, r=jackh726bors-8/+8
Cleanup the computation of lint levels This now uses an `IndexVec` and a special root `LintStackIndex = 0` to encode command-line levels.
2021-07-03Warn when `rustdoc::` group is omitted from lint namesJoshua Nelson-16/+0
2021-07-03Add a help message to `unused_doc_comments` lintYuki Okushi-2/+13
2021-07-01Rollup merge of #85520 - FabianWolff:issue-85475, r=jackh726Yuki Okushi-1/+1
Fix typo and improve documentation for E0632 Edit: After https://github.com/rust-lang/rust/pull/85520#issuecomment-870095546, this PR has been boiled down to just an extended description for `E0632` and a fixed typo.
2021-06-30Auto merge of #86689 - rylev:future-compat-lint-group, r=nikomatsakisbors-10/+13
Only include lint in future_incompatible lint group if not an edition lint A follow up to #86330 - this only includes lints annotated with `FutureIncompatibleInfo` in the `future_incompatibile` lint group if the future compatibility is not tied to an edition. We probably want to rename `FutureIncompatibleInfo` to something else since this type is now used to indicate future breakages of all kinds (even those that happen in editions). I'd prefer to do that in a separate PR though. r? `@nikomatsakis`
2021-06-29Encode CommandLine in the index only.Camille GILLOT-2/+2
2021-06-29Use a newtype_index instead of a u32.Camille GILLOT-8/+8
2021-06-29Auto merge of #86009 - cjgillot:fwarn, r=davidtwcobors-39/+30
Make ForceWarn a lint level. Follow-up to #85788 cc `@rylev`
2021-06-29Auto merge of #86446 - Smittyvb:rustc_insignificant_dtor-ice, r=Mark-Simulacrumbors-1/+1
Don't make `rustc_insignificant_dtor` feature gate This isn't a feature gate, it's an attribute that is feature gated behind the `rustc_attrs` attribute. Closes #85680.
2021-06-29Rollup merge of #86671 - m-ou-se:non-fmt-panic-future-incompatible, ↵Yuki Okushi-1/+8
r=nikomatsakis Turn non_fmt_panic into a future_incompatible edition lint. This turns the `non_fmt_panic` lint into a future_incompatible edition lint, so it becomes part of the `rust_2021_compatibility` group. See https://github.com/rust-lang/rust/issues/85894. This lint produces both warnings about semantical changes (e.g. `panic!("{{")`) and things that will become hard errors (e.g. `panic!("{")`). So I added a `explain_reason: false` that supresses the default "this will become a hard error" or "the semantics will change" message, and instead added a note depending on the situation. (cc `@rylev)` r? `@nikomatsakis`
2021-06-29Fix typo and improve documentation for E0632Fabian Wolff-1/+1
2021-06-28Make incomplete features part of delcarationSmitty-1/+1
This prevents mistakes where the feature is in the list of incomplete features but not actually a feature by making the incompleteness a part of the declaration.
2021-06-28Add comment for future_incompatible lint groupRyan Levick-0/+3
2021-06-28Only include lint in future_incompatible lint group if not an edition lintRyan Levick-10/+10
2021-06-27Auto merge of #85359 - lrh2000:reserved-prefixes, r=nikomatsakisbors-0/+9
Reserve prefixed identifiers and literals (RFC 3101) This PR denies any identifiers immediately followed by one of three tokens `"`, `'` or `#`, which is stricter than the requirements of RFC 3101 but may be necessary according to the discussion at [Zulip]. [Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/268952-edition-2021/topic/reserved.20prefixes/near/238470099 The tracking issue #84599 says we'll add a feature gate named `reserved_prefixes`, but I don't think I can do this because it is impossible for the lexer to know whether a feature is enabled or not. I guess determining the behavior by the edition information should be enough. Fixes #84599
2021-06-27Turn non_fmt_panic into a future_incompatible edition lint.Mara Bos-1/+8
2021-06-26Add migration lint for reserved prefixes.Mara Bos-0/+9
2021-06-26Better suggestion for array_into_iter in for loop.Mara Bos-18/+45
2021-06-26Add new suggestion to array_into_iter lint.Mara Bos-0/+8
2021-06-26Change wording on array_into_iter lint for 1.53 and edition changes.Mara Bos-17/+11
2021-06-26Make ForceWarn a lint level.Camille GILLOT-39/+30
2021-06-25Address PR feedbackRyan Levick-1/+0
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-10/+10
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-0/+1
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-2/+2
position.
2021-06-08Rollup merge of #85906 - LingMan:iter_find, r=matthewjasperYuki Okushi-8/+3
Use `Iterator::find` instead of open-coding it ```@rustbot``` modify labels +C-cleanup +T-compiler
2021-06-07Rollup merge of #85912 - LingMan:iter_any, r=nagisaGuillaume Gomez-9/+4
Use `Iterator::any` and `filter_map` instead of open-coding them ``@rustbot`` modify labels +C-cleanup +T-compiler