@@ -1983,15 +1983,53 @@ impl<'a> Resolver<'a> {
1983
1983
Applicability :: MaybeIncorrect ,
1984
1984
) )
1985
1985
} 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| {
1988
1989
(
1989
1990
vec ! [ ( ident. span, sugg. to_string( ) ) ] ,
1990
1991
String :: from ( "there is a crate or module with a similar name" ) ,
1991
1992
Applicability :: MaybeIncorrect ,
1992
1993
)
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
+ }
1995
2033
} ;
1996
2034
( format ! ( "use of undeclared crate or module `{}`" , ident) , suggestion)
1997
2035
}
0 commit comments