about summary refs log tree commit diff
path: root/compiler/rustc_lint
AgeCommit message (Collapse)AuthorLines
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-1/+1
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-18/+20
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-23Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-seMatthias Krüger-1/+1
panic_str only exists for the migration to 2021 panic macros The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.) The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist. I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
2024-04-23Auto merge of #124277 - matthiaskrgr:rollup-zdb93i4, r=matthiaskrgrbors-31/+75
Rollup of 7 pull requests Successful merges: - #123680 (Deny gen keyword in `edition_2024_compat` lints) - #124057 (Fix ICE when ADT tail has type error) - #124168 (Use `DefiningOpaqueTypes::Yes` in rustdoc, where the `InferCtxt` is guaranteed to have no opaque types it can define) - #124197 (Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml`) - #124200 (Improve handling of expr->field errors) - #124220 (Miri: detect wrong vtables in wide pointers) - #124266 (remove an unused type from the reentrant lock tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-23Rollup merge of #123680 - compiler-errors:gen-kw, r=NadrierilMatthias Krüger-31/+75
Deny gen keyword in `edition_2024_compat` lints Splits the `keyword_idents` lint into two -- `keyword_idents_2018` and `keyword_idents_2024` -- since each corresponds to a future-compat warning in a different edition. Group these together into a new `keyword_idents` lint group, and add the latter to the `rust_2024_compatibility` so that `gen` is ready for the 2024 edition. cc `@traviscross` `@ehuss`
2024-04-23Auto merge of #123992 - compiler-errors:no-has-typeck-results, r=jackh726bors-1/+1
`has_typeck_results` doesnt need to be a query self-explanatory
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-22Deny gen keyword in edition_2024_compat lintsMichael Goulet-31/+75
2024-04-21Auto merge of #123594 - Urgau:fix-non_local_def-lint-overflow, r=lcnrbors-1/+13
Fix trait solver overflow with `non_local_definitions` lint This PR fixes the trait solver overflow with the `non_local_definitions` lint reported in https://github.com/rust-lang/rust/issues/123573 using the suggestion from `@lcnr:` https://github.com/rust-lang/rust/issues/123573#issuecomment-2041348320 to use the next trait solver. ~~I have not (yet) tried to create a minimized repro~~ ``@compiler-errors`` did the minimization (thanks you) but I have manually tested on the `starlark-rust` project that it fixes the issue. Fixes #123573 r? `@lcnr`
2024-04-21Move "elided lifetime in path" to subdiagnostic structXiretza-8/+10
This requires nested subdiagnostics.
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-10/+10
2024-04-17has_typeck_results doesnt need to be a queryMichael Goulet-1/+1
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-2/+2
2024-04-17Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errorsMatthias Krüger-4/+5
Qualifier tweaking Adding and removing qualifiers in some cases that make things nicer. Details in individual commits. r? `@compiler-errors`
2024-04-16Rollup merge of #123501 - Urgau:stabilize-check-cfg, r=petrochenkovMatthias Krüger-2/+2
Stabilize checking of cfgs at compile-time: `--check-cfg` option This PR stabilize the `--check-cfg` CLI option of `rustc` (and `rustdoc`) :tada:. In particular this PR does two things: 1. it makes the `--check-cfg` option stable 2. and it moves the documentation to the stable books FCP: https://github.com/rust-lang/rust/issues/82450#issuecomment-1965328542 Resolves #82450 ``@rustbot`` labels +S-blocked +F-check-cfg r? ``@petrochenkov``
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-1/+1
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-4/+5
Because they're a bit redundant.
2024-04-15nitsMichael Goulet-8/+4
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-1/+1
2024-04-15Move --check-cfg documentation to stable booksUrgau-2/+2
2024-04-11Rollup merge of #123314 - surechen:fix_120642, r=NadrierilLeón Orell Valerian Liehr-9/+15
Skip `unused_parens` report for `Paren(Path(..))` in macro. fixes #120642 In following code, `unused_parens` suggest change `<($($rest),*)>::bar()` to `<$rest>::bar()` which will cause another err: `error: variable 'rest' is still repeating at this depth`: ```rust trait Foo { fn bar(); } macro_rules! problem { ($ty:ident) => { impl<$ty: Foo> Foo for ($ty,) { fn bar() { <$ty>::bar() } } }; ($ty:ident $(, $rest:ident)*) => { impl<$ty: Foo, $($rest: Foo),*> Foo for ($ty, $($rest),*) { fn bar() { <$ty>::bar(); <($($rest),*)>::bar() } } problem!($($rest),*); } } ``` I think maybe we can handle this by avoid warning for `Paren(Path(..))` in the macro. Is this reasonable approach?
2024-04-11Rollup merge of #122954 - fmease:defined-by-extern-prelude, r=petrochenkovLeón Orell Valerian Liehr-1/+1
Be more specific when flagging imports as redundant due to the extern prelude There are multiple distinct kinds of [preludes](https://doc.rust-lang.org/reference/names/preludes.html). Be more specific when flagging imports as redundant due to the [extern prelude](https://doc.rust-lang.org/reference/names/preludes.html#extern-prelude). r? Nilstrieb or compiler
2024-04-10skip `unused_parens`'s suggestion for `Paren` in macro.surechen-9/+15
fixes #120642
2024-04-09Add a helper for extending a span to include any trailing whitespaceMichael Goulet-4/+1
2024-04-09Fix trait solver overflow with `non_local_definitions` lintUrgau-1/+13
2024-04-08Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errorsbors-0/+10
Implement minimal, internal-only pattern types in the type system rebase of https://github.com/rust-lang/rust/pull/107606 You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`. This PR's implementation differs from the MCP's text. Specifically > This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types. is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field. Waiting on: * [x] move all unrelated commits into their own PRs. * [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f) * [x] add lots more tests * [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish * [x] some commit cleanup * [x] full self-review * [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think. * [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives * [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok r? `@BoxyUwU`
2024-04-08Be more specific when flagging imports that are redundant due to the extern ↵León Orell Valerian Liehr-1/+1
prelude
2024-04-08Rollup merge of #122807 - danielhuang:fix-1, r=davidtwcoMatthias Krüger-1/+1
Add consistency with phrases "meantime" and "mean time" "mean time" is used in a few places while "meantime" is used everywhere else; this would make usage consistent throughout the codebase.
2024-04-08Rollup merge of #120144 - petrochenkov:unty, r=davidtwcoMatthias Krüger-2/+3
privacy: Stabilize lint `unnameable_types` This is the last piece of ["RFC #2145: Type privacy and private-in-public lints"](https://github.com/rust-lang/rust/issues/48054). Having unstable lints is not very useful because you cannot even dogfood them in the compiler/stdlib in this case (https://github.com/rust-lang/rust/pull/113284). The worst thing that may happen when a lint is removed are some `removed_lints` warnings, but I haven't heard anyone suggesting removing this specific lint. This lint is allow-by-default and is supposed to be enabled explicitly. Some false positives are expected, because sometimes unnameable types are a legitimate pattern. This lint also have some unnecessary false positives, that can be fixed - see https://github.com/rust-lang/rust/issues/120146 and https://github.com/rust-lang/rust/issues/120149. Closes https://github.com/rust-lang/rust/issues/48054.
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+9
2024-04-08Thread pattern types through the HIROli Scherer-0/+1
2024-04-05Put non_local_definitions lint back to warn-by-defaultUrgau-1/+1
2024-04-05Update non-local impl definition lint rule noteUrgau-1/+1
2024-04-05Eliminate false-positives in the non-local lint with the type-systemUrgau-37/+168
2024-04-03update messagesDan-1/+1
2024-03-29Add support for NonNull in ambiguous_wide_ptr_comparisionsUrgau-14/+42
2024-03-29Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrierilbors-29/+43
Add detection of [Partial]Ord methods in the `ambiguous_wide_pointer_comparisons` lint Partially addresses https://github.com/rust-lang/rust/issues/121264 by adding diagnostics items for PartialOrd and Ord methods, detecting such diagnostics items as "binary operation" and suggesting the correct replacement. I also took the opportunity to change the suggestion to use new methods `.cast()` on `*mut T` an d `*const T`.
2024-03-29Add detection of [Partial]Ord methods to the ambiguous wide ptr cmp lintUrgau-29/+43
2024-03-26Don't check match scrutinee of postfix match for unused parensMichael Goulet-1/+3
2024-03-26panic_str only exists for the migration to 2021 panic macrosRalf Jung-1/+1
2024-03-24Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`Alex Macleod-23/+8
2024-03-23Rollup merge of #122780 - GuillaumeGomez:rename-hir-local, r=oli-obkMatthias Krüger-8/+8
Rename `hir::Local` into `hir::LetStmt` Follow-up of #122776. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far? r? ```@oli-obk```
2024-03-22Auto merge of #122900 - matthiaskrgr:rollup-nls90mb, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #114009 (compiler: allow transmute of ZST arrays with generics) - #122195 (Note that the caller chooses a type for type param) - #122651 (Suggest `_` for missing generic arguments in turbofish) - #122784 (Add `tag_for_variant` query) - #122839 (Split out `PredicatePolarity` from `ImplPolarity`) - #122873 (Merge my contributor emails into one using mailmap) - #122885 (Adjust better spastorino membership to triagebot's adhoc_groups) - #122888 (add a couple more tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-2/+2
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-8/+8
2024-03-22Split out ImplPolarity and PredicatePolarityMichael Goulet-1/+1
2024-03-22Make RawPtr take Ty and Mutbl separatelyMichael Goulet-8/+8
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-8/+6
2024-03-22Ty::new_ref and Ty::new_ptr stop using TypeAndMutMichael Goulet-2/+2
2024-03-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-2/+2
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers