about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
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
2020-06-08Rollup merge of #73090 - marmeladema:resolver-outputs-local-def-id, ↵Dylan DPC-28/+8
r=petrochenkov Use `LocalDefId` directly in `Resolver::export_map` This is to avoid the final conversion from `NodeId` to `HirId` during call to `(clone|into)_outputs` This brings down the post-lowering uses of `NodeId` down to 2 calls to convert the `trait_map`. cc #50928 r? @petrochenkov
2020-06-08Rollup merge of #73075 - jyn514:comment-module, r=Dylan-DPCRalf Jung-0/+6
Add comments to `Resolve::get_module` r? @Manishearth
2020-06-07Use `LocalDefId` directly in `Resolver::export_map` and `module_exports` querymarmeladema-28/+8
This is to avoid the final conversion from `NodeId` to `HirId` during call to `Resolver::(clone|into)_outputs`.
2020-06-06Add comments to `Resolve::get_module`Joshua Nelson-0/+6
2020-06-06Auto merge of #72927 - petrochenkov:rustc, r=Mark-Simulacrumbors-7/+8
Rename all remaining compiler crates to use the `rustc_foo` pattern libarena -> librustc_arena libfmt_macros -> librustc_parse_format libgraphviz -> librustc_graphviz libserialize -> librustc_serialize Closes https://github.com/rust-lang/rust/issues/71177 in particular.
2020-06-05Auto merge of #72982 - tblah:riscv-ui-tests, r=estebankbors-1/+2
resolve: Sort E0408 errors by Symbol str This is a request for comments implementing my suggested solution to https://github.com/rust-lang/rust/issues/72913 Previously errors were sorted by Symbol index instead of the string. The indexes are not the same between architectures because Symbols for architecture extensions (e.g. x86 AVX or RISC-V d) are interned before the source file is parsed. RISC-V's naming of extensions after single letters led to it having errors sorted differently for test cases using single letter variable names. Instead sort the errors by the Symbol string so that it is stable across architectures. While I was at it, there's also 8edb05c2 skipping some ui tests which I think are irrelevant for risc-v.
2020-06-04resolve: Sort E0408 errors by Symbol strTom Eccles-1/+2
Previously errors were sorted by Symbol index instead of the string. The indexes are not the same between architectures because Symbols for architecture extensions (e.g. x86 AVX or RISC-V d) are interned before the source file is parsed. RISC-V's naming of extensions after single letters led to it having errors sorted differently for test cases using single letter variable names. Instead sort the errors by the Symbol string so that it is stable across architectures.
2020-06-03Fix a typo in `late.rs`Patryk Wychowaniec-1/+1
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2020-06-02Improve E0433, so that it suggests missing importsPatryk Wychowaniec-41/+130
2020-06-02Rename the crates in source codeVadim Petrochenkov-7/+8
2020-06-02Make things build againVadim Petrochenkov-1/+1
2020-05-30resolve: Do not suggest imports from the same module in which we are resolvingVadim Petrochenkov-2/+6
2020-05-30resolve: Pass parent scope to the function providing import suggestionsVadim Petrochenkov-3/+9
2020-05-30Use `LocalDefId` instead of `NodeId` in `resolve_str_path_error`marmeladema-5/+2
2020-05-29Remove remaining calls to `as_local_node_id`marmeladema-28/+43
2020-05-27Store `LocalDefId` directly in `rustc_resolve::Resolver` where possiblemarmeladema-57/+30
This commit also include the following changes: * Remove unused `hir::Map::as_local_node_id` method * Remove outdated comment about `hir::Map::local_def_id` method * Remove confusing `GlobMap` type alias * Use `LocalDefId` instead of `DefId` in `extern_crate_map` * Use `LocalDefId` instead of `DefId` in `maybe_unused_extern_crates` * Modify `extern_mod_stmt_cnum` query to accept a `LocalDefId` instead of a `DefId`
2020-05-25Rollup merge of #72308 - Aaron1011:fix/hygiene-error-message, r=matthewjasperDylan DPC-4/+12
Emit a better diagnostic when function actually has a 'self' parameter Fixes #66898 When we are unable to resolve a reference to `self`, we current assume that the containing function doesn't have a `self` parameter, and emit an error message accordingly. However, if the reference to `self` was created by a macro invocation, then resolution will correctly fail, due to hygiene. In this case, we don't want to tell the user that the containing fuction doesn't have a 'self' paramter if it actually has one. This PR checks for the precense of a 'self' parameter, and adjusts the error message we emit accordingly. TODO: The exact error message we emit could probably be improved. Should we explicitly mention hygiene?
2020-05-24Rollup merge of #72402 - marmeladema:resolver-outputs-def-id, r=ecstatic-morseRalf Jung-13/+101
Remove all uses of `NodeId` in `ResolverOutputs` cc #50928 r? @ecstatic-morse
2020-05-22Remove `macro_defs` mapAaron Hill-14/+14
We store store the `DefId` directly in `ExpnData`. This will allow us to serialize `ExpnData` in PR #72121 without needing to manage a side table.