From 023939b627b7dc93b01471f7d41fb8553ddb4ffa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:24 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- .../where-clause-bounds-inconsistency.rs | 1 - ...where-clause-placement-assoc-type-in-impl.fixed | 28 +++++++++++++++ .../where-clause-placement-assoc-type-in-impl.rs | 28 +++++++++++++++ ...here-clause-placement-assoc-type-in-impl.stderr | 42 ++++++++++++++++++++++ ...here-clause-placement-assoc-type-in-trait.fixed | 15 ++++++++ .../where-clause-placement-assoc-type-in-trait.rs | 15 ++++++++ ...ere-clause-placement-assoc-type-in-trait.stderr | 29 +++++++++++++++ .../where-clause-placement-type-alias.rs | 11 ++++++ .../where-clause-placement-type-alias.stderr | 20 +++++++++++ 9 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr create mode 100644 tests/ui/where-clauses/where-clause-placement-type-alias.rs create mode 100644 tests/ui/where-clauses/where-clause-placement-type-alias.stderr (limited to 'tests/ui/where-clauses') diff --git a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs index cf7d06b61..ea60fa708 100644 --- a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs +++ b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs @@ -14,7 +14,6 @@ trait Trait { impl Trait for bool { fn a(&self, _: T) {} - //^~ This gets rejected but should be accepted fn b(&self, _: T) where T: Bound {} fn c(&self, _: T) {} fn d(&self, _: T) where T: Bound {} diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed new file mode 100644 index 000000000..2f47c0d91 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed @@ -0,0 +1,28 @@ +// check-pass +// run-rustfix + +trait Trait { + // Fine. + type Assoc where u32: Copy; + // Fine. + type Assoc2 where u32: Copy, i32: Copy; +} + +impl Trait for u32 { + // Not fine, suggests moving. + type Assoc = () where u32: Copy; + //~^ WARNING where clause not allowed here + // Not fine, suggests moving `u32: Copy` + type Assoc2 = () where i32: Copy, u32: Copy; + //~^ WARNING where clause not allowed here +} + +impl Trait for i32 { + // Fine. + type Assoc = () where u32: Copy; + // Not fine, suggests moving both. + type Assoc2 = () where u32: Copy, i32: Copy; + //~^ WARNING where clause not allowed here +} + +fn main() {} diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs new file mode 100644 index 000000000..b20aa9398 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs @@ -0,0 +1,28 @@ +// check-pass +// run-rustfix + +trait Trait { + // Fine. + type Assoc where u32: Copy; + // Fine. + type Assoc2 where u32: Copy, i32: Copy; +} + +impl Trait for u32 { + // Not fine, suggests moving. + type Assoc where u32: Copy = (); + //~^ WARNING where clause not allowed here + // Not fine, suggests moving `u32: Copy` + type Assoc2 where u32: Copy = () where i32: Copy; + //~^ WARNING where clause not allowed here +} + +impl Trait for i32 { + // Fine. + type Assoc = () where u32: Copy; + // Not fine, suggests moving both. + type Assoc2 where u32: Copy, i32: Copy = (); + //~^ WARNING where clause not allowed here +} + +fn main() {} diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr new file mode 100644 index 000000000..b4de05184 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr @@ -0,0 +1,42 @@ +warning: where clause not allowed here + --> $DIR/where-clause-placement-assoc-type-in-impl.rs:13:16 + | +LL | type Assoc where u32: Copy = (); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #89122 for more information + = note: `#[warn(deprecated_where_clause_location)]` on by default +help: move it to the end of the type declaration + | +LL - type Assoc where u32: Copy = (); +LL + type Assoc = () where u32: Copy; + | + +warning: where clause not allowed here + --> $DIR/where-clause-placement-assoc-type-in-impl.rs:16:17 + | +LL | type Assoc2 where u32: Copy = () where i32: Copy; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #89122 for more information +help: move it to the end of the type declaration + | +LL - type Assoc2 where u32: Copy = () where i32: Copy; +LL + type Assoc2 = () where i32: Copy, u32: Copy; + | + +warning: where clause not allowed here + --> $DIR/where-clause-placement-assoc-type-in-impl.rs:24:17 + | +LL | type Assoc2 where u32: Copy, i32: Copy = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #89122 for more information +help: move it to the end of the type declaration + | +LL - type Assoc2 where u32: Copy, i32: Copy = (); +LL + type Assoc2 = () where u32: Copy, i32: Copy; + | + +warning: 3 warnings emitted + diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed new file mode 100644 index 000000000..d171eba50 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed @@ -0,0 +1,15 @@ +// check-pass +// run-rustfix + +#![feature(associated_type_defaults)] + +trait Trait { + // Not fine, suggests moving. + type Assoc = () where u32: Copy; + //~^ WARNING where clause not allowed here + // Not fine, suggests moving `u32: Copy` + type Assoc2 = () where i32: Copy, u32: Copy; + //~^ WARNING where clause not allowed here +} + +fn main() {} diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs new file mode 100644 index 000000000..59afee657 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs @@ -0,0 +1,15 @@ +// check-pass +// run-rustfix + +#![feature(associated_type_defaults)] + +trait Trait { + // Not fine, suggests moving. + type Assoc where u32: Copy = (); + //~^ WARNING where clause not allowed here + // Not fine, suggests moving `u32: Copy` + type Assoc2 where u32: Copy = () where i32: Copy; + //~^ WARNING where clause not allowed here +} + +fn main() {} diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr new file mode 100644 index 000000000..a81cb8c8c --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr @@ -0,0 +1,29 @@ +warning: where clause not allowed here + --> $DIR/where-clause-placement-assoc-type-in-trait.rs:8:16 + | +LL | type Assoc where u32: Copy = (); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #89122 for more information + = note: `#[warn(deprecated_where_clause_location)]` on by default +help: move it to the end of the type declaration + | +LL - type Assoc where u32: Copy = (); +LL + type Assoc = () where u32: Copy; + | + +warning: where clause not allowed here + --> $DIR/where-clause-placement-assoc-type-in-trait.rs:11:17 + | +LL | type Assoc2 where u32: Copy = () where i32: Copy; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #89122 for more information +help: move it to the end of the type declaration + | +LL - type Assoc2 where u32: Copy = () where i32: Copy; +LL + type Assoc2 = () where i32: Copy, u32: Copy; + | + +warning: 2 warnings emitted + diff --git a/tests/ui/where-clauses/where-clause-placement-type-alias.rs b/tests/ui/where-clauses/where-clause-placement-type-alias.rs new file mode 100644 index 000000000..62e301cb4 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-type-alias.rs @@ -0,0 +1,11 @@ +// check-fail + +// Fine, but lints as unused +type Foo where u32: Copy = (); +// Not fine. +type Bar = () where u32: Copy; +//~^ ERROR where clauses are not allowed +type Baz = () where; +//~^ ERROR where clauses are not allowed + +fn main() {} diff --git a/tests/ui/where-clauses/where-clause-placement-type-alias.stderr b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr new file mode 100644 index 000000000..d341148b0 --- /dev/null +++ b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr @@ -0,0 +1,20 @@ +error: where clauses are not allowed after the type for type aliases + --> $DIR/where-clause-placement-type-alias.rs:6:15 + | +LL | type Bar = () where u32: Copy; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 for more information + = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable + +error: where clauses are not allowed after the type for type aliases + --> $DIR/where-clause-placement-type-alias.rs:8:15 + | +LL | type Baz = () where; + | ^^^^^ + | + = note: see issue #112792 for more information + = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + -- cgit v1.2.3