summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-01-06rustc_metadata: Make attribute decoding slightly faster and stricterVadim Petrochenkov-1/+1
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-4/+3
This makes it more uniform with other expanded nodes
2021-12-21resolve: Minor miscellaneous cleanups from #89059Vadim Petrochenkov-20/+14
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-1/+1
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-1/+0
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-01Improve suggestion for extern crate self error messageMichael-1/+3
2021-12-01Fix bad `NodeId` limit checking.Nicholas Nethercote-6/+3
`Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
2021-11-30Apply cfg-bootstrap switchMark Rousskov-1/+0
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-11Shorten Span of unused macro lintsMarcel Hellwig-1/+1
The span has been recuded to the actual ident, instead of linting the *whole* macro.
2021-11-03fix messageTakayuki Maeda-1/+1
2021-11-03add a suggestion about undeclared `alloc` moduleTakayuki Maeda-9/+19
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-25Edit error messages for rustc_resolve::AmbiguityKind variantspierwill-10/+8
Emit description of the ambiguity as a note. Co-authored-by: Noah Lev <camelidcamel@gmail.com> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-21Revert "Auto merge of #89100 - petrochenkov:localbind, r=cjgillot"Mark Rousskov-56/+138
This reverts commit 6162529a01473bbb2427fa27354cbafc3c514eee.
2021-10-20Auto merge of #89100 - petrochenkov:localbind, r=cjgillotbors-138/+56
resolve: Use `NameBinding` for local variables and generic parameters `NameBinding` is a structure used for representing any name introduction (an item, or import, or even a built-in). Except that local variables and generic parameters weren't represented as `NameBinding`s, for this reason they requires separate paths in name resolution code in several places. This PR introduces `NameBinding`s for local variables as well and simplifies all the code working with them leaving only the `NameBinding` paths.
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-0/+1
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-43/+10
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-18resolve: Use `NameBinding` for local variables and generic parametersVadim Petrochenkov-138/+56
2021-10-16Adopt let_else across the compilerest31-0/+1
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-13suggestion for typoed crate or moduleTakayuki Maeda-1/+16
avoid suggesting the same name sort candidates fix a message use `opt_def_id` instead of `def_id` move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs
2021-10-09Forbid hashing HIR outside of indexing.Camille GILLOT-39/+6
2021-10-09Store lowering outputs per owner.Camille GILLOT-4/+4
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-1/+1
2021-10-02resolve: Avoid comparing modules by optional def-idVadim Petrochenkov-7/+12
It makes all block modules identical during comparison
2021-10-02resolve: Cache module loading for all foreign modulesVadim Petrochenkov-3/+21
It was previously cached for modules loaded from `fn get_module`, but not for modules loaded from `fn build_reduced_graph_for_external_crate_res`. This also makes all foreign modules use their real parent, span and expansion instead of possibly a parent/span/expansion of their reexport. An ICE happening on attempt to decode expansions for foreign enums and traits is avoided. Also local enums and traits are now added to the module map.
2021-09-30Rollup merge of #89344 - jackh726:maybe-bound-eror, r=cjgillotManish Goregaokar-1/+1
Cleanup lower_generics_mut and make span be the bound itself Closes #86298 (supersedes those changes) r? `@cjgillot` since you reviewed the other PR (Used wrong branch for #89338)
2021-09-30Rollup merge of #88838 - FabianWolff:issue-88472, r=estebankManish Goregaokar-1/+9
Do not suggest importing inaccessible items Fixes #88472. For this example: ```rust mod a { struct Foo; } mod b { type Bar = Foo; } ``` rustc currently emits: ``` error[E0412]: cannot find type `Foo` in this scope --> test.rs:6:16 | 6 | type Bar = Foo; | ^^^ not found in this scope | help: consider importing this struct | 6 | use a::Foo; | ``` this is incorrect, as applying this suggestion leads to ``` error[E0603]: struct `Foo` is private --> test.rs:6:12 | 6 | use a::Foo; | ^^^ private struct | note: the struct `Foo` is defined here --> test.rs:2:5 | 2 | struct Foo; | ^^^^^^^^^^^ ``` With my changes, I get: ``` error[E0412]: cannot find type `Foo` in this scope --> test.rs:6:16 | 6 | type Bar = Foo; | ^^^ not found in this scope | = note: this struct exists but is inaccessible: a::Foo ``` As for the wildcard mentioned in #88472, I would argue that the warning is actually correct, since the import _is_ unused. I think the real issue is the wrong suggestion, which I have fixed here.
2021-09-30Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, ↵Manish Goregaokar-3/+3
r=estebank Suggest similarly named associated items in trait impls Fix #85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
2021-09-29Cleanup lower_generics_mut and make span be the bound itself, not the typejackh726-1/+1
2021-09-29Suggest similarly named assoc items in trait implsHirochika Matsumoto-3/+3
Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types and constants.
2021-09-28More tracing instrumentationOli Scherer-0/+3
2021-09-26Improve diagnostics for inaccessible itemsFabian Wolff-1/+9
2021-09-25Rollup merge of #89224 - TaKO8Ki:change-the-order-of-suggestions, r=joshtriplettManish Goregaokar-0/+1
Change the order of imports suggestions closes #83564
2021-09-25use `drain_filter` instead of `filter` and `retain`Takayuki Maeda-0/+1
2021-09-24resolve: Refactor obtaining `Module` from its `DefId`Vadim Petrochenkov-7/+6
The `Option<Module>` version is supported for the case where we don't know whether the `DefId` refers to a module or not. Non-local traits and enums are also correctly found now.
2021-09-24resolve: Use a single common map for local and foreign modulesVadim Petrochenkov-4/+2
2021-09-24resolve: Rename some expansion def scope methodsVadim Petrochenkov-4/+4
2021-09-24resolve: Cleanup module allocationVadim Petrochenkov-30/+36
Construction of all modules is now centralized and performed by `fn new_module`.
2021-09-24resolve: Do not cache nearest parent mod in `ModuleData`Vadim Petrochenkov-29/+27
2021-09-12Rollup merge of #88677 - petrochenkov:exportid, r=davidtwcoManish Goregaokar-1/+2
rustc: Remove local variable IDs from `Export`s Local variables can never be exported.
2021-09-11Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkovbors-10/+13
Encode spans relative to the enclosing item The aim of this PR is to avoid recomputing queries when code is moved without modification. MCP at https://github.com/rust-lang/compiler-team/issues/443 This is achieved by : 1. storing the HIR owner LocalDefId information inside the span; 2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache; 3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation. Since all client code uses `Span`, step 3 ensures that all manipulations of span byte positions actually create the dependency edge between the caller and the `source_span(LocalDefId)`. This query return the actual absolute span of the parent item. As a consequence, any source code motion that changes the absolute byte position of a node will either: - modify the distance to the parent's beginning, so change the relative span's hash; - dirty `source_span`, and trigger the incremental recomputation of all code that depends on the span's absolute byte position. With this scheme, I believe the dependency tracking to be accurate. For the moment, the spans are marked during lowering. I'd rather do this during def-collection, but the AST MutVisitor is not practical enough just yet. The only difference is that we attach macro-expanded spans to their expansion point instead of the macro itself.
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-1/+1
2021-09-10rustc: Remove local variable IDs from `Export`sVadim Petrochenkov-1/+2
Local variables can never be exported.
2021-09-10Encode spans relative to their parent.Camille GILLOT-0/+10
2021-09-10Keep def_spans collected by resolution.Camille GILLOT-10/+3