Skip to content
Open
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
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ ui/for-loop-while/issue-1257.rs
ui/for-loop-while/issue-2216.rs
ui/for-loop-while/issue-51345.rs
ui/for-loop-while/issue-69841.rs
ui/for/issue-20605.rs
ui/foreign/issue-74120-lowering-of-ffi-block-bodies.rs
ui/foreign/issue-91370-foreign-fn-block-impl.rs
ui/foreign/issue-99276-same-type-lifetimes.rs
Expand Down
10 changes: 0 additions & 10 deletions tests/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,6 @@ Exercises the `format!` macro.

A broad category of tests on functions.

## `tests/ui/for/`: `for` keyword

Tests on the `for` keyword and some of its associated errors, such as attempting to write the faulty pattern `for _ in 0..1 {} else {}`.

**FIXME**: Should be merged with `ui/for-loop-while`.

## `tests/ui/force-inlining/`: `#[rustc_force_inline]`

Tests for `#[rustc_force_inline]`, which will force a function to always be labelled as inline by the compiler (it will be inserted at the point of its call instead of being used as a normal function call.) If the compiler is unable to inline the function, an error will be reported. See <https://github.com/rust-lang/rust/pull/134082>.
Expand Down Expand Up @@ -1545,10 +1539,6 @@ Tests on `enum` variants.

**FIXME**: Contains a single test described as "Check that rustc accepts various version info flags.", should be rehomed.

## `tests/ui/warnings/`

**FIXME**: Contains a single test on non-explicit paths (`::one()`). Should be rehomed probably to `tests/ui/resolve/`.

## `tests/ui/wasm/`

These tests target the `wasm32` architecture specifically. They are usually regression tests for WASM-specific bugs which were observed in the past.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// E0277 should point exclusively at line 6, not the entire for loop span
//! Tests that the E0277 error span, generated by the `for` loop desugaring,
//! points exclusively to the loop header expression and not the full loop block.
fn main() {
for c in "asdf" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: `&str` is not an iterator
--> $DIR/for-c-in-str.rs:4:14
--> $DIR/for-c-in-str.rs:5:14
|
LL | for c in "asdf" {
| ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()`
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions tests/ui/for-loop-while/for-loop-bogosity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Tests that a struct with a `next` method but without the `Iterator` trait
//! implementation yields an error in a `for` loop.

struct MyStruct {
x: isize,
y: isize,
}

impl MyStruct {
fn next(&mut self) -> Option<isize> {
Some(self.x)
}
}

pub fn main() {
let mut bogus = MyStruct { x: 1, y: 2 };
for x in bogus {
//~^ ERROR `MyStruct` is not an iterator
drop(x);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | for x in bogus {
| ^^^^^ `MyStruct` is not an iterator
|
help: the trait `Iterator` is not implemented for `MyStruct`
--> $DIR/for-loop-bogosity.rs:1:1
--> $DIR/for-loop-bogosity.rs:4:1
|
LL | struct MyStruct {
| ^^^^^^^^^^^^^^^
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0425]: cannot find value `foo` in this scope
--> $DIR/for-expn.rs:6:7
--> $DIR/for-loop-diagnostic-span.rs:6:7
|
LL | foo
| ^^^ not found in this scope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! regression test for issue <https://github.com/rust-lang/rust/issues/16042>

pub fn main() {
let x = () + (); //~ ERROR cannot add `()` to `()`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0369]: cannot add `()` to `()`
--> $DIR/for-loop-type-error.rs:2:16
--> $DIR/for-loop-type-error.rs:4:16
|
LL | let x = () + ();
| -- ^ -- ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// Subtle changes in the desugaring can cause the
// type of elements in the vector to (incorrectly)
// fallback to `!` or `()`.
// regression test for issue <https://github.com/rust-lang/rust/issues/42618>

fn main() {
for i in Vec::new() { } //~ ERROR type annotations needed
for i in Vec::new() {} //~ ERROR type annotations needed
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0282]: type annotations needed
--> $DIR/for-loop-unconstrained-element-type.rs:8:14
--> $DIR/for-loop-unconstrained-element-type.rs:9:14
|
LL | for i in Vec::new() { }
LL | for i in Vec::new() {}
| ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec`
|
help: consider specifying the generic argument
|
LL | for i in Vec::<T>::new() { }
LL | for i in Vec::<T>::new() {}
| +++++

error: aborting due to 1 previous error
Expand Down
21 changes: 0 additions & 21 deletions tests/ui/for/for-loop-bogosity.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/for/issue-20605.rs

This file was deleted.

26 changes: 0 additions & 26 deletions tests/ui/for/iter_from_mac_call.rs

This file was deleted.

35 changes: 0 additions & 35 deletions tests/ui/for/iter_from_mac_call.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! regression test for issue <https://github.com/rust-lang/rust/issues/122509>
//@ build-pass
//@ compile-flags: -C codegen-units=2 --emit asm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
--> $DIR/issue-20605.rs:6:17
--> $DIR/dyn-iterator-deref-in-for-loop.rs:9:17
|
LL | for item in *things { *item = 0 }
LL | for item in *things {
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
help: consider mutably borrowing here
|
LL | for item in &mut *things { *item = 0 }
LL | for item in &mut *things {
| ++++

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
--> $DIR/issue-20605.rs:6:17
--> $DIR/dyn-iterator-deref-in-for-loop.rs:9:17
|
LL | for item in *things { *item = 0 }
LL | for item in *things {
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
help: consider mutably borrowing here
|
LL | for item in &mut *things { *item = 0 }
LL | for item in &mut *things {
| ++++

error: aborting due to 1 previous error
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/traits/dyn-iterator-deref-in-for-loop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Tests that dereferencing a Box<dyn Iterator> in a for loop correctly yields an error,
//! as the unsized trait object does not implement IntoIterator.
//! regression test for <https://github.com/rust-lang/rust/issues/20605>
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

fn changer<'a>(mut things: Box<dyn Iterator<Item = &'a mut u8>>) {
for item in *things {
//~^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator
*item = 0
}
}
Comment on lines +8 to +13
Copy link
Contributor Author

@reddevilmidzy reddevilmidzy Nov 29, 2025

Choose a reason for hiding this comment

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

I have a quastion.
Can it be considered the same as for-loop-while/iter-from-mac-call.rs and traits/dyn-iterator-deref-in-for-loop?
When this test was first added, there were no special flags. 3a62590

Copy link
Member

Choose a reason for hiding this comment

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

I feel like it's fine to consider them as the same test, because this two functions are basically the same, you maybe could remove this f1 function and keep traits/dyn-iterator-deref-in-for-loop


fn main() {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there was only one test in the trait-object directory (and it wasn't in README.md), I moved it to traits/object.

File renamed without changes.
Loading