Skip to content

Commit 224a190

Browse files
committed
method call debug backup
1 parent 7a7c0d1 commit 224a190

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,15 +1983,53 @@ impl<'a> Resolver<'a> {
19831983
Applicability::MaybeIncorrect,
19841984
))
19851985
} else {
1986-
self.find_similarly_named_module_or_crate(ident.name, &parent_scope.module).map(
1987-
|sugg| {
1986+
let similar = self
1987+
.find_similarly_named_module_or_crate(ident.name, &parent_scope.module)
1988+
.map(|sugg| {
19881989
(
19891990
vec![(ident.span, sugg.to_string())],
19901991
String::from("there is a crate or module with a similar name"),
19911992
Applicability::MaybeIncorrect,
19921993
)
1993-
},
1994-
)
1994+
});
1995+
if similar.is_some() {
1996+
similar
1997+
} else {
1998+
if let Some(ribs) = ribs {
1999+
let res = self.resolve_ident_in_lexical_scope(
2000+
ident,
2001+
ValueNS,
2002+
parent_scope,
2003+
None,
2004+
&ribs[ValueNS],
2005+
ignore_binding,
2006+
);
2007+
println!("res: {:?}", res);
2008+
let bind = match res {
2009+
Some(LexicalScopeBinding::Res(Res::Local(id))) => {
2010+
Some(*self.pat_span_map.get(&id).unwrap())
2011+
}
2012+
_ => None,
2013+
};
2014+
let next = self.next_node_id();
2015+
println!("bind: {:?}", bind);
2016+
println!("next: {:?}", next);
2017+
if bind.is_some() {
2018+
Some((
2019+
vec![(bind.unwrap(), String::from(""))],
2020+
format!(
2021+
"`{}` is defined here, but is not a crate or module",
2022+
ident
2023+
),
2024+
Applicability::MaybeIncorrect,
2025+
))
2026+
} else {
2027+
None
2028+
}
2029+
} else {
2030+
None
2031+
}
2032+
}
19952033
};
19962034
(format!("use of undeclared crate or module `{}`", ident), suggestion)
19972035
}

0 commit comments

Comments
 (0)