-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Resolver: Batched Import Resolution #145108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Resolver: Batched Import Resolution #145108
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Code looks a little better now and should be more correct than the previous commits, but I have yet to find a way to resolve the current test failures. |
This comment has been minimized.
This comment has been minimized.
Okey, I did fix |
a3f8ae2
to
4a2a0dc
Compare
This comment has been minimized.
This comment has been minimized.
Could you update the tests to make CI green, so I can see the difference? |
tests/ui/imports/ambiguous-9.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is definitely wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is wrong as well.
Moving |
I'll create a pr for it. |
This comment has been minimized.
This comment has been minimized.
I have no idea why these errors are still thrown. It has to do with the structure of the modules where we import // Separate module to reexport the macro `Debug` from prelude without the trait `Debug`.
pub(crate) mod macros {
/// Derive macro generating an impl of the trait `Debug`.
pub macro Debug($item:item) {
/* compiler built-in */
}
}
pub use macros::Debug; Same with `simd. mod core_simd;
#[unstable(feature = "portable_simd", issue = "86656")]
pub mod simd {
pub use crate::core_simd::simd::*;
} But it's pretty hard to debug this. Maybe you know a way? Or have a separate set of eyes look at this? And then there are Edit, is it possible this comment above
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The libcore errors appear when |
Maybe the commit loop will have to be split into two loops, the first one just setting |
This comment was marked as resolved.
This comment was marked as resolved.
I do not entirely agree with this. The errors started happening when we began using Reverting those changes did not resolve some of the errors; it even introduced new ones.
I've not been successful with this, but I should be getting close.
Thought of that as well, and this produces other errors. I've also noticed that meddling with the commit order produces a lot of different errors that make no more sense than the current ones. The most successful I've been in producing as few errors as possible is by first committing the glob side effects and then the single import side effects. The only errors that stay present are resolutions made of |
Currently doing this. |
fn resolve_import<'r>(mut self: CmResolver<'r, 'ra, 'tcx>, import: Import<'ra>) -> usize { | ||
/// Meanwhile, if resolution is successful, the side effect of the resolution is returned. | ||
fn resolve_import<'r>( | ||
self: &mut CmResolver<'r, 'ra, 'tcx>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self: &mut CmResolver<'r, 'ra, 'tcx>, | |
&self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does require some type of cm()
on a &Resolver
instead of a `&mut Resolver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires a &self
version of per_ns
.
per_ns(&self)
/per_ns_mut(&mut self)
, plus per_ns_cm(self: CmResolver)
if it's still used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I don't understand what you mean. I can't figure out how to pass a &Resolver
to resolve_imports
and then easily convert it to a CmResolver
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean nothing in resolve_import
should require &mut Resolver
or CmResolver
, only &Resolver
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That defeats the purpose of CmResolver
, no? maybe_resolve_path
and maybe_resolve_ident_in_module
require a CmResolver
. How do you expect me to change those? I could rename them to spec_*
and use CmResolver
in those functions.
Sorry for still not understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, how did I do it on my branch https://github.com/petrochenkov/rust/tree/batched-import-resolution then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, alright, resolve_glob_import
can use &self
, resolve_import
cannot.
resolve_import
can use CmResolver
by value though.
&mut CmResolver
almost never makes sense, because CmResolver
is already a reference, you can search for other uses of &mut CmResolver
and can try eliminating them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed resolve_glob_import
but resolve_import
still gets a CmResolver
. That's a good change, but i think resolve_import is how it should be for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve_import can use CmResolver by value though.
&mut CmResolver almost never makes sense, because CmResolver is already a reference, you can search for other uses of &mut CmResolver and can try eliminating them.
Oh right, thats true, thanks!
@@ -1484,66 +1583,47 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||
false | |||
} | |||
|
|||
fn resolve_glob_import(&mut self, import: Import<'ra>) { | |||
fn resolve_glob_import<'r>( | |||
self: &mut CmResolver<'r, 'ra, 'tcx>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self: &mut CmResolver<'r, 'ra, 'tcx>, | |
&self, |
3b2e50e
to
4efdee8
Compare
This comment has been minimized.
This comment has been minimized.
Original resolver errors are resolved, but... |
Collect side effects from the current set of undetermined imports and only apply them at the end.
4efdee8
to
8499dd2
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Some tests get different or duplicate errors on some lines. Not sure why this is yet. |
This comment was marked as resolved.
This comment was marked as resolved.
Had to bless/change a lot of tests, but they all look like duplicates; I didn't spot anything wrong going on. |
Answered on zulip about this. |
) { | ||
self.determined_imports.reserve(self.determined_imports.len()); | ||
for (import, side_effect) in import_resolutions.iter() { | ||
self.determined_imports.push(*import); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We push determined_imports
both here and above in resolve_imports
, that's where the duplication is coming from, most likely.
Transforms the current algorithm for resolving imports to a batched algorithm. Every import in the
indeterminate_imports
set is resolved in isolation. This is the only real difference from the current algorithm.r? petrochenkov