about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-07-16resolve: Remove trait `ToNameBinding`Vadim Petrochenkov-23/+34
2025-07-16resolve: Merge `NameBindingKind::Module` into `NameBindingKind::Res`Vadim Petrochenkov-21/+8
2025-07-15rustc_resolve: rename `check_hidden_glob_reexports` to `lint_reexports`David Mládek-3/+1
2025-07-15Define datastructures for `#[cfg]` attribute, move StrippedCfgItemJonathan Brouwer-1/+1
2025-07-13Rollup merge of #143734 - ↵Matthias Krüger-1/+1
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-0/+7
2025-07-12replace binding and shadowed_glob on NameResolution with non_glob_binding ↵b-naber-1/+1
and glob_binding
2025-07-09Use reference for MacroRulesScopeRef instead of Interned.LorrensP-2158466-1/+1
2025-07-09MacroData in ResolverArenas + split macro_map into extern_macro_map and ↵LorrensP-2158466-5/+19
local_macro_map.
2025-07-06mbe: Change `unused_macro_rules` to a `DenseBitSet`Josh Triplett-1/+2
Now that it only contains indexes, and no other information, a bitset provides a more compact and simpler representation.
2025-07-05mbe: Defer checks for `compile_error!` until reporting an unused macro ruleJosh Triplett-3/+3
The MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking. Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused. In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes. This ends up being a net simplification, and reduction in code size.
2025-07-04Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkovbors-13/+12
Avoid depending on forever-red DepNode when encoding metadata. Split from https://github.com/rust-lang/rust/pull/114669 for perf r? `@petrochenkov`
2025-07-02Hash resolutions.Camille GILLOT-13/+12
2025-06-25Don't give APITs names with macro expansion placeholder fragments in itMichael Goulet-0/+6
2025-06-13Auto merge of #134841 - estebank:serde-attr-4, r=wesleywiserbors-1/+1
Look at proc-macro attributes when encountering unknown attribute ``` error: cannot find attribute `sede` in this scope --> $DIR/missing-derive-2.rs:22:7 | LL | #[sede(untagged)] | ^^^^ | help: the derive macros `Deserialize` and `Serialize` accept the similarly named `serde` attribute | LL | #[serde(untagged)] | + error: cannot find attribute `serde` in this scope --> $DIR/missing-derive-2.rs:16:7 | LL | #[serde(untagged)] | ^^^^^ | note: `serde` is imported here, but it is a crate, not an attribute --> $DIR/missing-derive-2.rs:5:1 | LL | extern crate serde; | ^^^^^^^^^^^^^^^^^^^ help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | LL + #[derive(Serialize, Deserialize)] LL | enum B { | ``` Partially address #47608. This PR doesn't find [macros that haven't yet been imported by name](https://github.com/rust-lang/rust/pull/109278/commits/af945cb86e03b44a4b6dc4d54ec1424b00a2349e).
2025-06-12Detect when attribute is provided by missing `derive` macroEsteban Küber-1/+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-06-03resolve: Tweak `private_macro_use` lint to be compatible with upcoming macro ↵Vadim Petrochenkov-6/+20
prelude changes
2025-05-12update cfg(bootstrap)Pietro Albini-1/+0
2025-05-09Remove `Ident::empty`.Nicholas Nethercote-7/+18
All uses have been removed. And it's nonsensical: an identifier by definition has at least one char. The commits adds an is-non-empty assertion to `Ident::new` to enforce this, and converts some `Ident` constructions to use `Ident::new`. Adding the assertion requires making `Ident::new` and `Ident::with_dummy_span` non-const, which is no great loss. The commit amends a couple of places that do path splitting to ensure no empty identifiers are created.
2025-05-06Auto merge of #131160 - ↵bors-1/+1
ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk Handle `rustc_middle` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447 r? `@compiler-errors`
2025-05-05Handle rustc_middle cases of rustc::potential_query_instability lintismailarilik-1/+1
2025-05-05Auto merge of #140453 - Zoxc:next-disambiguator, r=oli-obkbors-1/+6
Remove global `next_disambiguator` state and handle it with a `DisambiguatorState` type This removes `Definitions.next_disambiguator` as it doesn't guarantee deterministic def paths when `create_def` is called in parallel. Instead a new `DisambiguatorState` type is passed as a mutable reference to `create_def` to help create unique def paths. `create_def` calls with distinct `DisambiguatorState` instances must ensure that that the def paths are unique without its help. Anon associated types did rely on this global state for uniqueness and are changed to use (method they're defined in + their position in the method return type) as the `DefPathData` to ensure uniqueness. This also means that the method they're defined in appears in error messages, which is nicer. `DefPathData::NestedStatic` is added to use for nested data inside statics instead of reusing `DefPathData::AnonConst` to avoid conflicts with those. cc `@oli-obk`
2025-05-02resolve: Support imports of associated types and glob imports from traitsVadim Petrochenkov-8/+2
2025-04-30Simplify `LazyAttrTokenStream`.Nicholas Nethercote-0/+1
This commit does the following. - Changes it from `Lrc<Box<dyn ToAttrTokenStream>>` to `Lrc<LazyAttrTokenStreamInner>`. - Reworks `LazyAttrTokenStreamImpl` as `LazyAttrTokenStreamInner`, which is a two-variant enum. - Removes the `ToAttrTokenStream` trait and the two impls of it. The recursion limit must be increased in some crates otherwise rustdoc aborts.
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-1/+6
`DisambiguatorState` type
2025-04-23Make #![feature(let_chains)] bootstrap conditional in compiler/est31-1/+1
2025-04-17Rollup merge of #139084 - petrochenkov:transpaque, r=davidtwcoMatthias Krüger-3/+3
hygiene: Rename semi-transparent to semi-opaque "Semi-transparent" is just too damn long for a name, especially when used multiple times on a single line, it bothered me when working on #139083. An optimist sees a macro as semi-opaque, a pessimist sees it as semi-transparent. Or is it the other way round?
2025-04-11Rollup merge of #139662 - nnethercote:tweak-DefPathData, r=compiler-errorsJacob Pratt-3/+3
Tweak `DefPathData` Some improvements in and around `DefPathData`, following on from #137977. r? `@spastorino`
2025-04-11Avoid a node_id_to_def_id call by just storing DefIds instead of NodeIdsOli Scherer-2/+2
2025-04-11Avoid storing the `LocalDefId` twiceOli Scherer-1/+1
2025-04-11Avoid another node_id_to_def_id callOli Scherer-1/+1
2025-04-11Avoid a reverse map that is only used in diagnostics pathsOli Scherer-6/+13
2025-04-11Adjust an assertion.Nicholas Nethercote-3/+3
No need to convert the `DefKind` to `DefPathData`, they're very similar types.
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-1/+1
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-04-02Rollup merge of #139184 - Urgau:crate-root-lint-levels, r=jieyouxuTakayuki Maeda-0/+2
Add unstable `--print=crate-root-lint-levels` This PR implements `--print=crate-root-lint-levels` from MCP 833 https://github.com/rust-lang/compiler-team/issues/833. Tracking issue: https://github.com/rust-lang/rust/issues/139180 Best reviewed commit by commit.
2025-03-31Expose `registered_tools` directly without `TyCtxt`-queryUrgau-0/+2
2025-03-31hygiene: Rename semi-transparent to semi-opaqueVadim Petrochenkov-3/+3
The former is just too long, see the examples in `hygiene.rs`
2025-03-25Rollup merge of #138929 - oli-obk:assoc-ctxt-of-trait, r=compiler-errorsMatthias Krüger-5/+0
Visitors track whether an assoc item is in a trait impl or an inherent impl `AssocCtxt::Impl` now contains an `of_trait` field. This allows ast lowering and nameres to not have to track whether we're in a trait impl or an inherent impl.
2025-03-25Rollup merge of #138924 - nnethercote:less-kw-Empty-3, r=compiler-errorsMatthias Krüger-7/+8
Reduce `kw::Empty` usage, part 3 Remove some more `kw::Empty` uses, in support of #137978. r? `@davidtwco`
2025-03-25Track whether an assoc item is in a trait impl or an inherent implOli Scherer-5/+0
2025-03-25Use `Option<Symbol>` in `ModuleKind::Def`.Nicholas Nethercote-7/+8
This way, `None` represents "crate root without a name" instead of `kw::Empty`. This changes makes it impossible to forget to handle the exceptional case.
2025-03-24resolve: Avoid some unstable iteration 2Vadim Petrochenkov-1/+1
2025-03-19Allow builtin macros to be used more than once.Mara Bos-7/+1
This removes E0773 "A builtin-macro was defined more than once."
2025-03-14resolve: Avoid some unstable iterationVadim Petrochenkov-12/+12
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Manish Goregaokar-1/+0
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? `````@jieyouxu`````
2025-03-12Disentangle ForwardGenericParamBan and ConstParamTy ribsMichael Goulet-3/+6
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-1/+0
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.