about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/ident.rs
AgeCommit message (Collapse)AuthorLines
2025-07-17resolve: Change `&mut Resolver` to `&Resolver` when possibleVadim Petrochenkov-2/+2
2025-07-17resolve: Move `self_binding` to `ModuleData`Vadim Petrochenkov-1/+1
2025-07-16resolve: Remove trait `ToNameBinding`Vadim Petrochenkov-9/+4
2025-07-16resolve: Merge `NameBindingKind::Module` into `NameBindingKind::Res`Vadim Petrochenkov-3/+3
2025-07-13Rollup merge of #143734 - ↵Matthias Krüger-2/+2
LorrensP-2158466:refactor-resolve-resolution-bindings, r=petrochenkov Refactor resolve resolution bindings This pr does the work asked in https://github.com/rust-lang/rust/pull/142547#issuecomment-3001339385. This part: > move the `(non)_glob_binding` change r? ````@petrochenkov````
2025-07-12merge source and target bindings into single fieldLorrensP-2158466-4/+3
2025-07-12replace binding and shadowed_glob on NameResolution with non_glob_binding ↵b-naber-2/+2
and glob_binding
2025-07-10extract single_import_can_define_name and finalize_glob_module_bindingb-naber-118/+143
2025-06-12Detect when attribute is provided by missing `derive` macroEsteban Küber-0/+1
``` error: cannot find attribute `empty_helper` in this scope --> $DIR/derive-helper-legacy-limits.rs:17:3 | LL | #[empty_helper] | ^^^^^^^^^^^^ | help: `empty_helper` is an attribute that can be used by the derive macro `Empty`, you might be missing a `derive` attribute | LL + #[derive(Empty)] LL | struct S2; | ``` Look at proc-macro attributes when encountering unknown attribute ``` error: cannot find attribute `sede` in this scope --> src/main.rs:18:7 | 18 | #[sede(untagged)] | ^^^^ | help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | 18 | #[serde(untagged)] | ~~~~~ error: cannot find attribute `serde` in this scope --> src/main.rs:12:7 | 12 | #[serde(untagged)] | ^^^^^ | = note: `serde` is in scope, but it is a crate, not an attribute help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | 10 | #[derive(Serialize, Deserialize)] | ```
2025-04-09Avoid an empty trait name in impl blocks.Nicholas Nethercote-3/+0
`resolve_ident_in_lexical_scope` checks for an empty name. Why is this necessary? Because `parse_item_impl` can produce an `impl` block with an empty trait name in some cases. This is pretty gross and very non-obvious. This commit avoids the use of the empty trait name. In one case the trait name is instead pulled from `TyKind::ImplTrait`, which prevents the output for `tests/ui/impl-trait/extra-impl-in-trait-impl.rs` from changing. In the other case we just fail the parse and don't try to recover. I think losing error recovery in this obscure case is worth the code cleanup. This change affects `tests/ui/parser/impl-parsing.rs`, which is split in two, and the obsolete `..` syntax cases are removed (they are tested elsewhere).
2025-03-24resolve: Avoid some unstable iteration 2Vadim Petrochenkov-1/+0
2025-03-14resolve: Avoid some unstable iterationVadim Petrochenkov-0/+1
2025-03-12Disentangle ForwardGenericParamBan and ConstParamTy ribsMichael Goulet-20/+41
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-28/+14
2025-02-08Rustfmtbjorn3-22/+35
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.