@@ -37,7 +37,7 @@ match foo {
3737a wildcard arm above a more specific arm will make the latter arm irrelevant.
3838
3939Ensure the ordering of the match arm is correct and remove any superfluous
40- checks .
40+ arms .
4141"## ,
4242
4343E0002 : r##"
@@ -81,8 +81,8 @@ match number {
8181}
8282```
8383
84- To match against NaN values, you should
85- instead use the `is_nan()` method in a guard, like so:
84+ To match against NaN values, you should instead use the `is_nan()` method in a
85+ guard, like so:
8686
8787```
8888match number {
@@ -333,8 +333,8 @@ Statics are shared everywhere, and if they refer to mutable data one might
333333violate memory safety since holding multiple mutable references to shared data
334334is not allowed.
335335
336- If you really want global mutable state, try using a global `UnsafeCell` or
337- `static mut `.
336+ If you really want global mutable state, try using `static mut` or a global
337+ `UnsafeCell `.
338338
339339"## ,
340340
@@ -416,7 +416,7 @@ is bad because the function body may not mutate `x`.
416416
417417Remove any mutable bindings from the argument list to fix this error. In case
418418you need to mutate the argument, try lazily initializing a global variable
419- instead of using a const fn, or refactoring the code to a functional style to
419+ instead of using a ` const fn` , or refactoring the code to a functional style to
420420avoid mutation if possible.
421421"## ,
422422
@@ -444,11 +444,11 @@ requirements are satisfied by the trait in question.
444444
445445Trait objects are a form of dynamic dispatch and use a dynamically sized type
446446for the inner type. So, for a given trait `Trait`, when `Trait` is treated as a
447- type, as in `Box<Trait>`, the inner type is " unsized" . In such cases the boxed
448- pointer is a " fat pointer" that contains an extra pointer to a table of methods
447+ type, as in `Box<Trait>`, the inner type is ' unsized' . In such cases the boxed
448+ pointer is a ' fat pointer' that contains an extra pointer to a table of methods
449449(among other things) for dynamic dispatch. This design mandates some
450450restrictions on the types of traits that are allowed to be used in trait
451- objects, which are collectively termed as " object safety" rules.
451+ objects, which are collectively termed as ' object safety' rules.
452452
453453Attempting to create a trait object for a non object-safe trait will trigger
454454this error.
@@ -513,7 +513,7 @@ fn call_foo(x: Box<Trait>) {
513513If only some methods aren't object-safe, you can add a `where Self: Sized` bound
514514on them to mark them as explicitly unavailable to trait objects. The
515515functionality will still be available to all other implementers, including
516- `Box<Trait>` which is itself sized (assuming you `impl Trait for Box<Trait>`)
516+ `Box<Trait>` which is itself sized (assuming you `impl Trait for Box<Trait>`).
517517
518518```
519519trait Trait {
@@ -530,7 +530,7 @@ that trait that aren't behind trait objects.
530530### Method has generic type parameters
531531
532532As mentioned before, trait objects contain pointers to method tables. So, if we
533- have
533+ have:
534534
535535```
536536trait Trait {
@@ -549,7 +549,7 @@ impl Trait for u8 {
549549// ...
550550```
551551
552- at compile time each implementation of `Trait` will produce a table containing
552+ At compile time each implementation of `Trait` will produce a table containing
553553the various methods (and other items) related to the implementation.
554554
555555This works fine, but when the method gains generic parameters, we can have a
@@ -578,7 +578,7 @@ that implements the trait. Now, if it has type parameters, we need to add
578578implementations for every type that implements the trait, and there could
579579theoretically be an infinite number of types.
580580
581- For example, with
581+ For example, with:
582582
583583```
584584trait Trait {
@@ -598,7 +598,7 @@ impl Trait for u8 {
598598// 8 more implementations
599599```
600600
601- Now, if I have the following code:
601+ Now, if we have the following code:
602602
603603```
604604fn call_foo(thing: Box<Trait>) {
@@ -647,7 +647,6 @@ an implementation.
647647
648648Adding a `Self: Sized` bound to these methods will generally make this compile.
649649
650-
651650```
652651trait Foo {
653652 fn foo() -> u8 where Self: Sized;
@@ -752,7 +751,8 @@ https://doc.rust-lang.org/reference.html#ffi-attributes
752751"## ,
753752
754753E0109 : r##"
755- You tried to give a type parameter to a type which doesn't need it; for example:
754+ You tried to give a type parameter to a type which doesn't need it. Erroneous
755+ code example:
756756
757757```
758758type X = u32<i32>; // error: type parameters are not allowed on this type
@@ -769,8 +769,8 @@ type X = u32; // this compiles
769769"## ,
770770
771771E0110 : r##"
772- You tried to give a lifetime parameter to a type which doesn't need it; for
773- example:
772+ You tried to give a lifetime parameter to a type which doesn't need it.
773+ Erroneous code example:
774774
775775```
776776type X = u32<'static>; // error: lifetime parameters are not allowed on
@@ -882,6 +882,14 @@ fn foo<T: MyTransmutableType>(x: Vec<T>) {
882882Each impl will be checked for a size match in the transmute as usual, and since
883883there are no unbound type parameters involved, this should compile unless there
884884is a size mismatch in one of the impls.
885+
886+ It is also possible to manually transmute:
887+
888+ ```
889+ let result: SomeType = mem::uninitialized();
890+ unsafe { copy_nonoverlapping(&v, &result) };
891+ result // `v` transmuted to type `SomeType`
892+ ```
885893"## ,
886894
887895E0152 : r##"
@@ -1157,7 +1165,7 @@ returning an appropriate value or panicking if necessary.
11571165
11581166E0270 : r##"
11591167Rust lets you define functions which are known to never return, i.e. are
1160- " diverging" , by marking its return type as `!`.
1168+ ' diverging' , by marking its return type as `!`.
11611169
11621170For example, the following functions never return:
11631171
@@ -1416,7 +1424,7 @@ add one of the same name as a type parameter. If you intended to use literal
14161424braces, use `{{` and `}}` to escape them.
14171425"## ,
14181426
1419- E0273 : r##"
1427+ E0274 : r##"
14201428The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
14211429message for when a particular trait isn't implemented on a type placed in a
14221430position that needs that trait. For example, when the following code is
0 commit comments