about summary refs log tree commit diff
path: root/compiler/rustc_lint
AgeCommit message (Collapse)AuthorLines
2024-02-14Rollup merge of #121075 - chenyukang:yukang-fix-121070-lint-range, r=oli-obkGuillaume Gomez-4/+12
Fix false positive with if let and ranges Fixes #121070
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-13/+10
2024-02-14Use fewer delayed bugs.Nicholas Nethercote-7/+6
For some cases where it's clear that an error has already occurred, e.g.: - there's a comment stating exactly that, or - things like HIR lowering, where we are lowering an error kind The commit also tweaks some comments around delayed bug sites.
2024-02-14Fix false positive with if let and rangesyukang-4/+12
2024-02-12Introduce small cache to avoid recomputing the same value twiceUrgau-4/+13
2024-02-12Lint on reference casting to bigger underlying allocationUrgau-8/+84
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-1/+1
2024-02-11Rollup merge of #120872 - petrochenkov:opthirpar, r=cjgillotMatthias Krüger-20/+14
hir: Refactor getters for HIR parents See individual commits. I ended up removing on of the FIXMEs from https://github.com/rust-lang/rust/pull/120206 instead of addressing it.
2024-02-10Rollup merge of #120866 - Zalathar:no-min-spec, r=compiler-errorsMatthias Krüger-1/+0
Remove unnecessary `#![feature(min_specialization)]` As of #119963 and #120676, we can now rely on `newtype_index!` having `#[allow_internal_unstable(min_specialization)]`, so there are a few compiler crates that no longer need to include min-spec in their own crate features. --- Some of the expansions of `newtype_index!` still appear to require min-spec in the crate features. I think this is because `#[orderable]` causes the expansion to include an implementation of `TrustedStep`, which is flagged with `#[rustc_specialization_trait]`, and for whatever reason that isn't permitted by allow-internal-unstable. So this PR only touches the crates where that isn't the case.
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-20/+14
2024-02-10Remove unnecessary `#![feature(min_specialization)]`Zalathar-1/+0
2024-02-10Rollup merge of #120853 - blyxyas:no-collect, r=cjgillotMatthias Krüger-6/+3
Avoid a collection and iteration on empty passes Just some mini optimization I saw in the wild. This way, we avoid a `collect` and `map` on an empty `passes`. Honestly, I don't even think this is big enough of a change to make a benchmark, but I'd still like to see results. Based on [this book](https://nnethercote.github.io/perf-book/iterators.html#collect-and-extend)
2024-02-09tidyblyxyas-4/+1
2024-02-09Avoid a collection and iteration on empty passesblyxyas-6/+6
2024-02-09Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789bors-1/+1
Bump bootstrap compiler to just-built 1.77 beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-5/+4
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-08Auto merge of #120544 - BoxyUwU:enter_forall, r=lcnrbors-89/+92
Introduce `enter_forall` to supercede `instantiate_binder_with_placeholders` r? `@lcnr` Long term we'd like to experiment with decrementing the universe count after "exiting" binders so that we do not end up creating infer vars in non-root universes even when they logically reside in the root universe. The fact that we dont do this currently results in a number of issues in the new trait solver where we consider goals to be ambiguous because otherwise it would require lowering the universe of an infer var. i.e. the goal `?x.0 eq <T as Trait<?y.1>>::Assoc` where the alias is rigid would not be able to instantiate `?x` with the alias as there would be a universe error. This PR is the first-ish sort of step towards being able to implement this as eventually we would want to decrement the universe in `enter_forall`. Unfortunately its Difficult to actually implement decrementing universes nicely so this is a separate step which moves us closer to the long term goal :sparkles:
2024-02-08introduce `enter_forall`Boxy-89/+92
2024-02-08Step all bootstrap cfgs forwardMark Rousskov-1/+1
This also takes care of other bootstrap-related changes.
2024-02-08Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errorsMatthias Krüger-42/+12
Add `SubdiagnosticMessageOp` as a trait alias. It avoids a lot of repetition. r? matthewjasper
2024-02-08Add `SubdiagnosticMessageOp` as a trait alias.Nicholas Nethercote-42/+12
It avoids a lot of repetition.
2024-02-06Rollup merge of #120435 - chenyukang:yukang-fix-120427-cfg-name, ↵Matthias Krüger-10/+40
r=Urgau,Nilstrieb Suggest name value cfg when only value is used for check-cfg Fixes #120427 r? `````````````@Nilstrieb`````````````
2024-02-06Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petrochenkovMatthias Krüger-0/+5
update indirect structural match lints to match RFC and to show up for dependencies This is a large step towards implementing https://github.com/rust-lang/rfcs/pull/3535. We currently have five lints related to "the structural match situation": - nontrivial_structural_match - indirect_structural_match - pointer_structural_match - const_patterns_without_partial_eq - illegal_floating_point_literal_pattern This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by https://github.com/rust-lang/rust/pull/116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies. Fixes https://github.com/rust-lang/rust/issues/73448 by removing the affected analysis.
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-1/+2
2024-02-06Invert diagnostic lints.Nicholas Nethercote-5/+4
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-02-05get rid of nontrivial_structural_match lint and custom_eq const qualifRalf Jung-0/+5
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-0/+4
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-05Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errorsMatthias Krüger-1/+1
Remove outdated references to librustc_middle The relevant comment is now in https://github.com/rust-lang/rust/blob/791a53f380d5cf800191f25941c94ace5099876e/compiler/rustc_middle/src/tests.rs#L3-L13
2024-01-31Auto merge of #120346 - petrochenkov:ownodes, r=oli-obkbors-1/+1
hir: Refactor getters for owner nodes
2024-01-30hir: Remove `hir::Map::{owner,expect_owner}`Vadim Petrochenkov-1/+1
2024-01-30add missing potential_query_instability for keys and values in hashmapyukang-6/+9
2024-01-30limit the names_possiblilities to less than 3Yukang-1/+1
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-10/+10
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-28Suggest name value cfg when only value is used for check-cfgyukang-10/+40
2024-01-26remove illegal_floating_point_literal_pattern lintRalf Jung-0/+4
2024-01-26Rollup merge of #120360 - compiler-errors:afit-sized-lol, r=lcnrMatthias Krüger-1/+12
Don't fire `OPAQUE_HIDDEN_INFERRED_BOUND` on sized return of AFIT Conceptually, we should probably not fire `OPAQUE_HIDDEN_INFERRED_BOUND` for methods like: ``` trait Foo { async fn bar() -> Self; } ``` Even though we technically cannot prove that `Self: Sized`, which is one of the item bounds of the `Output` type in the `-> impl Future<Output = Sized>` from the async desugaring. This is somewhat justifiable along the same lines as how we allow regular methods to return `-> Self` even though `Self` isn't sized. Fixes #113538 (side-note: some days i wonder if we should just remove the `OPAQUE_HIDDEN_INFERRED_BOUND` lint... it does make me sad that we have non-well-formed types in signatures, though.)
2024-01-25Remove unused featuresclubby789-3/+0
2024-01-25Don't fire OPAQUE_HIDDEN_INFERRED_BOUND on sized return of AFITMichael Goulet-1/+12
2024-01-23tidyHTGAzureX1212.-1/+1
2024-01-23address requested changesHTGAzureX1212.-7/+12
2024-01-23add list of characters to uncommon codepoints lintHTGAzureX1212.-3/+14
2024-01-23Auto merge of #120017 - nnethercote:lint-api, r=oli-obkbors-165/+155
Fix naming in the lint API Methods for emit lints are named very inconsistently. This PR fixes that up. r? `@compiler-errors`
2024-01-22Rollup merge of #120233 - oli-obk:revert_trait_obj_upcast_stabilization, r=lcnrMatthias Krüger-3/+12
Revert stabilization of trait_upcasting feature Reverts #118133 This reverts commit 6d2b84b3ed7848fd91b8d6151d4451b3103ed816, reversing changes made to 73bc12199ea8c7651ed98b069c0dd6b0bb5fabcf. The feature has a soundness bug: * #120222 It is unclear to me whether we'll actually want to destabilize, but I thought it was still prudent to open the PR for easy destabilization once we get there.
2024-01-23Rename `struct_lint_level` as `lint_level`.Nicholas Nethercote-10/+10
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-3/+3
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `TyCtxt::struct_lint_node` as `TyCtxt::node_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `LintLevelsBuilder::emit_spanned_lint` as ↵Nicholas Nethercote-7/+7
`LintLevelsBuilder::emit_span_lint`.
2024-01-23Rename `LintLevelsBuilder::struct_lint` as `LintLevelsBuilder::opt_span_lint`.Nicholas Nethercote-2/+2
2024-01-23Rename `LintContext::emit_spanned_lint` as `LintContext::emit_span_lint`.Nicholas Nethercote-128/+112