Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Probe for candidates on based on the actual receiver type
Impl blocks Self type is a TypeNoBouns which means it can be for types such as: impl<T> &T {}. I think we might need to change the probe algorithm for method calls to be fully based on the autoderef rather than trying to filter based on the Self type. More investigation is needed for the probe phase here. Fixes #808
- Loading branch information
Showing
2 changed files
with
41 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pub trait Foo { | ||
type Target; | ||
// { dg-warning "unused name" "" { target *-*-* } .-1 } | ||
|
||
fn bar(&self) -> &Self::Target; | ||
// { dg-warning "unused name .self." "" { target *-*-* } .-1 } | ||
// { dg-warning "unused name .Foo::bar." "" { target *-*-* } .-2 } | ||
} | ||
|
||
impl<T> Foo for &T { | ||
type Target = T; | ||
|
||
fn bar(&self) -> &T { | ||
*self | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let a: i32 = 123; | ||
let b: &i32 = &a; | ||
|
||
b.bar(); | ||
} |