-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't ignore
_
in type casts and ascriptions
- Loading branch information
1 parent
c76e557
commit 1593ac9
Showing
4 changed files
with
89 additions
and
10 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
40 changes: 40 additions & 0 deletions
40
src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.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,40 @@ | ||
// Check that repeated type variables are correctly handled | ||
|
||
#![allow(unused)] | ||
#![feature(nll, type_ascription)] | ||
|
||
type PairUncoupled<'a, 'b, T> = (&'a T, &'b T); | ||
type PairCoupledTypes<T> = (T, T); | ||
type PairCoupledRegions<'a, T> = (&'a T, &'a T); | ||
|
||
fn uncoupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),): (PairUncoupled<_>,); | ||
y // OK | ||
} | ||
|
||
fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); | ||
y //~ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); | ||
y //~ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn cast_uncoupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),) as (PairUncoupled<_>,); | ||
y // OK | ||
} | ||
|
||
fn cast_coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),) as (PairCoupledTypes<_>,); | ||
y //~ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn cast_coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
let ((y, _z),) = ((s, _x),) as (PairCoupledRegions<_>,); | ||
y //~ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn main() {} |
38 changes: 38 additions & 0 deletions
38
src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.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,38 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-57731-ascibed-coupled-types.rs:17:5 | ||
| | ||
LL | fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
| -- lifetime `'a` defined here | ||
LL | let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); | ||
LL | y //~ ERROR lifetime may not live long enough | ||
| ^ returning this value requires that `'a` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/issue-57731-ascibed-coupled-types.rs:22:5 | ||
| | ||
LL | fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
| -- lifetime `'a` defined here | ||
LL | let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); | ||
LL | y //~ ERROR lifetime may not live long enough | ||
| ^ returning this value requires that `'a` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/issue-57731-ascibed-coupled-types.rs:32:5 | ||
| | ||
LL | fn cast_coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
| -- lifetime `'a` defined here | ||
LL | let ((y, _z),) = ((s, _x),) as (PairCoupledTypes<_>,); | ||
LL | y //~ ERROR lifetime may not live long enough | ||
| ^ returning this value requires that `'a` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/issue-57731-ascibed-coupled-types.rs:37:5 | ||
| | ||
LL | fn cast_coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { | ||
| -- lifetime `'a` defined here | ||
LL | let ((y, _z),) = ((s, _x),) as (PairCoupledRegions<_>,); | ||
LL | y //~ ERROR lifetime may not live long enough | ||
| ^ returning this value requires that `'a` must outlive `'static` | ||
|
||
error: aborting due to 4 previous errors | ||
|