Rollup merge of #134573 - lukas-code:unimpl-dyn-pointerlike, r=compiler-errors
unimplement `PointerLike` for trait objects Values of type `dyn* PointerLike` or `dyn PointerLike` are not pointer-like so these types should not implement `PointerLike`. After https://github.com/rust-lang/rust/pull/133226, `PointerLike` allows user implementations, so we can't just mark it with `#[rustc_deny_explicit_impl(implement_via_object = false)]`. Instead, this PR splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two separate attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]` so that we opt out of the automatic `impl PointerLike for dyn PointerLike` and still allow user implementations. For traits that are marked with `#[do_not_implement_via_object]` but not `#[rustc_deny_explicit_impl]` I've also made it possible to add a manual `impl Trait for dyn Trait`. There is no immediate need for this, but it was one line to implement and seems nice to have. fixes https://github.com/rust-lang/rust/issues/134545 fixes https://github.com/rust-lang/rust/issues/134543 r? `@compiler-errors`
This commit is contained in:
commit
0b1834d66b
15 changed files with 217 additions and 93 deletions
|
@ -70,12 +70,12 @@ pub struct TraitDef {
|
|||
|
||||
/// Whether to add a builtin `dyn Trait: Trait` implementation.
|
||||
/// This is enabled for all traits except ones marked with
|
||||
/// `#[rustc_deny_explicit_impl(implement_via_object = false)]`.
|
||||
/// `#[rustc_do_not_implement_via_object]`.
|
||||
pub implement_via_object: bool,
|
||||
|
||||
/// Whether a trait is fully built-in, and any implementation is disallowed.
|
||||
/// This only applies to built-in traits, and is marked via
|
||||
/// `#[rustc_deny_explicit_impl(implement_via_object = ...)]`.
|
||||
/// `#[rustc_deny_explicit_impl]`.
|
||||
pub deny_explicit_impl: bool,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue