Bless tests.

This commit is contained in:
Camille GILLOT 2022-04-21 22:44:48 +02:00
parent 257d8fce3e
commit 84e19930e3
4 changed files with 0 additions and 267 deletions

View file

@ -1,109 +0,0 @@
// Issue #21633: reject duplicate loop labels in function bodies.
// This is testing interaction between lifetime-params and labels.
// check-pass
#![allow(dead_code, unused_variables)]
fn foo() {
fn foo<'a>() {
'a: loop { break 'a; }
//~^ WARN label name `'a` shadows a lifetime name that is already in scope
}
struct Struct<'b, 'c> { _f: &'b i8, _g: &'c i8 }
enum Enum<'d, 'e> { A(&'d i8), B(&'e i8) }
impl<'d, 'e> Struct<'d, 'e> {
fn meth_okay() {
'a: loop { break 'a; }
'b: loop { break 'b; }
'c: loop { break 'c; }
}
}
impl <'d, 'e> Enum<'d, 'e> {
fn meth_okay() {
'a: loop { break 'a; }
'b: loop { break 'b; }
'c: loop { break 'c; }
}
}
impl<'bad, 'c> Struct<'bad, 'c> {
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
impl<'b, 'bad> Struct<'b, 'bad> {
fn meth_bad2(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
impl<'b, 'c> Struct<'b, 'c> {
fn meth_bad3<'bad>(x: &'bad i8) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
fn meth_bad4<'a,'bad>(x: &'a i8, y: &'bad i8) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
impl <'bad, 'e> Enum<'bad, 'e> {
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
impl <'d, 'bad> Enum<'d, 'bad> {
fn meth_bad2(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
impl <'d, 'e> Enum<'d, 'e> {
fn meth_bad3<'bad>(x: &'bad i8) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
fn meth_bad4<'a,'bad>(x: &'bad i8) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
trait HasDefaultMethod1<'bad> {
fn meth_okay() {
'c: loop { break 'c; }
}
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
trait HasDefaultMethod2<'a,'bad> {
fn meth_bad(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
trait HasDefaultMethod3<'a,'b> {
fn meth_bad<'bad>(&self) {
'bad: loop { break 'bad; }
//~^ WARN label name `'bad` shadows a lifetime name that is already in scope
}
}
}
pub fn main() {
foo();
}

View file

@ -1,104 +0,0 @@
warning: label name `'a` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:10:9
|
LL | fn foo<'a>() {
| -- first declared here
LL | 'a: loop { break 'a; }
| ^^ lifetime `'a` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:35:13
|
LL | impl<'bad, 'c> Struct<'bad, 'c> {
| ---- first declared here
LL | fn meth_bad(&self) {
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:42:13
|
LL | impl<'b, 'bad> Struct<'b, 'bad> {
| ---- first declared here
LL | fn meth_bad2(&self) {
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:49:13
|
LL | fn meth_bad3<'bad>(x: &'bad i8) {
| ---- first declared here
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:54:13
|
LL | fn meth_bad4<'a,'bad>(x: &'a i8, y: &'bad i8) {
| ---- first declared here
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:61:13
|
LL | impl <'bad, 'e> Enum<'bad, 'e> {
| ---- first declared here
LL | fn meth_bad(&self) {
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:67:13
|
LL | impl <'d, 'bad> Enum<'d, 'bad> {
| ---- first declared here
LL | fn meth_bad2(&self) {
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:73:13
|
LL | fn meth_bad3<'bad>(x: &'bad i8) {
| ---- first declared here
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:78:13
|
LL | fn meth_bad4<'a,'bad>(x: &'bad i8) {
| ---- first declared here
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:88:13
|
LL | trait HasDefaultMethod1<'bad> {
| ---- first declared here
...
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:94:13
|
LL | trait HasDefaultMethod2<'a,'bad> {
| ---- first declared here
LL | fn meth_bad(&self) {
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: label name `'bad` shadows a lifetime name that is already in scope
--> $DIR/loops-reject-labels-shadowing-lifetimes.rs:100:13
|
LL | fn meth_bad<'bad>(&self) {
| ---- first declared here
LL | 'bad: loop { break 'bad; }
| ^^^^ lifetime `'bad` already in scope
warning: 12 warnings emitted

View file

@ -1,36 +0,0 @@
// check-pass
#![feature(label_break_value)]
#![allow(dead_code, unused_variables)]
// Issue #21633: reject duplicate loop labels and block labels in function bodies.
//
// Test rejection of lifetimes in *expressions* that shadow labels.
fn foo() {
// Reusing lifetime `'a` in function item is okay.
fn foo<'a>(x: &'a i8) -> i8 { *x }
// So is reusing `'a` in struct item
struct S1<'a> { x: &'a i8 } impl<'a> S1<'a> { fn m(&self) {} }
// and a method item
struct S2; impl S2 { fn m<'a>(&self) {} }
let z = 3_i8;
'a: loop {
let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>;
//~^ WARN lifetime name `'a` shadows a label name that is already in scope
assert_eq!((*b)(&z), z);
break 'a;
}
'b: {
let b = Box::new(|x: &()| ()) as Box<dyn for <'b> Fn(&'b ())>;
//~^ WARN lifetime name `'b` shadows a label name that is already in scope
break 'b;
}
}
pub fn main() {
foo();
}

View file

@ -1,18 +0,0 @@
warning: lifetime name `'a` shadows a label name that is already in scope
--> $DIR/loops-reject-lifetime-shadowing-label.rs:21:55
|
LL | 'a: loop {
| -- first declared here
LL | let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>;
| ^^ label `'a` already in scope
warning: lifetime name `'b` shadows a label name that is already in scope
--> $DIR/loops-reject-lifetime-shadowing-label.rs:28:55
|
LL | 'b: {
| -- first declared here
LL | let b = Box::new(|x: &()| ()) as Box<dyn for <'b> Fn(&'b ())>;
| ^^ label `'b` already in scope
warning: 2 warnings emitted