Skip to content

Commit 91b9dab

Browse files
committed
resolve: Rewrite resolve_pattern
1 parent ee00760 commit 91b9dab

28 files changed

+339
-483
lines changed

src/librustc/hir/def.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ impl PathResolution {
8888
depth: depth,
8989
}
9090
}
91+
92+
pub fn kind_name(&self) -> &'static str {
93+
if self.depth != 0 {
94+
"associated item"
95+
} else {
96+
self.base_def.kind_name()
97+
}
98+
}
9199
}
92100

93101
// Definition mapping
@@ -161,8 +169,8 @@ impl Def {
161169
Def::Struct(..) => "struct",
162170
Def::Trait(..) => "trait",
163171
Def::Method(..) => "method",
164-
Def::Const(..) => "const",
165-
Def::AssociatedConst(..) => "associated const",
172+
Def::Const(..) => "constant",
173+
Def::AssociatedConst(..) => "associated constant",
166174
Def::TyParam(..) => "type parameter",
167175
Def::PrimTy(..) => "builtin type",
168176
Def::Local(..) => "local variable",

src/librustc_resolve/diagnostics.rs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -842,32 +842,6 @@ match 0 {
842842
```
843843
"##,
844844

845-
E0419: r##"
846-
An unknown enum variant, struct or const was used. Example of erroneous code:
847-
848-
```compile_fail
849-
match 0 {
850-
Something::Foo => {} // error: unresolved enum variant, struct
851-
// or const `Foo`
852-
}
853-
```
854-
855-
Please verify you didn't misspell it and the enum variant, struct or const has
856-
been declared and imported into scope. Example:
857-
858-
```
859-
enum Something {
860-
Foo,
861-
NotFoo,
862-
}
863-
864-
match Something::NotFoo {
865-
Something::Foo => {} // ok!
866-
_ => {}
867-
}
868-
```
869-
"##,
870-
871845
E0422: r##"
872846
You are trying to use an identifier that is either undefined or not a struct.
873847
For instance:
@@ -1247,16 +1221,11 @@ impl Foo for i32 {}
12471221
}
12481222

12491223
register_diagnostics! {
1250-
// E0153, unused error code
1251-
// E0157, unused error code
12521224
E0254, // import conflicts with imported crate in this module
1253-
// E0257,
1254-
// E0258,
12551225
E0402, // cannot use an outer type parameter in this context
12561226
E0406, // undeclared associated type
1257-
// E0410, merged into 408
1258-
E0418, // is not an enum variant, struct or const
1259-
E0420, // is not an associated const
1260-
E0421, // unresolved associated const
1227+
E0418, // X bindings cannot shadow Ys
1228+
E0419, // unresolved pattern path kind `name`
1229+
E0420, // expected pattern path kind, found another pattern path kind
12611230
E0427, // cannot use `ref` binding mode with ...
12621231
}

0 commit comments

Comments
 (0)