File tree Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -2213,25 +2213,28 @@ impl<'a> Resolver<'a> {
22132213 } else {
22142214 let mut msg =
22152215 format ! ( "could not find `{}` in `{}`" , ident, path[ i - 1 ] . ident) ;
2216- if ns == TypeNS {
2217- if let FindBindingResult :: Binding ( Ok ( _) ) =
2218- find_binding_in_ns ( self , ValueNS )
2216+ if ns == TypeNS || ns == ValueNS {
2217+ let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS } ;
2218+ if let FindBindingResult :: Binding ( Ok ( binding) ) =
2219+ find_binding_in_ns ( self , ns_to_try)
22192220 {
2220- msg = format ! (
2221- "`{}` in `{}` is a concrete value, not a module or Struct you specified" ,
2222- ident,
2223- path[ i - 1 ] . ident
2224- ) ;
2225- } ;
2226- } else if ns == ValueNS {
2227- if let FindBindingResult :: Binding ( Ok ( _) ) =
2228- find_binding_in_ns ( self , TypeNS )
2229- {
2230- msg = format ! (
2231- "`{}` in `{}` is a type, not a concrete value you specified" ,
2232- ident,
2233- path[ i - 1 ] . ident
2234- ) ;
2221+ let mut found = |what| {
2222+ msg = format ! (
2223+ "expected {}, found {} `{}` in `{}`" ,
2224+ ns. descr( ) ,
2225+ what,
2226+ ident,
2227+ path[ i - 1 ] . ident
2228+ )
2229+ } ;
2230+ if binding. module ( ) . is_some ( ) {
2231+ found ( "module" )
2232+ } else {
2233+ match binding. res ( ) {
2234+ def:: Res :: < NodeId > :: Def ( kind, id) => found ( kind. descr ( id) ) ,
2235+ _ => found ( ns_to_try. descr ( ) ) ,
2236+ }
2237+ }
22352238 } ;
22362239 }
22372240 ( msg, None )
Original file line number Diff line number Diff line change @@ -2,5 +2,5 @@ use std::sync::mpsc;
22
33fn main ( ) {
44 let ( tx, rx) = mpsc:: channel:: new ( 1 ) ;
5- //~^ ERROR `channel` in `mpsc` is a concrete value, not a module or Struct you specified
5+ //~^ ERROR expected type, found function `channel` in `mpsc`
66}
Original file line number Diff line number Diff line change 1- error[E0433]: failed to resolve: `channel` in `mpsc` is a concrete value, not a module or Struct you specified
1+ error[E0433]: failed to resolve: expected type, found function `channel` in `mpsc`
22 --> $DIR/issue-71406.rs:4:26
33 |
44LL | let (tx, rx) = mpsc::channel::new(1);
5- | ^^^^^^^ `channel` in `mpsc` is a concrete value, not a module or Struct you specified
5+ | ^^^^^^^ expected type, found function `channel` in `mpsc`
66
77error: aborting due to previous error
88
You can’t perform that action at this time.
0 commit comments