Auto merge of #104758 - Manishearth:rollup-rh1tfum, r=Manishearth
Rollup of 6 pull requests Successful merges: - #103488 (Allow opaque types in trait impl headers and rely on coherence to reject unsound cases) - #104359 (Refactor must_use lint into two parts) - #104612 (Lower return type outside async block creation) - #104621 (Fix --extern library finding errors) - #104647 (enable fuzzy_provenance_casts lint in liballoc and libstd) - #104750 (Bump `fd-lock` in `bootstrap` again) Failed merges: - #104732 (Refactor `ty::ClosureKind` related stuff) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
3f2b2eee8f
98 changed files with 904 additions and 542 deletions
|
|
@ -225,13 +225,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fd-lock"
|
||||
version = "3.0.7"
|
||||
version = "3.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c93a581058d957dc4176875aad04f82f81613e6611d64aa1a9c755bdfb16711"
|
||||
checksum = "bb21c69b9fea5e15dbc1049e4b77145dd0ba1c84019c488102de0dc4ea4b0a27"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rustix",
|
||||
"windows-sys 0.42.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -319,9 +319,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "0.7.2"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24c3f4eff5495aee4c0399d7b6a0dc2b6e81be84242ffbfcf253ebacccc1d0cb"
|
||||
checksum = "a7d367024b3f3414d8e01f437f704f41a9f64ab36f9067fa73e526ad4c763c87"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
|
|
@ -337,15 +341,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.126"
|
||||
version = "0.2.137"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
||||
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.0.46"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
|
||||
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
|
|
@ -529,16 +533,16 @@ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
|||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.35.6"
|
||||
version = "0.36.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef258c11e17f5c01979a10543a30a4e12faef6aab217a74266e747eefa3aed88"
|
||||
checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.36.1",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -725,19 +729,6 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc 0.36.1",
|
||||
"windows_i686_gnu 0.36.1",
|
||||
"windows_i686_msvc 0.36.1",
|
||||
"windows_x86_64_gnu 0.36.1",
|
||||
"windows_x86_64_msvc 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.42.0"
|
||||
|
|
@ -745,12 +736,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc 0.42.0",
|
||||
"windows_i686_gnu 0.42.0",
|
||||
"windows_i686_msvc 0.42.0",
|
||||
"windows_x86_64_gnu 0.42.0",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc 0.42.0",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -759,48 +750,24 @@ version = "0.42.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.42.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.42.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.42.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.42.0"
|
||||
|
|
@ -813,12 +780,6 @@ version = "0.42.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.42.0"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ test = false
|
|||
|
||||
[dependencies]
|
||||
cmake = "0.1.38"
|
||||
fd-lock = "3.0.7"
|
||||
fd-lock = "3.0.8"
|
||||
filetime = "0.2"
|
||||
getopts = "0.2.19"
|
||||
cc = "1.0.69"
|
||||
|
|
|
|||
|
|
@ -318,6 +318,7 @@ pub(crate) fn clean_predicate<'tcx>(
|
|||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::Ambiguous
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => panic!("not user writable"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ fn defining_use() -> OpaqueClosure {
|
|||
struct Wrapper<T>(T);
|
||||
trait Trait {}
|
||||
impl Trait for Wrapper<OpaqueClosure> {}
|
||||
//~^ ERROR cannot implement trait on type alias impl trait
|
||||
impl<T: Sync> Trait for Wrapper<T> {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>`
|
||||
--> $DIR/coherence-with-closure.rs:12:1
|
||||
--> $DIR/coherence-with-closure.rs:11:1
|
||||
|
|
||||
LL | impl Trait for Wrapper<OpaqueClosure> {}
|
||||
| ------------------------------------- first implementation here
|
||||
LL |
|
||||
LL | impl<T: Sync> Trait for Wrapper<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueClosure>`
|
||||
|
||||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/coherence-with-closure.rs:10:24
|
||||
|
|
||||
LL | impl Trait for Wrapper<OpaqueClosure> {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/coherence-with-closure.rs:3:22
|
||||
|
|
||||
LL | type OpaqueClosure = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ fn defining_use() -> OpaqueGenerator {
|
|||
struct Wrapper<T>(T);
|
||||
trait Trait {}
|
||||
impl Trait for Wrapper<OpaqueGenerator> {}
|
||||
//~^ ERROR cannot implement trait on type alias impl trait
|
||||
impl<T: Sync> Trait for Wrapper<T> {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>`
|
||||
--> $DIR/coherence-with-generator.rs:16:1
|
||||
--> $DIR/coherence-with-generator.rs:15:1
|
||||
|
|
||||
LL | impl Trait for Wrapper<OpaqueGenerator> {}
|
||||
| --------------------------------------- first implementation here
|
||||
LL |
|
||||
LL | impl<T: Sync> Trait for Wrapper<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>`
|
||||
|
||||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/coherence-with-generator.rs:14:24
|
||||
|
|
||||
LL | impl Trait for Wrapper<OpaqueGenerator> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/coherence-with-generator.rs:3:24
|
||||
|
|
||||
LL | type OpaqueGenerator = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
8
src/test/ui/errors/issue-104621-extern-bad-file.rs
Normal file
8
src/test/ui/errors/issue-104621-extern-bad-file.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// compile-flags: --extern foo={{src-base}}/errors/issue-104621-extern-bad-file.rs
|
||||
// only-linux
|
||||
|
||||
extern crate foo;
|
||||
//~^ ERROR extern location for foo is of an unknown type
|
||||
//~| ERROR file name should be lib*.rlib or lib*.so
|
||||
//~| ERROR can't find crate for `foo` [E0463]
|
||||
fn main() {}
|
||||
21
src/test/ui/errors/issue-104621-extern-bad-file.stderr
Normal file
21
src/test/ui/errors/issue-104621-extern-bad-file.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
error: extern location for foo is of an unknown type: $DIR/issue-104621-extern-bad-file.rs
|
||||
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
||||
|
|
||||
LL | extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: file name should be lib*.rlib or lib*.so
|
||||
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
||||
|
|
||||
LL | extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0463]: can't find crate for `foo`
|
||||
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
||||
|
|
||||
LL | extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^ can't find crate
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0463`.
|
||||
4
src/test/ui/errors/issue-104621-extern-not-file.rs
Normal file
4
src/test/ui/errors/issue-104621-extern-not-file.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// compile-flags: --extern foo=.
|
||||
|
||||
extern crate foo; //~ ERROR extern location for foo is not a file: .
|
||||
fn main() {}
|
||||
8
src/test/ui/errors/issue-104621-extern-not-file.stderr
Normal file
8
src/test/ui/errors/issue-104621-extern-not-file.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: extern location for foo is not a file: .
|
||||
--> $DIR/issue-104621-extern-not-file.rs:3:1
|
||||
|
|
||||
LL | extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -20,7 +20,6 @@ impl<T: Send> AnotherTrait for T {}
|
|||
// in the future.)
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
//~| ERROR cannot implement trait on type alias impl trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,6 @@ LL | impl<T: Send> AnotherTrait for T {}
|
|||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||
|
||||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/auto-trait.rs:21:25
|
||||
|
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/auto-trait.rs:7:19
|
||||
|
|
||||
LL | type OpaqueType = impl OpaqueTrait;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ impl<T: std::fmt::Debug> AnotherTrait for T {}
|
|||
// This is in error, because we cannot assume that `OpaqueType: !Debug`
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
//~| ERROR cannot implement trait on type alias impl trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -9,18 +9,6 @@ LL | impl AnotherTrait for D<OpaqueType> {
|
|||
|
|
||||
= note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
|
||||
|
||||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/negative-reasoning.rs:19:25
|
||||
|
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/negative-reasoning.rs:7:19
|
||||
|
|
||||
LL | type OpaqueType = impl OpaqueTrait;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ type Foo = impl PartialEq<(Foo, i32)>;
|
|||
struct Bar;
|
||||
|
||||
impl PartialEq<(Foo, i32)> for Bar {
|
||||
//~^ ERROR cannot implement trait on type alias impl trait
|
||||
fn eq(&self, _other: &(Foo, i32)) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn foo() -> Foo {
|
||||
//~^ ERROR can't compare `Bar` with `(Bar, i32)`
|
||||
Bar
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:7:17
|
||||
error[E0277]: can't compare `Bar` with `(Bar, i32)`
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:13:13
|
||||
|
|
||||
LL | impl PartialEq<(Foo, i32)> for Bar {
|
||||
| ^^^
|
||||
LL | fn foo() -> Foo {
|
||||
| ^^^ no implementation for `Bar == (Bar, i32)`
|
||||
LL |
|
||||
LL | Bar
|
||||
| --- return type was inferred to be `Bar` here
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:3:12
|
||||
|
|
||||
LL | type Foo = impl PartialEq<(Foo, i32)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar`
|
||||
= help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
mod a {
|
||||
type Foo = impl PartialEq<(Foo, i32)>;
|
||||
//~^ ERROR: unconstrained opaque type
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl PartialEq<(Bar, i32)> for Bar {
|
||||
fn eq(&self, _other: &(Foo, i32)) -> bool {
|
||||
//~^ ERROR: `eq` has an incompatible type for trait
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -14,12 +16,13 @@ mod a {
|
|||
|
||||
mod b {
|
||||
type Foo = impl PartialEq<(Foo, i32)>;
|
||||
//~^ ERROR: unconstrained opaque type
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl PartialEq<(Foo, i32)> for Bar {
|
||||
//~^ ERROR cannot implement trait on type alias impl trait
|
||||
fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
//~^ ERROR: `eq` has an incompatible type for trait
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,49 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:20:21
|
||||
|
|
||||
LL | impl PartialEq<(Foo, i32)> for Bar {
|
||||
| ^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:16:16
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16
|
||||
|
|
||||
LL | type Foo = impl PartialEq<(Foo, i32)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `Foo` must be used in combination with a concrete type within the same module
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0053]: method `eq` has an incompatible type for trait
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:30
|
||||
|
|
||||
LL | type Foo = impl PartialEq<(Foo, i32)>;
|
||||
| -------------------------- the found opaque type
|
||||
...
|
||||
LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected struct `a::Bar`, found opaque type
|
||||
| help: change the parameter type to match the trait: `&(a::Bar, i32)`
|
||||
|
|
||||
= note: expected fn pointer `fn(&a::Bar, &(a::Bar, i32)) -> _`
|
||||
found fn pointer `fn(&a::Bar, &(a::Foo, i32)) -> _`
|
||||
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16
|
||||
|
|
||||
LL | type Foo = impl PartialEq<(Foo, i32)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `Foo` must be used in combination with a concrete type within the same module
|
||||
|
||||
error[E0053]: method `eq` has an incompatible type for trait
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:30
|
||||
|
|
||||
LL | type Foo = impl PartialEq<(Foo, i32)>;
|
||||
| -------------------------- the expected opaque type
|
||||
...
|
||||
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected opaque type, found struct `b::Bar`
|
||||
| help: change the parameter type to match the trait: `&(b::Foo, i32)`
|
||||
|
|
||||
= note: expected fn pointer `fn(&b::Bar, &(b::Foo, i32)) -> _`
|
||||
found fn pointer `fn(&b::Bar, &(b::Bar, i32)) -> _`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0053`.
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@
|
|||
// check-pass
|
||||
|
||||
#![warn(unused_must_use)]
|
||||
#![feature(never_type)]
|
||||
|
||||
fn deref_never(x: &!) {
|
||||
// Don't lint for uninhabited typess
|
||||
*x;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let val = 1;
|
||||
let val_pointer = &val;
|
||||
|
||||
// Comparison Operators
|
||||
// Comparison Operators
|
||||
val == 1; //~ WARNING unused comparison
|
||||
val < 1; //~ WARNING unused comparison
|
||||
val <= 1; //~ WARNING unused comparison
|
||||
|
|
@ -16,26 +22,30 @@ fn main() {
|
|||
val >= 1; //~ WARNING unused comparison
|
||||
val > 1; //~ WARNING unused comparison
|
||||
|
||||
// Arithmetic Operators
|
||||
// Arithmetic Operators
|
||||
val + 2; //~ WARNING unused arithmetic operation
|
||||
val - 2; //~ WARNING unused arithmetic operation
|
||||
val / 2; //~ WARNING unused arithmetic operation
|
||||
val * 2; //~ WARNING unused arithmetic operation
|
||||
val % 2; //~ WARNING unused arithmetic operation
|
||||
|
||||
// Logical Operators
|
||||
// Logical Operators
|
||||
true && true; //~ WARNING unused logical operation
|
||||
false || true; //~ WARNING unused logical operation
|
||||
|
||||
// Bitwise Operators
|
||||
// Bitwise Operators
|
||||
5 ^ val; //~ WARNING unused bitwise operation
|
||||
5 & val; //~ WARNING unused bitwise operation
|
||||
5 | val; //~ WARNING unused bitwise operation
|
||||
5 << val; //~ WARNING unused bitwise operation
|
||||
5 >> val; //~ WARNING unused bitwise operation
|
||||
|
||||
// Unary Operators
|
||||
// Unary Operators
|
||||
!val; //~ WARNING unused unary operation
|
||||
-val; //~ WARNING unused unary operation
|
||||
*val_pointer; //~ WARNING unused unary operation
|
||||
|
||||
if false {
|
||||
deref_never(&panic!());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:12:5
|
||||
--> $DIR/must-use-ops.rs:18:5
|
||||
|
|
||||
LL | val == 1;
|
||||
| ^^^^^^^^ the comparison produces a value
|
||||
|
|
@ -15,7 +15,7 @@ LL | let _ = val == 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:13:5
|
||||
--> $DIR/must-use-ops.rs:19:5
|
||||
|
|
||||
LL | val < 1;
|
||||
| ^^^^^^^ the comparison produces a value
|
||||
|
|
@ -26,7 +26,7 @@ LL | let _ = val < 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:14:5
|
||||
--> $DIR/must-use-ops.rs:20:5
|
||||
|
|
||||
LL | val <= 1;
|
||||
| ^^^^^^^^ the comparison produces a value
|
||||
|
|
@ -37,7 +37,7 @@ LL | let _ = val <= 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:15:5
|
||||
--> $DIR/must-use-ops.rs:21:5
|
||||
|
|
||||
LL | val != 1;
|
||||
| ^^^^^^^^ the comparison produces a value
|
||||
|
|
@ -48,7 +48,7 @@ LL | let _ = val != 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:16:5
|
||||
--> $DIR/must-use-ops.rs:22:5
|
||||
|
|
||||
LL | val >= 1;
|
||||
| ^^^^^^^^ the comparison produces a value
|
||||
|
|
@ -59,7 +59,7 @@ LL | let _ = val >= 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused comparison that must be used
|
||||
--> $DIR/must-use-ops.rs:17:5
|
||||
--> $DIR/must-use-ops.rs:23:5
|
||||
|
|
||||
LL | val > 1;
|
||||
| ^^^^^^^ the comparison produces a value
|
||||
|
|
@ -70,7 +70,7 @@ LL | let _ = val > 1;
|
|||
| +++++++
|
||||
|
||||
warning: unused arithmetic operation that must be used
|
||||
--> $DIR/must-use-ops.rs:20:5
|
||||
--> $DIR/must-use-ops.rs:26:5
|
||||
|
|
||||
LL | val + 2;
|
||||
| ^^^^^^^ the arithmetic operation produces a value
|
||||
|
|
@ -81,7 +81,7 @@ LL | let _ = val + 2;
|
|||
| +++++++
|
||||
|
||||
warning: unused arithmetic operation that must be used
|
||||
--> $DIR/must-use-ops.rs:21:5
|
||||
--> $DIR/must-use-ops.rs:27:5
|
||||
|
|
||||
LL | val - 2;
|
||||
| ^^^^^^^ the arithmetic operation produces a value
|
||||
|
|
@ -92,7 +92,7 @@ LL | let _ = val - 2;
|
|||
| +++++++
|
||||
|
||||
warning: unused arithmetic operation that must be used
|
||||
--> $DIR/must-use-ops.rs:22:5
|
||||
--> $DIR/must-use-ops.rs:28:5
|
||||
|
|
||||
LL | val / 2;
|
||||
| ^^^^^^^ the arithmetic operation produces a value
|
||||
|
|
@ -103,7 +103,7 @@ LL | let _ = val / 2;
|
|||
| +++++++
|
||||
|
||||
warning: unused arithmetic operation that must be used
|
||||
--> $DIR/must-use-ops.rs:23:5
|
||||
--> $DIR/must-use-ops.rs:29:5
|
||||
|
|
||||
LL | val * 2;
|
||||
| ^^^^^^^ the arithmetic operation produces a value
|
||||
|
|
@ -114,7 +114,7 @@ LL | let _ = val * 2;
|
|||
| +++++++
|
||||
|
||||
warning: unused arithmetic operation that must be used
|
||||
--> $DIR/must-use-ops.rs:24:5
|
||||
--> $DIR/must-use-ops.rs:30:5
|
||||
|
|
||||
LL | val % 2;
|
||||
| ^^^^^^^ the arithmetic operation produces a value
|
||||
|
|
@ -125,7 +125,7 @@ LL | let _ = val % 2;
|
|||
| +++++++
|
||||
|
||||
warning: unused logical operation that must be used
|
||||
--> $DIR/must-use-ops.rs:27:5
|
||||
--> $DIR/must-use-ops.rs:33:5
|
||||
|
|
||||
LL | true && true;
|
||||
| ^^^^^^^^^^^^ the logical operation produces a value
|
||||
|
|
@ -136,7 +136,7 @@ LL | let _ = true && true;
|
|||
| +++++++
|
||||
|
||||
warning: unused logical operation that must be used
|
||||
--> $DIR/must-use-ops.rs:28:5
|
||||
--> $DIR/must-use-ops.rs:34:5
|
||||
|
|
||||
LL | false || true;
|
||||
| ^^^^^^^^^^^^^ the logical operation produces a value
|
||||
|
|
@ -147,7 +147,7 @@ LL | let _ = false || true;
|
|||
| +++++++
|
||||
|
||||
warning: unused bitwise operation that must be used
|
||||
--> $DIR/must-use-ops.rs:31:5
|
||||
--> $DIR/must-use-ops.rs:37:5
|
||||
|
|
||||
LL | 5 ^ val;
|
||||
| ^^^^^^^ the bitwise operation produces a value
|
||||
|
|
@ -158,7 +158,7 @@ LL | let _ = 5 ^ val;
|
|||
| +++++++
|
||||
|
||||
warning: unused bitwise operation that must be used
|
||||
--> $DIR/must-use-ops.rs:32:5
|
||||
--> $DIR/must-use-ops.rs:38:5
|
||||
|
|
||||
LL | 5 & val;
|
||||
| ^^^^^^^ the bitwise operation produces a value
|
||||
|
|
@ -169,7 +169,7 @@ LL | let _ = 5 & val;
|
|||
| +++++++
|
||||
|
||||
warning: unused bitwise operation that must be used
|
||||
--> $DIR/must-use-ops.rs:33:5
|
||||
--> $DIR/must-use-ops.rs:39:5
|
||||
|
|
||||
LL | 5 | val;
|
||||
| ^^^^^^^ the bitwise operation produces a value
|
||||
|
|
@ -180,7 +180,7 @@ LL | let _ = 5 | val;
|
|||
| +++++++
|
||||
|
||||
warning: unused bitwise operation that must be used
|
||||
--> $DIR/must-use-ops.rs:34:5
|
||||
--> $DIR/must-use-ops.rs:40:5
|
||||
|
|
||||
LL | 5 << val;
|
||||
| ^^^^^^^^ the bitwise operation produces a value
|
||||
|
|
@ -191,7 +191,7 @@ LL | let _ = 5 << val;
|
|||
| +++++++
|
||||
|
||||
warning: unused bitwise operation that must be used
|
||||
--> $DIR/must-use-ops.rs:35:5
|
||||
--> $DIR/must-use-ops.rs:41:5
|
||||
|
|
||||
LL | 5 >> val;
|
||||
| ^^^^^^^^ the bitwise operation produces a value
|
||||
|
|
@ -202,7 +202,7 @@ LL | let _ = 5 >> val;
|
|||
| +++++++
|
||||
|
||||
warning: unused unary operation that must be used
|
||||
--> $DIR/must-use-ops.rs:38:5
|
||||
--> $DIR/must-use-ops.rs:44:5
|
||||
|
|
||||
LL | !val;
|
||||
| ^^^^ the unary operation produces a value
|
||||
|
|
@ -213,7 +213,7 @@ LL | let _ = !val;
|
|||
| +++++++
|
||||
|
||||
warning: unused unary operation that must be used
|
||||
--> $DIR/must-use-ops.rs:39:5
|
||||
--> $DIR/must-use-ops.rs:45:5
|
||||
|
|
||||
LL | -val;
|
||||
| ^^^^ the unary operation produces a value
|
||||
|
|
@ -224,7 +224,7 @@ LL | let _ = -val;
|
|||
| +++++++
|
||||
|
||||
warning: unused unary operation that must be used
|
||||
--> $DIR/must-use-ops.rs:40:5
|
||||
--> $DIR/must-use-ops.rs:46:5
|
||||
|
|
||||
LL | *val_pointer;
|
||||
| ^^^^^^^^^^^^ the unary operation produces a value
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#![deny(unused_must_use)]
|
||||
|
||||
#[must_use]
|
||||
#[derive(Clone, Copy)]
|
||||
struct S;
|
||||
|
||||
struct A;
|
||||
|
|
@ -34,6 +35,10 @@ fn array_of_arrays_of_arrays() -> [[[S; 1]; 2]; 1] {
|
|||
[[[S], [S]]]
|
||||
}
|
||||
|
||||
fn usize_max() -> [S; usize::MAX] {
|
||||
[S; usize::MAX]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
empty(); // ok
|
||||
singleton(); //~ ERROR unused array of `S` that must be used
|
||||
|
|
@ -44,4 +49,6 @@ fn main() {
|
|||
//~^ ERROR unused array of boxed `T` trait objects in tuple element 1 that must be used
|
||||
array_of_arrays_of_arrays();
|
||||
//~^ ERROR unused array of arrays of arrays of `S` that must be used
|
||||
usize_max();
|
||||
//~^ ERROR unused array of `S` that must be used
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: unused array of `S` that must be used
|
||||
--> $DIR/must_use-array.rs:39:5
|
||||
--> $DIR/must_use-array.rs:44:5
|
||||
|
|
||||
LL | singleton();
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -11,34 +11,40 @@ LL | #![deny(unused_must_use)]
|
|||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused array of `S` that must be used
|
||||
--> $DIR/must_use-array.rs:40:5
|
||||
--> $DIR/must_use-array.rs:45:5
|
||||
|
|
||||
LL | many();
|
||||
| ^^^^^^
|
||||
|
||||
error: unused array of `S` in tuple element 0 that must be used
|
||||
--> $DIR/must_use-array.rs:41:6
|
||||
--> $DIR/must_use-array.rs:46:6
|
||||
|
|
||||
LL | ([S], 0, ());
|
||||
| ^^^
|
||||
|
||||
error: unused array of implementers of `T` that must be used
|
||||
--> $DIR/must_use-array.rs:42:5
|
||||
--> $DIR/must_use-array.rs:47:5
|
||||
|
|
||||
LL | array_of_impl_trait();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused array of boxed `T` trait objects in tuple element 1 that must be used
|
||||
--> $DIR/must_use-array.rs:43:5
|
||||
--> $DIR/must_use-array.rs:48:5
|
||||
|
|
||||
LL | impl_array();
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: unused array of arrays of arrays of `S` that must be used
|
||||
--> $DIR/must_use-array.rs:45:5
|
||||
--> $DIR/must_use-array.rs:50:5
|
||||
|
|
||||
LL | array_of_arrays_of_arrays();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: unused array of `S` that must be used
|
||||
--> $DIR/must_use-array.rs:52:5
|
||||
|
|
||||
LL | usize_max();
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -9,5 +9,4 @@ trait AnotherTrait {}
|
|||
impl<T: Send> AnotherTrait for T {}
|
||||
impl AnotherTrait for OpaqueType {}
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
|
||||
//~| ERROR cannot implement trait on type alias impl trait
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,6 @@ LL | impl<T: Send> AnotherTrait for T {}
|
|||
LL | impl AnotherTrait for OpaqueType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType`
|
||||
|
||||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/issue-83613.rs:10:23
|
||||
|
|
||||
LL | impl AnotherTrait for OpaqueType {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/issue-83613.rs:4:19
|
||||
|
|
||||
LL | type OpaqueType = impl OpaqueTrait;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> {
|
|||
}
|
||||
|
||||
impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
|
||||
//~^ ERROR cannot implement trait on type alias impl trait
|
||||
//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/coherence.rs:14:41
|
||||
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
|
||||
--> $DIR/coherence.rs:14:1
|
||||
|
|
||||
LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------
|
||||
| | |
|
||||
| | `AliasOfForeignType<T>` is not defined in the current crate
|
||||
| impl doesn't use only types from inside the current crate
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/coherence.rs:9:30
|
||||
|
|
||||
LL | type AliasOfForeignType<T> = impl LocalTrait;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= note: define and implement a trait or new type instead
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0117`.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
trait Trait {}
|
||||
type Opaque<T> = impl Sized;
|
||||
fn foo<T>() -> Opaque<T> {
|
||||
()
|
||||
}
|
||||
|
||||
impl<T, V> Trait for (T, V, V, u32) {}
|
||||
impl<U, V> Trait for (Opaque<U>, V, i32, V) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
trait Foo {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl Foo for i32 {
|
||||
type Assoc = u32;
|
||||
}
|
||||
type ImplTrait = impl Sized;
|
||||
fn constrain() -> ImplTrait {
|
||||
1u64
|
||||
}
|
||||
impl Foo for i64 {
|
||||
type Assoc = ImplTrait;
|
||||
}
|
||||
|
||||
trait Bar<T> {}
|
||||
|
||||
impl<T: Foo> Bar<<T as Foo>::Assoc> for T {}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
trait Foo {}
|
||||
impl Foo for () {}
|
||||
impl Foo for i32 {}
|
||||
|
||||
type Bar<T: Foo> = impl std::fmt::Debug;
|
||||
fn defining_use<T: Foo>() -> Bar<T> {
|
||||
42
|
||||
}
|
||||
|
||||
trait Bop {}
|
||||
|
||||
impl Bop for Bar<()> {}
|
||||
|
||||
// If the hidden type is the same, this is effectively a second impl for the same type.
|
||||
impl Bop for Bar<i32> {}
|
||||
//~^ ERROR conflicting implementations
|
||||
|
||||
type Barr = impl std::fmt::Debug;
|
||||
fn defining_use2() -> Barr {
|
||||
42
|
||||
}
|
||||
|
||||
// Even completely different opaque types must conflict.
|
||||
impl Bop for Barr {}
|
||||
//~^ ERROR conflicting implementations
|
||||
|
||||
// And obviously the hidden type must conflict, too.
|
||||
impl Bop for i32 {}
|
||||
//~^ ERROR conflicting implementations
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>`
|
||||
--> $DIR/impl_trait_for_same_tait.rs:17:1
|
||||
|
|
||||
LL | impl Bop for Bar<()> {}
|
||||
| -------------------- first implementation here
|
||||
...
|
||||
LL | impl Bop for Bar<i32> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>`
|
||||
--> $DIR/impl_trait_for_same_tait.rs:26:1
|
||||
|
|
||||
LL | impl Bop for Bar<()> {}
|
||||
| -------------------- first implementation here
|
||||
...
|
||||
LL | impl Bop for Barr {}
|
||||
| ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>`
|
||||
--> $DIR/impl_trait_for_same_tait.rs:30:1
|
||||
|
|
||||
LL | impl Bop for Bar<()> {}
|
||||
| -------------------- first implementation here
|
||||
...
|
||||
LL | impl Bop for i32 {}
|
||||
| ^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
21
src/test/ui/type-alias-impl-trait/impl_trait_for_tait.rs
Normal file
21
src/test/ui/type-alias-impl-trait/impl_trait_for_tait.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// compile-flags: --crate-type=lib
|
||||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
type Alias = impl Sized;
|
||||
|
||||
fn constrain() -> Alias {
|
||||
1i32
|
||||
}
|
||||
|
||||
trait HideIt {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl HideIt for () {
|
||||
type Assoc = Alias;
|
||||
}
|
||||
|
||||
pub trait Yay {}
|
||||
|
||||
impl Yay for <() as HideIt>::Assoc {}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
type Foo = impl Debug;
|
||||
pub trait Yay { }
|
||||
impl Yay for Foo { }
|
||||
|
||||
fn foo() {
|
||||
is_yay::<u32>(); //~ ERROR: the trait bound `u32: Yay` is not satisfied
|
||||
is_debug::<u32>(); // OK
|
||||
is_yay::<Foo>(); // OK
|
||||
is_debug::<Foo>(); // OK
|
||||
}
|
||||
|
||||
fn is_yay<T: Yay>() { }
|
||||
fn is_debug<T: Debug>() { }
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error[E0277]: the trait bound `u32: Yay` is not satisfied
|
||||
--> $DIR/impl_trait_for_tait_bound.rs:10:14
|
||||
|
|
||||
LL | is_yay::<u32>();
|
||||
| ^^^ the trait `Yay` is not implemented for `u32`
|
||||
|
|
||||
= help: the trait `Yay` is implemented for `Foo`
|
||||
note: required by a bound in `is_yay`
|
||||
--> $DIR/impl_trait_for_tait_bound.rs:16:14
|
||||
|
|
||||
LL | fn is_yay<T: Yay>() { }
|
||||
| ^^^ required by this bound in `is_yay`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
type Foo = impl Debug;
|
||||
|
||||
pub trait Yay { }
|
||||
impl Yay for u32 { }
|
||||
|
||||
fn foo() {
|
||||
is_yay::<Foo>(); //~ ERROR: the trait bound `Foo: Yay` is not satisfied
|
||||
}
|
||||
|
||||
fn is_yay<T: Yay>() { }
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error[E0277]: the trait bound `Foo: Yay` is not satisfied
|
||||
--> $DIR/impl_trait_for_tait_bound2.rs:11:14
|
||||
|
|
||||
LL | is_yay::<Foo>();
|
||||
| ^^^ the trait `Yay` is not implemented for `Foo`
|
||||
|
|
||||
= help: the trait `Yay` is implemented for `u32`
|
||||
note: required by a bound in `is_yay`
|
||||
--> $DIR/impl_trait_for_tait_bound2.rs:14:14
|
||||
|
|
||||
LL | fn is_yay<T: Yay>() { }
|
||||
| ^^^ required by this bound in `is_yay`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -8,7 +8,7 @@ impl MyTrait for () {}
|
|||
type Bar = impl MyTrait;
|
||||
|
||||
impl MyTrait for Bar {}
|
||||
//~^ ERROR: cannot implement trait on type alias impl trait
|
||||
//~^ ERROR: conflicting implementations of trait `MyTrait` for type `()`
|
||||
|
||||
fn bazr() -> Bar { }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/issue-65384.rs:10:18
|
||||
error[E0119]: conflicting implementations of trait `MyTrait` for type `()`
|
||||
--> $DIR/issue-65384.rs:10:1
|
||||
|
|
||||
LL | impl MyTrait for () {}
|
||||
| ------------------- first implementation here
|
||||
...
|
||||
LL | impl MyTrait for Bar {}
|
||||
| ^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/issue-65384.rs:8:12
|
||||
|
|
||||
LL | type Bar = impl MyTrait;
|
||||
| ^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Regression test for issue #76202
|
||||
// Tests that we don't ICE when we have a trait impl on a TAIT.
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
trait Dummy {}
|
||||
|
|
@ -14,7 +16,12 @@ trait Test {
|
|||
}
|
||||
|
||||
impl Test for F {
|
||||
//~^ ERROR cannot implement trait
|
||||
fn test(self) {}
|
||||
}
|
||||
|
||||
// Ok because `i32` does not implement `Dummy`,
|
||||
// so it can't possibly be the hidden type of `F`.
|
||||
impl Test for i32 {
|
||||
fn test(self) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/issue-76202-trait-impl-for-tait.rs:16:15
|
||||
|
|
||||
LL | impl Test for F {
|
||||
| ^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/issue-76202-trait-impl-for-tait.rs:9:10
|
||||
|
|
||||
LL | type F = impl Dummy;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Regression test for issues #84660 and #86411: both are variations on #76202.
|
||||
// Tests that we don't ICE when we have an opaque type appearing anywhere in an impl header.
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
trait Foo {}
|
||||
|
|
@ -12,7 +14,7 @@ trait TraitArg<T> {
|
|||
fn f();
|
||||
}
|
||||
|
||||
impl TraitArg<Bar> for () { //~ ERROR cannot implement trait
|
||||
impl TraitArg<Bar> for () {
|
||||
fn f() {
|
||||
println!("ho");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/issue-84660-trait-impl-for-tait.rs:15:15
|
||||
|
|
||||
LL | impl TraitArg<Bar> for () {
|
||||
| ^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/issue-84660-trait-impl-for-tait.rs:8:12
|
||||
|
|
||||
LL | type Bar = impl Foo;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -13,14 +13,14 @@ trait Trait<T, In> {
|
|||
fn convert(i: In) -> Self::Out;
|
||||
}
|
||||
|
||||
impl<In, Out> Trait<Bar, In> for Out { //~ ERROR cannot implement trait
|
||||
impl<In, Out> Trait<Bar, In> for Out {
|
||||
type Out = Out;
|
||||
fn convert(_i: In) -> Self::Out {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
impl<In, Out> Trait<(), In> for Out {
|
||||
impl<In, Out> Trait<(), In> for Out { //~ ERROR conflicting implementations of trait `Trait<Bar, _>`
|
||||
type Out = In;
|
||||
fn convert(i: In) -> Self::Out {
|
||||
i
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/issue-84660-unsoundness.rs:16:21
|
||||
error[E0119]: conflicting implementations of trait `Trait<Bar, _>`
|
||||
--> $DIR/issue-84660-unsoundness.rs:23:1
|
||||
|
|
||||
LL | impl<In, Out> Trait<Bar, In> for Out {
|
||||
| ^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
--> $DIR/issue-84660-unsoundness.rs:8:12
|
||||
|
|
||||
LL | type Bar = impl Foo;
|
||||
| ^^^^^^^^
|
||||
| ------------------------------------ first implementation here
|
||||
...
|
||||
LL | impl<In, Out> Trait<(), In> for Out {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
type FooX = impl Debug;
|
||||
//~^ ERROR unconstrained opaque type
|
||||
|
||||
trait Foo<A> { }
|
||||
|
||||
impl Foo<FooX> for () { }
|
||||
//~^ cannot implement trait on type alias impl trait
|
||||
|
||||
fn foo() -> impl Foo<FooX> {
|
||||
()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
error: cannot implement trait on type alias impl trait
|
||||
--> $DIR/nested-tait-inference3.rs:10:10
|
||||
|
|
||||
LL | impl Foo<FooX> for () { }
|
||||
| ^^^^
|
||||
|
|
||||
note: type alias impl trait defined here
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/nested-tait-inference3.rs:6:13
|
||||
|
|
||||
LL | type FooX = impl Debug;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: `FooX` must be used in combination with a concrete type within the same module
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: Option<
|
|||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
|
||||
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {predicate:#?}"),
|
||||
ty::PredicateKind::Coerce(_) => panic!("coerce predicate on function: {predicate:#?}"),
|
||||
ty::PredicateKind::Ambiguous => panic!("ambiguous predicate on function: {predicate:#?}"),
|
||||
}
|
||||
}
|
||||
match predicates.parent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue