about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-11-13migrating rustc_resolve to SessionDiagnostic. work in progress. startRajput, Rajat-363/+665
implement binding_shadows migrate till self-in-generic-param-default use braces in fluent message as suggested by @compiler-errors. to fix lock file issue reported by CI migrate 'unreachable label' error run formatter name the variables correctly in fluent file SessionDiagnostic -> Diagnostic test "pattern/pat-tuple-field-count-cross.rs" passed test "resolve/bad-env-capture2.rs" passed test "enum/enum-in-scope.rs" and other depended on "resolve_binding_shadows_something_unacceptable" should be passed now. fix crash errors while running test-suite. there might be more. then_some(..) suits better here. all tests passed convert TraitImpl and InvalidAsm. TraitImpl is buggy yet. will fix after receiving help from Zulip migrate "Ralative-2018" migrate "ancestor only" migrate "expected found" migrate "Indeterminate" migrate "module only" revert to the older implementation for now. since this is failing at the moment. follow the convension for fluent variable order the diag attribute as suggested in review comment fix merge error. migrate trait-impl-duplicate make the changes compatible with "Flatten diagnostic slug modules #103345" fix merge remove commented code merge issues fix review comments fix tests
2022-11-13move span to `self` instead of `crate`SparkyPotato-1/+3
2022-11-13fix some typos in commentscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-12Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebankDylan DPC-12/+16
Unhide unknown spans r? ```@estebank```
2022-11-12Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obkDylan DPC-1/+1
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2022-11-11Rollup merge of #103531 - chenyukang:yukang/fix-103474, r=estebankManish Goregaokar-12/+12
Suggest calling the instance method of the same name when method not found Fixes #103474
2022-11-11Print all labels, even if they have no span. Fall back to main item's span.Oli Scherer-12/+16
2022-11-10Rollup merge of #104186 - chenyukang:yukang/fix-104086-let-binding-issue, ↵Manish Goregaokar-18/+17
r=oli-obk Tighten the 'introduce new binding' suggestion Fixes #104086
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-3/+3
2022-11-09DiagnosticBuilder -> DiagnosticMichael Goulet-5/+5
2022-11-10add 'is_assign_rhs' to avoid weird suggesting 'let'yukang-25/+17
2022-11-09fix tests and code cleanupyukang-5/+1
2022-11-09Fix #104086, Tighten the 'introduce new binding' suggestionyukang-7/+18
2022-11-08Auto merge of #103965 - petrochenkov:effvisperf3, r=oli-obkbors-94/+147
resolve: More detailed effective visibility tracking for imports Per-`DefId` tracking is not enough, due to glob imports in particular, which have a single `DefId` for the whole glob import item. We need to track this stuff per every introduced name (`NameBinding`). Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there. Later commits add some debug-only invariant checking and optimiaztions to mitigate regressions in https://github.com/rust-lang/rust/pull/103965#issuecomment-1304256445. This is a bugfix and continuation of https://github.com/rust-lang/rust/pull/102026.
2022-11-05Rollup merge of #103927 - ↵Matthias Krüger-2/+13
fee1-dead-contrib:E0425-no-typo-when-pattern-matching, r=cjgillot Do not make typo suggestions when suggesting pattern matching Fixes #103909.
2022-11-05Do not make typo suggestions when suggesting pattern matchingDeadbeef-2/+13
Fixes #103909.
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-86/+138
Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.
2022-11-04Rollup merge of #103953 - ↵Matthias Krüger-18/+10
TaKO8Ki:remove-unused-arg-from-throw_unresolved_import_error, r=oli-obk Remove unused argument from `throw_unresolved_import_error` `throw_unresolved_import_error` does not need the second argument.
2022-11-04remove unused argument from `throw_unresolved_import_error`Takayuki Maeda-18/+10
2022-11-01Rollup merge of #103760 - petrochenkov:macimp, r=cjgillotDylan DPC-157/+209
resolve: Turn the binding from `#[macro_export]` into a proper `Import` Continuation of https://github.com/rust-lang/rust/pull/91795. ```rust #[macro_export] macro_rules! m { /*...*/ } ``` is desugared to something like ```rust macro_rules! m { /*...*/ } // Non-modularized macro_rules item pub use m; // It's modularized reexport ``` This PR adjusts the internal representation to better match this model.
2022-11-01Rollup merge of #84022 - Aaron1011:remove-derive-res-fallback, r=petrochenkovDylan DPC-70/+13
Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error r? `@ghost`
2022-11-01Rollup merge of #103706 - zbyrn:issue-101637-fix, r=estebankDylan DPC-17/+37
Fix E0433 No Typo Suggestions Fixes #48676 Fixes #87791 Fixes #96625 Fixes #95462 Fixes #101637 Follows up PR #72923 Several open issues refer to the problem that E0433 does not suggest typos like other errors normally do. This fix augments the implementation of PR #72923. **Background** When the path of a function call, e.g. `Struct::foo()`, involves names that cannot be resolved, there are two errors that could be emitted by the compiler: - If `Struct` is not found, it is ``E0433: failed to resolve: use of undeclared type `Struct` ``. - If `foo` is not found in `Struct`, it is ``E0599: no function or associated item named `foo` found for struct `Struct` in the current scope`` When a name is used as a type, `e.g. fn foo() -> Struct`, and the name cannot be resolved, it is ``E0412: cannot find type `Struct` in this scope``. Before #72923, `E0433` does not implement any suggestions, and the PR introduces suggestions for missing `use`s. When a resolution error occurs in the path of a function call, it tries to smart resolve just the type part of the path, e.g. `module::Struct` of a call to `module::Struct::foo()`. However, along with the suggestions, the smart-resolve function will report `E0412` since it only knows that it is a type that we cannot resolve instead of being a part of the path. So, the original implementation swap out `E0412` errors returned by the smart-resolve function with the real `E0433` error, but keeps the "missing `use`" suggestions to be reported to the programmer. **Issue** The current implementation only reports if there are "missing `use`" suggestions returned by the smart-resolve function; otherwise, it would fall back the normal reporting, which does not emit suggestions. But the smart-resolve function could also produce typo suggestions, which are omitted currently. Also, it seems like that not all info has been swapped out when there are missing suggestions. The error message underlining the name in the snippet still says ``not found in this scope``, which is a `E0412` messages, if there are `use` suggestions, but says the normal `use of undeclared type` otherwise. **Fixes** This fix swaps out all fields in `Diagnostic` returned by the smart-resolve function except for `suggestions` with the current error, and merges the `suggestions` of the returned error and that of the current error together. If there are `use` suggestions, the error is saved to `use_injection` to be reported at the end; otherwise, the error is emitted immediately as `Resolver::report_error` does. Some tests are updated to use the correct underlining error messages, and one additional test for typo suggestion is added to the test suite. r? rust-lang/diagnostics
2022-10-31resolve: Turn the binding from `#[macro_export]` into a proper `Import`Vadim Petrochenkov-54/+68
2022-10-31resolve: Not all imports have their own `NodeId`Vadim Petrochenkov-104/+142
2022-10-30Rollup merge of #103560 - zbyrn:issue-103358-fix, r=cjgillotDylan DPC-29/+52
Point only to the identifiers in the typo suggestions of shadowed names instead of the entire struct Fixes #103358. As discussed in the issue, the `Span` of the candidate `Ident` for a typo replacement is stored alongside its `Symbol` in `TypoSuggestion`. Then, the span of the identifier is what the "you might have meant to refer to" note is pointed at, rather than the entire struct definition. Comments in #103111 and the issue both suggest that it is desirable to: 1. include names defined in the same crate as the typo, 2. ignore names defined elsewhere such as in `std`, _and_ 3. include names introduced indirectly via `use`. Since a name from another crate but introduced via `use` has non-local `def_id`, to achieve this, a suggestion is displayed if either the `def_id` of the suggested name is local, or the `span` of the suggested name is in the same file as the typo itself. Some UI tests have also been modified to reflect this change. r? `@cjgillot`
2022-10-30Rollup merge of #103726 - TaKO8Ki:avoid-&str-to-string-conversions, ↵Matthias Krüger-4/+1
r=compiler-errors Avoid unnecessary `&str` to `String` conversions
2022-10-29Auto merge of #103450 - cjgillot:elision-nodedup, r=Mark-Simulacrumbors-34/+69
Do not consider repeated lifetime params for elision. Fixes https://github.com/rust-lang/rust/issues/103330
2022-10-29avoid unnecessary `&str` to `String` conversionsTakayuki Maeda-4/+1
2022-10-27Only ban duplication across parameters.Camille GILLOT-31/+67
2022-10-27Remove redundant bracesByron Zhong-4/+3
2022-10-27Fix E0433 diagnostics ignoring typo suggestions and outputing wrong messageByron Zhong-16/+37
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-41/+41
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26Rollup merge of #103520 - petrochenkov:resout, r=cjgillotDylan DPC-14/+13
rustc_middle: Rearrange resolver outputs structures slightly Addresses https://github.com/rust-lang/rust/pull/98106#discussion_r898427061. I also haven't seen the motivation for moving `cstore` from its old place, so I moved it back in this PR. r? ```@cjgillot```
2022-10-25Modify check to output 'you might have meant' for indirect referenceByron Zhong-2/+15
2022-10-25Add check to only output 'you might have meant' when the candidate name is ↵Byron Zhong-1/+2
in the same crate
2022-10-25Add Span in TypoSuggestion and TypoCandidateByron Zhong-30/+39
2022-10-26Auto merge of #103158 - Bryanskiy:resolve_perf, r=petrochenkovbors-11/+11
Perf improvements for effective visibility calculating related to https://github.com/rust-lang/rust/pull/102026 r? `@petrochenkov`
2022-10-26suggest calling the method of the same name when method not foundyukang-12/+12
2022-10-25Perf improvements for effective visibility calculatingBryanskiy-11/+11
2022-10-25rustc_middle: Rearrange resolver outputs structures slightlyVadim Petrochenkov-14/+13
2022-10-25Rollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiserYuki Okushi-13/+29
Change terminology for assoc method suggestions when they are not called Fixes #103325 ```@rustbot``` label +A-diagnostics
2022-10-24Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard errorAaron Hill-70/+13
2022-10-23Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebankMichael Howell-2/+14
Add diagnostic for calling a function with the same name with unresolved Macro Fixes #103112
2022-10-23Do not consider repeated lifetime params for elision.Camille GILLOT-5/+5
2022-10-23Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obkDylan DPC-35/+18
resolve: Revert "Set effective visibilities for imports more precisely" In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components. Fixes https://github.com/rust-lang/rust/issues/102352 r? `@oli-obk`
2022-10-23Rollup merge of #101908 - chenyukang:fix-101880, r=estebankDylan DPC-53/+51
Suggest let for assignment, and some code refactor Fixes #101880
2022-10-21Different suggestions for when associated functions are referred toclubby789-13/+29
2022-10-21Rollup merge of #103111 - cjgillot:shadow-label, r=estebankDylan DPC-14/+69
Account for hygiene in typo suggestions, and use them to point to shadowed names Fixes https://github.com/rust-lang/rust/issues/97459 r? `@estebank`
2022-10-20Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obkMatthias Krüger-3/+3
Fix `SelfVisitor::is_self_ty` ICE Fixes #103202