Skip to content

Commit b501e58

Browse files
committed
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.
1 parent 598f865 commit b501e58

File tree

5 files changed

+66
-84
lines changed

5 files changed

+66
-84
lines changed

Diff for: src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3189,7 +3189,6 @@ ui/parser/issues/issue-108495-dec.rs
31893189
ui/parser/issues/issue-110014.rs
31903190
ui/parser/issues/issue-111148.rs
31913191
ui/parser/issues/issue-111416.rs
3192-
ui/parser/issues/issue-111692.rs
31933192
ui/parser/issues/issue-112188.rs
31943193
ui/parser/issues/issue-112458.rs
31953194
ui/parser/issues/issue-113110-non-item-at-module-root.rs

Diff for: tests/ui/parser/issues/issue-111692.rs

-34
This file was deleted.

Diff for: tests/ui/parser/issues/issue-111692.stderr

-46
This file was deleted.

Diff for: tests/ui/parser/struct-literals-in-invalid-places.rs

+20
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,30 @@ fn main() {
4545
println!("yo");
4646
}
4747

48+
// This uses `one()` over `1` as token `one` may begin a type and thus back when type ascription
49+
// `$expr : $ty` still existed, `{ x: one` could've been the start of a block expr which used to
50+
// make the compiler take a different execution path. Now it no longer makes a difference tho.
51+
4852
// Regression test for <https://github.com/rust-lang/rust/issues/82051>.
4953
if Foo { x: one(), }.hi() { //~ ERROR struct literals are not allowed here
5054
println!("Positive!");
5155
}
56+
57+
const FOO: Foo = Foo { x: 1 };
58+
// Below, test that we correctly parenthesize the struct literals.
59+
60+
// Regression test for <https://github.com/rust-lang/rust/issues/112278>.
61+
if FOO == self::Foo { x: one() } {} //~ ERROR struct literals are not allowed here
62+
63+
if FOO == Foo::<> { x: one() } {} //~ ERROR struct literals are not allowed here
64+
65+
fn env<T: Trait<Out = Foo>>() {
66+
if FOO == <T as Trait>::Out { x: one() } {} //~ ERROR struct literals are not allowed here
67+
//~^ ERROR usage of qualified paths in this context is experimental
68+
}
5269
}
5370

71+
#[derive(PartialEq, Eq)]
5472
struct Foo {
5573
x: isize,
5674
}
@@ -70,3 +88,5 @@ enum E {
7088
}
7189

7290
fn one() -> isize { 1 }
91+
92+
trait Trait { type Out; }

Diff for: tests/ui/parser/struct-literals-in-invalid-places.stderr

+46-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ LL | while || (Foo { x: 3 }).hi() {
120120
| + +
121121

122122
error: struct literals are not allowed here
123-
--> $DIR/struct-literals-in-invalid-places.rs:49:8
123+
--> $DIR/struct-literals-in-invalid-places.rs:53:8
124124
|
125125
LL | if Foo { x: one(), }.hi() {
126126
| ^^^^^^^^^^^^^^^^^
@@ -130,6 +130,49 @@ help: surround the struct literal with parentheses
130130
LL | if (Foo { x: one(), }).hi() {
131131
| + +
132132

133+
error: struct literals are not allowed here
134+
--> $DIR/struct-literals-in-invalid-places.rs:61:15
135+
|
136+
LL | if FOO == self::Foo { x: one() } {}
137+
| ^^^^^^^^^^^^^^^^^^^^^^
138+
|
139+
help: surround the struct literal with parentheses
140+
|
141+
LL | if FOO == (self::Foo { x: one() }) {}
142+
| + +
143+
144+
error: struct literals are not allowed here
145+
--> $DIR/struct-literals-in-invalid-places.rs:63:15
146+
|
147+
LL | if FOO == Foo::<> { x: one() } {}
148+
| ^^^^^^^^^^^^^^^^^^^^
149+
|
150+
help: surround the struct literal with parentheses
151+
|
152+
LL | if FOO == (Foo::<> { x: one() }) {}
153+
| + +
154+
155+
error: struct literals are not allowed here
156+
--> $DIR/struct-literals-in-invalid-places.rs:66:19
157+
|
158+
LL | if FOO == <T as Trait>::Out { x: one() } {}
159+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160+
|
161+
help: surround the struct literal with parentheses
162+
|
163+
LL | if FOO == (<T as Trait>::Out { x: one() }) {}
164+
| + +
165+
166+
error[E0658]: usage of qualified paths in this context is experimental
167+
--> $DIR/struct-literals-in-invalid-places.rs:66:19
168+
|
169+
LL | if FOO == <T as Trait>::Out { x: one() } {}
170+
| ^^^^^^^^^^^^^^^^^
171+
|
172+
= note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information
173+
= help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable
174+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
175+
133176
error[E0277]: `bool` is not an iterator
134177
--> $DIR/struct-literals-in-invalid-places.rs:9:14
135178
|
@@ -185,7 +228,7 @@ help: use parentheses to call this closure
185228
LL | while (|| Foo { x: 3 }.hi())() {
186229
| + +++
187230

188-
error: aborting due to 17 previous errors
231+
error: aborting due to 21 previous errors
189232

190-
Some errors have detailed explanations: E0277, E0308, E0533.
233+
Some errors have detailed explanations: E0277, E0308, E0533, E0658.
191234
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)