about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/dead.rs
AgeCommit message (Collapse)AuthorLines
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+2
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-21Use local key in providersMichael Goulet-2/+2
2023-03-13Don't opt_rpitit_info as a separate queryMichael Goulet-1/+1
2023-03-12Auto merge of #108700 - spastorino:new-rpitit-impl-side-2, r=compiler-errorsbors-0/+6
Make RPITITs simple cases work when using lower_impl_trait_in_trait_to_assoc_ty r? `@compiler-errors` It's probably best reviewed commit by commit.
2023-03-08Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholkbors-13/+11
Do not implement HashStable for HashSet (MCP 533) This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order. The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-06Avoid accessing HIR for RPITITs assoc type on mark_live_symbolsSantiago Pastorino-0/+6
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
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-01Use UnordSet instead of FxHashSet for names_imported_by_glob_use query.Michael Woerister-1/+1
2023-03-01Use LocalDefIdSet/Map instead of FxHashSet/Map for ↵Michael Woerister-14/+12
live_symbols_and_ignored_derived_traits query.
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-2/+2
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-2/+2
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-22Lint dead code in closuresclubby789-0/+3
2023-02-19Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726bors-1/+1
Properly check for builtin derived code Fixes #108122
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-2/+2
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-2/+2
2023-02-16Properly check for builtin derivesclubby789-1/+1
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-5/+3
2023-01-30Consider `#[allow(dead_code)]` before lang itemsMaybe Waffle-2/+2
2023-01-30Split `has_allow_dead_code_or_lang_attr` into sub functionsMaybe Waffle-16/+18
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-25/+13
2023-01-14change impl_trait_ref query to return EarlyBinder; remove ↵Kyle Matsuda-3/+3
bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14change usages of impl_trait_ref to bound_impl_trait_refKyle Matsuda-3/+3
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-10/+6
2022-12-19clippy::complexity fixesMatthias Krüger-1/+0
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-12-04drive-by: move field_index to typeck resultsMichael Goulet-3/+3
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-11-18couple of clippy::perf fixesMatthias Krüger-1/+1
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-8/+4
2022-11-04Rollup merge of #103397 - crlf0710:port_dead_code_lint, r=davidtwcoMatthias Krüger-91/+84
Port `dead_code` lints to be translatable. This adds an additional comma to lists with three or more items, to be consistent with list formatters like `icu4x`. r? `@davidtwco`
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-5/+0
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-23/+23
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-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-4/+4
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-91/+84
2022-10-07migrate dead.rs to translateable diagnosticsNathan Stocks-11/+5
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-27/+29
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = 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 #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01Refactor rustc lint APIMaybe Waffle-27/+29
2022-09-29Shrink `hir::def::Res`.Nicholas Nethercote-8/+2
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-24separate definitions and `HIR` ownersTakayuki Maeda-14/+19
fix a ui test use `into` fix clippy ui test fix a run-make-fulldeps test implement `IntoQueryParam<DefId>` for `OwnerId` use `OwnerId` for more queries change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-14change AccessLevels representationBryanskiy-7/+4
2022-09-09Handle generic parameters.Camille GILLOT-1/+1
2022-09-08Introduce `DotDotPos`.Nicholas Nethercote-7/+4
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-08-11Simplify `rustc_hir::intravisit::Visitor::visit_variant_data`.Nicholas Nethercote-8/+1
It has four arguments that are never used. This avoids lots of argument passing in functions that feed into `visit_variant_data`.
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-18/+111
2022-06-22Rewrite dead-code pass to avoid fetching HIR.Camille GILLOT-168/+89
2022-06-22Uniform spans in dead code lint.Camille GILLOT-96/+52
2022-06-22Simplify match.Camille GILLOT-5/+3
2022-06-22Mark inherent impls as using the type during liveness collection.Camille GILLOT-25/+21
2022-06-19collapse dead code warnings into a single diagnosticTakayuki Maeda-70/+181
add comments in `store_dead_field_or_variant` support multiple log level add a item ident label fix ui tests fix a ui test fix a rustdoc ui test use let chain refactor: remove `store_dead_field_or_variant` fix a tiny bug
2022-06-19emit only one note per unused struct fieldTakayuki Maeda-36/+51
2022-06-02don't use a `span_note` for ignored implslcnr-5/+1