-
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.
Make sure that the method resolution matches in note_source_of_type_m…
…ismatch_constraint
- Loading branch information
1 parent
54692c3
commit 70bf324
Showing
3 changed files
with
69 additions
and
6 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
25 changes: 25 additions & 0 deletions
25
tests/ui/mismatched_types/diagnostic-method-lookup-returns-sig-with-fewer-args.rs
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,25 @@ | ||
fn main() { | ||
let target: Target = create_target(); | ||
target.get(0); // correct arguments work | ||
target.get(10.0); // (used to crash here) | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
// must be generic | ||
fn create_target<T>() -> T { | ||
unimplemented!() | ||
} | ||
|
||
// unimplemented trait, but contains function with the same name | ||
pub trait RandomTrait { | ||
fn get(&mut self); // but less arguments | ||
} | ||
|
||
struct Target; | ||
|
||
impl Target { | ||
// correct function with arguments | ||
pub fn get(&self, data: i32) { | ||
unimplemented!() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/mismatched_types/diagnostic-method-lookup-returns-sig-with-fewer-args.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,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/diagnostic-method-lookup-returns-sig-with-fewer-args.rs:4:16 | ||
| | ||
LL | target.get(10.0); // (used to crash here) | ||
| --- ^^^^ expected `i32`, found floating-point number | ||
| | | ||
| arguments to this method are incorrect | ||
| | ||
note: method defined here | ||
--> $DIR/diagnostic-method-lookup-returns-sig-with-fewer-args.rs:22:12 | ||
| | ||
LL | pub fn get(&self, data: i32) { | ||
| ^^^ --------- | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |