-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Resolve: merge source_bindings
and target_bindings
into bindings
#143685
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?
Resolve: merge source_bindings
and target_bindings
into bindings
#143685
Conversation
I used |
This comment has been minimized.
This comment has been minimized.
@@ -40,6 +41,9 @@ use crate::{ | |||
|
|||
type Res = def::Res<NodeId>; | |||
|
|||
// Poll is a weird name. | |||
use std::task::Poll as Progress; |
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.
It feels weird to reuse std::task::Poll
when you are not using futures.
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.
Yeah, Vadim said in #gsoc > Project: Parallel Macro Expansion @ 💬 it was semantically correct as well.
I find it to convey the message more clearly than Option<Option<...>>
. Option::None
doesn't say anything that we're still trying to resolve it, but Progress::Pending
does. And Progres::Ready(None)
is also clearer than Option::Some(None)
.
If this is something that is not done, I'll change it.
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.
Defining your own Progress
enum would work, right? But I will leave it up to Vadim if they agree.
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.
Let's finish the correct implementation first, and then decide on the enum choice.
Unfortunately, this didn't fix the fail. I'll investigate it tomorrow. |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
e6d1789
to
564c205
Compare
source_bindings
and target_bindings
into 1 fieldsource_bindings
and target_bindings
into 1 field
source_bindings
and target_bindings
into 1 fieldsource_bindings
and target_bindings
into bindings
This comment has been minimized.
This comment has been minimized.
compiler/rustc_resolve/src/lib.rs
Outdated
@@ -891,6 +891,13 @@ impl<'ra> NameBindingData<'ra> { | |||
} | |||
} | |||
|
|||
fn maybe_source_binding(&self) -> Option<NameBinding<'ra>> { |
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.
fn maybe_source_binding(&self) -> Option<NameBinding<'ra>> { | |
fn import_source(&self) -> NameBinding<'ra> { |
I don't think you ever need either one or another.
compiler/rustc_resolve/src/lib.rs
Outdated
fn maybe_source_binding(&self) -> Option<NameBinding<'ra>> { | ||
match self.kind { | ||
NameBindingKind::Import { binding, .. } => Some(binding), | ||
_ => None, |
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.
_ => None, | |
_ => unreachable!(), |
@@ -24,7 +25,7 @@ use rustc_span::{Ident, Span, Symbol, kw, sym}; | |||
use smallvec::SmallVec; | |||
use tracing::debug; | |||
|
|||
use crate::Determinacy::{self, *}; | |||
use crate::Determinacy::{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.
use crate::Determinacy::{self}; | |
use crate::Determinacy; |
Weird importing.
&& source.name == kw::SelfLower | ||
// Silence `unresolved import` error if E0429 is already emitted | ||
&& let Err(Determined) = source_bindings.value_ns.get() | ||
// `indings` here is "target_bindings", if it is "Err(Determined)" then `source_bindings` as well. |
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 comment is only useful in context of this PR, and can be removed.
} else { | ||
return; | ||
}; | ||
|
||
let parent = import.parent_scope.module; | ||
match source_bindings[ns].get() { | ||
Ok(binding) => { | ||
match bindings[ns].get() { |
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 think this match can be merged into the match above, they are exactly the same.
@@ -1340,7 +1346,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||
let mut full_path = import.module_path.clone(); | |||
full_path.push(Segment::from_ident(ident)); | |||
self.per_ns(|this, ns| { | |||
if let Ok(binding) = source_bindings[ns].get() { | |||
if let Progress::Ready(Some(binding)) = bindings[ns].get() { |
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.
maybe_source_binding
was not applied here.
@@ -838,22 +832,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||
let mut indeterminate_count = 0; | |||
self.per_ns(|this, ns| { | |||
if !type_ns_only || ns == TypeNS { | |||
if let Err(Undetermined) = source_bindings[ns].get() { | |||
let binding = this.maybe_resolve_ident_in_module( | |||
if let Progress::Pending = bindings[ns].get() { |
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 have a strange feeling I should do the source_binding
extraction here as well? And if not, why shouldn't it be?
@rustbot ready |
Attempts to merge the 2 fields
source_bindings
andtarget_bindings
ofImportKind::Single
into 1 field calledbindings
.r? @petrochenkov