Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f67d0d2

Browse files
matthewjasperyaahc
andauthoredJul 29, 2022
Apply suggestions from code review
Co-authored-by: Jane Losare-Lusby <[email protected]>
1 parent 83c8e28 commit f67d0d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/code-considerations/using-unstable-lang/specialization.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ Only specialization using the `min_specialization` feature should be used. The f
6363
There are two unstable attributes that can be used to allow a trait bound in a specializing implementation that does not appear in the default implementation.
6464

6565
`rustc_specialization_trait` restricts the implementations of a trait to be "always applicable". Implementing traits annotated with `rustc_specialization_trait` is unstable, so this should not be used on any stable traits exported from the standard library. `Sized` is an exception, and can have this attribute because it already cannot be implemented by an `impl` block.
66+
**Note**: `rustc_specialization_trait` only prevents incorrect monomorphizations, it does not prevent a type from being coerced between specialized and unspecialized types which can be important when specialization must be applied consistently. See [rust-lang/rust#85863](https://github.com/rust-lang/rust/issues/85863) for more details.
6667

67-
`rustc_unsafe_specialization_marker` allows specializing on a trait with no associated items. The attribute is `unsafe` because lifetime constraints from the implementations of the trait are not considered when specializing. In the following example, the specialized implementation is used for *all* shared reference types, not just those with `'static` lifetime.
68+
`rustc_unsafe_specialization_marker` allows specializing on a trait with no associated items. The attribute is `unsafe` because lifetime constraints from the implementations of the trait are not considered when specializing. The following example demonstrates incorrect usage of `rustc_unsafe_specialization_marker`, the specialized implementation is used for *all* shared reference types, not just those with `'static` lifetime.
6869

6970
```rust,ignore
7071
#[rustc_unsafe_specialization_marker]

0 commit comments

Comments
 (0)
Please sign in to comment.