-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ```
- Loading branch information
Showing
14 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn foo(Option<i32>, String) {} | ||
fn bar(x, y: usize) {} | ||
|
||
fn main() { | ||
foo(Some(42), 2); | ||
foo(Some(42), 2, ""); | ||
bar("", ""); | ||
bar(1, 2); | ||
bar(1, 2, 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
error: expected one of `:` or `@`, found `<` | ||
--> $DIR/issue-34264.rs:11:14 | ||
| | ||
11 | fn foo(Option<i32>, String) {} | ||
| ^ | ||
|
||
error: expected one of `:` or `@`, found `)` | ||
--> $DIR/issue-34264.rs:11:27 | ||
| | ||
11 | fn foo(Option<i32>, String) {} | ||
| ^ | ||
|
||
error: expected one of `:` or `@`, found `,` | ||
--> $DIR/issue-34264.rs:12:9 | ||
| | ||
12 | fn bar(x, y: usize) {} | ||
| ^ | ||
|
||
error[E0061]: this function takes 2 parameters but 3 parameters were supplied | ||
--> $DIR/issue-34264.rs:16:9 | ||
| | ||
11 | fn foo(Option<i32>, String) {} | ||
| ------------------------------ defined here | ||
... | ||
16 | foo(Some(42), 2, ""); | ||
| ^^^^^^^^^^^^^^^ expected 2 parameters | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-34264.rs:17:13 | ||
| | ||
17 | bar("", ""); | ||
| ^^ expected usize, found reference | ||
| | ||
= note: expected type `usize` | ||
found type `&'static str` | ||
= help: here are some functions which might fulfill your needs: | ||
- .len() | ||
|
||
error[E0061]: this function takes 2 parameters but 3 parameters were supplied | ||
--> $DIR/issue-34264.rs:19:9 | ||
| | ||
12 | fn bar(x, y: usize) {} | ||
| ---------------------- defined here | ||
... | ||
19 | bar(1, 2, 3); | ||
| ^^^^^^^ expected 2 parameters | ||
|
||
error: aborting due to 3 previous errors | ||
|