Rollup merge of #102889 - petrochenkov:partres, r=cjgillot
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
This commit is contained in:
commit
cb67283392
12 changed files with 75 additions and 90 deletions
|
@ -205,13 +205,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
let static_def_id = self
|
let static_def_id = self
|
||||||
.resolver
|
.resolver
|
||||||
.get_partial_res(sym.id)
|
.get_partial_res(sym.id)
|
||||||
.filter(|res| res.unresolved_segments() == 0)
|
.and_then(|res| res.full_res())
|
||||||
.and_then(|res| {
|
.and_then(|res| match res {
|
||||||
if let Res::Def(DefKind::Static(_), def_id) = res.base_res() {
|
Res::Def(DefKind::Static(_), def_id) => Some(def_id),
|
||||||
Some(def_id)
|
_ => None,
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(def_id) = static_def_id {
|
if let Some(def_id) = static_def_id {
|
||||||
|
|
|
@ -1044,9 +1044,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
if let ExprKind::Path(qself, path) = &expr.kind {
|
if let ExprKind::Path(qself, path) = &expr.kind {
|
||||||
// Does the path resolve to something disallowed in a tuple struct/variant pattern?
|
// Does the path resolve to something disallowed in a tuple struct/variant pattern?
|
||||||
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
|
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
|
||||||
if partial_res.unresolved_segments() == 0
|
if let Some(res) = partial_res.full_res() && !res.expected_in_tuple_struct_pat() {
|
||||||
&& !partial_res.base_res().expected_in_tuple_struct_pat()
|
|
||||||
{
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1066,9 +1064,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
if let ExprKind::Path(qself, path) = &expr.kind {
|
if let ExprKind::Path(qself, path) = &expr.kind {
|
||||||
// Does the path resolve to something disallowed in a unit struct/variant pattern?
|
// Does the path resolve to something disallowed in a unit struct/variant pattern?
|
||||||
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
|
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
|
||||||
if partial_res.unresolved_segments() == 0
|
if let Some(res) = partial_res.full_res() && !res.expected_in_unit_struct_pat() {
|
||||||
&& !partial_res.base_res().expected_in_unit_struct_pat()
|
|
||||||
{
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -947,7 +947,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
}
|
}
|
||||||
AssocItemKind::MacCall(..) => unimplemented!(),
|
AssocItemKind::MacCall(..) => unimplemented!(),
|
||||||
},
|
},
|
||||||
trait_item_def_id: self.resolver.get_partial_res(i.id).map(|r| r.base_res().def_id()),
|
trait_item_def_id: self
|
||||||
|
.resolver
|
||||||
|
.get_partial_res(i.id)
|
||||||
|
.map(|r| r.expect_full_res().def_id()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1349,9 +1352,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
match self
|
match self
|
||||||
.resolver
|
.resolver
|
||||||
.get_partial_res(bound_pred.bounded_ty.id)
|
.get_partial_res(bound_pred.bounded_ty.id)
|
||||||
.map(|d| (d.base_res(), d.unresolved_segments()))
|
.and_then(|r| r.full_res())
|
||||||
{
|
{
|
||||||
Some((Res::Def(DefKind::TyParam, def_id), 0))
|
Some(Res::Def(DefKind::TyParam, def_id))
|
||||||
if bound_pred.bound_generic_params.is_empty() =>
|
if bound_pred.bound_generic_params.is_empty() =>
|
||||||
{
|
{
|
||||||
generics
|
generics
|
||||||
|
|
|
@ -175,12 +175,7 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let partial_res = self.partial_res_map.get(&expr.id)?;
|
if let Res::Def(DefKind::Fn, def_id) = self.partial_res_map.get(&expr.id)?.full_res()? {
|
||||||
if partial_res.unresolved_segments() != 0 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Res::Def(DefKind::Fn, def_id) = partial_res.base_res() {
|
|
||||||
// We only support cross-crate argument rewriting. Uses
|
// We only support cross-crate argument rewriting. Uses
|
||||||
// within the same crate should be updated to use the new
|
// within the same crate should be updated to use the new
|
||||||
// const generics style.
|
// const generics style.
|
||||||
|
@ -753,12 +748,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
|
fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
|
||||||
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| {
|
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
|
||||||
if pr.unresolved_segments() != 0 {
|
|
||||||
panic!("path not fully resolved: {:?}", pr);
|
|
||||||
}
|
|
||||||
pr.base_res()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expect_full_res_from_use(&mut self, id: NodeId) -> impl Iterator<Item = Res<NodeId>> {
|
fn expect_full_res_from_use(&mut self, id: NodeId) -> impl Iterator<Item = Res<NodeId>> {
|
||||||
|
@ -1138,8 +1128,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
// type and value namespaces. If we resolved the path in the value namespace, we
|
// type and value namespaces. If we resolved the path in the value namespace, we
|
||||||
// transform it into a generic const argument.
|
// transform it into a generic const argument.
|
||||||
TyKind::Path(ref qself, ref path) => {
|
TyKind::Path(ref qself, ref path) => {
|
||||||
if let Some(partial_res) = self.resolver.get_partial_res(ty.id) {
|
if let Some(res) = self
|
||||||
let res = partial_res.base_res();
|
.resolver
|
||||||
|
.get_partial_res(ty.id)
|
||||||
|
.and_then(|partial_res| partial_res.full_res())
|
||||||
|
{
|
||||||
if !res.matches_ns(Namespace::TypeNS) {
|
if !res.matches_ns(Namespace::TypeNS) {
|
||||||
debug!(
|
debug!(
|
||||||
"lower_generic_arg: Lowering type argument as const argument: {:?}",
|
"lower_generic_arg: Lowering type argument as const argument: {:?}",
|
||||||
|
@ -1206,8 +1199,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
// by `ty_path`.
|
// by `ty_path`.
|
||||||
if qself.is_none()
|
if qself.is_none()
|
||||||
&& let Some(partial_res) = self.resolver.get_partial_res(t.id)
|
&& let Some(partial_res) = self.resolver.get_partial_res(t.id)
|
||||||
&& partial_res.unresolved_segments() == 0
|
&& let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
|
||||||
&& let Res::Def(DefKind::Trait | DefKind::TraitAlias, _) = partial_res.base_res()
|
|
||||||
{
|
{
|
||||||
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
|
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
|
||||||
let poly_trait_ref = this.ast_arena.ptr.alloc(PolyTraitRef {
|
let poly_trait_ref = this.ast_arena.ptr.alloc(PolyTraitRef {
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
lower_sub: impl FnOnce(&mut Self) -> Option<&'hir hir::Pat<'hir>>,
|
lower_sub: impl FnOnce(&mut Self) -> Option<&'hir hir::Pat<'hir>>,
|
||||||
) -> hir::PatKind<'hir> {
|
) -> hir::PatKind<'hir> {
|
||||||
match self.resolver.get_partial_res(p.id).map(|d| d.base_res()) {
|
match self.resolver.get_partial_res(p.id).map(|d| d.expect_full_res()) {
|
||||||
// `None` can occur in body-less function signatures
|
// `None` can occur in body-less function signatures
|
||||||
res @ (None | Some(Res::Local(_))) => {
|
res @ (None | Some(Res::Local(_))) => {
|
||||||
let canonical_id = match res {
|
let canonical_id = match res {
|
||||||
|
|
|
@ -29,11 +29,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
let partial_res =
|
let partial_res =
|
||||||
self.resolver.get_partial_res(id).unwrap_or_else(|| PartialRes::new(Res::Err));
|
self.resolver.get_partial_res(id).unwrap_or_else(|| PartialRes::new(Res::Err));
|
||||||
|
let base_res = partial_res.base_res();
|
||||||
|
let unresolved_segments = partial_res.unresolved_segments();
|
||||||
|
|
||||||
let path_span_lo = p.span.shrink_to_lo();
|
let path_span_lo = p.span.shrink_to_lo();
|
||||||
let proj_start = p.segments.len() - partial_res.unresolved_segments();
|
let proj_start = p.segments.len() - unresolved_segments;
|
||||||
let path = self.arena.alloc(hir::Path {
|
let path = self.arena.alloc(hir::Path {
|
||||||
res: self.lower_res(partial_res.base_res()),
|
res: self.lower_res(base_res),
|
||||||
segments: self.arena.alloc_from_iter(p.segments[..proj_start].iter().enumerate().map(
|
segments: self.arena.alloc_from_iter(p.segments[..proj_start].iter().enumerate().map(
|
||||||
|(i, segment)| {
|
|(i, segment)| {
|
||||||
let param_mode = match (qself_position, param_mode) {
|
let param_mode = match (qself_position, param_mode) {
|
||||||
|
@ -46,7 +48,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
_ => param_mode,
|
_ => param_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
let parenthesized_generic_args = match partial_res.base_res() {
|
let parenthesized_generic_args = match base_res {
|
||||||
// `a::b::Trait(Args)`
|
// `a::b::Trait(Args)`
|
||||||
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
|
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
|
||||||
ParenthesizedGenericArgs::Ok
|
ParenthesizedGenericArgs::Ok
|
||||||
|
@ -83,7 +85,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
// Simple case, either no projections, or only fully-qualified.
|
// Simple case, either no projections, or only fully-qualified.
|
||||||
// E.g., `std::mem::size_of` or `<I as Iterator>::Item`.
|
// E.g., `std::mem::size_of` or `<I as Iterator>::Item`.
|
||||||
if partial_res.unresolved_segments() == 0 {
|
if unresolved_segments == 0 {
|
||||||
return hir::QPath::Resolved(qself, path);
|
return hir::QPath::Resolved(qself, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -464,6 +464,16 @@ impl PartialRes {
|
||||||
pub fn unresolved_segments(&self) -> usize {
|
pub fn unresolved_segments(&self) -> usize {
|
||||||
self.unresolved_segments
|
self.unresolved_segments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn full_res(&self) -> Option<Res<NodeId>> {
|
||||||
|
(self.unresolved_segments == 0).then_some(self.base_res)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn expect_full_res(&self) -> Res<NodeId> {
|
||||||
|
self.full_res().expect("unexpected unresolved segments")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Different kinds of symbols can coexist even if they share the same textual name.
|
/// Different kinds of symbols can coexist even if they share the same textual name.
|
||||||
|
|
|
@ -326,7 +326,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||||
}
|
}
|
||||||
PathResult::Module(..) => Err(VisResolutionError::ModuleOnly(path.span)),
|
PathResult::Module(..) => Err(VisResolutionError::ModuleOnly(path.span)),
|
||||||
PathResult::NonModule(partial_res) => {
|
PathResult::NonModule(partial_res) => {
|
||||||
expected_found_error(partial_res.base_res())
|
expected_found_error(partial_res.expect_full_res())
|
||||||
}
|
}
|
||||||
PathResult::Failed { span, label, suggestion, .. } => {
|
PathResult::Failed { span, label, suggestion, .. } => {
|
||||||
Err(VisResolutionError::FailedToResolve(span, label, suggestion))
|
Err(VisResolutionError::FailedToResolve(span, label, suggestion))
|
||||||
|
|
|
@ -641,8 +641,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
// Check whether we should interpret this as a bare trait object.
|
// Check whether we should interpret this as a bare trait object.
|
||||||
if qself.is_none()
|
if qself.is_none()
|
||||||
&& let Some(partial_res) = self.r.partial_res_map.get(&ty.id)
|
&& let Some(partial_res) = self.r.partial_res_map.get(&ty.id)
|
||||||
&& partial_res.unresolved_segments() == 0
|
&& let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
|
||||||
&& let Res::Def(DefKind::Trait | DefKind::TraitAlias, _) = partial_res.base_res()
|
|
||||||
{
|
{
|
||||||
// This path is actually a bare trait object. In case of a bare `Fn`-trait
|
// This path is actually a bare trait object. In case of a bare `Fn`-trait
|
||||||
// object with anonymous lifetimes, we need this rib to correctly place the
|
// object with anonymous lifetimes, we need this rib to correctly place the
|
||||||
|
@ -1929,7 +1928,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
match ty.kind {
|
match ty.kind {
|
||||||
TyKind::ImplicitSelf => true,
|
TyKind::ImplicitSelf => true,
|
||||||
TyKind::Path(None, _) => {
|
TyKind::Path(None, _) => {
|
||||||
let path_res = self.r.partial_res_map[&ty.id].base_res();
|
let path_res = self.r.partial_res_map[&ty.id].expect_full_res();
|
||||||
if let Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } = path_res {
|
if let Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } = path_res {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1970,7 +1969,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|res| res.base_res())
|
.map(|res| res.expect_full_res())
|
||||||
.filter(|res| {
|
.filter(|res| {
|
||||||
// Permit the types that unambiguously always
|
// Permit the types that unambiguously always
|
||||||
// result in the same type constructor being used
|
// result in the same type constructor being used
|
||||||
|
@ -2530,7 +2529,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
Finalize::new(trait_ref.ref_id, trait_ref.path.span),
|
Finalize::new(trait_ref.ref_id, trait_ref.path.span),
|
||||||
);
|
);
|
||||||
self.diagnostic_metadata.currently_processing_impl_trait = None;
|
self.diagnostic_metadata.currently_processing_impl_trait = None;
|
||||||
if let Some(def_id) = res.base_res().opt_def_id() {
|
if let Some(def_id) = res.expect_full_res().opt_def_id() {
|
||||||
new_id = Some(def_id);
|
new_id = Some(def_id);
|
||||||
new_val = Some((self.r.expect_module(def_id), trait_ref.clone()));
|
new_val = Some((self.r.expect_module(def_id), trait_ref.clone()));
|
||||||
}
|
}
|
||||||
|
@ -2886,7 +2885,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_base_res_local(&self, nid: NodeId) -> bool {
|
fn is_base_res_local(&self, nid: NodeId) -> bool {
|
||||||
matches!(self.r.partial_res_map.get(&nid).map(|res| res.base_res()), Some(Res::Local(..)))
|
matches!(
|
||||||
|
self.r.partial_res_map.get(&nid).map(|res| res.expect_full_res()),
|
||||||
|
Some(Res::Local(..))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that all of the arms in an or-pattern have exactly the
|
/// Checks that all of the arms in an or-pattern have exactly the
|
||||||
|
@ -3373,12 +3375,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
source.defer_to_typeck(),
|
source.defer_to_typeck(),
|
||||||
finalize,
|
finalize,
|
||||||
) {
|
) {
|
||||||
Ok(Some(partial_res)) if partial_res.unresolved_segments() == 0 => {
|
Ok(Some(partial_res)) if let Some(res) = partial_res.full_res() => {
|
||||||
if source.is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err
|
if source.is_expected(res) || res == Res::Err {
|
||||||
{
|
|
||||||
partial_res
|
partial_res
|
||||||
} else {
|
} else {
|
||||||
report_errors(self, Some(partial_res.base_res()))
|
report_errors(self, Some(res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3586,20 +3587,21 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if path.len() > 1
|
if path.len() > 1
|
||||||
&& result.base_res() != Res::Err
|
&& let Some(res) = result.full_res()
|
||||||
|
&& res != Res::Err
|
||||||
&& path[0].ident.name != kw::PathRoot
|
&& path[0].ident.name != kw::PathRoot
|
||||||
&& path[0].ident.name != kw::DollarCrate
|
&& path[0].ident.name != kw::DollarCrate
|
||||||
{
|
{
|
||||||
let unqualified_result = {
|
let unqualified_result = {
|
||||||
match self.resolve_path(&[*path.last().unwrap()], Some(ns), None) {
|
match self.resolve_path(&[*path.last().unwrap()], Some(ns), None) {
|
||||||
PathResult::NonModule(path_res) => path_res.base_res(),
|
PathResult::NonModule(path_res) => path_res.expect_full_res(),
|
||||||
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
|
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
|
||||||
module.res().unwrap()
|
module.res().unwrap()
|
||||||
}
|
}
|
||||||
_ => return Ok(Some(result)),
|
_ => return Ok(Some(result)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if result.base_res() == unqualified_result {
|
if res == unqualified_result {
|
||||||
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
|
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
|
||||||
self.r.lint_buffer.buffer_lint(
|
self.r.lint_buffer.buffer_lint(
|
||||||
lint,
|
lint,
|
||||||
|
|
|
@ -968,11 +968,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
let Some(partial_res) = self.r.partial_res_map.get(&bounded_ty.id) else {
|
let Some(partial_res) = self.r.partial_res_map.get(&bounded_ty.id) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if !(matches!(
|
if !matches!(
|
||||||
partial_res.base_res(),
|
partial_res.full_res(),
|
||||||
hir::def::Res::Def(hir::def::DefKind::AssocTy, _)
|
Some(hir::def::Res::Def(hir::def::DefKind::AssocTy, _))
|
||||||
) && partial_res.unresolved_segments() == 0)
|
) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
(ty, position, path)
|
(ty, position, path)
|
||||||
|
@ -986,11 +985,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
let Some(partial_res) = self.r.partial_res_map.get(&peeled_ty.id) else {
|
let Some(partial_res) = self.r.partial_res_map.get(&peeled_ty.id) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if !(matches!(
|
if !matches!(
|
||||||
partial_res.base_res(),
|
partial_res.full_res(),
|
||||||
hir::def::Res::Def(hir::def::DefKind::TyParam, _)
|
Some(hir::def::Res::Def(hir::def::DefKind::TyParam, _))
|
||||||
) && partial_res.unresolved_segments() == 0)
|
) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if let (
|
if let (
|
||||||
|
@ -1518,20 +1516,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
{
|
{
|
||||||
// Look for a field with the same name in the current self_type.
|
// Look for a field with the same name in the current self_type.
|
||||||
if let Some(resolution) = self.r.partial_res_map.get(&node_id) {
|
if let Some(resolution) = self.r.partial_res_map.get(&node_id) {
|
||||||
match resolution.base_res() {
|
if let Some(Res::Def(DefKind::Struct | DefKind::Union, did)) =
|
||||||
Res::Def(DefKind::Struct | DefKind::Union, did)
|
resolution.full_res()
|
||||||
if resolution.unresolved_segments() == 0 =>
|
{
|
||||||
{
|
if let Some(field_names) = self.r.field_names.get(&did) {
|
||||||
if let Some(field_names) = self.r.field_names.get(&did) {
|
if field_names.iter().any(|&field_name| ident.name == field_name.node) {
|
||||||
if field_names
|
return Some(AssocSuggestion::Field);
|
||||||
.iter()
|
|
||||||
.any(|&field_name| ident.name == field_name.node)
|
|
||||||
{
|
|
||||||
return Some(AssocSuggestion::Field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1883,12 +1883,10 @@ impl<'a> Resolver<'a> {
|
||||||
|
|
||||||
match self.maybe_resolve_path(&segments, Some(ns), &parent_scope) {
|
match self.maybe_resolve_path(&segments, Some(ns), &parent_scope) {
|
||||||
PathResult::Module(ModuleOrUniformRoot::Module(module)) => Some(module.res().unwrap()),
|
PathResult::Module(ModuleOrUniformRoot::Module(module)) => Some(module.res().unwrap()),
|
||||||
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
|
PathResult::NonModule(path_res) => path_res.full_res(),
|
||||||
Some(path_res.base_res())
|
PathResult::Module(ModuleOrUniformRoot::ExternPrelude) | PathResult::Failed { .. } => {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
PathResult::Module(ModuleOrUniformRoot::ExternPrelude)
|
|
||||||
| PathResult::NonModule(..)
|
|
||||||
| PathResult::Failed { .. } => None,
|
|
||||||
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
|
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1939,12 +1937,8 @@ impl<'a> Resolver<'a> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let partial_res = self.partial_res_map.get(&expr.id)?;
|
let res = self.partial_res_map.get(&expr.id)?.full_res()?;
|
||||||
if partial_res.unresolved_segments() != 0 {
|
if let Res::Def(def::DefKind::Fn, def_id) = res {
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Res::Def(def::DefKind::Fn, def_id) = partial_res.base_res() {
|
|
||||||
// We only support cross-crate argument rewriting. Uses
|
// We only support cross-crate argument rewriting. Uses
|
||||||
// within the same crate should be updated to use the new
|
// within the same crate should be updated to use the new
|
||||||
// const generics style.
|
// const generics style.
|
||||||
|
|
|
@ -590,9 +590,7 @@ impl<'a> Resolver<'a> {
|
||||||
|
|
||||||
let res = if path.len() > 1 {
|
let res = if path.len() > 1 {
|
||||||
let res = match self.maybe_resolve_path(&path, Some(MacroNS), parent_scope) {
|
let res = match self.maybe_resolve_path(&path, Some(MacroNS), parent_scope) {
|
||||||
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
|
PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => Ok(res),
|
||||||
Ok(path_res.base_res())
|
|
||||||
}
|
|
||||||
PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined),
|
PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined),
|
||||||
PathResult::NonModule(..)
|
PathResult::NonModule(..)
|
||||||
| PathResult::Indeterminate
|
| PathResult::Indeterminate
|
||||||
|
@ -692,9 +690,8 @@ impl<'a> Resolver<'a> {
|
||||||
Some(Finalize::new(ast::CRATE_NODE_ID, path_span)),
|
Some(Finalize::new(ast::CRATE_NODE_ID, path_span)),
|
||||||
None,
|
None,
|
||||||
) {
|
) {
|
||||||
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
|
PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => {
|
||||||
let res = path_res.base_res();
|
check_consistency(self, &path, path_span, kind, initial_res, res)
|
||||||
check_consistency(self, &path, path_span, kind, initial_res, res);
|
|
||||||
}
|
}
|
||||||
path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed { .. } => {
|
path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed { .. } => {
|
||||||
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
|
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue