-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix suggestions for
&a: T
parameters
Previously we were suggesting stuff like `fn f( &u32) {}`
- Loading branch information
1 parent
f19ccc2
commit e9d49b2
Showing
12 changed files
with
476 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fn ugh(&[bar]: &u32) {} //~ ERROR expected an array or slice | ||
|
||
fn bgh(&&bar: u32) {} //~ ERROR mismatched types | ||
|
||
fn main() {} |
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,21 @@ | ||
error[E0529]: expected an array or slice, found `u32` | ||
--> $DIR/issue-38371-unfixable.rs:1:9 | ||
| | ||
LL | fn ugh(&[bar]: &u32) {} | ||
| ^^^^^ pattern cannot match with input type `u32` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-38371-unfixable.rs:3:8 | ||
| | ||
LL | fn bgh(&&bar: u32) {} | ||
| ^^^^^ --- expected due to this | ||
| | | ||
| expected `u32`, found reference | ||
| | ||
= note: expected type `u32` | ||
found reference `&_` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0308, E0529. | ||
For more information about an error, try `rustc --explain E0308`. |
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 @@ | ||
// run-rustfix | ||
// see also issue-38371-unfixable.rs | ||
#![allow(dead_code)] | ||
|
||
#[derive(Copy, Clone)] | ||
struct Foo {} | ||
|
||
fn foo(_a: &Foo) {} //~ ERROR mismatched types | ||
|
||
fn bar(_a: Foo) {} | ||
|
||
fn qux(_a: &Foo) {} | ||
|
||
fn zar(&_a: &Foo) {} | ||
|
||
fn agh(&_a: &u32) {} //~ ERROR mismatched types | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,27 +1,18 @@ | ||
struct Foo { | ||
} | ||
// run-rustfix | ||
// see also issue-38371-unfixable.rs | ||
#![allow(dead_code)] | ||
|
||
fn foo(&foo: Foo) { //~ ERROR mismatched types | ||
} | ||
#[derive(Copy, Clone)] | ||
struct Foo {} | ||
|
||
fn bar(foo: Foo) { | ||
} | ||
fn foo(&_a: Foo) {} //~ ERROR mismatched types | ||
|
||
fn qux(foo: &Foo) { | ||
} | ||
fn bar(_a: Foo) {} | ||
|
||
fn zar(&foo: &Foo) { | ||
} | ||
fn qux(_a: &Foo) {} | ||
|
||
// The somewhat unexpected help message in this case is courtesy of | ||
// match_default_bindings. | ||
fn agh(&&bar: &u32) { //~ ERROR mismatched types | ||
} | ||
fn zar(&_a: &Foo) {} | ||
|
||
fn bgh(&&bar: u32) { //~ ERROR mismatched types | ||
} | ||
|
||
fn ugh(&[bar]: &u32) { //~ ERROR expected an array or slice | ||
} | ||
fn agh(&&_a: &u32) {} //~ ERROR mismatched types | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,46 +1,35 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-38371.rs:4:8 | ||
--> $DIR/issue-38371.rs:8:8 | ||
| | ||
LL | fn foo(&foo: Foo) { | ||
| ^^^^----- | ||
| | | | ||
| | expected due to this | ||
LL | fn foo(&_a: Foo) {} | ||
| ^^^ --- expected due to this | ||
| | | ||
| expected struct `Foo`, found reference | ||
| help: did you mean `foo`: `&Foo` | ||
| | ||
= note: expected struct `Foo` | ||
found reference `&_` | ||
help: to take parameter by ref, move `&` to the type | ||
| | ||
LL - fn foo(&_a: Foo) {} | ||
LL + fn foo(_a: &Foo) {} | ||
| | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-38371.rs:18:9 | ||
--> $DIR/issue-38371.rs:16:9 | ||
| | ||
LL | fn agh(&&bar: &u32) { | ||
| ^^^^ ---- expected due to this | ||
LL | fn agh(&&_a: &u32) {} | ||
| ^^^ ---- expected due to this | ||
| | | ||
| expected `u32`, found reference | ||
| help: you can probably remove the explicit borrow: `bar` | ||
| | ||
= note: expected type `u32` | ||
found reference `&_` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-38371.rs:21:8 | ||
| | ||
LL | fn bgh(&&bar: u32) { | ||
| ^^^^^ --- expected due to this | ||
| | | ||
| expected `u32`, found reference | ||
| | ||
= note: expected type `u32` | ||
found reference `&_` | ||
|
||
error[E0529]: expected an array or slice, found `u32` | ||
--> $DIR/issue-38371.rs:24:9 | ||
help: consider removing `&` from the pattern | ||
| | ||
LL | fn ugh(&[bar]: &u32) { | ||
| ^^^^^ pattern cannot match with input type `u32` | ||
LL - fn agh(&&_a: &u32) {} | ||
LL + fn agh(&_a: &u32) {} | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0308, E0529. | ||
For more information about an error, try `rustc --explain E0308`. | ||
For more information about this error, try `rustc --explain E0308`. |
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,24 @@ | ||
// run-rustfix | ||
|
||
fn _f0(_a: &u32) {} //~ ERROR mismatched types | ||
fn _f1(_a: &mut u32) {} //~ ERROR mismatched types | ||
fn _f2(&_a: &u32) {} //~ ERROR mismatched types | ||
fn _f3(&mut _a: &mut u32) {} //~ ERROR mismatched types | ||
fn _f4(&_a: &u32) {} //~ ERROR mismatched types | ||
fn _f5(&mut _a: &mut u32) {} //~ ERROR mismatched types | ||
|
||
fn main() { | ||
let _: fn(u32) = |_a| (); //~ ERROR mismatched types | ||
let _: fn(u32) = |_a| (); //~ ERROR mismatched types | ||
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types | ||
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types | ||
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types | ||
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types | ||
|
||
let _ = |_a: &u32| (); //~ ERROR mismatched types | ||
let _ = |_a: &mut u32| (); //~ ERROR mismatched types | ||
let _ = |&_a: &u32| (); //~ ERROR mismatched types | ||
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types | ||
let _ = |&_a: &u32| (); //~ ERROR mismatched types | ||
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types | ||
} |
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,24 @@ | ||
// run-rustfix | ||
|
||
fn _f0(&_a: u32) {} //~ ERROR mismatched types | ||
fn _f1(&mut _a: u32) {} //~ ERROR mismatched types | ||
fn _f2(&&_a: &u32) {} //~ ERROR mismatched types | ||
fn _f3(&mut &_a: &mut u32) {} //~ ERROR mismatched types | ||
fn _f4(&&mut _a: &u32) {} //~ ERROR mismatched types | ||
fn _f5(&mut &mut _a: &mut u32) {} //~ ERROR mismatched types | ||
|
||
fn main() { | ||
let _: fn(u32) = |&_a| (); //~ ERROR mismatched types | ||
let _: fn(u32) = |&mut _a| (); //~ ERROR mismatched types | ||
let _: fn(&u32) = |&&_a| (); //~ ERROR mismatched types | ||
let _: fn(&mut u32) = |&mut &_a| (); //~ ERROR mismatched types | ||
let _: fn(&u32) = |&&mut _a| (); //~ ERROR mismatched types | ||
let _: fn(&mut u32) = |&mut &mut _a| (); //~ ERROR mismatched types | ||
|
||
let _ = |&_a: u32| (); //~ ERROR mismatched types | ||
let _ = |&mut _a: u32| (); //~ ERROR mismatched types | ||
let _ = |&&_a: &u32| (); //~ ERROR mismatched types | ||
let _ = |&mut &_a: &mut u32| (); //~ ERROR mismatched types | ||
let _ = |&&mut _a: &u32| (); //~ ERROR mismatched types | ||
let _ = |&mut &mut _a: &mut u32| (); //~ ERROR mismatched types | ||
} |
Oops, something went wrong.