bohan
1775722410
fix: modify the condition that resolve_imports stops
2023-03-19 20:18:45 +08:00
Vadim Petrochenkov
2a5208011d
resolve: Improve debug impls for NameBinding
...
Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
2023-03-17 13:34:15 +04:00
Vadim Petrochenkov
c83553da31
rustc_middle: Remove trait DefIdTree
...
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
Vadim Petrochenkov
d275114bda
resolve: Remove ImportResolver
...
It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22 21:29:38 +04:00
Oli Scherer
a04e78730e
Use source_span query instead of passing the untracked vec around
2023-02-21 08:29:55 +00:00
bors
2deff71719
Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkov
...
give the resolver access to TyCtxt
The resolver is now created after TyCtxt is created. Then macro expansion and name resolution are run and the results fed into queries just like before this PR.
Since the resolver had (before this PR) mutable access to the `CStore` and the source span table, these two datastructures are now behind a `RwLock`. To ensure that these are not mutated anymore after the resolver is done, a read lock to them is leaked right after the resolver finishes.
### PRs split out of this one and leading up to it:
* https://github.com/rust-lang/rust/pull/105423
* https://github.com/rust-lang/rust/pull/105357
* https://github.com/rust-lang/rust/pull/105603
* https://github.com/rust-lang/rust/pull/106776
* https://github.com/rust-lang/rust/pull/106810
* https://github.com/rust-lang/rust/pull/106812
* https://github.com/rust-lang/rust/pull/108032
2023-02-21 01:19:25 +00:00
Oli Scherer
4953d70e2f
Stuff a TyCtxt into the Resolver
2023-02-20 15:28:59 +00:00
Oli Scherer
6924e3c374
Make untracked.source_span lockable so that resolution can still write to it when using TyCtxt
2023-02-20 15:28:58 +00:00
Oli Scherer
d191de63f0
Prepare for adding a TyCtxt to Resolver
2023-02-20 10:38:48 +00:00
Jacob Pratt
378c4ab9ab
Make public API, docs algorithm-agnostic
2023-02-19 04:11:10 +00:00
Oli Scherer
43a5cc383d
Separate the lifetime of the session and the arena in the resolver
2023-02-14 10:01:25 +00:00
Vadim Petrochenkov
9080b79f2b
rustdoc: Eliminate remaining uses of resolver
2023-02-13 00:10:15 +04:00
Michael Goulet
1d66a675bb
review comment
2023-01-09 18:07:34 +00:00
Michael Goulet
050bc95ce2
Fix some totally useless suggestions
2022-12-27 07:17:22 +00:00
Michael Goulet
d2404d6dca
Dont clobber as .. rename in import suggestion
2022-12-27 07:05:45 +00:00
Michael Goulet
9e2536b938
Note alternative import candidates in nested use tree
2022-12-27 05:09:43 +00:00
Michael Goulet
564435f20a
Suppress suggestions for nested use tree
2022-12-27 05:09:43 +00:00
Oli Scherer
1c1d3570ee
Move the untracked cstore and source_span into a struct
2022-12-09 14:53:24 +00:00
yukang
795b2afd20
fix #105069 , Add AmbiguityError for inconsistent resolution for an import
2022-12-03 22:28:35 +08:00
Vadim Petrochenkov
b32a4edb20
rustc_ast_lowering: Stop lowering imports into multiple items
...
Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-12-01 18:51:20 +03:00
Maybe Waffle
1d42936b18
Prefer doc comments over //-comments in compiler
2022-11-27 11:19:04 +00:00
Matthias Krüger
1edd63f1e7
Rollup merge of #103953 - 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-04 12:18:03 +01:00
Takayuki Maeda
97ddc6343a
remove unused argument from throw_unresolved_import_error
2022-11-04 13:59:04 +09:00
Vadim Petrochenkov
84317518ff
resolve: Turn the binding from #[macro_export] into a proper Import
2022-10-31 21:25:00 +04:00
Vadim Petrochenkov
637bfe68a1
resolve: Not all imports have their own NodeId
2022-10-31 20:25:27 +04:00
Vadim Petrochenkov
ba4834c092
resolve: Revert "Set effective visibilities for imports more precisely"
2022-10-19 18:42:47 +04:00
Vadim Petrochenkov
f767f2297d
resolve: Shadow erroneous glob imports with erroneous single imports
2022-10-16 00:10:16 +04:00
SparrowLii
0571b0af65
suggest candidates for unresolved import
2022-10-10 11:14:32 +08:00
Vadim Petrochenkov
4ddff03917
resolve: Set effective visibilities for imports more precisely
...
Instead of setting them for all primary and additional IDs of the import, only set them for the binding's true ID.
2022-09-22 15:00:24 +03:00
Vadim Petrochenkov
d8d3b83e3a
rustc: Parameterize ty::Visibility over used ID
...
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-07 13:35:41 +04:00
Guillaume Gomez
1aaf9aec95
Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkov
...
optimization of access level table construction
Refactoring which was mentioned in #87487
2022-09-02 11:34:48 +02:00
Oli Scherer
ee3c835018
Always import all tracing macros for the entire crate instead of piecemeal by module
2022-09-01 14:54:27 +00:00
Bryanskiy
10804672c2
access_levels.rs refactor
2022-08-31 14:23:01 +03:00
Vadim Petrochenkov
fc3f3c304b
rustc_middle: Remove Visibility::Invisible
2022-08-27 22:34:18 +03:00
Camille Gillot
611221d8ae
Update compiler/rustc_resolve/src/imports.rs
2022-08-15 20:51:32 +02:00
Camille GILLOT
4a5c46fb02
Manually implement Debug for ImportKind.
2022-08-15 18:29:43 +02:00
Takayuki Maeda
089471b129
change the type of note field to Option<String>
2022-07-28 18:17:55 +09:00
Nicholas Nethercote
0e475b5d5e
Avoid unnecessary work in finalize_resolutions_in.
...
If `module.opt_def_id()` returns `None`, we can skip most of the work.
2022-06-29 09:20:32 +10:00
Takayuki Maeda
0d24405211
implement MacroData
2022-06-15 00:31:21 +09:00
Takayuki Maeda
801725a77b
suggest adding a #[macro_export] to a private macro
2022-06-14 14:58:46 +09:00
Matthias Krüger
daedae7b23
Rollup merge of #97264 - TaKO8Ki:suggest-extern-crate-when-failing-to-resolve-use-crate, r=estebank
...
Suggest `extern crate foo` when failing to resolve `use foo`
closes #97095
r? ``@estebank``
2022-06-01 17:11:05 +02:00
Takayuki Maeda
b2480a0251
suggest extern crate foo when failing to resolve use foo
...
fix ci error
2022-05-25 09:58:19 +09:00
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler
2022-05-20 20:04:54 -04:00
Vadim Petrochenkov
5b5964f569
rustc: Panic by default in DefIdTree::parent
...
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.
Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
Vadim Petrochenkov
7841247ca9
resolve: Rename unusable_binding to ignore_binding
2022-05-01 18:02:37 +03:00
Vadim Petrochenkov
f0e0434feb
resolve: Merge last_import_segment into Finalize
2022-05-01 18:02:35 +03:00
Vadim Petrochenkov
ffedcec4e8
resolve: Pass full Finalize in nearly all cases
2022-05-01 18:02:01 +03:00
Vadim Petrochenkov
900607f49a
resolve: Turn enum Finalize into an optional struct
2022-05-01 17:42:22 +03:00
Dylan DPC
0a8acac7a3
Rollup merge of #95887 - petrochenkov:doclink5, r=cjgillot
...
resolve: Create dummy bindings for all unresolved imports
Apparently such bindings weren't previously created for all unresolved imports, causing issues like https://github.com/rust-lang/rust/issues/95879 .
In this PR I'm trying to create such dummy bindings in a more centralized way by calling `import_dummy_binding` once for all imports in `finalize_imports`.
Fixes https://github.com/rust-lang/rust/issues/95879 .
2022-04-16 14:25:55 +02:00
Camille GILLOT
24b37a7374
Pass last_import_segment and unusable_binding as parameters.
2022-04-12 19:51:46 +02:00