Skip to content

Commit 02d0a8b

Browse files
committed
docs
1 parent ad7e33e commit 02d0a8b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/doc/reference.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,13 @@ macro scope.
21172117
destructors from being run twice. Destructors might be run multiple times on
21182118
the same object with this attribute.
21192119
- `doc` - Doc comments such as `/// foo` are equivalent to `#[doc = "foo"]`.
2120+
- `rustc_on_unimplemented` - Write a custom note to be shown along with the error
2121+
when the trait is found to be unimplemented on a type.
2122+
You may use format arguments like `{T}`, `{A}` to correspond to the
2123+
types at the point of use corresponding to the type parameters of the
2124+
trait of the same name. `{Self}` will be replaced with the type that is supposed
2125+
to implement the trait but doesn't. To use this, the `on_unimplemented` feature gate
2126+
must be enabled.
21202127

21212128
### Conditional compilation
21222129

src/test/compile-fail/on-unimplemented-bad-anno.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ trait BadAnnotation1 {}
2929
//~^ ERROR there is no type parameter C on trait BadAnnotation2
3030
trait BadAnnotation2<A,B> {}
3131

32+
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
33+
//~^ only named substitution parameters are allowed
34+
trait BadAnnotation3<A,B> {}
3235

3336
pub fn main() {
3437
}

0 commit comments

Comments
 (0)