about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/effective_visibilities.rs
AgeCommit message (Collapse)AuthorLines
2025-07-26resolve: Minimize borrow scopes for `resolutions`Vadim Petrochenkov-3/+1
2025-07-17resolve: Change `&mut Resolver` to `&Resolver` when possibleVadim Petrochenkov-3/+3
2025-07-17resolve: Use `module_map` and `get_module` lessVadim Petrochenkov-2/+1
2025-05-28Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.Nicholas Nethercote-2/+2
So they match the order of the parts in the source code, e.g.: ``` struct Foo<T, U> { t: T, u: U } <-><----> <------------> / | \ ident generics variant_data ```
2025-04-01Move `ast::Item::ident` into `ast::ItemKind`.Nicholas Nethercote-2/+2
`ast::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, `Trait`, `TraitAlias`, `MacroDef`, `Delegation`. - It's always empty for these item kinds: `Use`, `ForeignMod`, `GlobalAsm`, `Impl`, `MacCall`, `DelegationMac`. There is a similar story for `AssocItemKind` and `ForeignItemKind`. Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - `ast::Item` got 8 bytes bigger. This could be avoided by boxing the fields within some of the `ast::ItemKind` variants (specifically: `Struct`, `Union`, `Enum`). I might do that in a follow-up; this commit is big enough already. - For the visitors: `FnKind` no longer needs an `ident` field because the `Fn` within how has one. - In the parser, the `ItemInfo` typedef is no longer needed. It was used in various places to return an `Ident` alongside an `ItemKind`, but now the `Ident` (if present) is within the `ItemKind`. - In a few places I renamed identifier variables called `name` (or `foo_name`) as `ident` (or `foo_ident`), to better match the type, and because `name` is normally used for `Symbol`s. It's confusing to see something like `foo_name.name`.
2025-01-21rustc_resolve: reduce rightwards drift with `let..else` 👉💨Yotam Ofek-29/+30
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-12Introduce `'ra` lifetime name.Nicholas Nethercote-14/+19
`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-07-29Reformat `use` declarations.Nicholas Nethercote-10/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-25resolve: Tweak some naming around import ambiguitiesVadim Petrochenkov-1/+1
2024-05-18Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebankbors-0/+1
`rustc_resolve` cleanups Some improvements I found while looking through this code. r? `@estebank`
2024-05-15delegation: Implement list delegationVadim Petrochenkov-1/+1
```rust reuse prefix::{a, b, c} ```
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-01-12Delegation implementation: step 1Bryanskiy-1/+2
2023-12-18resolve: Replace visibility table in resolver outputs with query feedingVadim Petrochenkov-2/+2
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-10-13Format all the let chains in compilerMichael Goulet-1/+2
2023-08-31fix(resolve): update def if binding is warning ambiguitybohan-3/+6
2023-07-05resolve: Use `Interned` for `NameBinding`Vadim Petrochenkov-11/+7
2023-06-08increase the accuracy of effective visibilities calculationBryanskiy-1/+1
2023-05-11Populate effective visibilities in rustc_privacyBryanskiy-2/+2
2023-05-08Revert "Populate effective visibilities in `rustc_privacy`"Michael Goulet-2/+2
This reverts commit cff85f22f5030fbe7266d272da74a9e76160523c.
2023-05-05Populate effective visibilities in `rustc_privacy`Bryanskiy-2/+2
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-31resolve: Restore some effective visibility optimizationsVadim Petrochenkov-8/+28
Something similar was previously removed as a part of #104602, but after this PR all table changes should also be "locally correct" after every update.
2023-03-28effvis: Stop considering crate root its own parentVadim Petrochenkov-7/+6
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-28effvis: Merge two similar code pathsVadim Petrochenkov-34/+23
2023-03-20Lint ambiguous glob re-exports许杰友 Jieyou Xu (Joe)-18/+50
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-2/+2
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-02-20Remove `ResolverTree`Oli Scherer-6/+2
2023-02-20Remove IntoDefIdTreeOli Scherer-12/+7
2023-02-20Stuff a TyCtxt into the ResolverOli Scherer-1/+1
2023-02-14Separate the lifetime of the session and the arena in the resolverOli Scherer-8/+11
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-2/+2
2022-12-09Fold `Definitions` into the untracked dataOli Scherer-4/+1
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-1/+4
2022-12-09Generate crate loaders on the flyOli Scherer-1/+1
2022-12-09ResolverTree does not require access to the crate loader, only the storeOli Scherer-1/+1
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-23/+6
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-11-24effective visibility: Stop recalculating current private visibilityVadim Petrochenkov-2/+16
It becomes relatively expensive if done often and shows up during perf profiling.
2022-11-24effective visibility: Always add table entries for nodes used as parentsVadim Petrochenkov-7/+14
Previously if the parent was not in the table, and there was nothing to inherit from, the child's private visibility was used, but that's not correct - the parent may have a larger visibility so we should set it to at least the parent's private visibility. That parent's private visibility is also inserted into the table for caching, so it's not recalculated later if used again.
2022-11-24effective visibility: Fix private visibility calculation for modulesVadim Petrochenkov-4/+6
Optimizations removed in the previous commit required this function to behave incorrectly, but now those optimizations are gone so we can fix the bug. Fixes https://github.com/rust-lang/rust/issues/104249
2022-11-24effective visibility: Remove questionable optimizationsVadim Petrochenkov-30/+20
First, they require eagerly calculating private visibility (current normal module), which is somewhat expensive. Private visibilities are also lost once calculated, instead of being cached in the table. Second, I cannot prove that the optimizations are correct. Maybe they can be partially reinstated in the future in cases when it's cheap and provably correct to do them. They will also probably be merged into `fn update` in that case. Partially fixes https://github.com/rust-lang/rust/issues/104249 Fixes https://github.com/rust-lang/rust/issues/104539
2022-11-24effective visibility: Satisfy borrow checker to use resolver lazily from a ↵Vadim Petrochenkov-13/+26
closure
2022-11-13fix some typos in commentscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-05resolve: Fill effective visibilities for import def ids in a separate passVadim Petrochenkov-32/+33
This should result in less update calls than doing it repeatedly during the fix point iteration.
2022-11-05resolve: More detailed effective visibility tracking for importsVadim Petrochenkov-83/+122
Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.
2022-10-31resolve: Turn the binding from `#[macro_export]` into a proper `Import`Vadim Petrochenkov-7/+5
2022-10-31resolve: Not all imports have their own `NodeId`Vadim Petrochenkov-17/+31
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-0/+188
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054