about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/check_unused.rs
AgeCommit message (Collapse)AuthorLines
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-10-16compiler: use `is_none_or` where it is clearly betterJubilee Young-2/+2
heuristic was: if it easily allows removing bangs entirely? worth it. if it requires more effort or just moves the bang? not.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-12Introduce `'ra` lifetime name.Nicholas Nethercote-4/+4
`rustc_resolve` allocates many things in `ResolverArenas`. The lifetime used for references into the arena is mostly `'a`, and sometimes `'b`. This commit changes it to `'ra`, which is much more descriptive. The commit also changes the order of lifetimes on a couple of structs so that '`ra` is second last, before `'tcx`, and does other minor renamings such as `'r` to `'a`.
2024-08-10rm `import.used`bohan-3/+3
2024-08-07make `import.vis` is not mutablebohan-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-6/+6
2024-05-21Make early lints translatableXiretza-23/+11
2024-05-21Convert uses of BuiltinLintDiag::Normal to custom variantsXiretza-7/+8
This ensures all diagnostic messages are created at diagnostic emission time, making them translatable.
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-16/+7
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-19fix typoPietro Albini-6/+6
2024-04-14 remove braces when fixing a nested use tree into a single usePietro Albini-1/+26
2024-04-14store the span of the nested part of the use tree in the astPietro Albini-3/+3
2024-04-14turn all_nested_unused into used_childsPietro Albini-5/+5
2024-04-14remove redundant flat vs nested distinction to simplify enumPietro Albini-19/+10
2024-04-14add enum variant field names to make the code clearerPietro Albini-13/+13
2024-03-14fixes #121331surechen-4/+56
2024-03-06Fix redundant import errors for preload extern crateyukang-69/+77
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-4/+4
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-10/+36
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-13Bump `indexmap`clubby789-1/+2
`swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though.
2024-01-21exclude unexported macro bindings from extern cratebohan-2/+2
2024-01-11Rollup merge of #119788 - mj10021:issue-119787-fix, r=oli-obkMatthias Krüger-1/+1
change function name in comments fixes #119787 where I believe an incorrect function name is used in the comments
2024-01-09change function name in commentsmj10021-1/+1
2023-10-26Rollup merge of #116905 - Fenex:refactor/compiler/resolve, r=petrochenkovMatthias Krüger-11/+10
refactor(compiler/resolve): simplify some code Removes unnecessary allocate and double-sorting the same vector, makes the code a little nicer.
2023-10-22use visibility to check unused imports and delete some stmtsbohan-4/+1
2023-10-19refactor(compiler/resolve): simplify some codeVitaliy Busko-11/+10
Removes unnecessary allocates and double-sorting the same vector, makes the code a little nicer.
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-1/+1
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-1/+1
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-9/+4
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-09Migrate `sess.opts.tests` uses to `sess.is_test_crate()`blyxyas-1/+1
2023-03-22Move useless_anynous_reexport lint into unused_importsGuillaume Gomez-2/+40
2023-02-25Address review.Camille GILLOT-10/+6
2023-02-22Remove some resolver outputs.Camille GILLOT-1/+0
2023-02-22Move the unused extern crate check back to the resolver.Camille GILLOT-13/+125
2023-02-20Prepare for adding a `TyCtxt` to `Resolver`Oli Scherer-2/+2
2023-02-14Separate the lifetime of the session and the arena in the resolverOli Scherer-5/+5
2023-01-19Use UnordMap instead of FxHashMap in define_id_collections!().Michael Woerister-5/+5
2022-10-31resolve: Not all imports have their own `NodeId`Vadim Petrochenkov-4/+4
2022-09-27rustc_typeck to rustc_hir_analysislcnr-1/+1
2022-08-27rustc_middle: Remove `Visibility::Invisible`Vadim Petrochenkov-1/+1
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-1/+0
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+1
2022-05-17Omit unnecessary help to add `#[cfg(test)]` when already annotatedKen Matsui-14/+21
2022-04-05span: move `MultiSpan`David Wood-2/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2021-12-16suggest adding a `#[cfg(test)]` to test modulesTakayuki Maeda-1/+19
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`