2022-04-21 02:47:01 -05:00
|
|
|
error[E0117]: only traits defined in the current crate can be implemented for primitive types
|
2019-10-26 10:28:02 -05:00
|
|
|
--> $DIR/coherence-impls-copy.rs:5:1
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
Move some implementations of Clone and Copy to libcore
Add implementations of `Clone` and `Copy` for some primitive types to
libcore so that they show up in the documentation. The concerned types
are the following:
* All primitive signed and unsigned integer types (`usize`, `u8`, `u16`,
`u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`);
* All primitive floating point types (`f32`, `f64`)
* `bool`
* `char`
* `!`
* Raw pointers (`*const T` and `*mut T`)
* Shared references (`&'a T`)
These types already implemented `Clone` and `Copy`, but the
implementation was provided by the compiler. The compiler no longer
provides these implementations and instead tries to look them up as
normal trait implementations. The goal of this change is to make the
implementations appear in the generated documentation.
For `Copy` specifically, the compiler would reject an attempt to write
an `impl` for the primitive types listed above with error `E0206`; this
error no longer occurs for these types, but it will still occur for the
other types that used to raise that error.
The trait implementations are guarded with `#[cfg(not(stage0))]` because
they are invalid according to the stage0 compiler. When the stage0
compiler is updated to a revision that includes this change, the
attribute will have to be removed, otherwise the stage0 build will fail
because the types mentioned above no longer implement `Clone` or `Copy`.
For type variants that are variadic, such as tuples and function
pointers, and for array types, the `Clone` and `Copy` implementations
are still provided by the compiler, because the language is not
expressive enough yet to be able to write the appropriate
implementations in Rust.
The initial plan was to add `impl` blocks guarded by `#[cfg(dox)]` to
make them apply only when generating documentation, without having to
touch the compiler. However, rustdoc's usage of the compiler still
rejected those `impl` blocks.
This is a [breaking-change] for users of `#![no_core]`, because they
will now have to supply their own implementations of `Clone` and `Copy`
for the primitive types listed above. The easiest way to do that is to
simply copy the implementations from `src/libcore/clone.rs` and
`src/libcore/marker.rs`.
Fixes #25893
2018-02-12 00:17:32 -06:00
|
|
|
LL | impl Copy for i32 {}
|
2019-10-12 16:31:23 -05:00
|
|
|
| ^^^^^^^^^^^^^^---
|
|
|
|
| | |
|
|
|
|
| | `i32` is not defined in the current crate
|
|
|
|
| impl doesn't use only types from inside the current crate
|
Move some implementations of Clone and Copy to libcore
Add implementations of `Clone` and `Copy` for some primitive types to
libcore so that they show up in the documentation. The concerned types
are the following:
* All primitive signed and unsigned integer types (`usize`, `u8`, `u16`,
`u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`);
* All primitive floating point types (`f32`, `f64`)
* `bool`
* `char`
* `!`
* Raw pointers (`*const T` and `*mut T`)
* Shared references (`&'a T`)
These types already implemented `Clone` and `Copy`, but the
implementation was provided by the compiler. The compiler no longer
provides these implementations and instead tries to look them up as
normal trait implementations. The goal of this change is to make the
implementations appear in the generated documentation.
For `Copy` specifically, the compiler would reject an attempt to write
an `impl` for the primitive types listed above with error `E0206`; this
error no longer occurs for these types, but it will still occur for the
other types that used to raise that error.
The trait implementations are guarded with `#[cfg(not(stage0))]` because
they are invalid according to the stage0 compiler. When the stage0
compiler is updated to a revision that includes this change, the
attribute will have to be removed, otherwise the stage0 build will fail
because the types mentioned above no longer implement `Clone` or `Copy`.
For type variants that are variadic, such as tuples and function
pointers, and for array types, the `Clone` and `Copy` implementations
are still provided by the compiler, because the language is not
expressive enough yet to be able to write the appropriate
implementations in Rust.
The initial plan was to add `impl` blocks guarded by `#[cfg(dox)]` to
make them apply only when generating documentation, without having to
touch the compiler. However, rustdoc's usage of the compiler still
rejected those `impl` blocks.
This is a [breaking-change] for users of `#![no_core]`, because they
will now have to supply their own implementations of `Clone` and `Copy`
for the primitive types listed above. The easiest way to do that is to
simply copy the implementations from `src/libcore/clone.rs` and
`src/libcore/marker.rs`.
Fixes #25893
2018-02-12 00:17:32 -06:00
|
|
|
|
|
|
|
|
= note: define and implement a trait or new type instead
|
2017-12-10 13:47:55 -06:00
|
|
|
|
2022-11-09 22:21:11 -06:00
|
|
|
error[E0119]: conflicting implementations of trait `Copy` for type `&NotSync`
|
2021-05-09 13:53:13 -05:00
|
|
|
--> $DIR/coherence-impls-copy.rs:28:1
|
|
|
|
|
|
|
|
|
LL | impl Copy for &'static NotSync {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: conflicting implementation in crate `core`:
|
|
|
|
- impl<T> Copy for &T
|
|
|
|
where T: ?Sized;
|
|
|
|
|
2017-12-10 13:47:55 -06:00
|
|
|
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
|
2021-05-09 13:53:13 -05:00
|
|
|
--> $DIR/coherence-impls-copy.rs:33:1
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
2021-05-09 13:53:13 -05:00
|
|
|
LL | impl Copy for &'static [NotSync] {}
|
|
|
|
| ^^^^^^^^^^^^^^------------------
|
2019-10-12 16:31:23 -05:00
|
|
|
| | |
|
2021-05-09 13:53:13 -05:00
|
|
|
| | this is not defined in the current crate because slices are always foreign
|
2019-10-12 16:31:23 -05:00
|
|
|
| impl doesn't use only types from inside the current crate
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
|
|
|
= note: define and implement a trait or new type instead
|
|
|
|
|
|
|
|
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
|
2021-05-09 13:53:13 -05:00
|
|
|
--> $DIR/coherence-impls-copy.rs:25:1
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
2021-05-09 13:53:13 -05:00
|
|
|
LL | impl Copy for (MyType, MyType) {}
|
|
|
|
| ^^^^^^^^^^^^^^----------------
|
2019-10-12 16:31:23 -05:00
|
|
|
| | |
|
2021-05-09 13:53:13 -05:00
|
|
|
| | this is not defined in the current crate because tuples are always foreign
|
2019-10-12 16:31:23 -05:00
|
|
|
| impl doesn't use only types from inside the current crate
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
|
|
|
= note: define and implement a trait or new type instead
|
|
|
|
|
|
|
|
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
|
2021-05-09 13:53:13 -05:00
|
|
|
--> $DIR/coherence-impls-copy.rs:30:1
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
2021-05-09 13:53:13 -05:00
|
|
|
LL | impl Copy for [MyType] {}
|
|
|
|
| ^^^^^^^^^^^^^^--------
|
2019-10-12 16:31:23 -05:00
|
|
|
| | |
|
2019-10-23 19:06:01 -05:00
|
|
|
| | this is not defined in the current crate because slices are always foreign
|
2019-10-12 16:31:23 -05:00
|
|
|
| impl doesn't use only types from inside the current crate
|
2017-12-10 13:47:55 -06:00
|
|
|
|
|
|
|
|
= note: define and implement a trait or new type instead
|
|
|
|
|
2021-10-21 08:36:35 -05:00
|
|
|
error[E0206]: the trait `Copy` may not be implemented for this type
|
|
|
|
--> $DIR/coherence-impls-copy.rs:21:15
|
|
|
|
|
|
|
|
|
LL | impl Copy for &'static mut MyType {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration
|
|
|
|
|
|
|
|
error[E0206]: the trait `Copy` may not be implemented for this type
|
|
|
|
--> $DIR/coherence-impls-copy.rs:25:15
|
|
|
|
|
|
|
|
|
LL | impl Copy for (MyType, MyType) {}
|
|
|
|
| ^^^^^^^^^^^^^^^^ type is not a structure or enumeration
|
|
|
|
|
|
|
|
error[E0206]: the trait `Copy` may not be implemented for this type
|
|
|
|
--> $DIR/coherence-impls-copy.rs:30:15
|
|
|
|
|
|
|
|
|
LL | impl Copy for [MyType] {}
|
|
|
|
| ^^^^^^^^ type is not a structure or enumeration
|
|
|
|
|
|
|
|
error: aborting due to 8 previous errors
|
2017-12-10 13:47:55 -06:00
|
|
|
|
2019-04-17 12:26:38 -05:00
|
|
|
Some errors have detailed explanations: E0117, E0119, E0206.
|
2018-03-03 08:59:40 -06:00
|
|
|
For more information about an error, try `rustc --explain E0117`.
|