about summary refs log tree commit diff
path: root/compiler/rustc_lint
AgeCommit message (Collapse)AuthorLines
2022-11-22Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgrbors-2/+2
Rollup of 11 pull requests Successful merges: - #103396 (Pin::new_unchecked: discuss pinning closure captures) - #104416 (Fix using `include_bytes` in pattern position) - #104557 (Add a test case for async dyn* traits) - #104559 (Split `MacArgs` in two.) - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`) - #104656 (Move tests) - #104657 (Do not check transmute if has non region infer) - #104663 (rustdoc: factor out common button CSS) - #104666 (Migrate alias search result to CSS variables) - #104674 (Make negative_impl and negative_impl_exists take the right types) - #104692 (Update test's cfg-if dependency to 1.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-2/+2
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-6/+10
2022-11-21Use ty::List instead of InternalSubstsOli Scherer-7/+2
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+2
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-0/+1
allow trait resolution to prove false things during coherence
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-1/+1
Add `PolyExistentialPredicate` type alias Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-20Change to Ty::is_inhabited_fromCameron Steffen-2/+2
2022-11-20Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errorsbors-1/+1
Minimal implementation of implicit deref patterns for Strings cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121 ~~I forgot to add a feature gate, will do so in a minute~~ Done
2022-11-19Refactor `must_use` lint into two partsNilstrieb-113/+203
Before, the lint did the checking for `must_use` and pretty printing the types in a special format in one pass, causing quite complex and untranslatable code. Now the collection and printing is split in two. That should also make it easier to translate or extract the type pretty printing in the future. Also fixes an integer overflow in the array length pluralization calculation.
2022-11-19Rollup merge of #104566 - matthiaskrgr:clippy_perf_nov18, r=oli-obkDylan DPC-2/+2
couple of clippy::perf fixes
2022-11-19drive-by: PolyExistentialPredicateMichael Goulet-1/+1
2022-11-18Auto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkovbors-2/+5
Shrink `ast::Expr` harder r? `@ghost`
2022-11-18couple of clippy::perf fixesMatthias Krüger-2/+2
2022-11-18Rm diagnostic item, use lang itemDeadbeef-1/+1
2022-11-17Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errorsMatthias Krüger-0/+1
Convert predicates into Predicate in the Obligation constructor instead of having almost all callers do that. This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17Rollup merge of #104433 - TaKO8Ki:fix-104392, r=estebankMatthias Krüger-9/+7
Fix `emit_unused_delims_expr` ICE Fixes #104392
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-11/+8
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-2/+5
patterns.
2022-11-16Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkovbors-11/+11
Use `token::Lit` in `ast::ExprKind::Lit`. Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. r? `@petrochenkov`
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-0/+1
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-11/+11
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-15Merge branch 'master' into patch-2Kagami Sascha Rosylight-105/+138
2022-11-15Rollup merge of #104296 - compiler-errors:opaque-ty-ffi-normalization-cycle, ↵Matthias Krüger-22/+17
r=lcnr Walk types more carefully in `ProhibitOpaqueTypes` visitor The visitor didn't account for the case where you could have `<TAIT as Trait>::Assoc` normalize to itself, in the case of a `type TAIT = impl Trait` with an unconstrained associated type. That causes the visitor to loop on the same type over and over. Fixes #104291
2022-11-15return when expr has errorsTakayuki Maeda-0/+5
add ui tests
2022-11-15simplify `emit_unused_delims_expr`Takayuki Maeda-10/+3
2022-11-15Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgrbors-1/+2
Rollup of 13 pull requests Successful merges: - #103842 (Adding Fuchsia compiler testing script, docs) - #104354 (Remove leading newlines from `NonZero*` doc examples) - #104372 (Update compiler-builtins) - #104380 (rustdoc: remove unused CSS `code { opacity: 1 }`) - #104381 (Remove dead NoneError diagnostic handling) - #104383 (Remove unused symbols and diagnostic items) - #104391 (Deriving cleanups) - #104403 (Specify language of code comment to generate document) - #104404 (Fix missing minification for static files) - #104413 ([llvm-wrapper] adapt for LLVM API change) - #104415 (rustdoc: fix corner case in search keyboard commands) - #104422 (Fix suggest associated call syntax) - #104426 (Add test for #102154) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-15Normalize types before looking for opaquesMichael Goulet-22/+17
2022-11-14Specify language of code comment to generate documentkoka-1/+2
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-11/+8
2022-11-13fix some typos in commentscui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-12Auto merge of #103530 - cjgillot:hir-lifetimes-direct, r=estebankbors-1/+1
Resolve lifetimes independently for each item-like. Now that the heavy-lifting is done on the AST and during lowering, we do not need to perform HIR lifetime resolution on a full item at once. Instead, we can treat each item-like independently, and look at `generics_of` the parent exceptionally for associated items.
2022-11-11Auto merge of #104293 - Manishearth:rollup-xj92d0k, r=Manishearthbors-13/+29
Rollup of 8 pull requests Successful merges: - #95292 (Allow specialized const trait impls.) - #100386 (Make `Sized` coinductive, again) - #102215 (Implement the `+whole-archive` modifier for `wasm-ld`) - #103468 (Fix unused lint and parser caring about spaces to won't produce invalid code) - #103531 (Suggest calling the instance method of the same name when method not found) - #103960 (piece of diagnostic migrate) - #104051 (update Miri) - #104129 (rustdoc: use javascript to layout notable traits popups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-11Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, ↵Manish Goregaokar-13/+29
r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes #103435
2022-11-11Tweak signatures in rustc_middle::hir::map.Camille GILLOT-1/+1
2022-11-10review commentsEsteban Küber-3/+10
2022-11-10Consider `#[must_use]` annotation on `async fn` as also affecting the ↵Esteban Küber-1/+13
`Future::Output` No longer lint against `#[must_use] async fn foo()`. When encountering a statement that awaits on a `Future`, check if the `Future`'s parent item is annotated with `#[must_use]` and emit a lint if so. This effectively makes `must_use` an annotation on the `Future::Output` instead of only the `Future` itself. Fix #78149.
2022-11-10Tweak span for `#[must_use]`Esteban Küber-6/+3
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-11-07fix: lint against lint functionsRejyr-0/+6
fix: lint against the functions `LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}`, `TyCtxt::struct_lint_node`, `LintLevelsBuilder::struct_lint`.
2022-11-05Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726Matthias Krüger-9/+2
Use `TraitEngine` (by itself) less Replace `TraitEngine` in favor of `ObligationCtxt` or `fully_solve_*`, improving code readability.
2022-11-02Use TraitEngine lessMichael Goulet-9/+2
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-2/+3
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-10-31Rollup merge of #103338 - l4l:enum-unreachable-pub, r=nagisaDylan DPC-2/+6
Fix unreachable_pub suggestion for enum with fields Resolves #103317
2022-10-29Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errorsGuillaume Gomez-4/+4
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions` This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3 r? `@compiler-errors`
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-34/+34
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-4/+4
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-26Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]Xiretza-2/+3
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-11/+12
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-25Fix failing examplesKagami Sascha Rosylight-6/+10
2022-10-24Update let_underscore.rsKagami Sascha Rosylight-2/+2