Introduce TyErr independent from TyInfer
Add a `TyErr` type to represent unknown types in places where
parse errors have happened, while still able to build the AST.
Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use `TyInfer` for this as
`_` is not allowed as a valid argument type.
Example output:
```rust
error: expected one of `:` or `@`, found `,`
--> file.rs:12:9
|
12 | fn bar(x, y: usize) {}
| ^
error[E0061]: this function takes 2 parameters but 3 parameters were supplied
--> file.rs:19:9
|
12 | fn bar(x, y) {}
| --------------- defined here
...
19 | bar(1, 2, 3);
| ^^^^^^^ expected 2 parameters
```
This commit is contained in:
@@ -358,7 +358,7 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
|
||||
t.map(|Ty {id, node, span}| Ty {
|
||||
id: fld.new_id(id),
|
||||
node: match node {
|
||||
TyKind::Infer | TyKind::ImplicitSelf => node,
|
||||
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => node,
|
||||
TyKind::Slice(ty) => TyKind::Slice(fld.fold_ty(ty)),
|
||||
TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
|
||||
TyKind::Rptr(region, mt) => {
|
||||
|
||||
Reference in New Issue
Block a user