about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2025-02-21Move methods from Map to TyCtxt, part 3.Nicholas Nethercote-8/+8
Continuing the work from #137162. Every method gains a `hir_` prefix.
2025-02-20Reword messageEsteban Küber-3/+3
2025-02-19Specify scope in `out_of_scope_macro_calls` lintEsteban Küber-2/+5
``` warning: cannot find macro `in_root` in the crate root --> $DIR/key-value-expansion-scope.rs:1:10 | LL | #![doc = in_root!()] | ^^^^^^^ not found in the crate root | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition = note: `#[warn(out_of_scope_macro_calls)]` on by default ```
2025-02-19Register USAGE_OF_TYPE_IR_INHERENT, remove inherent usagesMichael Goulet-0/+1
2025-02-18update `cfg(bootstrap)`Josh Stone-1/+0
2025-02-18update version placeholdersJosh Stone-1/+1
(cherry picked from commit e4840ce59bdddb19394df008c5c26d9c493725f8)
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-5/+5
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=UrgauMatthias Krüger-1/+9
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535 Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-6/+6
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-12/+10
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-16invalid_from_utf8[_unchecked]: also lint inherent methodsPavel Grigorenko-1/+9
2025-02-15Remove unnecessary check code in unused_delimsyukang-24/+0
2025-02-12Auto merge of #135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obkbors-1/+1
Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424. r? `@Noratrieb`
2025-02-12Rollup merge of #136900 - workingjubilee:format-externabi-directly, r=oli-obkGuillaume Gomez-4/+4
compiler: replace `ExternAbi::name` calls with formatters Most of these just format the ABI string, so... just format ExternAbi? This makes it more consistent and less jank when we can do it.
2025-02-11compiler: replace ExternAbi::name calls with formattersJubilee Young-4/+4
Most of these just format the ABI string, so... just format ExternAbi? This makes it more consistent and less jank when we can do it.
2025-02-11Handle pattern types wrapped in `Option` in FFI checksOli Scherer-0/+32
2025-02-11Correctly handle pattern types in FFI redeclaration lintsOli Scherer-58/+60
2025-02-11Correctly handle pattern types in FFI safetyOli Scherer-5/+3
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-1/+1
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-09Remove lifetime_capture_rules_2024 featureMichael Goulet-4/+2
2025-02-09Rollup merge of #136760 - chenyukang:fix-overflowing-int-lint-crash, r=oli-obkMatthias Krüger-4/+7
Fix unwrap error in overflowing int literal Fixes #136675 it's maybe `negative` only from [check_lit](https://github.com/chenyukang/rust/blob/526e3288feb68eac55013746e03fb54d6a0b9a1e/compiler/rustc_lint/src/types.rs#L546), in this scenario the fields in `TypeLimits` is none. r? ``@oli-obk``
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-407/+543
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-09Fix unwrap error in overflowing int literalyukang-4/+7
2025-02-08Rustfmtbjorn3-407/+543
2025-02-08Rollup merge of #136657 - jdonszelmann:empty-line-after, ↵Matthias Krüger-0/+10
r=y21,flip1995,WaffleLapkin Make empty-line-after an early clippy lint r? ```@y21``` 95% a refiling of https://github.com/rust-lang/rust-clippy/pull/13658 but for correctness it needed 2 extra methods in `rust_lint` which made it much easier to apply on `rust-lang/rust` than `rust-lang/rust-clippy`. Commits have been thoroughly reviewed on `rust-lang/clippy already`. The last two review comments there (about using `Option` and popping for assoc items have been applied here.
2025-02-07fix empty after lint on impl/trait itemsJonathan Dönszelmann-0/+10
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-02-06allow+update `deref_into_dyn_supertrait`Waffle Lapkin-13/+11
this commit makes `deref_into_dyn_supertrait` lint allow-by-default, removes future incompatibility (we finally live in a broken world), and changes the wording in the documentation. previously documentation erroneously said that it lints against *usage* of the deref impl, while it actually (since 104742) lints on the impl itself (oooops, my oversight, should have updated it 2+ years ago...)
2025-02-06change `deref_into_dyn_supertrait` lint wordingWaffle Lapkin-5/+6
(so that it doesn't talk about trait upcasting stabilization in the future tense)
2025-02-06stabilize `feature(trait_upcasting)`Waffle Lapkin-1/+1
2025-02-06Rollup merge of #136393 - oli-obk:pattern-type-lit-oflo-checks, ↵Matthias Krüger-32/+60
r=compiler-errors Fix accidentally not emitting overflowing literals lints anymore in patterns This was regressed in https://github.com/rust-lang/rust/pull/134228 (not in beta yet). The issue was that previously we nested `hir::Expr` inside `hir::PatKind::Lit`, so it was linted by the expression code. So now I've set it up for visitors to be able to directly visit literals and get all literals
2025-02-05Uniformly handle HIR literals in visitors and lintsOli Scherer-5/+24
2025-02-05Avoid passing around an `Expr` that is only needed for its HirId and its SpanOli Scherer-31/+40
2025-02-05Rollup merge of #135964 - ehuss:cenum_impl_drop_cast, r=Nadrieril许杰友 Jieyou Xu (Joe)-0/+5
Make cenum_impl_drop_cast a hard error This changes the `cenum_impl_drop_cast` lint to be a hard error. This lint has been deny-by-default and warning in dependencies since https://github.com/rust-lang/rust/pull/97652 about 2.5 years ago. Closes https://github.com/rust-lang/rust/issues/73333
2025-02-04Rollup merge of #136242 - samueltardieu:remove-match-def-path, r=flip1995Matthias Krüger-25/+1
Remove `LateContext::match_def_path()` This function was only kept for Clippy use. The last use in Clippy was removed in c9315bc3953fcf15154df21f788f2f7a5e8d6e7d.
2025-02-02Rollup merge of #136422 - nnethercote:convert-lint-functions, r=NoratriebMatthias Krüger-9/+8
Convert two `rustc_middle::lint` functions to `Span` methods. `rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints. r? ``@Noratrieb``
2025-02-02Convert two `rustc_middle::lint` functions to `Span` methods.Nicholas Nethercote-9/+8
`rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints.
2025-02-01Rename `tcx.ensure()` to `tcx.ensure_ok()`Zalathar-1/+1
2025-01-31Rollup merge of #135860 - fmease:compiler-mv-obj-save-dyn-compat-ii, r=jieyouxuMatthias Krüger-1/+1
Compiler: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #130826. Part of #130852. ~~Blocking it on #133372.~~ (merged) r? ghost
2025-01-30Auto merge of #136038 - compiler-errors:outlives, r=lcnrbors-4/+2
Simplify and consolidate the way we handle construct `OutlivesEnvironment` for lexical region resolution This is best reviewed commit-by-commit. I tried to consolidate the API for lexical region resolution *first*, then change the API when it was finally behind a single surface. r? lcnr or reassign
2025-01-29Eliminate PatKind::PathOli Scherer-8/+10
2025-01-29Remove `LateContext::match_def_path()`Samuel Tardieu-25/+1
This function was only kept for Clippy use. The last use in Clippy was removed in c9315bc3953fcf15154df21f788f2f7a5e8d6e7d.
2025-01-29Rollup merge of #136164 - celinval:chores-fnkind, r=oli-obkLeón Orell Valerian Liehr-3/+5
Refactor FnKind variant to hold &Fn Pulling the change suggested in #128045 to reduce the impact of changing `Fn` item. r? `@oli-obk`
2025-01-28Refactor FnKind variant to hold &FnCelina G. Val-3/+5
2025-01-28Make item self/non-self bound naming less whackMichael Goulet-19/+16
2025-01-28Move outlives env computation into methodsMichael Goulet-4/+2
2025-01-28Consolidate OutlivesEnv construction with resolve_regionsMichael Goulet-1/+1
2025-01-27Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxuGuillaume Gomez-6/+6
Use identifiers more in diagnostics code This should make the diagnostics code slightly more correct when rendering idents in mixed crate edition situations. Kinda a no-op, but a cleanup regardless. r? oli-obk or reassign
2025-01-27Remove redundant to_ident_string callsMichael Goulet-2/+2
2025-01-27Use identifiers in diagnostics more oftenMichael Goulet-4/+4
2025-01-26Compiler: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-1/+1