From 16fcaa40ef015b09726266982b87a8f027510ece Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 11:20:08 -0500 Subject: [PATCH 01/39] Fix `issue-79099.rs` --- ...79099.stderr => issue-79099.edition2015.stderr} | 4 ++-- .../issues/issue-79099.edition2021.stderr | 14 ++++++++++++++ tests/ui/impl-trait/issues/issue-79099.rs | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) rename tests/ui/impl-trait/issues/{issue-79099.stderr => issue-79099.edition2015.stderr} (95%) create mode 100644 tests/ui/impl-trait/issues/issue-79099.edition2021.stderr diff --git a/tests/ui/impl-trait/issues/issue-79099.stderr b/tests/ui/impl-trait/issues/issue-79099.edition2015.stderr similarity index 95% rename from tests/ui/impl-trait/issues/issue-79099.stderr rename to tests/ui/impl-trait/issues/issue-79099.edition2015.stderr index d7c0c494454c4..43c16ae909172 100644 --- a/tests/ui/impl-trait/issues/issue-79099.stderr +++ b/tests/ui/impl-trait/issues/issue-79099.edition2015.stderr @@ -1,5 +1,5 @@ error: expected identifier, found `1` - --> $DIR/issue-79099.rs:3:65 + --> $DIR/issue-79099.rs:7:65 | LL | let f: impl core::future::Future = async { 1 }; | ----- ^ expected identifier @@ -10,7 +10,7 @@ LL | let f: impl core::future::Future = async { 1 }; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/issue-79099.rs:3:16 + --> $DIR/issue-79099.rs:7:16 | LL | let f: impl core::future::Future = async { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/issues/issue-79099.edition2021.stderr b/tests/ui/impl-trait/issues/issue-79099.edition2021.stderr new file mode 100644 index 0000000000000..c1369d60f8bd5 --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-79099.edition2021.stderr @@ -0,0 +1,14 @@ +error[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/issue-79099.rs:7:16 + | +LL | let f: impl core::future::Future = async { 1 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/impl-trait/issues/issue-79099.rs b/tests/ui/impl-trait/issues/issue-79099.rs index c2bad59045b22..ade3eaebd8ada 100644 --- a/tests/ui/impl-trait/issues/issue-79099.rs +++ b/tests/ui/impl-trait/issues/issue-79099.rs @@ -1,8 +1,12 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 +// struct Bug { V1: [(); { let f: impl core::future::Future = async { 1 }; //~^ ERROR `impl Trait` is not allowed in the type of variable bindings - //~| ERROR expected identifier + //[edition2015]~| ERROR expected identifier 1 }], } From 31e6422bacc79c965cbffe678eace6c46c3bb5ae Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 11:25:05 -0500 Subject: [PATCH 02/39] Fix `dyn-trait-return-should-be-impl-trait.rs` --- ...n-should-be-impl-trait.edition2015.stderr} | 42 +-- ...rn-should-be-impl-trait.edition2021.stderr | 308 ++++++++++++++++++ .../dyn-trait-return-should-be-impl-trait.rs | 14 +- 3 files changed, 339 insertions(+), 25 deletions(-) rename tests/ui/impl-trait/{dyn-trait-return-should-be-impl-trait.stderr => dyn-trait-return-should-be-impl-trait.edition2015.stderr} (93%) create mode 100644 tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2015.stderr similarity index 93% rename from tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr rename to tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2015.stderr index 304d7d43b78b3..a2c0d3e43178b 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2015.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,7 +9,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:13 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -19,7 +19,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = note: the return type of a function must have a statically known size error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:20:13 | LL | fn bap() -> Trait { Struct } | ^^^^^ doesn't have a size known at compile-time @@ -34,7 +34,7 @@ LL | fn bap() -> Box { Box::new(Struct) } | +++++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:23:13 | LL | fn ban() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -50,7 +50,7 @@ LL | fn ban() -> Box { Box::new(Struct) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13 | LL | fn bak() -> dyn Trait { unimplemented!() } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -66,7 +66,7 @@ LL | fn bak() -> Box { Box::new(unimplemented!()) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 | LL | fn bal() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -86,7 +86,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:33:13 | LL | fn bax() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -106,7 +106,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 | LL | fn bat() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -126,7 +126,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:74:13 | LL | fn bay() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -146,7 +146,7 @@ LL ~ Box::new(42) | error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:35 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^ expected `dyn Trait`, found `Struct` @@ -156,7 +156,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:30 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:30 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -166,7 +166,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:39 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:39 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^ expected `dyn Trait`, found `Struct` @@ -176,7 +176,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:34 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:34 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -186,7 +186,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 | LL | fn bam() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -203,7 +203,7 @@ LL | return Box::new(Struct); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:38:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 | LL | fn bam() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -220,7 +220,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:16 | LL | fn baq() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -237,7 +237,7 @@ LL | return Box::new(0); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:5 | LL | fn baq() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -254,7 +254,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:54:9 | LL | fn baz() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -271,7 +271,7 @@ LL | Box::new(Struct) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:56:9 | LL | fn baz() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -288,7 +288,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:61:9 | LL | fn baw() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -305,7 +305,7 @@ LL | Box::new(0) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:57:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:63:9 | LL | fn baw() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr new file mode 100644 index 0000000000000..6753260e87b10 --- /dev/null +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr @@ -0,0 +1,308 @@ +error[E0782]: expected a type, found a trait + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:21 + | +LL | fn fuz() -> (usize, Trait) { (42, Struct) } + | ^^^^^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | fn fuz() -> (usize, dyn Trait) { (42, Struct) } + | +++ + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:13 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: the return type of a function must have a statically known size + +error[E0782]: expected a type, found a trait + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:20:13 + | +LL | fn bap() -> Trait { Struct } + | ^^^^^ + | +help: use `impl Trait` to return an opaque type, as long as you return a single underlying type + | +LL | fn bap() -> impl Trait { Struct } + | ++++ +help: alternatively, you can return an owned trait object + | +LL | fn bap() -> Box { Struct } + | +++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:23:13 + | +LL | fn ban() -> dyn Trait { Struct } + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn ban() -> dyn Trait { Struct } +LL + fn ban() -> impl Trait { Struct } + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn ban() -> Box { Box::new(Struct) } + | ++++ + +++++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13 + | +LL | fn bak() -> dyn Trait { unimplemented!() } + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bak() -> dyn Trait { unimplemented!() } +LL + fn bak() -> impl Trait { unimplemented!() } + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn bak() -> Box { Box::new(unimplemented!()) } + | ++++ + +++++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 + | +LL | fn bal() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bal() -> dyn Trait { +LL + fn bal() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bal() -> Box { +LL | if true { +LL ~ return Box::new(Struct); +LL | } +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:33:13 + | +LL | fn bax() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bax() -> dyn Trait { +LL + fn bax() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bax() -> Box { +LL | if true { +LL ~ Box::new(Struct) +LL | } else { +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 + | +LL | fn bat() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bat() -> dyn Trait { +LL + fn bat() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bat() -> Box { +LL | if true { +LL ~ return Box::new(0); +LL | } +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:74:13 + | +LL | fn bay() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bay() -> dyn Trait { +LL + fn bay() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bay() -> Box { +LL | if true { +LL ~ Box::new(0) +LL | } else { +LL ~ Box::new(42) + | + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:39 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^ expected `dyn Trait`, found `Struct` + | + = note: expected trait object `(dyn Trait + 'static)` + found struct `Struct` + = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:16:34 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: tuples must have a statically known size to be initialized + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 + | +LL | fn bam() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | return Struct; + | ^^^^^^ expected `Box`, found `Struct` + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found struct `Struct` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | return Box::new(Struct); + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 + | +LL | fn bam() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:16 + | +LL | fn baq() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | return 0; + | ^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | return Box::new(0); + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:5 + | +LL | fn baq() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:54:9 + | +LL | fn baz() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | Struct + | ^^^^^^ expected `Box`, found `Struct` + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found struct `Struct` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(Struct) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:56:9 + | +LL | fn baz() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:61:9 + | +LL | fn baw() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | 0 + | ^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(0) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:63:9 + | +LL | fn baw() -> Box { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error: aborting due to 19 previous errors + +Some errors have detailed explanations: E0277, E0308, E0746, E0782. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs index ccf0a1ad3d443..4c4800ccf6a28 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs @@ -1,3 +1,7 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 +// #![allow(bare_trait_objects)] struct Struct; trait Trait {} @@ -5,15 +9,17 @@ impl Trait for Struct {} impl Trait for u32 {} fn fuz() -> (usize, Trait) { (42, Struct) } -//~^ ERROR E0277 -//~| ERROR E0277 -//~| ERROR E0308 +//[edition2015]~^ ERROR E0277 +//[edition2015]~| ERROR E0277 +//[edition2015]~| ERROR E0308 +//[edition2021]~^^^^ ERROR E0782 fn bar() -> (usize, dyn Trait) { (42, Struct) } //~^ ERROR E0277 //~| ERROR E0277 //~| ERROR E0308 fn bap() -> Trait { Struct } -//~^ ERROR E0746 +//[edition2015]~^ ERROR E0746 +//[edition2021]~^^ ERROR E0782 fn ban() -> dyn Trait { Struct } //~^ ERROR E0746 fn bak() -> dyn Trait { unimplemented!() } //~ ERROR E0746 From fc4ec762b792cb46462d6ed6f31293e8e14f4c96 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 11:45:49 -0500 Subject: [PATCH 03/39] Fix `dyn-use.rs` --- ...-use.stderr => dyn-use.edition2015.stderr} | 2 +- .../dyn-use.edition2021.stderr | 26 +++++++++++++++++++ .../impl-trait/precise-capturing/dyn-use.rs | 11 +++++++- 3 files changed, 37 insertions(+), 2 deletions(-) rename tests/ui/impl-trait/precise-capturing/{dyn-use.stderr => dyn-use.edition2015.stderr} (90%) create mode 100644 tests/ui/impl-trait/precise-capturing/dyn-use.edition2021.stderr diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2015.stderr similarity index 90% rename from tests/ui/impl-trait/precise-capturing/dyn-use.stderr rename to tests/ui/impl-trait/precise-capturing/dyn-use.edition2015.stderr index d8903fc412910..4f411622eb005 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2015.stderr @@ -1,5 +1,5 @@ error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` - --> $DIR/dyn-use.rs:1:26 + --> $DIR/dyn-use.rs:5:26 | LL | fn dyn() -> &'static dyn use<> { &() } | ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.edition2021.stderr b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2021.stderr new file mode 100644 index 0000000000000..1b604549353f6 --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2021.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `dyn` + --> $DIR/dyn-use.rs:5:4 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^ expected identifier, found keyword + | +help: escape `dyn` to use it as an identifier + | +LL | fn r#dyn() -> &'static dyn use<> { &() } + | ++ + +error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds + --> $DIR/dyn-use.rs:5:26 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^^^ + +error[E0224]: at least one trait is required for an object type + --> $DIR/dyn-use.rs:5:22 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0224`. diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.rs b/tests/ui/impl-trait/precise-capturing/dyn-use.rs index fb2f83e2d21cf..1eb31d81e6bb5 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.rs +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.rs @@ -1,2 +1,11 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 +// fn dyn() -> &'static dyn use<> { &() } -//~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` +//[edition2015]~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` +//[edition2021]~^^ ERROR expected identifier +//[edition2021]~| ERROR precise capturing syntax not allowed +//[edition2021]~| ERROR at least one trait is required + +fn main() {} From 459ddd59f735474dc7f957183851ced8ef802e55 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 13:05:10 -0500 Subject: [PATCH 04/39] Fix `ambiguous-14.rs` --- ...stderr => ambiguous-14.edition2015.stderr} | 6 ++-- .../imports/ambiguous-14.edition2021.stderr | 35 +++++++++++++++++++ tests/ui/imports/ambiguous-14.rs | 13 +++++-- 3 files changed, 48 insertions(+), 6 deletions(-) rename tests/ui/imports/{ambiguous-14.stderr => ambiguous-14.edition2015.stderr} (89%) create mode 100644 tests/ui/imports/ambiguous-14.edition2021.stderr diff --git a/tests/ui/imports/ambiguous-14.stderr b/tests/ui/imports/ambiguous-14.edition2015.stderr similarity index 89% rename from tests/ui/imports/ambiguous-14.stderr rename to tests/ui/imports/ambiguous-14.edition2015.stderr index bece585366826..d77d3715b3218 100644 --- a/tests/ui/imports/ambiguous-14.stderr +++ b/tests/ui/imports/ambiguous-14.edition2015.stderr @@ -1,5 +1,5 @@ warning: `foo` is ambiguous - --> $DIR/ambiguous-14.rs:23:8 + --> $DIR/ambiguous-14.rs:30:8 | LL | g::foo(); | ^^^ ambiguous name @@ -8,13 +8,13 @@ LL | g::foo(); = note: for more information, see issue #114095 = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the function imported here - --> $DIR/ambiguous-14.rs:13:13 + --> $DIR/ambiguous-14.rs:16:13 | LL | pub use a::*; | ^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here - --> $DIR/ambiguous-14.rs:14:13 + --> $DIR/ambiguous-14.rs:18:13 | LL | pub use b::*; | ^^^^ diff --git a/tests/ui/imports/ambiguous-14.edition2021.stderr b/tests/ui/imports/ambiguous-14.edition2021.stderr new file mode 100644 index 0000000000000..04a369062ae4d --- /dev/null +++ b/tests/ui/imports/ambiguous-14.edition2021.stderr @@ -0,0 +1,35 @@ +error[E0432]: unresolved import `a` + --> $DIR/ambiguous-14.rs:16:13 + | +LL | pub use a::*; + | ^ help: a similar path exists: `crate::a` + | + = note: `use` statements changed in Rust 2018; read more at + +error[E0432]: unresolved import `b` + --> $DIR/ambiguous-14.rs:18:13 + | +LL | pub use b::*; + | ^ help: a similar path exists: `crate::b` + | + = note: `use` statements changed in Rust 2018; read more at + +error[E0432]: unresolved import `a` + --> $DIR/ambiguous-14.rs:23:13 + | +LL | pub use a::*; + | ^ help: a similar path exists: `crate::a` + | + = note: `use` statements changed in Rust 2018; read more at + +error[E0432]: unresolved import `f` + --> $DIR/ambiguous-14.rs:25:13 + | +LL | pub use f::*; + | ^ help: a similar path exists: `crate::f` + | + = note: `use` statements changed in Rust 2018; read more at + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/ambiguous-14.rs b/tests/ui/imports/ambiguous-14.rs index 30d14be9d0efa..3d745bf45d545 100644 --- a/tests/ui/imports/ambiguous-14.rs +++ b/tests/ui/imports/ambiguous-14.rs @@ -1,4 +1,7 @@ -//@ check-pass +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2015] check-pass +//@[edition2021] edition: 2021 // https://github.com/rust-lang/rust/issues/98467 mod a { @@ -11,16 +14,20 @@ mod b { mod f { pub use a::*; + //[edition2021]~^ E0432 pub use b::*; + //[edition2021]~^ E0432 } mod g { pub use a::*; + //[edition2021]~^ E0432 pub use f::*; + //[edition2021]~^ E0432 } fn main() { g::foo(); - //~^ WARNING `foo` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //[edition2015]~^ WARNING `foo` is ambiguous + //[edition2015]~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } From 8255c95b631b66018edeae6f96bd67f64c103d23 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 13:37:49 -0500 Subject: [PATCH 05/39] Fix `ambiguous-17.rs` --- tests/ui/imports/ambiguous-17.rs | 1 + tests/ui/imports/ambiguous-17.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/ui/imports/ambiguous-17.rs b/tests/ui/imports/ambiguous-17.rs index 28c9c1cc86486..443b6f547ae66 100644 --- a/tests/ui/imports/ambiguous-17.rs +++ b/tests/ui/imports/ambiguous-17.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass // https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 diff --git a/tests/ui/imports/ambiguous-17.stderr b/tests/ui/imports/ambiguous-17.stderr index 55bc01095c7b0..c3bcaf46aaf66 100644 --- a/tests/ui/imports/ambiguous-17.stderr +++ b/tests/ui/imports/ambiguous-17.stderr @@ -1,5 +1,5 @@ warning: ambiguous glob re-exports - --> $DIR/ambiguous-17.rs:4:9 + --> $DIR/ambiguous-17.rs:5:9 | LL | pub use evp::*; | ^^^^^^ the name `id` in the value namespace is first re-exported here @@ -9,7 +9,7 @@ LL | pub use handwritten::*; = note: `#[warn(ambiguous_glob_reexports)]` on by default warning: `id` is ambiguous - --> $DIR/ambiguous-17.rs:26:5 + --> $DIR/ambiguous-17.rs:27:5 | LL | id(); | ^^ ambiguous name @@ -18,13 +18,13 @@ LL | id(); = note: for more information, see issue #114095 = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-17.rs:4:9 + --> $DIR/ambiguous-17.rs:5:9 | LL | pub use evp::*; | ^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-17.rs:5:9 + --> $DIR/ambiguous-17.rs:6:9 | LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ From 0a6253b84254af4d0dfa671bd47b1fa962ce348d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 13:47:42 -0500 Subject: [PATCH 06/39] Fix `ambiguous-4-extern.rs` --- tests/ui/imports/ambiguous-4-extern.rs | 1 + tests/ui/imports/ambiguous-4-extern.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/ui/imports/ambiguous-4-extern.rs b/tests/ui/imports/ambiguous-4-extern.rs index a045ab3d8a597..0185dcea67980 100644 --- a/tests/ui/imports/ambiguous-4-extern.rs +++ b/tests/ui/imports/ambiguous-4-extern.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass // https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 diff --git a/tests/ui/imports/ambiguous-4-extern.stderr b/tests/ui/imports/ambiguous-4-extern.stderr index 0011973212bc6..87103b9a6a735 100644 --- a/tests/ui/imports/ambiguous-4-extern.stderr +++ b/tests/ui/imports/ambiguous-4-extern.stderr @@ -1,5 +1,5 @@ warning: ambiguous glob re-exports - --> $DIR/ambiguous-4-extern.rs:10:9 + --> $DIR/ambiguous-4-extern.rs:11:9 | LL | pub use evp::*; | ^^^^^^ the name `id` in the value namespace is first re-exported here @@ -9,7 +9,7 @@ LL | pub use handwritten::*; = note: `#[warn(ambiguous_glob_reexports)]` on by default warning: `id` is ambiguous - --> $DIR/ambiguous-4-extern.rs:23:5 + --> $DIR/ambiguous-4-extern.rs:24:5 | LL | id(); | ^^ ambiguous name @@ -18,13 +18,13 @@ LL | id(); = note: for more information, see issue #114095 = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:10:9 + --> $DIR/ambiguous-4-extern.rs:11:9 | LL | pub use evp::*; | ^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:11:9 + --> $DIR/ambiguous-4-extern.rs:12:9 | LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ From 385720497e45fb16ec74defdf3f97e6d31c5e3c7 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 14:13:59 -0500 Subject: [PATCH 07/39] Fix `duplicate.rs` --- tests/ui/imports/duplicate.rs | 18 +++++++++--------- tests/ui/imports/duplicate.stderr | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs index 0c5a376da3866..69ec82aafbdcf 100644 --- a/tests/ui/imports/duplicate.rs +++ b/tests/ui/imports/duplicate.rs @@ -7,27 +7,27 @@ mod b { } mod c { - pub use a::foo; + pub use crate::a::foo; } mod d { - use a::foo; - use a::foo; //~ ERROR the name `foo` is defined multiple times + use crate::a::foo; + use crate::a::foo; //~ ERROR the name `foo` is defined multiple times } mod e { - pub use a::*; - pub use c::*; // ok + pub use crate::a::*; + pub use crate::c::*; // ok } mod f { - pub use a::*; - pub use b::*; + pub use crate::a::*; + pub use crate::b::*; } mod g { - pub use a::*; - pub use f::*; + pub use crate::a::*; + pub use crate::f::*; } fn main() { diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr index d7a7dfce921f1..f7dc7312b9da6 100644 --- a/tests/ui/imports/duplicate.stderr +++ b/tests/ui/imports/duplicate.stderr @@ -1,10 +1,10 @@ error[E0252]: the name `foo` is defined multiple times --> $DIR/duplicate.rs:15:9 | -LL | use a::foo; - | ------ previous import of the value `foo` here -LL | use a::foo; - | ^^^^^^ `foo` reimported here +LL | use crate::a::foo; + | ------------- previous import of the value `foo` here +LL | use crate::a::foo; + | ^^^^^^^^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module @@ -38,14 +38,14 @@ LL | f::foo(); note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:24:13 | -LL | pub use a::*; - | ^^^^ +LL | pub use crate::a::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here --> $DIR/duplicate.rs:25:13 | -LL | pub use b::*; - | ^^^^ +LL | pub use crate::b::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate error[E0659]: `foo` is ambiguous @@ -80,14 +80,14 @@ LL | g::foo(); note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:24:13 | -LL | pub use a::*; - | ^^^^ +LL | pub use crate::a::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here --> $DIR/duplicate.rs:25:13 | -LL | pub use b::*; - | ^^^^ +LL | pub use crate::b::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate = note: `#[warn(ambiguous_glob_imports)]` on by default From c4f1fb2afc134229d240e3a93d2069d0b6556ed9 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 14:20:09 -0500 Subject: [PATCH 08/39] Fix `export-glob-imports-target.rs` --- tests/ui/imports/export-glob-imports-target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/export-glob-imports-target.rs b/tests/ui/imports/export-glob-imports-target.rs index 6fde9fef0b67d..84b9ffa83ff1c 100644 --- a/tests/ui/imports/export-glob-imports-target.rs +++ b/tests/ui/imports/export-glob-imports-target.rs @@ -9,7 +9,7 @@ mod foo { - use foo::bar::*; + use crate::foo::bar::*; pub mod bar { pub static a : isize = 10; } From f08ce2b197f0f34cb30f860e4b8cd2c58abe26d0 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 14:33:41 -0500 Subject: [PATCH 09/39] Fix `glob-conflict-cross-crate-1.rs` --- tests/ui/imports/auxiliary/glob-conflict.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/imports/auxiliary/glob-conflict.rs b/tests/ui/imports/auxiliary/glob-conflict.rs index 8a146378b4395..747581977b905 100644 --- a/tests/ui/imports/auxiliary/glob-conflict.rs +++ b/tests/ui/imports/auxiliary/glob-conflict.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 #![allow(ambiguous_glob_reexports)] mod m1 { From 2adb653ad25f41928bd48e168ce5ac0364832808 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 15:58:18 -0500 Subject: [PATCH 10/39] Fix `extern-prelude-extern-crate-restricted-shadowing.rs` --- .../extern-prelude-extern-crate-restricted-shadowing.rs | 1 + .../extern-prelude-extern-crate-restricted-shadowing.stderr | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs b/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs index 666b9f279ae50..69c1b8d8c8894 100644 --- a/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs +++ b/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ aux-build:two_macros.rs macro_rules! define_vec { diff --git a/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr b/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr index ade479ed10221..d09d14b27f90f 100644 --- a/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr +++ b/tests/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9 + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:20:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,14 +10,14 @@ LL | define_other_core!(); = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `Vec` is ambiguous - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9 + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:14:9 | LL | Vec::panic!(); | ^^^ ambiguous name | = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution note: `Vec` could refer to the crate imported here - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9 + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:6:9 | LL | extern crate std as Vec; | ^^^^^^^^^^^^^^^^^^^^^^^^ From 98ed6ff1085ff4543a8cbf97188a47819a49841d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 16:05:56 -0500 Subject: [PATCH 11/39] Fix `glob-shadowing.rs` --- tests/ui/imports/glob-shadowing.rs | 6 +++--- tests/ui/imports/glob-shadowing.stderr | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/ui/imports/glob-shadowing.rs b/tests/ui/imports/glob-shadowing.rs index 3a33b592b0081..72848aac51143 100644 --- a/tests/ui/imports/glob-shadowing.rs +++ b/tests/ui/imports/glob-shadowing.rs @@ -6,7 +6,7 @@ mod m { } mod glob_in_normal_module { - use m::*; + use crate::m::*; fn check() { let x = env!("PATH"); //~ ERROR `env` is ambiguous } @@ -14,7 +14,7 @@ mod glob_in_normal_module { mod glob_in_block_module { fn block() { - use m::*; + use crate::m::*; fn check() { let x = env!("PATH"); //~ ERROR `env` is ambiguous } @@ -24,7 +24,7 @@ mod glob_in_block_module { mod glob_shadows_item { pub macro fenv($e: expr) { $e } fn block() { - use m::*; + use crate::m::*; fn check() { let x = fenv!(); //~ ERROR `fenv` is ambiguous } diff --git a/tests/ui/imports/glob-shadowing.stderr b/tests/ui/imports/glob-shadowing.stderr index aff2eff68ac86..0ce8d4f54f8d5 100644 --- a/tests/ui/imports/glob-shadowing.stderr +++ b/tests/ui/imports/glob-shadowing.stderr @@ -9,8 +9,8 @@ LL | let x = env!("PATH"); note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:9:9 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate = help: or use `self::env` to refer to this macro unambiguously @@ -25,8 +25,8 @@ LL | let x = env!("PATH"); note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:17:13 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate error[E0659]: `fenv` is ambiguous @@ -39,8 +39,8 @@ LL | let x = fenv!(); note: `fenv` could refer to the macro imported here --> $DIR/glob-shadowing.rs:27:13 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `fenv` to disambiguate note: `fenv` could also refer to the macro defined here --> $DIR/glob-shadowing.rs:25:5 From 263bacddb3569d2cac291a4f23bc2d23d207dff3 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 29 Apr 2025 16:13:00 -0500 Subject: [PATCH 12/39] Fix `glob-cycles.rs` --- tests/ui/imports/glob-cycles.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/imports/glob-cycles.rs b/tests/ui/imports/glob-cycles.rs index 066aa3b53ea86..d9850bec4ca24 100644 --- a/tests/ui/imports/glob-cycles.rs +++ b/tests/ui/imports/glob-cycles.rs @@ -1,12 +1,12 @@ //@ check-pass mod foo { - pub use bar::*; - pub use main as f; + pub use crate::bar::*; + pub use crate::main as f; } mod bar { - pub use foo::*; + pub use crate::foo::*; } pub use foo::*; From 0a61cf530f7ba62a5d0ac6fda224f7532daceb57 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 15:33:43 -0500 Subject: [PATCH 13/39] Fix `where-allowed.rs` --- ...tderr => where-allowed.edition2015.stderr} | 106 ++-- .../where-allowed.edition2021.stderr | 463 ++++++++++++++++++ tests/ui/impl-trait/where-allowed.rs | 3 + 3 files changed, 519 insertions(+), 53 deletions(-) rename tests/ui/impl-trait/{where-allowed.stderr => where-allowed.edition2015.stderr} (90%) create mode 100644 tests/ui/impl-trait/where-allowed.edition2021.stderr diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.edition2015.stderr similarity index 90% rename from tests/ui/impl-trait/where-allowed.stderr rename to tests/ui/impl-trait/where-allowed.edition2015.stderr index 052ae5a99315c..1e72012bd14dc 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.edition2015.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:50:51 + --> $DIR/where-allowed.rs:53:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | --------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:59:57 + --> $DIR/where-allowed.rs:62:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | --------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in associated types is unstable - --> $DIR/where-allowed.rs:121:16 + --> $DIR/where-allowed.rs:124:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | type Out = impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:158:23 + --> $DIR/where-allowed.rs:161:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | type InTypeAlias = impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:162:39 + --> $DIR/where-allowed.rs:165:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/where-allowed.rs:18:40 + --> $DIR/where-allowed.rs:21:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:22:42 + --> $DIR/where-allowed.rs:25:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/where-allowed.rs:26:38 + --> $DIR/where-allowed.rs:29:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:30:40 + --> $DIR/where-allowed.rs:33:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:34:49 + --> $DIR/where-allowed.rs:37:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:38:51 + --> $DIR/where-allowed.rs:41:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:42:55 + --> $DIR/where-allowed.rs:45:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!( = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:50:51 + --> $DIR/where-allowed.rs:53:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:55:53 + --> $DIR/where-allowed.rs:58:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:59:57 + --> $DIR/where-allowed.rs:62:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:68:38 + --> $DIR/where-allowed.rs:71:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ @@ -135,7 +135,7 @@ LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:72:40 + --> $DIR/where-allowed.rs:75:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ @@ -143,7 +143,7 @@ LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:85:32 + --> $DIR/where-allowed.rs:88:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ @@ -151,7 +151,7 @@ LL | struct InBraceStructField { x: impl Debug } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:89:41 + --> $DIR/where-allowed.rs:92:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | struct InAdtInBraceStructField { x: Vec } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:93:27 + --> $DIR/where-allowed.rs:96:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | struct InTupleStructField(impl Debug); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:98:25 + --> $DIR/where-allowed.rs:101:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | InBraceVariant { x: impl Debug }, = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:100:20 + --> $DIR/where-allowed.rs:103:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ @@ -183,7 +183,7 @@ LL | InTupleVariant(impl Debug), = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `extern fn` parameters - --> $DIR/where-allowed.rs:142:33 + --> $DIR/where-allowed.rs:145:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ @@ -191,7 +191,7 @@ LL | fn in_foreign_parameters(_: impl Debug); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `extern fn` return types - --> $DIR/where-allowed.rs:145:31 + --> $DIR/where-allowed.rs:148:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | fn in_foreign_return() -> impl Debug; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:162:39 + --> $DIR/where-allowed.rs:165:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -207,7 +207,7 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in traits - --> $DIR/where-allowed.rs:167:16 + --> $DIR/where-allowed.rs:170:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ @@ -215,7 +215,7 @@ LL | impl PartialEq for () { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:172:24 + --> $DIR/where-allowed.rs:175:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ @@ -223,7 +223,7 @@ LL | impl PartialEq<()> for impl Debug { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:177:6 + --> $DIR/where-allowed.rs:180:6 | LL | impl impl Debug { | ^^^^^^^^^^ @@ -231,7 +231,7 @@ LL | impl impl Debug { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:183:24 + --> $DIR/where-allowed.rs:186:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ @@ -239,7 +239,7 @@ LL | impl InInherentImplAdt { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:189:11 + --> $DIR/where-allowed.rs:192:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ @@ -247,7 +247,7 @@ LL | where impl Debug: Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:196:15 + --> $DIR/where-allowed.rs:199:15 | LL | where Vec: Debug | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | where Vec: Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:203:24 + --> $DIR/where-allowed.rs:206:24 | LL | where T: PartialEq | ^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | where T: PartialEq = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:210:17 + --> $DIR/where-allowed.rs:213:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | where T: Fn(impl Debug) = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:217:22 + --> $DIR/where-allowed.rs:220:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | where T: Fn() -> impl Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:223:40 + --> $DIR/where-allowed.rs:226:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | struct InStructGenericParamDefault(T); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:227:36 + --> $DIR/where-allowed.rs:230:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | enum InEnumGenericParamDefault { Variant(T) } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:231:38 + --> $DIR/where-allowed.rs:234:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ @@ -303,7 +303,7 @@ LL | trait InTraitGenericParamDefault {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:235:41 + --> $DIR/where-allowed.rs:238:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ @@ -311,7 +311,7 @@ LL | type InTypeAliasGenericParamDefault = T; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:239:11 + --> $DIR/where-allowed.rs:242:11 | LL | impl T {} | ^^^^^^^^^^ @@ -319,7 +319,7 @@ LL | impl T {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:246:40 + --> $DIR/where-allowed.rs:249:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ @@ -327,7 +327,7 @@ LL | fn in_method_generic_param_default(_: T) {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/where-allowed.rs:252:29 + --> $DIR/where-allowed.rs:255:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ @@ -338,7 +338,7 @@ LL | let _in_local_variable: impl Fn() = || {}; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in closure return types - --> $DIR/where-allowed.rs:254:46 + --> $DIR/where-allowed.rs:257:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ @@ -346,7 +346,7 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0053]: method `in_trait_impl_return` has an incompatible type for trait - --> $DIR/where-allowed.rs:128:34 + --> $DIR/where-allowed.rs:131:34 | LL | type Out = impl Debug; | ---------- the expected opaque type @@ -355,7 +355,7 @@ LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ expected opaque type, found a different opaque type | note: type in trait - --> $DIR/where-allowed.rs:118:34 + --> $DIR/where-allowed.rs:121:34 | LL | fn in_trait_impl_return() -> Self::Out; | ^^^^^^^^^ @@ -369,7 +369,7 @@ LL + fn in_trait_impl_return() -> <() as DummyTrait>::Out { () } | error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:246:36 + --> $DIR/where-allowed.rs:249:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -379,7 +379,7 @@ LL | fn in_method_generic_param_default(_: T) {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:7 + --> $DIR/where-allowed.rs:242:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -388,7 +388,7 @@ LL | impl T {} = note: for more information, see issue #36887 error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:46:57 + --> $DIR/where-allowed.rs:49:57 | LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } | ^^^^^^^^^^ cannot infer type @@ -396,7 +396,7 @@ LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic! = note: cannot satisfy `_: Debug` error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:64:46 + --> $DIR/where-allowed.rs:67:46 | LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type @@ -408,7 +408,7 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani where Args: Tuple, F: Fn, A: Allocator, F: ?Sized; error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:239:1 + --> $DIR/where-allowed.rs:242:1 | LL | impl T {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type @@ -416,7 +416,7 @@ LL | impl T {} = note: either implement a trait on it or create a newtype to wrap it instead error: unconstrained opaque type - --> $DIR/where-allowed.rs:121:16 + --> $DIR/where-allowed.rs:124:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -424,7 +424,7 @@ LL | type Out = impl Debug; = note: `Out` must be used in combination with a concrete type within the same impl error: unconstrained opaque type - --> $DIR/where-allowed.rs:158:23 + --> $DIR/where-allowed.rs:161:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -437,7 +437,7 @@ Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0658, E0666 For more information about an error, try `rustc --explain E0053`. Future incompatibility report: Future breakage diagnostic: error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:246:36 + --> $DIR/where-allowed.rs:249:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -448,7 +448,7 @@ LL | fn in_method_generic_param_default(_: T) {} Future breakage diagnostic: error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:7 + --> $DIR/where-allowed.rs:242:7 | LL | impl T {} | ^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/where-allowed.edition2021.stderr b/tests/ui/impl-trait/where-allowed.edition2021.stderr new file mode 100644 index 0000000000000..6e0fca7c2f182 --- /dev/null +++ b/tests/ui/impl-trait/where-allowed.edition2021.stderr @@ -0,0 +1,463 @@ +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/where-allowed.rs:53:51 + | +LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } + | --------^^^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/where-allowed.rs:62:57 + | +LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } + | --------^^^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0658]: `impl Trait` in associated types is unstable + --> $DIR/where-allowed.rs:124:16 + | +LL | type Out = impl Debug; + | ^^^^^^^^^^ + | + = note: see issue #63063 for more information + = help: add `#![feature(impl_trait_in_assoc_type)]` 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[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/where-allowed.rs:161:23 + | +LL | type InTypeAlias = impl Debug; + | ^^^^^^^^^^ + | + = note: see issue #63063 for more information + = help: add `#![feature(type_alias_impl_trait)]` 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[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/where-allowed.rs:165:39 + | +LL | type InReturnInTypeAlias = fn() -> impl Debug; + | ^^^^^^^^^^ + | + = note: see issue #63063 for more information + = help: add `#![feature(type_alias_impl_trait)]` 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[E0562]: `impl Trait` is not allowed in `fn` pointer parameters + --> $DIR/where-allowed.rs:21:40 + | +LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `fn` pointer return types + --> $DIR/where-allowed.rs:25:42 + | +LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters + --> $DIR/where-allowed.rs:29:38 + | +LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `fn` pointer return types + --> $DIR/where-allowed.rs:33:40 + | +LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:37:49 + | +LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds + --> $DIR/where-allowed.rs:41:51 + | +LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:45:55 + | +LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:53:51 + | +LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds + --> $DIR/where-allowed.rs:58:53 + | +LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:62:57 + | +LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:71:38 + | +LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds + --> $DIR/where-allowed.rs:75:40 + | +LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in field types + --> $DIR/where-allowed.rs:88:32 + | +LL | struct InBraceStructField { x: impl Debug } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in field types + --> $DIR/where-allowed.rs:92:41 + | +LL | struct InAdtInBraceStructField { x: Vec } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in field types + --> $DIR/where-allowed.rs:96:27 + | +LL | struct InTupleStructField(impl Debug); + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in field types + --> $DIR/where-allowed.rs:101:25 + | +LL | InBraceVariant { x: impl Debug }, + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in field types + --> $DIR/where-allowed.rs:103:20 + | +LL | InTupleVariant(impl Debug), + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `extern fn` parameters + --> $DIR/where-allowed.rs:145:33 + | +LL | fn in_foreign_parameters(_: impl Debug); + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `extern fn` return types + --> $DIR/where-allowed.rs:148:31 + | +LL | fn in_foreign_return() -> impl Debug; + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in `fn` pointer return types + --> $DIR/where-allowed.rs:165:39 + | +LL | type InReturnInTypeAlias = fn() -> impl Debug; + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in traits + --> $DIR/where-allowed.rs:170:16 + | +LL | impl PartialEq for () { + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in impl headers + --> $DIR/where-allowed.rs:175:24 + | +LL | impl PartialEq<()> for impl Debug { + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in impl headers + --> $DIR/where-allowed.rs:180:6 + | +LL | impl impl Debug { + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in impl headers + --> $DIR/where-allowed.rs:186:24 + | +LL | impl InInherentImplAdt { + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in bounds + --> $DIR/where-allowed.rs:192:11 + | +LL | where impl Debug: Debug + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in bounds + --> $DIR/where-allowed.rs:199:15 + | +LL | where Vec: Debug + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in bounds + --> $DIR/where-allowed.rs:206:24 + | +LL | where T: PartialEq + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds + --> $DIR/where-allowed.rs:213:17 + | +LL | where T: Fn(impl Debug) + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds + --> $DIR/where-allowed.rs:220:22 + | +LL | where T: Fn() -> impl Debug + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:226:40 + | +LL | struct InStructGenericParamDefault(T); + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:230:36 + | +LL | enum InEnumGenericParamDefault { Variant(T) } + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:234:38 + | +LL | trait InTraitGenericParamDefault {} + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:238:41 + | +LL | type InTypeAliasGenericParamDefault = T; + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:242:11 + | +LL | impl T {} + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in generic parameter defaults + --> $DIR/where-allowed.rs:249:40 + | +LL | fn in_method_generic_param_default(_: T) {} + | ^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/where-allowed.rs:255:29 + | +LL | let _in_local_variable: impl Fn() = || {}; + | ^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in closure return types + --> $DIR/where-allowed.rs:257:46 + | +LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; + | ^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0053]: method `in_trait_impl_return` has an incompatible type for trait + --> $DIR/where-allowed.rs:131:34 + | +LL | type Out = impl Debug; + | ---------- the expected opaque type +... +LL | fn in_trait_impl_return() -> impl Debug { () } + | ^^^^^^^^^^ expected opaque type, found a different opaque type + | +note: type in trait + --> $DIR/where-allowed.rs:121:34 + | +LL | fn in_trait_impl_return() -> Self::Out; + | ^^^^^^^^^ + = note: expected signature `fn() -> <() as DummyTrait>::Out` + found signature `fn() -> impl Debug` + = note: distinct uses of `impl Trait` result in different opaque types +help: change the output type to match the trait + | +LL - fn in_trait_impl_return() -> impl Debug { () } +LL + fn in_trait_impl_return() -> <() as DummyTrait>::Out { () } + | + +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:249:36 + | +LL | fn in_method_generic_param_default(_: T) {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default + +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:242:7 + | +LL | impl T {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + +error[E0283]: type annotations needed + --> $DIR/where-allowed.rs:49:57 + | +LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ -------- return type was inferred to be `!` here + | | + | cannot infer type + | + = note: cannot satisfy `_: Debug` + +error[E0283]: type annotations needed + --> $DIR/where-allowed.rs:67:46 + | +LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^^^^^^^^^^^^^^ -------- return type was inferred to be `!` here + | | + | cannot infer type + | + = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: + - impl Fn for &F + where A: Tuple, F: Fn, F: ?Sized; + - impl Fn for Box + where Args: Tuple, F: Fn, A: Allocator, F: ?Sized; + +error[E0118]: no nominal type found for inherent implementation + --> $DIR/where-allowed.rs:242:1 + | +LL | impl T {} + | ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type + | + = note: either implement a trait on it or create a newtype to wrap it instead + +error: unconstrained opaque type + --> $DIR/where-allowed.rs:124:16 + | +LL | type Out = impl Debug; + | ^^^^^^^^^^ + | + = note: `Out` must be used in combination with a concrete type within the same impl + +error: unconstrained opaque type + --> $DIR/where-allowed.rs:161:23 + | +LL | type InTypeAlias = impl Debug; + | ^^^^^^^^^^ + | + = note: `InTypeAlias` must be used in combination with a concrete type within the same crate + +error: aborting due to 50 previous errors + +Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0658, E0666. +For more information about an error, try `rustc --explain E0053`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:249:36 + | +LL | fn in_method_generic_param_default(_: T) {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default + +Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:242:7 + | +LL | impl T {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index 1c3c66c537ff9..7c3d82035ec7a 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 //! A simple test for testing many permutations of allowedness of //! impl Trait #![feature(impl_trait_in_fn_trait_return)] From 76a14a78207cd99c2891fc225cbf52979f33e634 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 15:35:22 -0500 Subject: [PATCH 14/39] Fix `where-allowed-2.rs` --- ...-2.stderr => where-allowed-2.edition2015.stderr} | 2 +- .../impl-trait/where-allowed-2.edition2021.stderr | 13 +++++++++++++ tests/ui/impl-trait/where-allowed-2.rs | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) rename tests/ui/impl-trait/{where-allowed-2.stderr => where-allowed-2.edition2015.stderr} (90%) create mode 100644 tests/ui/impl-trait/where-allowed-2.edition2021.stderr diff --git a/tests/ui/impl-trait/where-allowed-2.stderr b/tests/ui/impl-trait/where-allowed-2.edition2015.stderr similarity index 90% rename from tests/ui/impl-trait/where-allowed-2.stderr rename to tests/ui/impl-trait/where-allowed-2.edition2015.stderr index c421e587a9ef6..87b90e03717ab 100644 --- a/tests/ui/impl-trait/where-allowed-2.stderr +++ b/tests/ui/impl-trait/where-allowed-2.edition2015.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/where-allowed-2.rs:3:30 + --> $DIR/where-allowed-2.rs:6:30 | LL | fn in_adt_in_return() -> Vec { panic!() } | ^^^^^^^^^^ cannot infer type diff --git a/tests/ui/impl-trait/where-allowed-2.edition2021.stderr b/tests/ui/impl-trait/where-allowed-2.edition2021.stderr new file mode 100644 index 0000000000000..7ae3eef6ed2c7 --- /dev/null +++ b/tests/ui/impl-trait/where-allowed-2.edition2021.stderr @@ -0,0 +1,13 @@ +error[E0283]: type annotations needed + --> $DIR/where-allowed-2.rs:6:30 + | +LL | fn in_adt_in_return() -> Vec { panic!() } + | ^^^^^^^^^^ -------- return type was inferred to be `!` here + | | + | cannot infer type + | + = note: cannot satisfy `_: Debug` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/impl-trait/where-allowed-2.rs b/tests/ui/impl-trait/where-allowed-2.rs index 1a1210d00726d..17748785d4dac 100644 --- a/tests/ui/impl-trait/where-allowed-2.rs +++ b/tests/ui/impl-trait/where-allowed-2.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 use std::fmt::Debug; fn in_adt_in_return() -> Vec { panic!() } From 3e1a795c5069203934410e0ecaab9e269aecf27d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 15:39:01 -0500 Subject: [PATCH 15/39] Fix `import-from-missing-star-2.rs` --- ... => import-from-missing-star-2.edition2015.stderr} | 2 +- .../import-from-missing-star-2.edition2021.stderr | 11 +++++++++++ tests/ui/imports/import-from-missing-star-2.rs | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) rename tests/ui/imports/{import-from-missing-star-2.stderr => import-from-missing-star-2.edition2015.stderr} (89%) create mode 100644 tests/ui/imports/import-from-missing-star-2.edition2021.stderr diff --git a/tests/ui/imports/import-from-missing-star-2.stderr b/tests/ui/imports/import-from-missing-star-2.edition2015.stderr similarity index 89% rename from tests/ui/imports/import-from-missing-star-2.stderr rename to tests/ui/imports/import-from-missing-star-2.edition2015.stderr index 9fe2bdbcfa279..b71f8236bc727 100644 --- a/tests/ui/imports/import-from-missing-star-2.stderr +++ b/tests/ui/imports/import-from-missing-star-2.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `spam` - --> $DIR/import-from-missing-star-2.rs:2:9 + --> $DIR/import-from-missing-star-2.rs:5:9 | LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` diff --git a/tests/ui/imports/import-from-missing-star-2.edition2021.stderr b/tests/ui/imports/import-from-missing-star-2.edition2021.stderr new file mode 100644 index 0000000000000..b253a18aae06e --- /dev/null +++ b/tests/ui/imports/import-from-missing-star-2.edition2021.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `spam` + --> $DIR/import-from-missing-star-2.rs:5:9 + | +LL | use spam::*; + | ^^^^ use of unresolved module or unlinked crate `spam` + | + = help: you might be missing a crate named `spam` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/import-from-missing-star-2.rs b/tests/ui/imports/import-from-missing-star-2.rs index cb341b0b0ca42..24f7a64280ffa 100644 --- a/tests/ui/imports/import-from-missing-star-2.rs +++ b/tests/ui/imports/import-from-missing-star-2.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 mod foo { use spam::*; //~ ERROR unresolved import `spam` [E0432] } From 2fd65e69189de5cf125a8aea07042e315695ff17 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 15:44:14 -0500 Subject: [PATCH 16/39] Fix `import-glob-1.rs` --- tests/ui/imports/import-glob-1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/import-glob-1.rs b/tests/ui/imports/import-glob-1.rs index 510f38145678f..8beec4ce469d1 100644 --- a/tests/ui/imports/import-glob-1.rs +++ b/tests/ui/imports/import-glob-1.rs @@ -21,7 +21,7 @@ mod bar { } mod foo { - use bar::Baz::{Baz1, Baz2}; + use crate::bar::Baz::{Baz1, Baz2}; } fn main() {} From 2dec1c573d87c93130073b48bb389ec77c8b08e1 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:02:49 -0500 Subject: [PATCH 17/39] Fix `import-glob-circular.rs` --- tests/ui/imports/import-glob-circular.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/imports/import-glob-circular.rs b/tests/ui/imports/import-glob-circular.rs index e47fa870c0639..2dcfc7721fa9c 100644 --- a/tests/ui/imports/import-glob-circular.rs +++ b/tests/ui/imports/import-glob-circular.rs @@ -1,17 +1,17 @@ mod circ1 { - pub use circ2::f2; + pub use crate::circ2::f2; pub fn f1() { println!("f1"); } pub fn common() -> usize { return 0; } } mod circ2 { - pub use circ1::f1; + pub use crate::circ1::f1; pub fn f2() { println!("f2"); } pub fn common() -> usize { return 1; } } mod test { - use circ1::*; + use crate::circ1::*; fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope } From 1d201797380ec07f3ced0f20e23d6dc764c629b1 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:06:23 -0500 Subject: [PATCH 18/39] Fix `import-from-missing-star.rs` --- ...rr => import-from-missing-star.edition2015.stderr} | 2 +- .../import-from-missing-star.edition2021.stderr | 11 +++++++++++ tests/ui/imports/import-from-missing-star.rs | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) rename tests/ui/imports/{import-from-missing-star.stderr => import-from-missing-star.edition2015.stderr} (89%) create mode 100644 tests/ui/imports/import-from-missing-star.edition2021.stderr diff --git a/tests/ui/imports/import-from-missing-star.stderr b/tests/ui/imports/import-from-missing-star.edition2015.stderr similarity index 89% rename from tests/ui/imports/import-from-missing-star.stderr rename to tests/ui/imports/import-from-missing-star.edition2015.stderr index 768e1ea1e2cf8..ab4ea341ddebe 100644 --- a/tests/ui/imports/import-from-missing-star.stderr +++ b/tests/ui/imports/import-from-missing-star.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `spam` - --> $DIR/import-from-missing-star.rs:1:5 + --> $DIR/import-from-missing-star.rs:4:5 | LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` diff --git a/tests/ui/imports/import-from-missing-star.edition2021.stderr b/tests/ui/imports/import-from-missing-star.edition2021.stderr new file mode 100644 index 0000000000000..f7ad86af7a1c4 --- /dev/null +++ b/tests/ui/imports/import-from-missing-star.edition2021.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `spam` + --> $DIR/import-from-missing-star.rs:4:5 + | +LL | use spam::*; + | ^^^^ use of unresolved module or unlinked crate `spam` + | + = help: you might be missing a crate named `spam` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/import-from-missing-star.rs b/tests/ui/imports/import-from-missing-star.rs index cb21e16ba6773..ce40d8579a9da 100644 --- a/tests/ui/imports/import-from-missing-star.rs +++ b/tests/ui/imports/import-from-missing-star.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 use spam::*; //~ ERROR unresolved import `spam` [E0432] fn main() { From 4db4b82ccd0d7817abe09f7d7a722d211e6065af Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:07:36 -0500 Subject: [PATCH 19/39] Fix `import-loop-2.rs` --- tests/ui/imports/import-loop-2.rs | 4 ++-- tests/ui/imports/import-loop-2.stderr | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ui/imports/import-loop-2.rs b/tests/ui/imports/import-loop-2.rs index 1bd0f06c671a3..42f9a07fff389 100644 --- a/tests/ui/imports/import-loop-2.rs +++ b/tests/ui/imports/import-loop-2.rs @@ -1,9 +1,9 @@ mod a { - pub use b::x; + pub use crate::b::x; } mod b { - pub use a::x; //~ ERROR unresolved import `a::x` + pub use crate::a::x; //~ ERROR unresolved import `crate::a::x` fn main() { let y = x; } } diff --git a/tests/ui/imports/import-loop-2.stderr b/tests/ui/imports/import-loop-2.stderr index 2521b6e7c0440..2ef40c4e21829 100644 --- a/tests/ui/imports/import-loop-2.stderr +++ b/tests/ui/imports/import-loop-2.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `a::x` +error[E0432]: unresolved import `crate::a::x` --> $DIR/import-loop-2.rs:6:13 | -LL | pub use a::x; - | ^^^^ no `x` in `a` +LL | pub use crate::a::x; + | ^^^^^^^^^^^ no `x` in `a` error: aborting due to 1 previous error From d8b91732f260170552690050e04c0c8b7046f202 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:15:22 -0500 Subject: [PATCH 20/39] Fix `import-loop.rs` --- tests/ui/imports/import-loop.rs | 2 +- tests/ui/imports/import-loop.stderr | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ui/imports/import-loop.rs b/tests/ui/imports/import-loop.rs index fc5bd32adeee9..9248377071172 100644 --- a/tests/ui/imports/import-loop.rs +++ b/tests/ui/imports/import-loop.rs @@ -1,7 +1,7 @@ use y::x; mod y { - pub use y::x; //~ ERROR unresolved import `y::x` + pub use crate::y::x; //~ ERROR unresolved import `crate::y::x` } fn main() { } diff --git a/tests/ui/imports/import-loop.stderr b/tests/ui/imports/import-loop.stderr index 801fc2552b6ee..888ca11293cc2 100644 --- a/tests/ui/imports/import-loop.stderr +++ b/tests/ui/imports/import-loop.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `y::x` +error[E0432]: unresolved import `crate::y::x` --> $DIR/import-loop.rs:4:13 | -LL | pub use y::x; - | ^^^^ no `x` in `y` +LL | pub use crate::y::x; + | ^^^^^^^^^^^ no `x` in `y` error: aborting due to 1 previous error From e69bb3b4d4939026ade584156b384916b72ac325 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:18:39 -0500 Subject: [PATCH 21/39] Fix `import-from-missing-star-3.rs` --- ...rt-from-missing-star-3.edition2015.stderr} | 4 ++-- ...ort-from-missing-star-3.edition2021.stderr | 19 +++++++++++++++++++ .../ui/imports/import-from-missing-star-3.rs | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) rename tests/ui/imports/{import-from-missing-star-3.stderr => import-from-missing-star-3.edition2015.stderr} (87%) create mode 100644 tests/ui/imports/import-from-missing-star-3.edition2021.stderr diff --git a/tests/ui/imports/import-from-missing-star-3.stderr b/tests/ui/imports/import-from-missing-star-3.edition2015.stderr similarity index 87% rename from tests/ui/imports/import-from-missing-star-3.stderr rename to tests/ui/imports/import-from-missing-star-3.edition2015.stderr index c0b2e5675d391..016fd2c483bea 100644 --- a/tests/ui/imports/import-from-missing-star-3.stderr +++ b/tests/ui/imports/import-from-missing-star-3.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `spam` - --> $DIR/import-from-missing-star-3.rs:2:9 + --> $DIR/import-from-missing-star-3.rs:5:9 | LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` @@ -10,7 +10,7 @@ LL + extern crate spam; | error[E0432]: unresolved import `spam` - --> $DIR/import-from-missing-star-3.rs:27:13 + --> $DIR/import-from-missing-star-3.rs:30:13 | LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` diff --git a/tests/ui/imports/import-from-missing-star-3.edition2021.stderr b/tests/ui/imports/import-from-missing-star-3.edition2021.stderr new file mode 100644 index 0000000000000..403b937a1a317 --- /dev/null +++ b/tests/ui/imports/import-from-missing-star-3.edition2021.stderr @@ -0,0 +1,19 @@ +error[E0432]: unresolved import `spam` + --> $DIR/import-from-missing-star-3.rs:5:9 + | +LL | use spam::*; + | ^^^^ use of unresolved module or unlinked crate `spam` + | + = help: you might be missing a crate named `spam` + +error[E0432]: unresolved import `spam` + --> $DIR/import-from-missing-star-3.rs:30:13 + | +LL | use spam::*; + | ^^^^ use of unresolved module or unlinked crate `spam` + | + = help: you might be missing a crate named `spam` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/import-from-missing-star-3.rs b/tests/ui/imports/import-from-missing-star-3.rs index bec51fd47b375..5f8613c55cab4 100644 --- a/tests/ui/imports/import-from-missing-star-3.rs +++ b/tests/ui/imports/import-from-missing-star-3.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 mod foo { use spam::*; //~ ERROR unresolved import `spam` [E0432] From 145702fb7392acce5141f0873a0e20971489919f Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:25:51 -0500 Subject: [PATCH 22/39] Fix `import-glob-crate.rs` --- tests/ui/imports/import-glob-crate.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/imports/import-glob-crate.rs b/tests/ui/imports/import-glob-crate.rs index 0a2ca6ef2c315..ee0679318766b 100644 --- a/tests/ui/imports/import-glob-crate.rs +++ b/tests/ui/imports/import-glob-crate.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-pass use std::mem::*; From 7c872670d7873766859647d5fffc4becced56c2b Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:33:24 -0500 Subject: [PATCH 23/39] Fix `import-rpass.rs` --- tests/ui/imports/import-rpass.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/imports/import-rpass.rs b/tests/ui/imports/import-rpass.rs index 97c64fd9c6320..f03f974d573ab 100644 --- a/tests/ui/imports/import-rpass.rs +++ b/tests/ui/imports/import-rpass.rs @@ -4,8 +4,8 @@ mod foo { } mod bar { - use foo::x; - use foo::x as z; + use crate::foo::x; + use crate::foo::x as z; pub fn thing() { x(10); z(10); } } From 45b6844fd44bdb5aa39601f40bee48167b848912 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:37:51 -0500 Subject: [PATCH 24/39] Fix `import3.rs` --- .../{import3.stderr => import3.edition2015.stderr} | 2 +- tests/ui/imports/import3.edition2021.stderr | 9 +++++++++ tests/ui/imports/import3.rs | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) rename tests/ui/imports/{import3.stderr => import3.edition2015.stderr} (93%) create mode 100644 tests/ui/imports/import3.edition2021.stderr diff --git a/tests/ui/imports/import3.stderr b/tests/ui/imports/import3.edition2015.stderr similarity index 93% rename from tests/ui/imports/import3.stderr rename to tests/ui/imports/import3.edition2015.stderr index 871104ce50da1..5ca0eae5c1f01 100644 --- a/tests/ui/imports/import3.stderr +++ b/tests/ui/imports/import3.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `main` - --> $DIR/import3.rs:1:5 + --> $DIR/import3.rs:4:5 | LL | use main::bar; | ^^^^ use of unresolved module or unlinked crate `main` diff --git a/tests/ui/imports/import3.edition2021.stderr b/tests/ui/imports/import3.edition2021.stderr new file mode 100644 index 0000000000000..d8896654c9880 --- /dev/null +++ b/tests/ui/imports/import3.edition2021.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `main` + --> $DIR/import3.rs:4:5 + | +LL | use main::bar; + | ^^^^ function `main` is not a crate or module + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/import3.rs b/tests/ui/imports/import3.rs index 7bd6458cba103..f526d1f4b17db 100644 --- a/tests/ui/imports/import3.rs +++ b/tests/ui/imports/import3.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 use main::bar; //~ ERROR unresolved import `main` fn main() { println!("foo"); } From b061666fe7000b5419efaab80bfc7f8479cdd06c Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:38:55 -0500 Subject: [PATCH 25/39] Fix `import6.rs` --- tests/ui/imports/import6.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/import6.rs b/tests/ui/imports/import6.rs index 8632c21e5f7e9..1677003c0ecd6 100644 --- a/tests/ui/imports/import6.rs +++ b/tests/ui/imports/import6.rs @@ -10,6 +10,6 @@ mod foo { } } mod bar { - pub use foo::zed::baz; + pub use crate::foo::zed::baz; } pub fn main() { baz(); } From 27466a36e42ecd7d4a0a8c11bff5490ab86a84d8 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:41:00 -0500 Subject: [PATCH 26/39] Fix `import4.rs` --- tests/ui/imports/import4.rs | 4 ++-- tests/ui/imports/import4.stderr | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ui/imports/import4.rs b/tests/ui/imports/import4.rs index 01535fc6f45d7..f670cc06201c0 100644 --- a/tests/ui/imports/import4.rs +++ b/tests/ui/imports/import4.rs @@ -1,4 +1,4 @@ -mod a { pub use b::foo; } -mod b { pub use a::foo; } //~ ERROR unresolved import `a::foo` +mod a { pub use crate::b::foo; } +mod b { pub use crate::a::foo; } //~ ERROR unresolved import `crate::a::foo` fn main() { println!("loop"); } diff --git a/tests/ui/imports/import4.stderr b/tests/ui/imports/import4.stderr index c979d6c9ae24e..4faa5f0520a9d 100644 --- a/tests/ui/imports/import4.stderr +++ b/tests/ui/imports/import4.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `a::foo` +error[E0432]: unresolved import `crate::a::foo` --> $DIR/import4.rs:2:17 | -LL | mod b { pub use a::foo; } - | ^^^^^^ no `foo` in `a` +LL | mod b { pub use crate::a::foo; } + | ^^^^^^^^^^^^^ no `foo` in `a` error: aborting due to 1 previous error From 02748e9c970973d46be57d9dcb1bfe06f2f1651d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:45:12 -0500 Subject: [PATCH 27/39] Fix `import.rs` --- tests/ui/imports/import.rs | 6 +++--- tests/ui/imports/import.stderr | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ui/imports/import.rs b/tests/ui/imports/import.rs index 3170dd2fae108..c196dbff5f8e0 100644 --- a/tests/ui/imports/import.rs +++ b/tests/ui/imports/import.rs @@ -7,11 +7,11 @@ use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] mod zed { pub fn bar() { println!("bar"); } - use foo; //~ ERROR unresolved import `foo` [E0432] - //~^ no `foo` in the root + use crate::foo; //~ ERROR unresolved import `crate::foo` [E0432] + //~^ no `foo` in the root } fn main() { - zed::foo(); //~ ERROR `foo` is private + crate::zed::foo(); //~ ERROR `foo` is private bar(); } diff --git a/tests/ui/imports/import.stderr b/tests/ui/imports/import.stderr index 797712e2db99e..a85b525f894e7 100644 --- a/tests/ui/imports/import.stderr +++ b/tests/ui/imports/import.stderr @@ -7,23 +7,23 @@ LL | use zed::baz; | | help: a similar name exists in the module: `bar` | no `baz` in `zed` -error[E0432]: unresolved import `foo` +error[E0432]: unresolved import `crate::foo` --> $DIR/import.rs:10:9 | -LL | use foo; - | ^^^ no `foo` in the root +LL | use crate::foo; + | ^^^^^^^^^^ no `foo` in the root error[E0603]: unresolved item import `foo` is private - --> $DIR/import.rs:15:10 + --> $DIR/import.rs:15:17 | -LL | zed::foo(); - | ^^^ private unresolved item import +LL | crate::zed::foo(); + | ^^^ private unresolved item import | note: the unresolved item import `foo` is defined here --> $DIR/import.rs:10:9 | -LL | use foo; - | ^^^ +LL | use crate::foo; + | ^^^^^^^^^^ error: aborting due to 3 previous errors From 69519269f23a84299a77efc60f357b33e645fda0 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:47:18 -0500 Subject: [PATCH 28/39] Fix `import5.rs` --- tests/ui/imports/import5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/import5.rs b/tests/ui/imports/import5.rs index 96d6c62d48a52..7c7d99d71750a 100644 --- a/tests/ui/imports/import5.rs +++ b/tests/ui/imports/import5.rs @@ -1,7 +1,7 @@ //@ run-pass use foo::bar; mod foo { - pub use foo::zed::bar; + pub use crate::foo::zed::bar; pub mod zed { pub fn bar() { println!("foo"); } } From dc843f80773df9c2cbc77bbc14fb1934ac6df3df Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:53:31 -0500 Subject: [PATCH 29/39] Fix `issue-109343.rs` --- ...-109343.stderr => issue-109343.edition2015.stderr} | 2 +- tests/ui/imports/issue-109343.edition2021.stderr | 11 +++++++++++ tests/ui/imports/issue-109343.rs | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) rename tests/ui/imports/{issue-109343.stderr => issue-109343.edition2015.stderr} (93%) create mode 100644 tests/ui/imports/issue-109343.edition2021.stderr diff --git a/tests/ui/imports/issue-109343.stderr b/tests/ui/imports/issue-109343.edition2015.stderr similarity index 93% rename from tests/ui/imports/issue-109343.stderr rename to tests/ui/imports/issue-109343.edition2015.stderr index e1071e45b924c..77d4964a96fff 100644 --- a/tests/ui/imports/issue-109343.stderr +++ b/tests/ui/imports/issue-109343.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `unresolved` - --> $DIR/issue-109343.rs:4:9 + --> $DIR/issue-109343.rs:7:9 | LL | pub use unresolved::f; | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` diff --git a/tests/ui/imports/issue-109343.edition2021.stderr b/tests/ui/imports/issue-109343.edition2021.stderr new file mode 100644 index 0000000000000..6be3b48d04ccd --- /dev/null +++ b/tests/ui/imports/issue-109343.edition2021.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/issue-109343.rs:7:9 + | +LL | pub use unresolved::f; + | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` + | + = help: you might be missing a crate named `unresolved` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-109343.rs b/tests/ui/imports/issue-109343.rs index 0c10259bcd716..99325d587c1cb 100644 --- a/tests/ui/imports/issue-109343.rs +++ b/tests/ui/imports/issue-109343.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 #![crate_type = "lib"] pub mod f {} From 6ae926d93cf4e24a734452b7e91db6e519e881e5 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:54:17 -0500 Subject: [PATCH 30/39] Fix `import7.rs` --- tests/ui/imports/import7.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/import7.rs b/tests/ui/imports/import7.rs index ee1ce1a5d3e1d..ff2f9e5fc4eb2 100644 --- a/tests/ui/imports/import7.rs +++ b/tests/ui/imports/import7.rs @@ -10,7 +10,7 @@ mod foo { } } mod bar { - pub use foo::zed::baz; + pub use crate::foo::zed::baz; pub mod foo { pub mod zed {} } From b010733f03a665b0fbfac124be845a8acaff5dda Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:56:12 -0500 Subject: [PATCH 31/39] Fix `issue-18083.rs` --- tests/ui/imports/issue-18083.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/imports/issue-18083.rs b/tests/ui/imports/issue-18083.rs index 97c0bc83ad58b..c111c9b5aa86d 100644 --- a/tests/ui/imports/issue-18083.rs +++ b/tests/ui/imports/issue-18083.rs @@ -5,7 +5,7 @@ // each other and be reported as unresolved. mod a { - use b::{B}; + use crate::b::{B}; pub use self::inner::A; mod inner { @@ -14,7 +14,7 @@ mod a { } mod b { - use a::{A}; + use crate::a::{A}; pub use self::inner::B; mod inner { From fe8b343b085e9b6eaa3f1502e27d58724eaf6ed8 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 16:57:34 -0500 Subject: [PATCH 32/39] Fix `issue-1697.rs` --- ...ssue-1697.stderr => issue-1697.edition2015.stderr} | 2 +- tests/ui/imports/issue-1697.edition2021.stderr | 11 +++++++++++ tests/ui/imports/issue-1697.rs | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) rename tests/ui/imports/{issue-1697.stderr => issue-1697.edition2015.stderr} (93%) create mode 100644 tests/ui/imports/issue-1697.edition2021.stderr diff --git a/tests/ui/imports/issue-1697.stderr b/tests/ui/imports/issue-1697.edition2015.stderr similarity index 93% rename from tests/ui/imports/issue-1697.stderr rename to tests/ui/imports/issue-1697.edition2015.stderr index 96e371c64f9e5..d2e78c4fa98a3 100644 --- a/tests/ui/imports/issue-1697.stderr +++ b/tests/ui/imports/issue-1697.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `unresolved` - --> $DIR/issue-1697.rs:3:5 + --> $DIR/issue-1697.rs:6:5 | LL | use unresolved::*; | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` diff --git a/tests/ui/imports/issue-1697.edition2021.stderr b/tests/ui/imports/issue-1697.edition2021.stderr new file mode 100644 index 0000000000000..a4088cc40a87b --- /dev/null +++ b/tests/ui/imports/issue-1697.edition2021.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/issue-1697.rs:6:5 + | +LL | use unresolved::*; + | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` + | + = help: you might be missing a crate named `unresolved` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-1697.rs b/tests/ui/imports/issue-1697.rs index 3d3d4a17d6c19..38a762ef5fd2a 100644 --- a/tests/ui/imports/issue-1697.rs +++ b/tests/ui/imports/issue-1697.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 // Testing that we don't fail abnormally after hitting the errors use unresolved::*; From a9437516e28f2f0cd9ba1e70500672d8decf68e0 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 17:01:01 -0500 Subject: [PATCH 33/39] Fix `imports.rs` --- tests/ui/imports/imports.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/ui/imports/imports.rs b/tests/ui/imports/imports.rs index a770103c212c0..e39325e161d8c 100644 --- a/tests/ui/imports/imports.rs +++ b/tests/ui/imports/imports.rs @@ -3,7 +3,7 @@ // Like other items, private imports can be imported and used non-lexically in paths. mod a { - use a as foo; + use crate::a as foo; use self::foo::foo as bar; mod b { @@ -18,22 +18,22 @@ pub fn f() -> bool { true } // Items and explicit imports shadow globs. fn g() { - use foo::*; - use bar::*; + use crate::foo::*; + use crate::bar::*; fn f() -> bool { true } let _: bool = f(); } fn h() { - use foo::*; - use bar::*; - use f; + use crate::foo::*; + use crate::bar::*; + use crate::f; let _: bool = f(); } // Here, there appears to be shadowing but isn't because of namespaces. mod b { - use foo::*; // This imports `f` in the value namespace. + use crate::foo::*; // This imports `f` in the value namespace. use super::b as f; // This imports `f` only in the type namespace, fn test() { self::f(); } // so the glob isn't shadowed. } @@ -55,12 +55,12 @@ mod c { // Unused names can be ambiguous. mod d { - pub use foo::*; // This imports `f` in the value namespace. - pub use bar::*; // This also imports `f` in the value namespace. + pub use crate::foo::*; // This imports `f` in the value namespace. + pub use crate::bar::*; // This also imports `f` in the value namespace. } mod e { - pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. + pub use crate::d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. } fn main() {} From accebb02c45ff1351e7f5008f1d273956790ef8f Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:17:14 -0500 Subject: [PATCH 34/39] Fix `issue-19498.rs` --- tests/ui/imports/issue-19498.rs | 2 +- tests/ui/imports/issue-19498.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ui/imports/issue-19498.rs b/tests/ui/imports/issue-19498.rs index 5fe6742f55e03..0d4f962b23eed 100644 --- a/tests/ui/imports/issue-19498.rs +++ b/tests/ui/imports/issue-19498.rs @@ -5,7 +5,7 @@ mod A {} //~ ERROR the name `A` is defined multiple times pub mod B {} //~ ERROR the name `B` is defined multiple times //~| `B` redefined here mod C { - use C::D; + use crate::C::D; mod D {} //~ ERROR the name `D` is defined multiple times //~| `D` redefined here } diff --git a/tests/ui/imports/issue-19498.stderr b/tests/ui/imports/issue-19498.stderr index 69bdb67d3898b..fa692f3e939bd 100644 --- a/tests/ui/imports/issue-19498.stderr +++ b/tests/ui/imports/issue-19498.stderr @@ -31,16 +31,16 @@ LL | use self::B as OtherB; error[E0255]: the name `D` is defined multiple times --> $DIR/issue-19498.rs:9:5 | -LL | use C::D; - | ---- previous import of the module `D` here +LL | use crate::C::D; + | ----------- previous import of the module `D` here LL | mod D {} | ^^^^^ `D` redefined here | = note: `D` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL | use C::D as OtherD; - | +++++++++ +LL | use crate::C::D as OtherD; + | +++++++++ error: aborting due to 3 previous errors From 6582c89c62a2c50fe5ae0784767dfb692a1ca51a Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:18:09 -0500 Subject: [PATCH 35/39] Fix `issue-32222.rs` --- tests/ui/imports/issue-32222.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/imports/issue-32222.rs b/tests/ui/imports/issue-32222.rs index 8c528bc0a1ebc..6f5530a065c0a 100644 --- a/tests/ui/imports/issue-32222.rs +++ b/tests/ui/imports/issue-32222.rs @@ -16,7 +16,7 @@ mod a { } mod b { - pub use a::bar; + pub use crate::a::bar; } fn main() {} From 8d2cf4fe0d49fb9f0395e012d5585546ef3d814b Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:19:32 -0500 Subject: [PATCH 36/39] Fix `issue-28388-1.rs` --- ...e-28388-1.stderr => issue-28388-1.edition2015.stderr} | 2 +- tests/ui/imports/issue-28388-1.edition2021.stderr | 9 +++++++++ tests/ui/imports/issue-28388-1.rs | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) rename tests/ui/imports/{issue-28388-1.stderr => issue-28388-1.edition2015.stderr} (86%) create mode 100644 tests/ui/imports/issue-28388-1.edition2021.stderr diff --git a/tests/ui/imports/issue-28388-1.stderr b/tests/ui/imports/issue-28388-1.edition2015.stderr similarity index 86% rename from tests/ui/imports/issue-28388-1.stderr rename to tests/ui/imports/issue-28388-1.edition2015.stderr index 8256f96c62dd9..9a216abc62eb9 100644 --- a/tests/ui/imports/issue-28388-1.stderr +++ b/tests/ui/imports/issue-28388-1.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `foo` - --> $DIR/issue-28388-1.rs:3:5 + --> $DIR/issue-28388-1.rs:6:5 | LL | use foo::{}; | ^^^^^^^ no `foo` in the root diff --git a/tests/ui/imports/issue-28388-1.edition2021.stderr b/tests/ui/imports/issue-28388-1.edition2021.stderr new file mode 100644 index 0000000000000..904d58dd4dac6 --- /dev/null +++ b/tests/ui/imports/issue-28388-1.edition2021.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `foo` + --> $DIR/issue-28388-1.rs:6:5 + | +LL | use foo::{}; + | ^^^^^^^ no external crate `foo` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-28388-1.rs b/tests/ui/imports/issue-28388-1.rs index 14de621405dfe..2578940aa32dd 100644 --- a/tests/ui/imports/issue-28388-1.rs +++ b/tests/ui/imports/issue-28388-1.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 // Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. use foo::{}; //~ ERROR unresolved import `foo` From 78595a052cb1fa895cb704ad6da62ec231035522 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:20:57 -0500 Subject: [PATCH 37/39] Fix `issue-33464.rs` --- ....stderr => issue-33464.edition2015.stderr} | 6 ++--- .../ui/imports/issue-33464.edition2021.stderr | 27 +++++++++++++++++++ tests/ui/imports/issue-33464.rs | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) rename tests/ui/imports/{issue-33464.stderr => issue-33464.edition2015.stderr} (91%) create mode 100644 tests/ui/imports/issue-33464.edition2021.stderr diff --git a/tests/ui/imports/issue-33464.stderr b/tests/ui/imports/issue-33464.edition2015.stderr similarity index 91% rename from tests/ui/imports/issue-33464.stderr rename to tests/ui/imports/issue-33464.edition2015.stderr index dba4518467580..071b84a478c4d 100644 --- a/tests/ui/imports/issue-33464.stderr +++ b/tests/ui/imports/issue-33464.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `abc` - --> $DIR/issue-33464.rs:3:5 + --> $DIR/issue-33464.rs:6:5 | LL | use abc::one_el; | ^^^ use of unresolved module or unlinked crate `abc` @@ -10,7 +10,7 @@ LL + extern crate abc; | error[E0432]: unresolved import `abc` - --> $DIR/issue-33464.rs:5:5 + --> $DIR/issue-33464.rs:8:5 | LL | use abc::{a, bbb, cccccc}; | ^^^ use of unresolved module or unlinked crate `abc` @@ -21,7 +21,7 @@ LL + extern crate abc; | error[E0432]: unresolved import `a_very_long_name` - --> $DIR/issue-33464.rs:7:5 + --> $DIR/issue-33464.rs:10:5 | LL | use a_very_long_name::{el, el2}; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `a_very_long_name` diff --git a/tests/ui/imports/issue-33464.edition2021.stderr b/tests/ui/imports/issue-33464.edition2021.stderr new file mode 100644 index 0000000000000..f3ff115f7c57e --- /dev/null +++ b/tests/ui/imports/issue-33464.edition2021.stderr @@ -0,0 +1,27 @@ +error[E0432]: unresolved import `abc` + --> $DIR/issue-33464.rs:6:5 + | +LL | use abc::one_el; + | ^^^ use of unresolved module or unlinked crate `abc` + | + = help: you might be missing a crate named `abc` + +error[E0432]: unresolved import `abc` + --> $DIR/issue-33464.rs:8:5 + | +LL | use abc::{a, bbb, cccccc}; + | ^^^ use of unresolved module or unlinked crate `abc` + | + = help: you might be missing a crate named `abc` + +error[E0432]: unresolved import `a_very_long_name` + --> $DIR/issue-33464.rs:10:5 + | +LL | use a_very_long_name::{el, el2}; + | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `a_very_long_name` + | + = help: you might be missing a crate named `a_very_long_name` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-33464.rs b/tests/ui/imports/issue-33464.rs index a0edb5fdb6f93..789c2872f2b7c 100644 --- a/tests/ui/imports/issue-33464.rs +++ b/tests/ui/imports/issue-33464.rs @@ -1,3 +1,6 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 // Make sure that the spans of import errors are correct. use abc::one_el; From adf8c4300997dda3d216160ac4f2c53d886b552c Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:25:11 -0500 Subject: [PATCH 38/39] Fix `issue-37887.rs` --- ....stderr => issue-37887.edition2015.stderr} | 4 ++-- .../ui/imports/issue-37887.edition2021.stderr | 23 +++++++++++++++++++ tests/ui/imports/issue-37887.rs | 7 +++++- 3 files changed, 31 insertions(+), 3 deletions(-) rename tests/ui/imports/{issue-37887.stderr => issue-37887.edition2015.stderr} (93%) create mode 100644 tests/ui/imports/issue-37887.edition2021.stderr diff --git a/tests/ui/imports/issue-37887.stderr b/tests/ui/imports/issue-37887.edition2015.stderr similarity index 93% rename from tests/ui/imports/issue-37887.stderr rename to tests/ui/imports/issue-37887.edition2015.stderr index b83ba273a0194..285b74cd36908 100644 --- a/tests/ui/imports/issue-37887.stderr +++ b/tests/ui/imports/issue-37887.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `test` - --> $DIR/issue-37887.rs:3:9 + --> $DIR/issue-37887.rs:7:9 | LL | use test::*; | ^^^^ use of unresolved module or unlinked crate `test` @@ -10,7 +10,7 @@ LL + extern crate test; | error[E0658]: use of unstable library feature `test` - --> $DIR/issue-37887.rs:2:5 + --> $DIR/issue-37887.rs:6:5 | LL | extern crate test; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/imports/issue-37887.edition2021.stderr b/tests/ui/imports/issue-37887.edition2021.stderr new file mode 100644 index 0000000000000..ea8f235819d90 --- /dev/null +++ b/tests/ui/imports/issue-37887.edition2021.stderr @@ -0,0 +1,23 @@ +error[E0658]: use of unstable library feature `test` + --> $DIR/issue-37887.rs:6:5 + | +LL | extern crate test; + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #50297 for more information + = help: add `#![feature(test)]` 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[E0658]: use of unstable library feature `test` + --> $DIR/issue-37887.rs:7:9 + | +LL | use test::*; + | ^^^^ + | + = note: see issue #50297 for more information + = help: add `#![feature(test)]` 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: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/imports/issue-37887.rs b/tests/ui/imports/issue-37887.rs index 919f46d34c6d9..728fa702ff41f 100644 --- a/tests/ui/imports/issue-37887.rs +++ b/tests/ui/imports/issue-37887.rs @@ -1,4 +1,9 @@ +//@ revisions: edition2015 edition2021 +//@[edition2015] edition: 2015 +//@[edition2021] edition: 2021 +// fn main() { extern crate test; //~ ERROR use of unstable - use test::*; //~ ERROR unresolved import + use test::*; //[edition2015]~ ERROR unresolved import + //[edition2021]~^ ERROR use of unstable } From 6a9255b96434944c0969b5e91c0c4163befe5fc6 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 5 May 2025 20:26:54 -0500 Subject: [PATCH 39/39] Fix `issue-45799-bad-extern-crate-rename-suggestion-formatting.rs` --- ...ue-45799-bad-extern-crate-rename-suggestion-formatting.fixed | 1 + ...issue-45799-bad-extern-crate-rename-suggestion-formatting.rs | 1 + ...e-45799-bad-extern-crate-rename-suggestion-formatting.stderr | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed index bc5b72c3f7294..8ae38647747ae 100644 --- a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed +++ b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed @@ -1,4 +1,5 @@ //@ run-rustfix +//@ edition: 2015 extern crate std as other_std; fn main() {} diff --git a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs index 5ac7407371d52..11d6236612601 100644 --- a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs +++ b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs @@ -1,4 +1,5 @@ //@ run-rustfix +//@ edition: 2015 extern crate std; fn main() {} diff --git a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr index 2621f913186ee..e6b99b9aef661 100644 --- a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr +++ b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr @@ -1,5 +1,5 @@ error[E0259]: the name `std` is defined multiple times - --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:3:1 + --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:4:1 | LL | extern crate std; | ^^^^^^^^^^^^^^^^^ `std` reimported here