about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-26Reverting switching test to no_std and adjust output after rebase.Jakob Degen-1/+0
2021-10-26Adds hint if a trait fails to resolve and a newly added one in Edition 2021 ↵Jakob Degen-7/+51
is suggested
2021-10-25Edit error messages for rustc_resolve::AmbiguityKind variantspierwill-17/+10
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-25Rollup merge of #90127 - JohnTitor:fix-90113, r=estebankMatthias Krüger-0/+9
Do not mention a reexported item if it's private Fixes #90113 The _actual_ regression was introduced in #73652, then #88838 made it worse. This fixes the issue by not counting such an import as a candidate.
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-21Don't suggest importing items with hygienic namesMatthew Jasper-0/+2
This will potentially hide a few correct suggestions, but importing these items from another module is not generally possible.
2021-10-21Handle cross-crate module `ExpnId`s consistentlyMatthew Jasper-6/+1
- Always use the ExpnId serialized to `tables` - Use the Id for traits and enums from other crates in resolution.
2021-10-21Revert "Auto merge of #89100 - petrochenkov:localbind, r=cjgillot"Mark Rousskov-145/+213
This reverts commit 6162529a01473bbb2427fa27354cbafc3c514eee.
2021-10-21Do not mention a reexported item if it's privateYuki Okushi-0/+9
2021-10-20Auto merge of #89100 - petrochenkov:localbind, r=cjgillotbors-213/+145
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-6/+3
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-46/+13
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-213/+145
2021-10-18Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiserMatthias Krüger-2/+2
rustc_span: `Ident::invalid` -> `Ident::empty` The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.
2021-10-17rustc_span: `Ident::invalid` -> `Ident::empty`Vadim Petrochenkov-2/+2
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-17Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisaMatthias Krüger-1/+1
Some "parenthesis" and "parentheses" fixes "Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that. Inspired by #89958
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-10-16clippy::complexity changesMatthias Krüger-1/+1
2021-10-16Update the syn crate and adopt let_else in three more placesest31-3/+1
The syn crate has gained support for let_else syntax in version 1.0.76, see https://github.com/dtolnay/syn/pull/1057 . In the three instances that use let_else, we've sent code through an attr macro, which would create compile errors when there was no let_else support in syn. To avoid this, we ran `cargo +nightly update -p syn` for updating the syn crate.
2021-10-16Adopt let_else across the compilerest31-3/+2
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-13Rollup merge of #89347 - TaKO8Ki:crate-or-module-typo, r=estebankMatthias Krüger-1/+44
suggestion for typoed crate or module Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules. #76208 before: ``` error[E0433]: failed to resolve: use of undeclared type or module `chono` --> src/main.rs:2:5 | 2 | use chono::prelude::*; | ^^^^^ use of undeclared type or module `chono` ``` after: ``` error[E0433]: failed to resolve: use of undeclared type or module `chono` --> src/main.rs:2:5 | 2 | use chono::prelude::*; | ^^^^^ | | | use of undeclared crate or module `chono` | help: a similar crate or module exists: `chrono` ```
2021-10-13suggestion for typoed crate or moduleTakayuki Maeda-1/+44
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-7/+7
2021-10-08remove unwrap_or! macroklensy-5/+4
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-2/+2
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-2/+2
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-1/+1
2021-10-02resolve: Avoid comparing modules by optional def-idVadim Petrochenkov-15/+19
It makes all block modules identical during comparison
2021-10-02resolve: Cache module loading for all foreign modulesVadim Petrochenkov-23/+36
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-10-01Auto merge of #89417 - Manishearth:rollup-j2gdu95, r=Manishearthbors-33/+119
Rollup of 7 pull requests Successful merges: - #88838 (Do not suggest importing inaccessible items) - #89251 (Detect when negative literal indices are used and suggest appropriate code) - #89321 (Rebase resume argument projections during state transform) - #89327 (Pick one possible lifetime in case there are multiple choices) - #89344 (Cleanup lower_generics_mut and make span be the bound itself) - #89397 (Update `llvm` submodule to fix function name mangling on x86 Windows) - #89412 (Add regression test for issues #88969 and #89119 ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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-32/+118
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-10-01Auto merge of #89395 - ↵bors-1/+1
In-line:remove_visible_path_from_allowed_deprecated_lint, r=jyn514 Remove visible path calculation from allowed deprecation lint
2021-09-30Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, ↵Manish Goregaokar-16/+86
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-30Remove visible path calculation from allowed deprecation lintAlik Aslanyan-1/+1
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-16/+86
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/+6
2021-09-27suggest path for tuple structTakayuki Maeda-1/+7
2021-09-26Improve diagnostics for inaccessible itemsFabian Wolff-18/+73
2021-09-26Do not suggest importing inaccessible itemsFabian Wolff-27/+58
2021-09-25Rollup merge of #89224 - TaKO8Ki:change-the-order-of-suggestions, r=joshtriplettManish Goregaokar-0/+4
Change the order of imports suggestions closes #83564
2021-09-25Auto merge of #87220 - petrochenkov:derivecfglimit2, r=Aaron1011bors-32/+0
Make `#[derive(A, B, ...)]` cfg-eval its input only for `A, B, ...` and stabilize `feature(macro_attributes_in_derive_output)` Stabilization report: https://github.com/rust-lang/rust/pull/87220#issuecomment-881923657 Closes #81119 r? `@Aaron1011`
2021-09-25use `drain_filter` instead of `filter` and `retain`Takayuki Maeda-4/+2
2021-09-24Stabilize `feature(macro_attributes_in_derive_output)`Vadim Petrochenkov-32/+0
2021-09-24resolve: Refactor obtaining `Module` from its `DefId`Vadim Petrochenkov-77/+75
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-20/+13