debug logging, added conditional error message, tests updated
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index ebd2c87..e449fec 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -3010,6 +3010,7 @@
// Visit all direct subpatterns of this pattern.
let outer_pat_id = pat.id;
pat.walk(&mut |pat| {
+ debug!("resolve_pattern pat={:?} node={:?}", pat, pat.node);
match pat.node {
PatKind::Ident(bmode, ident, ref opt_pat) => {
// First try to resolve the identifier as some existing
@@ -3166,6 +3167,7 @@
format!("not found in {}", mod_str),
item_span)
};
+
let code = DiagnosticId::Error(code.into());
let mut err = this.session.struct_span_err_with_code(base_span, &base_msg, code);
@@ -3189,11 +3191,22 @@
return (err, Vec::new());
}
if is_self_value(path, ns) {
+ debug!("smart_resolve_path_fragment E0424 source:{:?}", source);
+
__diagnostic_used!(E0424);
err.code(DiagnosticId::Error("E0424".into()));
- err.span_label(span, format!("`self` value is a keyword \
- only available in \
- methods with `self` parameter"));
+ err.span_label(span, match source {
+ PathSource::Pat => {
+ format!("`self` value is a keyword \
+ and may not be bound to \
+ variables or shadowed")
+ }
+ _ => {
+ format!("`self` value is a keyword \
+ only available in methods \
+ with `self` parameter")
+ }
+ });
return (err, Vec::new());
}
diff --git a/src/test/ui/error-codes/E0424.rs b/src/test/ui/error-codes/E0424.rs
index 445d0c5..20d42da 100644
--- a/src/test/ui/error-codes/E0424.rs
+++ b/src/test/ui/error-codes/E0424.rs
@@ -19,4 +19,5 @@
}
fn main () {
+ let self = "self"; //~ ERROR E0424
}
diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr
index a1b7a5f..5eccd7d 100644
--- a/src/test/ui/error-codes/E0424.stderr
+++ b/src/test/ui/error-codes/E0424.stderr
@@ -4,6 +4,12 @@
LL | self.bar(); //~ ERROR E0424
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
-error: aborting due to previous error
+error[E0424]: expected unit struct/variant or constant, found module `self`
+ --> $DIR/E0424.rs:22:9
+ |
+LL | let self = "self"; //~ ERROR E0424
+ | ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0424`.