Incorporate issue-111692.rs into the larger test file and add more test cases

Note that issue-111692.rs was incorrectly named: It's a regression test for
issue [#]112278, not for [#]111692. That's been addressed, too.
This commit is contained in:
León Orell Valerian Liehr 2025-03-24 17:39:38 +01:00
parent 598f865874
commit b501e58c2e
No known key found for this signature in database
GPG key ID: D17A07215F68E713
5 changed files with 66 additions and 84 deletions

View file

@ -3189,7 +3189,6 @@ ui/parser/issues/issue-108495-dec.rs
ui/parser/issues/issue-110014.rs
ui/parser/issues/issue-111148.rs
ui/parser/issues/issue-111416.rs
ui/parser/issues/issue-111692.rs
ui/parser/issues/issue-112188.rs
ui/parser/issues/issue-112458.rs
ui/parser/issues/issue-113110-non-item-at-module-root.rs

View file

@ -1,34 +0,0 @@
mod module {
#[derive(Eq, PartialEq)]
pub struct Type {
pub x: u8,
pub y: u8,
}
pub const C: u8 = 32u8;
}
fn test(x: module::Type) {
if x == module::Type { x: module::C, y: 1 } { //~ ERROR struct literals are not allowed here
}
}
fn test2(x: module::Type) {
if x ==module::Type { x: module::C, y: 1 } { //~ ERROR struct literals are not allowed here
}
}
fn test3(x: module::Type) {
use module::Type;
if x == Type { x: module::C, y: 1 } { //~ ERROR struct literals are not allowed here
}
}
fn test4(x: module::Type) {
use module as demo_module;
if x == demo_module::Type { x: module::C, y: 1 } { //~ ERROR struct literals are not allowed here
}
}
fn main() { }

View file

@ -1,46 +0,0 @@
error: struct literals are not allowed here
--> $DIR/issue-111692.rs:12:13
|
LL | if x == module::Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if x == (module::Type { x: module::C, y: 1 }) {
| + +
error: struct literals are not allowed here
--> $DIR/issue-111692.rs:17:12
|
LL | if x ==module::Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if x ==(module::Type { x: module::C, y: 1 }) {
| + +
error: struct literals are not allowed here
--> $DIR/issue-111692.rs:24:13
|
LL | if x == Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if x == (Type { x: module::C, y: 1 }) {
| + +
error: struct literals are not allowed here
--> $DIR/issue-111692.rs:30:13
|
LL | if x == demo_module::Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if x == (demo_module::Type { x: module::C, y: 1 }) {
| + +
error: aborting due to 4 previous errors

View file

@ -45,12 +45,30 @@ fn main() {
println!("yo");
}
// This uses `one()` over `1` as token `one` may begin a type and thus back when type ascription
// `$expr : $ty` still existed, `{ x: one` could've been the start of a block expr which used to
// make the compiler take a different execution path. Now it no longer makes a difference tho.
// Regression test for <https://github.com/rust-lang/rust/issues/82051>.
if Foo { x: one(), }.hi() { //~ ERROR struct literals are not allowed here
println!("Positive!");
}
const FOO: Foo = Foo { x: 1 };
// Below, test that we correctly parenthesize the struct literals.
// Regression test for <https://github.com/rust-lang/rust/issues/112278>.
if FOO == self::Foo { x: one() } {} //~ ERROR struct literals are not allowed here
if FOO == Foo::<> { x: one() } {} //~ ERROR struct literals are not allowed here
fn env<T: Trait<Out = Foo>>() {
if FOO == <T as Trait>::Out { x: one() } {} //~ ERROR struct literals are not allowed here
//~^ ERROR usage of qualified paths in this context is experimental
}
}
#[derive(PartialEq, Eq)]
struct Foo {
x: isize,
}
@ -70,3 +88,5 @@ enum E {
}
fn one() -> isize { 1 }
trait Trait { type Out; }

View file

@ -120,7 +120,7 @@ LL | while || (Foo { x: 3 }).hi() {
| + +
error: struct literals are not allowed here
--> $DIR/struct-literals-in-invalid-places.rs:49:8
--> $DIR/struct-literals-in-invalid-places.rs:53:8
|
LL | if Foo { x: one(), }.hi() {
| ^^^^^^^^^^^^^^^^^
@ -130,6 +130,49 @@ help: surround the struct literal with parentheses
LL | if (Foo { x: one(), }).hi() {
| + +
error: struct literals are not allowed here
--> $DIR/struct-literals-in-invalid-places.rs:61:15
|
LL | if FOO == self::Foo { x: one() } {}
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if FOO == (self::Foo { x: one() }) {}
| + +
error: struct literals are not allowed here
--> $DIR/struct-literals-in-invalid-places.rs:63:15
|
LL | if FOO == Foo::<> { x: one() } {}
| ^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if FOO == (Foo::<> { x: one() }) {}
| + +
error: struct literals are not allowed here
--> $DIR/struct-literals-in-invalid-places.rs:66:19
|
LL | if FOO == <T as Trait>::Out { x: one() } {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: surround the struct literal with parentheses
|
LL | if FOO == (<T as Trait>::Out { x: one() }) {}
| + +
error[E0658]: usage of qualified paths in this context is experimental
--> $DIR/struct-literals-in-invalid-places.rs:66:19
|
LL | if FOO == <T as Trait>::Out { x: one() } {}
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information
= help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0277]: `bool` is not an iterator
--> $DIR/struct-literals-in-invalid-places.rs:9:14
|
@ -185,7 +228,7 @@ help: use parentheses to call this closure
LL | while (|| Foo { x: 3 }.hi())() {
| + +++
error: aborting due to 17 previous errors
error: aborting due to 21 previous errors
Some errors have detailed explanations: E0277, E0308, E0533.
Some errors have detailed explanations: E0277, E0308, E0533, E0658.
For more information about an error, try `rustc --explain E0277`.