about summary refs log tree commit diff
path: root/compiler/rustc_lint
AgeCommit message (Collapse)AuthorLines
2022-12-22Fix `explicit_outlives_requirements` lint in macrosLukas Markeffsky-20/+30
Show the suggestion if and only if the bounds are from the same source context.
2022-12-22Rollup merge of #104741 - bryangarza:bug-104588-async-track-caller, ↵Matthias Krüger-1/+72
r=compiler-errors Switch `#[track_caller]` back to a no-op unless feature gate is enabled This patch fixes a regression, in which `#[track_caller]`, which was previously a no-op, was changed to actually turn on the behavior. This should instead only happen behind the `closure_track_caller` feature gate. Also, add a warning for the user to understand how their code will compile depending on the feature gate being turned on or not. Fixes #104588
2022-12-22Rollup merge of #106008 - uweigand:s390x-lintgroup-order, r=NilstriebYuki Okushi-1/+10
Sort lint_groups in no_lint_suggestion The no_lint_suggestion routine passes a vector of lint group names to find_best_match_for_name. That routine depends on the sort order of its input vector, which matters in case multiple inputs are at the same Levenshtein distance to the target name. However, no_lint_suggestion currently just passes lint_groups.keys() as input vector - this is sorted in hash value order, which is not guaranteed to be stable, and in fact differs between big- and little-endian host platforms, causing test failures on s390x. To fix this, always sort the lint groups before using their names as input to find_best_match_for_name. In doing so, prefer non- deprecated lint group names over deprecated ones, and then use alphabetical order. Fixes https://github.com/rust-lang/rust/issues/105379
2022-12-21Sort lint_groups in no_lint_suggestionUlrich Weigand-1/+10
The no_lint_suggestion routine passes a vector of lint group names to find_best_match_for_name. That routine depends on the sort order of its input vector, which matters in case multiple inputs are at the same Levenshtein distance to the target name. However, no_lint_suggestion currently just passes lint_groups.keys() as input vector - this is sorted in hash value order, which is not guaranteed to be stable, and in fact differs between big- and little-endian host platforms, causing test failures on s390x. To fix this, always sort the lint groups before using their names as input to find_best_match_for_name. In addition, deprecated lint groups should never be suggested, so filter those out. Fixes https://github.com/rust-lang/rust/issues/105379
2022-12-21Improve code based on feedback.Bryan Garza-16/+10
This patch improves the readability of some of the code by using if-let-chains. Also, make use of the `add_feature_diagnostics` function.
2022-12-21Add lint doc commentBryan Garza-1/+20
2022-12-21Update track_caller logic/lint after rebaseBryan Garza-4/+13
2022-12-21update wording of lintBryan Garza-1/+1
2022-12-21Update code based on PR commentsBryan Garza-3/+9
This patch does the following: - Refactor some repeated lines into a single one - Split the `ungated_async_fn_caller` lint into multiple lines, and make one of those lines only print out on nightly - Use test revisions instead of copying an existing test
2022-12-21Switch `#[track_caller]` back to a no-op unless feature gate is enabledBryan Garza-1/+44
This patch fixes a regression, in which `#[track_caller]`, which was previously a no-op, was changed to actually turn on the behavior. This should instead only happen behind the `closure_track_caller` feature gate. Also, add a warning for the user to understand how their code will compile depending on the feature gate being turned on or not. Fixes #104588
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-20Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obkbors-2/+2
Improve syntax of `newtype_index` This makes it more like proper Rust and also makes the implementation a lot simpler. Mostly just turns weird flags in the body into proper attributes. It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-19Fix stack overflow in recursive AST walk in early lintUlrich Weigand-1/+2
The src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs test case added to verify https://github.com/rust-lang/rust/issues/74564 still crashes with a stack overflow on s390x-ibm-linux. Symptom is a very deep recursion in compiler/rustc_lint/src/early.rs: fn visit_expr(&mut self, e: &'a ast::Expr) { self.with_lint_attrs(e.id, &e.attrs, |cx| { lint_callback!(cx, check_expr, e); ast_visit::walk_expr(cx, e); }) } (where walk_expr recursively calls back into visit_expr). The crash happens at a nesting depth of over 17000 stack frames when using the default 8 MB stack size on s390x. This patch fixes the problem by adding a ensure_sufficient_stack call to the with_lint_attrs routine (which also should take care of all the other mutually recursive visitors here). Fixes part of https://github.com/rust-lang/rust/issues/105383.
2022-12-18Rollup merge of #105873 - matthiaskrgr:clippy_fmt, r=NilstriebMatthias Krüger-3/+3
use &str / String literals instead of format!()
2022-12-18Rollup merge of #105869 - matthiaskrgr:clone_on_copy, r=compiler-errorsMatthias Krüger-2/+2
don't clone Copy types
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-1/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[custom_encodable]` an attribute for `newtype_index`Nilstrieb-1/+1
Makes the syntax a little more rusty.
2022-12-18don't restuct references just to reborrowMatthias Krüger-6/+6
2022-12-18use &str / String literals instead of format!()Matthias Krüger-3/+3
2022-12-18don't clone Copy typesMatthias Krüger-2/+2
2022-12-17Rollup merge of #105768 - fee1-dead-contrib:iat-style, r=eholkMatthias Krüger-1/+11
Detect inherent associated types not having CamelCase Fixes #105341.
2022-12-16Detect inherent associated types not having CamelCaseDeadbeef-1/+11
Fixes #105341.
2022-12-14Ensure no one constructs `AliasTy`s themselvesOli Scherer-3/+3
2022-12-14Remove many more cases of `mk_substs_trait` that can now use the iterator ↵Oli Scherer-1/+1
scheme`
2022-12-13Combine projection and opaque into aliasMichael Goulet-9/+11
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-3/+3
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-2/+2
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-3/+3
2022-12-12Speed up the "builtin lints only" case.Nicholas Nethercote-7/+51
This commit partly undoes #104863, which combined the builtin lints pass with other lints. This caused a slowdown, because often there are no other lints, and it's faster to do a pass with a single lint directly than it is to do a combined pass with a `passes` vector containing a single lint.
2022-12-12Reinstate `{Early,Late}LintPassObjects`.Nicholas Nethercote-40/+106
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-12Rename `run_early_passes` as `lint_callback`.Nicholas Nethercote-28/+28
This matches the name used in `late.rs`.
2022-12-11Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-deadMatthias Krüger-2/+1
compiler: remove unnecessary imports and qualified paths Some of these imports were necessary before Edition 2021, others were already in the prelude. I hope it's fine that this PR is so spread-out across files :/
2022-12-10Auto merge of #105416 - nnethercote:more-linting-tweaks, r=cjgillotbors-58/+80
More linting tweaks Squeeze a little more blood from this stone. r? `@cjgillot`
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-2/+1
2022-12-10Rollup merge of #105505 - WaffleLapkin:yeet_unused_parens_lint, r=fee1-deadMatthias Krüger-1/+4
Don't warn about unused parens when they are used by yeet expr Don't even get me started on how I've found this.
2022-12-09Account for macros in const genericsEsteban Küber-0/+1
2022-12-09Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiserMatthias Krüger-1/+31
Make `missing_copy_implementations` more cautious - Fixes https://github.com/rust-lang/rust/issues/98348 - Also makes the lint not fire on large types and types containing raw pointers. Thoughts?
2022-12-09Don't warn about unused parens when they are used by yeet exprMaybe Waffle-1/+4
2022-12-09Implement allow-by-default multiple_supertrait_upcastable lintGary Guo-0/+66
2022-12-07Rollup merge of #105267 - compiler-errors:issue-104613, r=oli-obkMatthias Krüger-1/+1
Don't ICE in ExprUseVisitor on FRU for non-existent struct Fixes #104613 Fixes #105202
2022-12-07Split `EarlyContextAndPasses::check_id` in two.Nicholas Nethercote-2/+9
2022-12-07Inline some hot lint pass functions.Nicholas Nethercote-0/+6
These each have a single call site, due to being called from a "combined" lint pass.
2022-12-07Rename `$passes` as `$pass` in several macros.Nicholas Nethercote-14/+14
Because it makes more sense that way.
2022-12-07Add some useful comments.Nicholas Nethercote-1/+12
2022-12-07Remove `$hir` argument from `late_lint_methods!`.Nicholas Nethercote-42/+40
Because it's always `'tcx`.
2022-12-07Auto merge of #105291 - nnethercote:remove-LintPassObjects, r=cjgillotbors-100/+51
Remove `{Early,Late}LintPassObjects`. `EarlyContextAndPass` wraps a single early lint pass. We aggregate multiple passes into that single pass by using `EarlyLintPassObjects`. This commit removes `EarlyLintPassObjects` by changing `EarlyContextAndPass` into `EarlyContextAndPasses`. I.e. it just removes a level of indirection. This makes the code simpler and slightly faster. The commit does likewise for late lints. r? `@cjgillot`
2022-12-06Rollup merge of #105004 - TaKO8Ki:fix-104897, r=wesleywiserMatthias Krüger-5/+26
Fix `emit_unused_delims_expr` ICE Fixes #104897 This is also related to #104433.
2022-12-06Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiserMatthias Krüger-1/+1
Put all cached values into a central struct instead of just the stable hash cc `@nnethercote` this allows re-use of the type for Predicate without duplicating all the logic for the non-hash cached fields
2022-12-05Remove `{Early,Late}LintPassObjects`.Nicholas Nethercote-100/+51
`EarlyContextAndPass` wraps a single early lint pass. We aggregate multiple passes into that single pass by using `EarlyLintPassObjects`. This commit removes `EarlyLintPassObjects` by changing `EarlyContextAndPass` into `EarlyContextAndPasses`. I.e. it just removes a level of indirection. This makes the code simpler and slightly faster. The commit does likewise for late lints.
2022-12-04drive-by: move field_index to typeck resultsMichael Goulet-1/+1