summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2020-07-11Rollup merge of #74213 - pickfire:patch-1, r=jonas-schievinkManish Goregaokar-3/+1
Minor refactor for rustc_resolve diagnostics match Use `matches!` instead of old `if let`
2020-07-11Rollup merge of #74197 - estebank:self-sugg, r=petrochenkovManish Goregaokar-2/+2
Reword incorrect `self` token suggestion
2020-07-11Rollup merge of #74168 - JohnTitor:help-for-in-band-lifetimes, r=petrochenkovManish Goregaokar-0/+11
Add a help to use `in_band_lifetimes` in nightly Fixes #73775
2020-07-10Avoid "whitelist"Tamir Duberstein-1/+1
Other terms are more inclusive and precise.
2020-07-10Minor refactor for rustc_resolve diagnostics matchIvan Tham-3/+1
Use `matches!` instead of old `if let`
2020-07-10Tweak wordingYuki Okushi-1/+1
2020-07-10Add a help to use `in_band_lifetimes` in nightlyYuki Okushi-0/+11
2020-07-09Reword incorrect `self` token suggestionEsteban Küber-2/+2
2020-07-09Rollup merge of #74188 - estebank:tweak-ascription-typo-heuristic, ↵Manish Goregaokar-35/+33
r=petrochenkov Tweak `::` -> `:` typo heuristic and reduce verbosity Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription. Clean up indentation. r? @petrochenkov
2020-07-09Rollup merge of #74150 - tamird:blocklist, r=nikomatsakisManish Goregaokar-23/+23
Avoid "blacklist" Other terms are more inclusive and precise. Clippy still has a lint named "blacklisted-name", but renaming it would be a breaking change, so is left for future work. The target configuration option "abi-blacklist" has been depreciated and renamed to "unsupported-abis". The old name continues to work.
2020-07-09Reduce indentationEsteban Küber-35/+33
2020-07-08Avoid "blacklist"Tamir Duberstein-23/+23
Other terms are more inclusive and precise. Clippy still has a lint named "blacklisted-name", but renaming it would be a breaking change, so is left for future work. The target configuration option "abi-blacklist" has been depreciated and renamed to "unsupported-abis". The old name continues to work.
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-2/+2
2020-07-02resolve: disallow label use through closure/asyncDavid Wood-81/+200
This commit modifies resolve to disallow `break`/`continue` to labels through closures or async blocks. This doesn't make sense and should have been prohibited anyway. Signed-off-by: David Wood <david@davidtw.co>
2020-07-01Remove `token::FlattenGroup`Vadim Petrochenkov-2/+2
2020-06-27Rename two `Resolver` traitsVadim Petrochenkov-10/+9
2020-06-26Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morseManish Goregaokar-3/+3
Record span of `const` kw in GenericParamKind Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
2020-06-26proc_macro: Stop flattening groups with dummy spansVadim Petrochenkov-2/+2
2020-06-24Rollup merge of #73652 - da-x:add-reexported-to-use-suggestions, r=petrochenkovDylan DPC-8/+27
Add re-exports to use suggestions In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead. ```rust mod foo { mod bar { pub struct X; } pub use self::bar::X; } fn main() { X; } ``` This fixes the issue.
2020-06-23Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petrochenkovManish Goregaokar-95/+177
Move remaining `NodeId` APIs from `Definitions` to `Resolver` Implements https://github.com/rust-lang/rust/pull/73291#issuecomment-643515557 TL;DR: it moves all fields that are only needed during name resolution passes into the `Resolver` and keep the rest in `Definitions`. This effectively enforces that all references to `NodeId`s are gone once HIR lowering is completed. After this, the only remaining work for #50928 should be to adjust the dev guide. r? @petrochenkov
2020-06-23Review fixesDan Aloni-2/+7
2020-06-23Record span of `const` kw in GenericParamKindAyaz Hafiz-3/+3
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
2020-06-23Add re-exports to use suggestionsDan Aloni-8/+22
In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead. ``` mod foo { mod bar { pub struct X; } pub use self::bar::X; } fn main() { X; } ``` This fixes the issue.
2020-06-22Rollup merge of #72623 - da-x:use-suggest-public-path, r=petrochenkovDylan DPC-23/+49
Prefer accessible paths in 'use' suggestions This PR addresses issue https://github.com/rust-lang/rust/issues/26454, where `use` suggestions are made for paths that don't work. For example: ```rust mod foo { mod bar { struct X; } } fn main() { X; } // suggests `use foo::bar::X;` ```
2020-06-21Move `next_disambiguator` to `Resolver`marmeladema-1/+13
2020-06-21Always create a root definition when creating a new `Definitions` object.marmeladema-6/+6
2020-06-21Move remaining `NodeId` APIs from `Definitions` to `Resolver`marmeladema-94/+164
2020-06-21Prefer accessible paths in 'use' suggestionsDan Aloni-23/+49
This fixes an issue with the following sample: mod foo { mod inaccessible { pub struct X; } pub mod avail { pub struct X; } } fn main() { X; } Instead of suggesting both `use crate::foo::inaccessible::X;` and `use crate::foo::avail::X;`, it should only suggest the latter. It is done by trimming the list of suggestions from inaccessible paths if accessible paths are present. Visibility is checked with `is_accessible_from` now instead of being hard-coded. - Some tests fixes are trivial, and others require a bit more explaining, here are my comments: src/test/ui/issues/issue-35675.stderr: Only needs to make the enum public to have the suggestion make sense. src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't help because its constructor is not visible, so the attempted constructor does not work. In that case, it's better not to suggest it. The case where the constructor is public is covered in `issue-26545.rs`.
2020-06-20Rollup merge of #73291 - marmeladema:hir-id-ification-fix, r=petrochenkovManish Goregaokar-11/+4
Pre-compute `LocalDefId` <-> `HirId` mappings and remove `NodeId` <-> `HirId` conversion APIs cc #50928 I don't know who is exactly the best person to review this. r? @petrochenkov
2020-06-20Correctly handle binders inside trait predicatesMatthew Jasper-5/+8
2020-06-20Move `trait_map` into `hir::Crate`marmeladema-11/+4
2020-06-19Rollup merge of #73357 - petrochenkov:tmap, r=davidtwcoManish Goregaokar-25/+9
Use `LocalDefId` for import IDs in trait map cc https://github.com/rust-lang/rust/pull/73291#discussion_r439734867
2020-06-18Rollup merge of #73320 - estebank:type-param-sugg-more, r=davidtwcoManish Goregaokar-14/+44
Make new type param suggestion more targetted Do not suggest new type param when encountering a missing type in an ADT field with generic parameters. Fix #72640.
2020-06-17review commentsEsteban Küber-6/+8
2020-06-16Suggest new type param on single char identEsteban Küber-8/+33
Suggest new type parameter on single char uppercase ident even if it doesn't appear in a field's type parameter. Address comment in #72641.
2020-06-15Use `LocalDefId` for import IDs in trait mapVadim Petrochenkov-25/+9
2020-06-15Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakisbors-59/+34
Clean up type alias impl trait implementation - Removes special case for top-level impl trait - Removes associated opaque types - Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types. - Handle lifetimes in type alias impl trait more uniformly with other parameters cc #69323 cc #63063 Closes #57188 Closes #62988 Closes #69136 Closes #73061
2020-06-13Make new type param suggestion more targettedEsteban Küber-7/+10
Do not suggest new type param when encountering a missing type in an ADT field with generic parameters. Fix #72640.
2020-06-12Rollup merge of #73178 - petrochenkov:explint, r=varkorDylan DPC-4/+14
expand: More precise locations for expansion-time lints First commit: a macro expansion doesn't have a `NodeId` associated with it, but it has a parent `DefId` which we can use for linting. The observable effect is that lints associated with macro expansions can now be `allow`ed at finer-grained level than whole crate. Second commit: each macro definition has a `NodeId` which we can use for linting, unless that macro definition was decoded from other crate.
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-1/+1
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-11Document some opaque types codeMatthew Jasper-2/+2
2020-06-11Rename `TyKind::Def` to `OpaqueDef`Matthew Jasper-4/+4
2020-06-11Forbid lifetime elision in let position impl TraitMatthew Jasper-1/+12
This is consistent with types.
2020-06-11Remove associated opaque typesMatthew Jasper-39/+1
They're unused now.
2020-06-11Stop special casing top level TAITMatthew Jasper-19/+21
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-1/+1
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-10Rollup merge of #73023 - ayushmishra2005:remove_noisy_suggestion, r=davidtwcoDylan DPC-1/+3
Remove noisy suggestion of hash_map Remove noisy suggestion of hash_map #72642 fixes #72642
2020-06-10Rollup merge of #72789 - petrochenkov:impcand, r=davidtwcoDylan DPC-4/+14
resolve: Do not suggest imports from the same module in which we are resolving Based on the idea from https://github.com/rust-lang/rust/pull/72623.
2020-06-09expand: Give reasonable NodeIds to lints associated with macro expansionsVadim Petrochenkov-4/+14
2020-06-09Remove noisy suggestion of hash_map #72642Ayush Kumar Mishra-1/+3
Fixed failing test-cases Remove noisy suggestion of hash_map #72642 Fixed failing test-cases