about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/ident.rs
AgeCommit message (Collapse)AuthorLines
2025-01-21rustc_resolve: flatten nested `if`sYotam Ofek-51/+47
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-12-10Keep track of parse errors in `mod`s and don't emit resolve errors for paths ↵Esteban Küber-29/+53
involving them When we expand a `mod foo;` and parse `foo.rs`, we now track whether that file had an unrecovered parse error that reached the end of the file. If so, we keep that information around. When resolving a path like `foo::bar`, we do not emit any errors for "`bar` not found in `foo`", as we know that the parse error might have caused `bar` to not be parsed and accounted for. When this happens in an existing project, every path referencing `foo` would be an irrelevant compile error. Instead, we now skip emitting anything until `foo.rs` is fixed. Tellingly enough, we didn't have any test for errors caused by `mod` expansion. Fix #97734.
2024-11-20Store resolution for self and crate root module segmentsMichael Goulet-4/+10
2024-11-14Replace the `restricted_shadowing` boolean argument with an enum.Nicholas Nethercote-12/+22
It makes the code clearer.
2024-11-14Remove two `_ext` methods.Nicholas Nethercote-56/+13
`resolve_ident_in_module` is a very thin wrapper around `resolve_ident_in_module_ext`, and `resolve_ident_in_module_unadjusted` is a very thin wrapper around `resolve_ident_in_module_unadjusted_ext`. The wrappers make the call sites slightly more concise, but I don't think that's worth the extra code and indirection. This commit removes the two wrappers and removes the `_ext` suffixes from the inner methods.
2024-11-14Use an atom comparison for a keyword check.Nicholas Nethercote-1/+3
Instead of a string comparison.
2024-11-13Use iteration instead of indexing to access ribs.Nicholas Nethercote-6/+5
This gives a small but noticeable performance improvement.
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-43/+30
2024-09-12Rollup merge of #130208 - nnethercote:rslv-lifetime, r=petrochenkovMatthias Krüger-53/+53
Introduce `'ra` lifetime name. `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 `'rslv`, which is much more descriptive. The commit also changes the order of lifetimes on a couple of structs so that '`rslv` is second last, before `'tcx`, and does other minor renamings such as `'r` to `'a`. r? ``@petrochenkov`` cc ``@oli-obk``
2024-09-12Introduce `'ra` lifetime name.Nicholas Nethercote-53/+53
`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-09-11Simplify some nested if statementsMichael Goulet-6/+6
2024-09-02chore: Fix typos in 'compiler' (batch 2)Alexander Cyon-1/+1
2024-08-07make `import.vis` is not mutablebohan-15/+55
2024-07-29Reformat `use` declarations.Nicholas Nethercote-12/+10
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-11Account for `let foo = expr`; to suggest `const foo: Ty = expr;`Esteban Küber-12/+32
2024-06-17mark undetermined if target binding in current ns is not gotbohan-9/+16
2024-06-07mark binding undetermined if target name exist and not obtainedbohan-5/+5
2024-06-04resolve: mark it undetermined if single import is not has any bindingsbohan-2/+27
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-1/+1
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-8/+5
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-10Remove `#[macro_use] extern crate tracing` from `rustc_resolve`.Nicholas Nethercote-0/+1
Explicit imports are more standard nowadays and easier to read.
2024-04-03Fix f16 and f128 feature gates in editions other than 2015Trevor Gross-0/+2
Fixes https://github.com/rust-lang/rust/issues/123282 Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2024-03-14Add feature gates for `f16` and `f128`Trevor Gross-1/+31
Includes related tests and documentation pages. Michael Goulet: Don't issue feature error in resolver for f16/f128 unless finalize Co-authored-by: Michael Goulet <michael@errs.io>
2024-03-06avoid overlapping privacy suggestion for single nested importsbohan-1/+2
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-2/+2
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-02-27Remove an unnecessary `span_delayed_bug` in `Resolver::valid_res_from_ribs`.Nicholas Nethercote-3/+2
`Resolver::report_error` always emits (this commit makes that clearer), so the `span_delayed_bug` is unnecessary.
2024-02-20Add newtype for using the prelude in resolutionclubby789-7/+17
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-5/+5
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-06Rollup merge of #119939 - clubby789:static-const-generic-note, r=compiler-errorsMatthias Krüger-10/+20
Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items Fixes #109596 Fixes #119936
2024-01-14Add note to resolve error about generics from inside static/constclubby789-10/+20
2024-01-13store the segment name when resolution failsbohan-27/+17
2023-12-30Update to bitflags 2 in the compilerNilstrieb-0/+1
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-2/+2
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-25resolve: Avoid clones of `MacroData`Vadim Petrochenkov-1/+1
And move declarative macro compilation to an earlier point in def collector, which is required for #118188.
2023-10-27Rename `RibKind::ClosureOrAsync` to reflect how it is actually usedOli Scherer-3/+3
2023-10-13Format all the let chains in compilerMichael Goulet-5/+9
2023-09-13resolve: determined binding after parent module macro expandbohan-3/+2
2023-09-10Generalize E0401León Orell Valerian Liehr-8/+2
2023-08-24resolve: Leave a comment about name bindings for legacy derive helpersVadim Petrochenkov-0/+5
2023-08-24resolve: Make bindings for derive helper attributes uniqueVadim Petrochenkov-21/+9
instead of creating them every time such attribute is used
2023-08-24resolve: Make bindings for crate roots uniqueVadim Petrochenkov-3/+1
instead of creating a new every time `crate` or `$crate` is used
2023-08-24resolve: Pre-intern tool module bindingsVadim Petrochenkov-2/+2
2023-08-24resolve: Pre-intern builtin name bindingsVadim Petrochenkov-16/+7
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-3/+3
2023-07-29fix(resolve): update the ambiguity glob binding as warning recursivelybohan-0/+2
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-2/+2
2023-07-05resolve: Use `Interned` for `Module`Vadim Petrochenkov-3/+1