-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
typeck_results.node_type
to resolve types (#351)
...in the suspicious trait object lint so that all type paths are handled, even in the case of a possible associated type.
- Loading branch information
Showing
4 changed files
with
66 additions
and
23 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,30 @@ | ||
#![crate_type = "lib"] | ||
|
||
trait Object { | ||
type Output; | ||
} | ||
|
||
impl<T: ?Sized> Object for T { | ||
type Output = &'static u64; | ||
} | ||
|
||
trait HasGenericAssoc { | ||
type Ohno<'a>: ?Sized; | ||
} | ||
|
||
impl HasGenericAssoc for () { | ||
type Ohno<'a> = dyn Object<Output = &'a u64>; | ||
} | ||
|
||
fn foo<'a, T: ?Sized>(x: <T as Object>::Output) -> &'a u64 { | ||
x | ||
} | ||
|
||
fn transmute_lifetime<'a, 'b>(x: &'a u64) -> &'b u64 { | ||
foo::<<() as HasGenericAssoc>::Ohno<'a>>(x) | ||
} | ||
|
||
pub fn get_dangling<'a>() -> &'a u64 { | ||
let x = 0; | ||
transmute_lifetime(&x) | ||
} |
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: using trait objects in turbofish position is forbidden by PL/Rust | ||
--> $DIR/sus_trait_object_gat.rs:24:5 | ||
| | ||
LL | foo::<<() as HasGenericAssoc>::Ohno<'a>>(x) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-F plrust-suspicious-trait-object` implied by `-F plrust-lints` | ||
|
||
error: aborting due to previous error | ||
|