about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-03-22Move useless_anynous_reexport lint into unused_importsGuillaume Gomez-3/+0
2023-03-12Add lint for useless anonymous reexportsGuillaume Gomez-0/+3
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-02-23Add lint against `Iterator::map` receiving a callable that returns `()`Obei Sideg-1/+5
2023-02-22errors: generate typed identifiers in each crateDavid Wood-0/+4
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-31make unaligned_reference a hard errorRalf Jung-1/+10
2023-01-28Reintroduce multiple_supertrait_upcastable lintGary Guo-0/+3
2023-01-14fix issues in unused lintyukang-1/+1
2023-01-09refactor: cleanupRejyr-2/+2
2023-01-09add: `lints.rs`Rejyr-0/+3
add: `lints.rs` refactor: move `InvalidAtomicOrderingDiag` to `lints.rs`
2022-12-29Revert "Implement allow-by-default multiple_supertrait_upcastable lint"David Tolnay-3/+0
This reverts commit 5e44a65517bfcccbe6624a70b54b9f192baa94f3.
2022-12-28Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errorsfee1-dead-0/+3
Implement allow-by-default `multiple_supertrait_upcastable` lint The lint detects when an object-safe trait has multiple supertraits. Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them. r? `@nikomatsakis`
2022-12-21Update track_caller logic/lint after rebaseBryan Garza-0/+1
2022-12-12Reinstate `{Early,Late}LintPassObjects`.Nicholas Nethercote-6/+0
I removed these in #105291, and subsequently learned they are necessary for performance. This commit reinstates them with the new and more descriptive names `RuntimeCombined{Early,Late}LintPass`, similar to the existing passes like `BuiltinCombinedEarlyLintPass`. It also adds some comments, particularly emphasising how we have ways to combine passes at both compile-time and runtime. And it moves some comments around.
2022-12-09Implement allow-by-default multiple_supertrait_upcastable lintGary Guo-0/+3
2022-12-07Add some useful comments.Nicholas Nethercote-1/+8
2022-12-07Remove `$hir` argument from `late_lint_methods!`.Nicholas Nethercote-4/+2
Because it's always `'tcx`.
2022-12-02Remove six macros relating to lint definitions.Nicholas Nethercote-119/+103
These were enabled by the removal of `-Zno-interleave-lints`.
2022-12-02Remove `-Zno-interleave-lints`.Nicholas Nethercote-44/+7
Because it complicates lint implementation greatly.
2022-11-23Make `deref_into_dyn_supertrait` lint the impl and not the usageMaybe Waffle-0/+3
2022-11-07fix: lint against lint functionsRejyr-0/+1
fix: lint against the functions `LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}`, `TyCtxt::struct_lint_node`, `LintLevelsBuilder::struct_lint`.
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-1/+1
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-09fixup lint nameMaybe Waffle-3/+3
2022-10-09Start uplifting `clippy::for_loops_over_fallibles`Maybe Waffle-0/+3
I refactored the code: - Removed handling of methods, as it felt entirely unnecessary - Removed clippy utils (obviously...) - Used some shiny compiler features (let-else is very handy for lints :eyes:) - I also renamed the lint to `for_loop_over_fallibles` (note: no `s`). I'm not sure what's the naming convention here, so maybe I'm wrong.
2022-10-07make const_err a hard errorRalf Jung-0/+5
2022-10-02Make it a lint for all opaque typesMichael Goulet-3/+3
2022-10-02Lint for unsatisfied nested opaquesMichael Goulet-0/+3
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+1
2022-09-22Revert "Auto merge of #101620 - cjgillot:compute_lint_levels_by_def, r=oli-obk"Camille GILLOT-1/+0
This reverts commit 2cb9a65684dba47c52de8fa938febf97a73e70a9, reversing changes made to 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c.
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-14Move some code and add comments.Camille GILLOT-0/+1
2022-09-06Allow lint passes to be bound by `TyCtxt`Jason Newcomb-14/+29
2022-09-03Auto merge of #100574 - Urgau:check-cfg-warn-cfg, r=petrochenkovbors-0/+1
Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in https://github.com/rust-lang/rust/pull/99519. r? `@petrochenkov`
2022-09-02Add warning against unexpected --cfg with --check-cfgUrgau-0/+1
2022-09-02Rollup merge of #97739 - a2aaron:let_underscore, r=estebankGuillaume Gomez-0/+5
Uplift the `let_underscore` lints from clippy into rustc. This PR resolves #97241. This PR adds three lints from clippy--`let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use`, which are meant to capture likely-incorrect uses of `let _ = ...` bindings (in particular, doing this on a type with a non-trivial `Drop` causes the `Drop` to occur immediately, instead of at the end of the scope. For a type like `MutexGuard`, this effectively releases the lock immediately, which is almost certainly the wrong behavior) In porting the lints from clippy I had to copy over a bunch of utility functions from `clippy_util` that these lints also relied upon. Is that the right approach? Note that I've set the `must_use` and `drop` lints to Allow by default and set `lock` to Deny by default (this matches the same settings that clippy has). In talking with `@estebank` he informed me to do a Crater run (I am not sure what type of Crater run to request here--I think it's just "check only"?) On the linked issue, there's some discussion about using `must_use` and `Drop` together as a heuristic for when to warn--I did not implement this yet. r? `@estebank`
2022-09-01Rollup merge of #94467 - ibraheemdev:master, r=pnkfelixMatthias Krüger-0/+1
Add `special_module_name` lint Declaring `lib` as a module is one of the most common beginner mistakes when trying to setup a binary and library target in the same crate. `special_module_name` lints against it, as well as `mod main;` ``` warning: found module declaration for main.rs --> $DIR/special_module_name.rs:4:1 | LL | mod main; | ^^^^^^^^^ | = note: a binary crate cannot be used as library warning: found module declaration for lib.rs --> $DIR/special_module_name.rs:1:1 | LL | mod lib; | ^^^^^^^^ | = note: `#[warn(special_module_name)]` on by default = note: lib.rs is the root of this crate's library target = help: to refer to it from other targets, use the library's name as the path ``` Note that the help message is not the best in that it doesn't provide an example of an import path (`the_actual_crate_name::`), and doesn't check whether the current file is part of a library/binary target to provide more specific error messages. I'm not sure where this lint would have to be run to access that information.
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-0/+2
by module
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-23cleanup: commented lintsRejyr-2/+0
2022-08-22migrate: `UnknownTool` error to `SessionDiagnostic`Rejyr-0/+3
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-07-30Rollup merge of #99888 - nnethercote:streamline-visitors, r=cjgillotYuki Okushi-1/+1
Streamline lint checking The early (AST) and late (HIR) lint checkers have a number of functions that aren't used by rustc or clippy. Might as well remove them -- it's not like there's a canonical API here, as shown by the ad hoc use of `check_foo`/`check_foo_post` combinations. r? `@cjgillot`
2022-07-29Remove some late `check_*` functions.Nicholas Nethercote-1/+1
They're not used by rustc or clippy.
2022-07-27lint: add bad opt access internal lintDavid Wood-0/+3
Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`. Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted. A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27lint: add comment about diag lints in groupDavid Wood-0/+4
Add a brief comment explaining why the diagnostic migration lints aren't included in the `rustc::internal` diagnostic group. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-06Make AST lowering a query.Camille GILLOT-1/+1
2022-06-19Make some lints incremental.Camille GILLOT-14/+13
2022-06-10lint: add diagnostic translation migration lintsDavid Wood-0/+2
Introduce allow-by-default lints for checking whether diagnostics are written in `SessionDiagnostic`/`AddSubdiagnostic` impls and whether diagnostics are translatable. These lints can be denied for modules once they are fully migrated to impls and translation. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-05Remove `let_underscore_must_use`Aaron Kofsky-6/+1
The `let_underscore_must_use` lint was really only added because clippy included it, but it doesn't actually seem very useful.