Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/ui/array-slice-vec/closure-in-array-len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! regression test for <https://github.com/rust-lang/rust/issues/50600>
struct Foo(
fn([u8; |x: u8| {}]), //~ ERROR mismatched types
);

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0308]: mismatched types
--> $DIR/issue-50600.rs:2:13
--> $DIR/closure-in-array-len.rs:3:13
|
LL | fn([u8; |x: u8| {}]),
| ^^^^^^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
found closure `{closure@$DIR/issue-50600.rs:2:13: 2:20}`
found closure `{closure@$DIR/closure-in-array-len.rs:3:13: 3:20}`

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! regression test for <https://github.com/rust-lang/rust/issues/51714>
fn main() {
//~^ NOTE: not the enclosing function body
//~| NOTE: not the enclosing function body
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:6:13
--> $DIR/return-in-array-len.rs:7:13
|
LL | / fn main() {
... |
Expand All @@ -10,7 +10,7 @@ LL | | }
| |_- ...not the enclosing function body

error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:10:10
--> $DIR/return-in-array-len.rs:11:10
|
LL | / fn main() {
... |
Expand All @@ -21,7 +21,7 @@ LL | | }
| |_- ...not the enclosing function body

error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:14:10
--> $DIR/return-in-array-len.rs:15:10
|
LL | / fn main() {
... |
Expand All @@ -32,7 +32,7 @@ LL | | }
| |_- ...not the enclosing function body

error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:18:10
--> $DIR/return-in-array-len.rs:19:10
|
LL | / fn main() {
... |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! regression test for <https://github.com/rust-lang/rust/issues/17503>
//@ run-pass
fn main() {
let s: &[isize] = &[0, 1, 2, 3, 4];
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/derives/derive-hygiene-struct-builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! regression test for <https://github.com/rust-lang/rust/issues/42453>
//! struct named "builder" conflicted with derive macro internals.
//@ run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]

#[derive(Debug)]
struct builder;

fn main() {}
8 changes: 8 additions & 0 deletions tests/ui/dst/unsized-str-mutability.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! regression test for <https://github.com/rust-lang/rust/issues/17361>
//! Test that HIR ty lowering doesn't forget about mutability of `&mut str`.
//@ run-pass

fn main() {
fn foo<T: ?Sized>(_: &mut T) {}
let _f: fn(&mut str) = foo;
}
40 changes: 31 additions & 9 deletions tests/ui/for-loop-while/break-outside-loop.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
struct Foo {
t: String
t: String,
}

fn cond() -> bool { true }
fn cond() -> bool {
true
}

fn foo<F>(_: F) where F: FnOnce() {}
fn foo<F>(_: F)
where
F: FnOnce(),
{
}

fn main() {
let pth = break; //~ ERROR: `break` outside of a loop
if cond() { continue } //~ ERROR: `continue` outside of a loop
if cond() {
continue; //~ ERROR: `continue` outside of a loop
}

while cond() {
if cond() { break }
if cond() { continue }
if cond() {
break;
}
if cond() {
continue;
}
foo(|| {
if cond() { break } //~ ERROR: `break` inside of a closure
if cond() { continue } //~ ERROR: `continue` inside of a closure
if cond() {
break; //~ ERROR: `break` inside of a closure
}
if cond() {
continue; //~ ERROR: `continue` inside of a closure
}
})
}

let rs: Foo = Foo{t: pth};
let rs: Foo = Foo { t: pth };

let unconstrained = break; //~ ERROR: `break` outside of a loop

Expand All @@ -32,4 +48,10 @@ fn main() {
//~| ERROR `break` inside of a closure
};
}

// Make sure that a continue span actually contains the keyword. (#28105)
continue //~ ERROR `continue` outside of a loop
;
break //~ ERROR `break` outside of a loop
;
}
43 changes: 28 additions & 15 deletions tests/ui/for-loop-while/break-outside-loop.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0767]: use of unreachable label `'lab`
--> $DIR/break-outside-loop.rs:30:19
--> $DIR/break-outside-loop.rs:46:19
|
LL | 'lab: loop {
| ---- unreachable label defined here
Expand All @@ -10,49 +10,62 @@ LL | break 'lab;
= note: labels are unreachable through functions, closures, async blocks and modules

error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-outside-loop.rs:10:15
--> $DIR/break-outside-loop.rs:16:15
|
LL | let pth = break;
| ^^^^^ cannot `break` outside of a loop or labeled block

error[E0268]: `continue` outside of a loop
--> $DIR/break-outside-loop.rs:11:17
--> $DIR/break-outside-loop.rs:18:9
|
LL | if cond() { continue }
| ^^^^^^^^ cannot `continue` outside of a loop
LL | continue;
| ^^^^^^^^ cannot `continue` outside of a loop

error[E0267]: `break` inside of a closure
--> $DIR/break-outside-loop.rs:17:25
--> $DIR/break-outside-loop.rs:30:17
|
LL | foo(|| {
| -- enclosing closure
LL | if cond() { break }
| ^^^^^ cannot `break` inside of a closure
LL | if cond() {
LL | break;
| ^^^^^ cannot `break` inside of a closure

error[E0267]: `continue` inside of a closure
--> $DIR/break-outside-loop.rs:18:25
--> $DIR/break-outside-loop.rs:33:17
|
LL | foo(|| {
| -- enclosing closure
LL | if cond() { break }
LL | if cond() { continue }
| ^^^^^^^^ cannot `continue` inside of a closure
...
LL | continue;
| ^^^^^^^^ cannot `continue` inside of a closure

error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-outside-loop.rs:24:25
--> $DIR/break-outside-loop.rs:40:25
|
LL | let unconstrained = break;
| ^^^^^ cannot `break` outside of a loop or labeled block

error[E0267]: `break` inside of a closure
--> $DIR/break-outside-loop.rs:30:13
--> $DIR/break-outside-loop.rs:46:13
|
LL | || {
| -- enclosing closure
LL | break 'lab;
| ^^^^^^^^^^ cannot `break` inside of a closure

error: aborting due to 7 previous errors
error[E0268]: `continue` outside of a loop
--> $DIR/break-outside-loop.rs:53:5
|
LL | continue
| ^^^^^^^^ cannot `continue` outside of a loop

error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-outside-loop.rs:55:5
|
LL | break
| ^^^^^ cannot `break` outside of a loop or labeled block

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0267, E0268, E0767.
For more information about an error, try `rustc --explain E0267`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is generics

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! regression test for <https://github.com/rust-lang/rust/issues/22706>
fn is_copy<T: ::std::marker<i32>::Copy>() {}
//~^ ERROR type arguments are not allowed on module `marker` [E0109]
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0109]: type arguments are not allowed on module `marker`
--> $DIR/issue-22706.rs:1:29
--> $DIR/type-args-on-module-in-bound.rs:2:29
|
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
| ------ ^^^ type argument not allowed
Expand Down
8 changes: 0 additions & 8 deletions tests/ui/issues/issue-16725.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/issues/issue-17361.rs

This file was deleted.

25 changes: 0 additions & 25 deletions tests/ui/issues/issue-22577.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/issues/issue-28105.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/ui/issues/issue-28105.stderr

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/issues/issue-28433.rs

This file was deleted.

19 changes: 0 additions & 19 deletions tests/ui/issues/issue-28433.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/issues/issue-42453.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/ui/issues/issue-43057.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/ui/issues/issue-50600.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Make sure that label for continue and break is spanned correctly
//! regression test for <https://github.com/rust-lang/rust/issues/28109>
//! Make sure that label for continue and break is spanned correctly.

fn main() {
loop {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0426]: use of undeclared label `'b`
--> $DIR/issue-28109.rs:6:9
--> $DIR/undeclared-label-span.rs:7:9
|
LL | 'b
| ^^ undeclared label `'b`

error[E0426]: use of undeclared label `'c`
--> $DIR/issue-28109.rs:9:9
--> $DIR/undeclared-label-span.rs:10:9
|
LL | 'c
| ^^ undeclared label `'c`
Expand Down
Loading
Loading