-
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.
- Loading branch information
1 parent
4db3d12
commit c6a694f
Showing
2 changed files
with
194 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#[derive(Copy, Clone)] | ||
struct Type; | ||
|
||
struct NewType; | ||
|
||
const fn get_size() -> usize { | ||
10 | ||
} | ||
|
||
fn get_dyn_size() -> usize { | ||
10 | ||
} | ||
|
||
fn main() { | ||
let a = ["a", 10]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create an array | ||
|
||
const size_b: usize = 20; | ||
let b = [Type, size_b]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create an array | ||
|
||
let size_c: usize = 13; | ||
let c = [Type, size_c]; | ||
//~^ ERROR mismatched types | ||
|
||
const size_d: bool = true; | ||
let d = [Type, size_d]; | ||
//~^ ERROR mismatched types | ||
|
||
let e = [String::new(), 10]; | ||
//~^ ERROR mismatched types | ||
//~| HELP try using a conversion method | ||
|
||
let f = ["f", get_size()]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create an array | ||
|
||
let m = ["m", get_dyn_size()]; | ||
//~^ ERROR mismatched types | ||
|
||
// is_vec, is_clone, is_usize_like | ||
let g = vec![String::new(), 10]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create a vector | ||
|
||
let dyn_size = 10; | ||
let h = vec![Type, dyn_size]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create a vector | ||
|
||
let i = vec![Type, get_dyn_size()]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create a vector | ||
|
||
let k = vec!['c', 10]; | ||
//~^ ERROR mismatched types | ||
//~| HELP replace comma with semicolon to create a vector | ||
|
||
let j = vec![Type, 10_u8]; | ||
//~^ ERROR mismatched types | ||
|
||
let l = vec![NewType, 10]; | ||
//~^ ERROR mismatched types | ||
|
||
let byte_size: u8 = 10; | ||
let h = vec![Type, byte_size]; | ||
//~^ ERROR mismatched types | ||
} |
124 changes: 124 additions & 0 deletions
124
tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.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,124 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:15:19 | ||
| | ||
LL | let a = ["a", 10]; | ||
| ^^ expected `&str`, found integer | ||
| | ||
help: replace comma with semicolon to create an array | ||
| | ||
LL | let a = ["a"; 10]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:20:20 | ||
| | ||
LL | let b = [Type, size_b]; | ||
| ^^^^^^ expected `Type`, found `usize` | ||
| | ||
help: replace comma with semicolon to create an array | ||
| | ||
LL | let b = [Type; size_b]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:25:20 | ||
| | ||
LL | let c = [Type, size_c]; | ||
| ^^^^^^ expected `Type`, found `usize` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:29:20 | ||
| | ||
LL | let d = [Type, size_d]; | ||
| ^^^^^^ expected `Type`, found `bool` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:32:29 | ||
| | ||
LL | let e = [String::new(), 10]; | ||
| ^^- help: try using a conversion method: `.to_string()` | ||
| | | ||
| expected `String`, found integer | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:36:19 | ||
| | ||
LL | let f = ["f", get_size()]; | ||
| ^^^^^^^^^^ expected `&str`, found `usize` | ||
| | ||
help: replace comma with semicolon to create an array | ||
| | ||
LL | let f = ["f"; get_size()]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:40:19 | ||
| | ||
LL | let m = ["m", get_dyn_size()]; | ||
| ^^^^^^^^^^^^^^ expected `&str`, found `usize` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:44:33 | ||
| | ||
LL | let g = vec![String::new(), 10]; | ||
| ^^ expected `String`, found integer | ||
| | ||
help: replace comma with semicolon to create a vector | ||
| | ||
LL | let g = vec![String::new(); 10]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:49:24 | ||
| | ||
LL | let h = vec![Type, dyn_size]; | ||
| ^^^^^^^^ expected `Type`, found integer | ||
| | ||
help: replace comma with semicolon to create a vector | ||
| | ||
LL | let h = vec![Type; dyn_size]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:53:24 | ||
| | ||
LL | let i = vec![Type, get_dyn_size()]; | ||
| ^^^^^^^^^^^^^^ expected `Type`, found `usize` | ||
| | ||
help: replace comma with semicolon to create a vector | ||
| | ||
LL | let i = vec![Type; get_dyn_size()]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:57:23 | ||
| | ||
LL | let k = vec!['c', 10]; | ||
| ^^ expected `char`, found `u8` | ||
| | ||
help: replace comma with semicolon to create a vector | ||
| | ||
LL | let k = vec!['c'; 10]; | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:61:24 | ||
| | ||
LL | let j = vec![Type, 10_u8]; | ||
| ^^^^^ expected `Type`, found `u8` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:64:27 | ||
| | ||
LL | let l = vec![NewType, 10]; | ||
| ^^ expected `NewType`, found integer | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/typo-in-repeat-expr-issue-80173.rs:68:24 | ||
| | ||
LL | let h = vec![Type, byte_size]; | ||
| ^^^^^^^^^ expected `Type`, found `u8` | ||
|
||
error: aborting due to 14 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |