@@ -1359,8 +1359,84 @@ for v in &vs {
13591359"## ,
13601360
13611361E0272 : r##"
1362+ The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
1363+ message for when a particular trait isn't implemented on a type placed in a
1364+ position that needs that trait. For example, when the following code is
1365+ compiled:
13621366
1363- The `#[rustc_on_unimplemented]` attribute lets you specify
1367+ ```
1368+ fn foo<T: Index<u8>>(x: T){}
1369+
1370+ #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
1371+ trait Index<Idx> { ... }
1372+
1373+ foo(true); // `bool` does not implement `Index<u8>`
1374+ ```
1375+
1376+ there will be an error about `bool` not implementing `Index<u8>`, followed by a
1377+ note saying "the type `bool` cannot be indexed by `u8`".
1378+
1379+ As you can see, you can specify type parameters in curly braces for substitution
1380+ with the actual types (using the regular format string syntax) in a given
1381+ situation. Furthermore, `{Self}` will substitute to the type (in this case,
1382+ `bool`) that we tried to use.
1383+
1384+ This error appears when the curly braces contain an identifier which doesn't
1385+ match with any of the type parameters or the string `Self`. This might happen if
1386+ you misspelled a type parameter, or if you intended to use literal curly braces.
1387+ If it is the latter, escape the curly braces with a second curly brace of the
1388+ same type; e.g. a literal `{` is `{{`
1389+ "## ,
1390+
1391+ E0273 : r##"
1392+ The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
1393+ message for when a particular trait isn't implemented on a type placed in a
1394+ position that needs that trait. For example, when the following code is
1395+ compiled:
1396+
1397+ ```
1398+ fn foo<T: Index<u8>>(x: T){}
1399+
1400+ #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
1401+ trait Index<Idx> { ... }
1402+
1403+ foo(true); // `bool` does not implement `Index<u8>`
1404+ ```
1405+
1406+ there will be an error about `bool` not implementing `Index<u8>`, followed by a
1407+ note saying "the type `bool` cannot be indexed by `u8`".
1408+
1409+ As you can see, you can specify type parameters in curly braces for substitution
1410+ with the actual types (using the regular format string syntax) in a given
1411+ situation. Furthermore, `{Self}` will substitute to the type (in this case,
1412+ `bool`) that we tried to use.
1413+
1414+ This error appears when the curly braces do not contain an identifier. Please
1415+ add one of the same name as a type parameter. If you intended to use literal
1416+ braces, use `{{` and `}}` to escape them.
1417+ "## ,
1418+
1419+ E0273 : r##"
1420+ The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
1421+ message for when a particular trait isn't implemented on a type placed in a
1422+ position that needs that trait. For example, when the following code is
1423+ compiled:
1424+
1425+ ```
1426+ fn foo<T: Index<u8>>(x: T){}
1427+
1428+ #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
1429+ trait Index<Idx> { ... }
1430+
1431+ foo(true); // `bool` does not implement `Index<u8>`
1432+ ```
1433+
1434+ there will be an error about `bool` not implementing `Index<u8>`, followed by a
1435+ note saying "the type `bool` cannot be indexed by `u8`".
1436+
1437+ For this to work, some note must be specified. An empty attribute will not do
1438+ anything, please remove the attribute or add some helpful note for users of the
1439+ trait.
13641440"## ,
13651441
13661442E0277 : r##"
@@ -1787,9 +1863,6 @@ register_diagnostics! {
17871863// E0134,
17881864// E0135,
17891865 E0264 , // unknown external lang item
1790- E0272 , // rustc_on_unimplemented attribute refers to non-existent type parameter
1791- E0273 , // rustc_on_unimplemented must have named format arguments
1792- E0274 , // rustc_on_unimplemented must have a value
17931866 E0275 , // overflow evaluating requirement
17941867 E0276 , // requirement appears on impl method but not on corresponding trait method
17951868 E0278 , // requirement is not satisfied
0 commit comments