File tree 3 files changed +24
-21
lines changed
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> {
2213
2213
} else {
2214
2214
let mut msg =
2215
2215
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)
2219
2220
{
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
+ }
2235
2238
} ;
2236
2239
}
2237
2240
( msg, None )
Original file line number Diff line number Diff line change @@ -2,5 +2,5 @@ use std::sync::mpsc;
2
2
3
3
fn main ( ) {
4
4
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`
6
6
}
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`
2
2
--> $DIR/issue-71406.rs:4:26
3
3
|
4
4
LL | 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`
6
6
7
7
error: aborting due to previous error
8
8
You can’t perform that action at this time.
0 commit comments