about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2023-04-04Replace another lock with an append-only vecOli Scherer-1/+1
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+1
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-29Rollup merge of #109554 - MU001999:master, r=WaffleLapkinMatthias Krüger-14/+56
Suggest ..= when someone tries to create an overflowing range Fixes #109529
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-2/+1
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27Rollup merge of #109641 - compiler-errors:dont-elaborate-non-obl, r=oli-obkMatthias Krüger-2/+2
Don't elaborate non-obligations into obligations It's suspicious to elaborate a `PolyTraitRef` or `Predicate` into an `Obligation`, since the former does not have a param-env associated with it, but the latter does. This is a footgun that, while not being misused *currently* in the compiler, easily could be misused by someone less familiar with the elaborator's inner workings. This PR just changes the API -- ideally, the elaborator wouldn't even have to deal with obligations if we're not elaborating obligations, but that would require a bit more abstraction than I could be bothered with today.
2023-03-26Don't elaborate non-obligations into obligationsMichael Goulet-2/+2
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-3/+2
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-25Emits suggestions for expressions with parentheses or not separatelyMu001999-14/+47
2023-03-24Use independent suggestionsMu42-22/+18
2023-03-24Suggest ..= when someone tries to create an overflowing rangeMu42-7/+20
2023-03-23Rollup merge of #109487 - GuillaumeGomez:move-useless-reexport-check, ↵Matthias Krüger-93/+0
r=petrochenkov Move useless_anynous_reexport lint into unused_imports As mentioned in https://github.com/rust-lang/rust/pull/109003, this check should have been merged with `unused_imports` in the start. r? `@petrochenkov`
2023-03-23Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkovMatthias Krüger-0/+4
Lint ambiguous glob re-exports Attempts to fix #107563. We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoeristerbors-5/+5
rustc_interface: Add a new query `pre_configure` It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes. This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working. Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgrbors-4/+19
Rollup of 7 pull requests Successful merges: - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs) - #109137 (resolve: Querify most cstore access methods (subset 2)) - #109380 (add `known-bug` test for unsoundness issue) - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate)) - #109475 (Simpler checked shifts in MIR building) - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.) - #109506 (make param bound vars visibly bound vars with -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23rustc_interface: Add a new query `pre_configure`Vadim Petrochenkov-5/+5
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-23Rollup merge of #109462 - compiler-errors:alias-relate, r=BoxyUwU,lcnrMatthias Krüger-1/+1
Make alias-eq have a relation direction (and rename it to alias-relate) Emitting an "alias-eq" is too strict in some situations, since we don't always want strict equality between a projection and rigid ty. Adds a relation direction. * I could probably just reuse this [`RelationDir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/combine/enum.RelationDir.html) -- happy to uplift that struct into middle and use that instead, but I didn't feel compelled to... 🤷 * Some of the matching in `compute_alias_relate_goal` is a bit verbose -- I guess I could simplify it by using [`At::relate`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/at/struct.At.html#method.relate) and mapping the relation-dir to a variance. * Alternatively, I coulld simplify things by making more helper functions on `EvalCtxt` (e.g. `EvalCtxt::relate_with_direction(T, T)` that also does the nested goal registration). No preference. r? ```@lcnr``` cc ```@BoxyUwU``` though boxy can claim it if she wants NOTE: first commit is all the changes, the second is just renaming stuff
2023-03-23Nested impl traits trigger opaque_hidden_inferred_bound too muchMichael Goulet-3/+18
2023-03-23Rename AliasEq -> AliasRelateMichael Goulet-1/+1
2023-03-22Move useless_anynous_reexport lint into unused_importsGuillaume Gomez-93/+0
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-17/+15
2023-03-22Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errorsbors-4/+7
a general type system cleanup removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context. changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR. also removes some other small - and imo unnecessary - helpers. r? types
2023-03-21Use local key in providersMichael Goulet-10/+5
2023-03-21use the correct param envlcnr-2/+1
2023-03-21remove some trait solver helperslcnr-3/+7
they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.
2023-03-20remove bad commentDaniPopes-1/+0
2023-03-20fix ClashingExternDeclarations lint ICEDaniPopes-13/+11
2023-03-20Lint ambiguous glob re-exports许杰友 Jieyou Xu (Joe)-0/+4
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-2/+1
2023-03-19Rollup merge of #109003 - GuillaumeGomez:useless-anonymous-reexport-lint, ↵Dylan DPC-0/+93
r=cjgillot Add `useless_anonymous_reexport` lint This is a follow-up of https://github.com/rust-lang/rust/pull/108936. We once again show all anonymous re-exports in rustdoc, however we also wanted to add a lint to let users know that it very likely doesn't have the effect they think it has.
2023-03-16Rollup merge of #109158 - Ezrashaw:expand-sugg-for-unused-lint, r=NilstriebMatthias Krüger-31/+22
error-msg: expand suggestion for `unused_def` lint Fixes #108885 Expands `let _ = ..` suggestion into more positions.
2023-03-15error-msg: expand suggestion for unused lintEzra Shaw-31/+22
2023-03-15Fix #109152, fix the scenario that we may can not get span of funcyukang-2/+9
2023-03-12Add test for useless_anonymous_reexport lintGuillaume Gomez-0/+1
2023-03-12Add lint for useless anonymous reexportsGuillaume Gomez-0/+92
2023-03-12Remove uses of `box_syntax` in rustc and toolsclubby789-1/+0
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11Rollup merge of #108806 - cjgillot:query-lints, r=davidtwcoMatthias Krüger-2/+2
Querify register_tools and post-expansion early lints The 2 extra queries correspond to code that happen before and after macro expansion, and don't need the resolver to exist.
2023-03-11Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=NilstriebMatthias Krüger-2/+6
Make `unused_allocation` lint against `Box::new` too Previously it only linted against `box` syntax, which likely won't ever be stabilized, which is pretty useless. Even now I'm not sure if it's a meaningful lint, but it's at least something :shrug: This means that code like the following will be linted against: ```rust Box::new([1, 2, 3]).len(); f(&Box::new(1)); // where f : &i32 -> () ``` The lint works by checking if a `Box::new` (or `box`) expression has an a borrow adjustment, meaning that the code that first stores the box in a variable won't be linted against: ```rust let boxed = Box::new([1, 2, 3]); // no lint boxed.len(); ```
2023-03-09Document tool lintsclubby789-0/+30
2023-03-06Querify registered_tools.Camille GILLOT-2/+2
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-2/+2
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-03Make `unused_allocation` lint warn against `Box::new`Maybe Waffle-2/+6
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-2/+2
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-27Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkinMatthias Krüger-0/+17
Move the unused extern crate check back to the resolver. It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-26Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillotMatthias Krüger-1/+141
Lint against `Iterator::map` receiving a callable that returns `()` Close #106991
2023-02-24Use `List::empty()` instead of `mk_substs(&[])`.Nicholas Nethercote-3/+3
2023-02-24Rename many interner functions.Nicholas Nethercote-3/+3
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Emit `map_unit_fn` lint in closure caseObei Sideg-0/+16
2023-02-23Add lint against `Iterator::map` receiving a callable that returns `()`Obei Sideg-1/+125