summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2021-10-16clippy::complexity changesMatthias Krüger-1/+1
2021-10-13suggestion for typoed crate or moduleTakayuki Maeda-0/+28
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-02resolve: Avoid comparing modules by optional def-idVadim Petrochenkov-2/+2
It makes all block modules identical during comparison
2021-09-30Rollup merge of #88838 - FabianWolff:issue-88472, r=estebankManish Goregaokar-31/+109
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/+27
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-29Suggest similarly named assoc items in trait implsHirochika Matsumoto-3/+27
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-26Improve diagnostics for inaccessible itemsFabian Wolff-17/+64
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/+3
Change the order of imports suggestions closes #83564
2021-09-25use `drain_filter` instead of `filter` and `retain`Takayuki Maeda-4/+1
2021-09-24resolve: Refactor obtaining `Module` from its `DefId`Vadim Petrochenkov-2/+1
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-25change the order of path suggestionsTakayuki Maeda-0/+6
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-2/+1
2021-08-30rename const_evaluatable_checked to generic_const_exprsEllen-2/+2
:sparkles:
2021-08-23Improve wording of macro-not-found-but-name-exists note.Mara Bos-8/+18
2021-08-23Show what things are, but also what they are not.Mara Bos-1/+7
2021-08-23Don't confuse the user with notes about tool modules.Mara Bos-5/+5
2021-08-23Clarify what attribute and derive macros look like.Mara Bos-1/+2
2021-08-23Say what things are, instead of what they are not.Mara Bos-10/+9
2021-08-23Silence confusing 'unused import' warnings.Mara Bos-0/+3
2021-08-23Look for macro names in all namespaces for diagnostics.Mara Bos-0/+33
2021-08-22Suggest importing the right kind of macro.Mara Bos-3/+1
2021-08-06Add hint for unresolved associated trait items if the trait has a single itemJakub Beránek-19/+43
2021-07-14Change type param -> generic paramEllen-3/+3
2021-06-01Add test for forward declared const param defaultsEllen-1/+1
2021-05-19Disallow shadowing const parametersFabian Wolff-9/+14
2021-04-29make feature recommendations optionallcnr-1/+7
2021-04-21fix name resolution for param defaultslcnr-11/+0
2021-04-11detect when suggested paths enter extern crates more rigorouslySNCPlay42-11/+7
2021-03-27resolve: Partially unify early and late scope-relative ident resolutionVadim Petrochenkov-2/+2
2021-03-23Some refactoringvarkor-2/+2
2021-02-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-3/+3
Refactor `PrimitiveTypeTable` for Clippy I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-05Small refactor with Iterator::reduceCameron Steffen-3/+2
2021-02-03Refactor out PrimitiveTypeTableCameron Steffen-3/+3
2021-01-29fix typoHenry Boisdequin-1/+1
2021-01-17resolve: Reject ambiguity built-in attr vs different built-in attrVadim Petrochenkov-1/+1
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-1/+2
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
2021-01-07Use correct span for structured suggestionEsteban Küber-8/+18
On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-1/+2
2021-01-07Add pointing const identifier when emitting E0435Daiki Ihara-1/+7
2020-11-24Move lev_distance to rustc_ast, make non-genericArlie Davis-2/+2
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing unnecessarily design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated at nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.
2020-11-24Swap note for helpmendess-1/+1
2020-11-24Requested changesmendess-1/+1
2020-11-24Add note to use nightly when using expr in const genericsmendess-0/+1
2020-11-20update bug message for cgBastian Kauschke-1/+1
2020-11-19resolve: Introduce a separate `NonMacroAttrKind` for legacy derive helpersVadim Petrochenkov-1/+1
2020-11-13Auto merge of #78826 - petrochenkov:mrscopes2, r=eddybbors-1/+1
resolve: Collapse `macro_rules` scope chains on the fly Otherwise they grow too long and you have to endlessly walk through them when resolving macros or imports. Addresses https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Slow.20Builtin.20Derives/near/215750815
2020-11-08rustc_resolve: Use `#![feature(format_args_capture)]`Vadim Petrochenkov-37/+11
2020-11-07resolve: Collapse `macro_rules` scope chains on the flyVadim Petrochenkov-1/+1
2020-10-30Add back missing commentsJoshua Nelson-0/+1