-
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.
Check unnormalized signature on pointer cast
- Loading branch information
1 parent
a7d02aa
commit 86a3123
Showing
7 changed files
with
126 additions
and
13 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
11 changes: 11 additions & 0 deletions
11
tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance-early-bound.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,11 @@ | ||
static UNIT: &'static &'static () = &&(); | ||
|
||
fn foo<'a: 'a, 'b: 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v } | ||
|
||
fn bad<'a, T>(x: &'a T) -> &'static T { | ||
let f: fn(_, &'a T) -> &'static T = foo; | ||
//~^ ERROR lifetime may not live long enough | ||
f(UNIT, x) | ||
} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance-early-bound.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,10 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/implied-bounds-on-nested-references-plus-variance-early-bound.rs:6:12 | ||
| | ||
LL | fn bad<'a, T>(x: &'a T) -> &'static T { | ||
| -- lifetime `'a` defined here | ||
LL | let f: fn(_, &'a T) -> &'static T = foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` | ||
|
||
error: aborting due to 1 previous error | ||
|
17 changes: 17 additions & 0 deletions
17
tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance-unnormalized.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,17 @@ | ||
trait ToArg<T> { | ||
type Arg; | ||
} | ||
impl<T, U> ToArg<T> for U { | ||
type Arg = T; | ||
} | ||
|
||
fn extend_inner<'a, 'b>(x: &'a str) -> <&'b &'a () as ToArg<&'b str>>::Arg { x } | ||
fn extend<'a, 'b>(x: &'a str) -> &'b str { | ||
(extend_inner as fn(_) -> _)(x) | ||
//~^ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn main() { | ||
let y = extend(&String::from("Hello World")); | ||
println!("{}", y); | ||
} |
14 changes: 14 additions & 0 deletions
14
...s/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance-unnormalized.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,14 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/implied-bounds-on-nested-references-plus-variance-unnormalized.rs:10:5 | ||
| | ||
LL | fn extend<'a, 'b>(x: &'a str) -> &'b str { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
LL | (extend_inner as fn(_) -> _)(x) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | ||
| | ||
= help: consider adding the following bound: `'a: 'b` | ||
|
||
error: aborting due to 1 previous error | ||
|
7 changes: 1 addition & 6 deletions
7
tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.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
10 changes: 10 additions & 0 deletions
10
tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.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,10 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/implied-bounds-on-nested-references-plus-variance.rs:6:12 | ||
| | ||
LL | fn bad<'a, T>(x: &'a T) -> &'static T { | ||
| -- lifetime `'a` defined here | ||
LL | let f: fn(_, &'a T) -> &'static T = foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` | ||
|
||
error: aborting due to 1 previous error | ||
|