forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59150 - estebank:type-ascription, r=varkor
Expand suggestions for type ascription parse errors Fix rust-lang#51222. CC rust-lang#48016, rust-lang#47666, rust-lang#54516, rust-lang#34255.
- Loading branch information
Showing
21 changed files
with
302 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
enum Test { | ||
Drill { | ||
field: i32, | ||
} | ||
} | ||
|
||
fn main() { | ||
Test::Drill(field: 42); | ||
//~^ ERROR expected type, found | ||
} |
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,16 @@ | ||
error: expected type, found `42` | ||
--> $DIR/issue-34255-1.rs:8:24 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^^ expecting a type here because of type ascription | ||
| | ||
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>` | ||
note: this expression expects an ascribed type after the colon | ||
--> $DIR/issue-34255-1.rs:8:17 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^^^^^ | ||
= help: this might be indicative of a syntax error elsewhere | ||
|
||
error: aborting due to previous error | ||
|
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,10 @@ | ||
fn fun(x: i32) -> i32 { x } | ||
|
||
fn main() { | ||
let closure_annotated = |value: i32| -> i32 { | ||
temp: i32 = fun(5i32); | ||
//~^ ERROR cannot find value `temp` in this scope | ||
temp + value + 1 | ||
//~^ ERROR cannot find value `temp` in this scope | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/suggestions/type-ascription-instead-of-let.stderr
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,18 @@ | ||
error[E0425]: cannot find value `temp` in this scope | ||
--> $DIR/type-ascription-instead-of-let.rs:5:9 | ||
| | ||
LL | temp: i32 = fun(5i32); | ||
| ^^^^ | ||
| | | ||
| not found in this scope | ||
| help: maybe you meant to write an assignment here: `let temp` | ||
|
||
error[E0425]: cannot find value `temp` in this scope | ||
--> $DIR/type-ascription-instead-of-let.rs:7:9 | ||
| | ||
LL | temp + value + 1 | ||
| ^^^^ not found in this scope | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
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,4 @@ | ||
fn main() { | ||
Box:new("foo".to_string()) | ||
//~^ ERROR expected type, found | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/suggestions/type-ascription-instead-of-method.stderr
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,10 @@ | ||
error: expected type, found `"foo"` | ||
--> $DIR/type-ascription-instead-of-method.rs:2:13 | ||
| | ||
LL | Box:new("foo".to_string()) | ||
| - ^^^^^ expecting a type here because of type ascription | ||
| | | ||
| help: maybe you meant to write a path separator here: `::` | ||
|
||
error: aborting due to previous error | ||
|
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,5 @@ | ||
fn main() { | ||
std:io::stdin(); | ||
//~^ ERROR failed to resolve: use of undeclared type or module `io` | ||
//~| ERROR expected value, found module | ||
} |
Oops, something went wrong.