Skip to content

Commit e6d1789

Browse files
catch both Pending and Ready(None)
1 parent e6e3a41 commit e6d1789

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::{Ident, Span, kw, sym};
1313
use tracing::{debug, instrument};
1414

1515
use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
16-
use crate::imports::Import;
16+
use crate::imports::{Import, Progress};
1717
use crate::late::{ConstantHasGenerics, NoConstantGenericsReason, PathSource, Rib, RibKind};
1818
use crate::macros::{MacroRulesScope, sub_namespace_match};
1919
use crate::{
@@ -983,12 +983,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
983983
if source != target {
984984
// This branch allows the binding to be defined or updated later if the target name
985985
// can hide the source.
986-
if bindings.iter().all(|binding| binding.get().is_pending()) {
986+
if bindings.iter().all(|binding| {
987+
matches!(binding.get(), Progress::Pending | Progress::Ready(None))
988+
}) {
987989
// None of the target bindings are available, so we can't determine
988990
// if this binding is correct or not.
989991
// See more details in #124840
990992
return Err((Undetermined, Weak::No));
991-
} else if bindings[ns].get().is_pending() && binding.is_some() {
993+
} else if matches!(bindings[ns].get(), Progress::Pending | Progress::Ready(None))
994+
&& binding.is_some()
995+
{
992996
// `binding.is_some()` avoids the condition where the binding
993997
// truly doesn't exist in this namespace and should return `Err(Determined)`.
994998
return Err((Undetermined, Weak::No));

compiler/rustc_resolve/src/imports.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use crate::{
4242
type Res = def::Res<NodeId>;
4343

4444
// Poll is a weird name.
45-
use std::task::Poll as Progress;
45+
pub(crate) use std::task::Poll as Progress;
4646

4747
/// Contains data for specific kinds of imports.
4848
#[derive(Clone)]
@@ -490,7 +490,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
490490
// or indeterminate resolution, also mark such failed imports as used to avoid duplicate diagnostics.
491491
fn import_dummy_binding(&mut self, import: Import<'ra>, is_indeterminate: bool) {
492492
if let ImportKind::Single { target, ref bindings, .. } = import.kind {
493-
if !(is_indeterminate || bindings.iter().all(|binding| binding.get().is_pending())) {
493+
if !(is_indeterminate
494+
|| bindings.iter().all(|binding| {
495+
matches!(binding.get(), Progress::Pending | Progress::Ready(None))
496+
}))
497+
{
494498
return; // Has resolution, do not create the dummy binding
495499
}
496500
let dummy_binding = self.dummy_binding;

0 commit comments

Comments
 (0)