@@ -3010,6 +3010,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3010
3010
// Visit all direct subpatterns of this pattern.
3011
3011
let outer_pat_id = pat. id ;
3012
3012
pat. walk ( & mut |pat| {
3013
+ debug ! ( "resolve_pattern pat={:?} node={:?}" , pat, pat. node) ;
3013
3014
match pat. node {
3014
3015
PatKind :: Ident ( bmode, ident, ref opt_pat) => {
3015
3016
// First try to resolve the identifier as some existing
@@ -3166,6 +3167,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3166
3167
format ! ( "not found in {}" , mod_str) ,
3167
3168
item_span)
3168
3169
} ;
3170
+
3169
3171
let code = DiagnosticId :: Error ( code. into ( ) ) ;
3170
3172
let mut err = this. session . struct_span_err_with_code ( base_span, & base_msg, code) ;
3171
3173
@@ -3189,11 +3191,22 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3189
3191
return ( err, Vec :: new ( ) ) ;
3190
3192
}
3191
3193
if is_self_value ( path, ns) {
3194
+ debug ! ( "smart_resolve_path_fragment E0424 source:{:?}" , source) ;
3195
+
3192
3196
__diagnostic_used ! ( E0424 ) ;
3193
3197
err. code ( DiagnosticId :: Error ( "E0424" . into ( ) ) ) ;
3194
- err. span_label ( span, format ! ( "`self` value is a keyword \
3195
- only available in \
3196
- methods with `self` parameter") ) ;
3198
+ err. span_label ( span, match source {
3199
+ PathSource :: Pat => {
3200
+ format ! ( "`self` value is a keyword \
3201
+ and may not be bound to \
3202
+ variables or shadowed")
3203
+ }
3204
+ _ => {
3205
+ format ! ( "`self` value is a keyword \
3206
+ only available in methods \
3207
+ with `self` parameter")
3208
+ }
3209
+ } ) ;
3197
3210
return ( err, Vec :: new ( ) ) ;
3198
3211
}
3199
3212
0 commit comments