Dejargnonize subst
This commit is contained in:
parent
084ce5bdb5
commit
3856df059e
128 changed files with 574 additions and 541 deletions
|
@ -22,9 +22,9 @@ fn foo<T>(x: Vec<T>) {
|
|||
In this specific case there's a good chance that the transmute is harmless (but
|
||||
this is not guaranteed by Rust). However, when alignment and enum optimizations
|
||||
come into the picture, it's quite likely that the sizes may or may not match
|
||||
with different type parameter substitutions. It's not possible to check this for
|
||||
_all_ possible types, so `transmute()` simply only accepts types without any
|
||||
unsubstituted type parameters.
|
||||
with different type parameter instantiations. It's not possible to check this
|
||||
for _all_ possible types, so `transmute()` simply only accepts types without any
|
||||
uninstantiated type parameters.
|
||||
|
||||
If you need this, there's a good chance you're doing something wrong. Keep in
|
||||
mind that Rust doesn't guarantee much about the layout of different structs
|
||||
|
@ -32,7 +32,7 @@ mind that Rust doesn't guarantee much about the layout of different structs
|
|||
there is a solution that avoids the transmute entirely, try it instead.
|
||||
|
||||
If it's possible, hand-monomorphize the code by writing the function for each
|
||||
possible type substitution. It's possible to use traits to do this cleanly,
|
||||
possible type instantiation. It's possible to use traits to do this cleanly,
|
||||
for example:
|
||||
|
||||
```
|
||||
|
|
|
@ -15,9 +15,9 @@ There will be an error about `bool` not implementing `Index<u8>`, followed by a
|
|||
note saying "the type `bool` cannot be indexed by `u8`".
|
||||
|
||||
As you can see, you can specify type parameters in curly braces for
|
||||
substitution with the actual types (using the regular format string syntax) in
|
||||
a given situation. Furthermore, `{Self}` will substitute to the type (in this
|
||||
case, `bool`) that we tried to use.
|
||||
instantiation with the actual types (using the regular format string syntax) in
|
||||
a given situation. Furthermore, `{Self}` will be instantiated to the type (in
|
||||
this case, `bool`) that we tried to use.
|
||||
|
||||
This error appears when the curly braces contain an identifier which doesn't
|
||||
match with any of the type parameters or the string `Self`. This might happen
|
||||
|
|
|
@ -15,9 +15,9 @@ there will be an error about `bool` not implementing `Index<u8>`, followed by a
|
|||
note saying "the type `bool` cannot be indexed by `u8`".
|
||||
|
||||
As you can see, you can specify type parameters in curly braces for
|
||||
substitution with the actual types (using the regular format string syntax) in
|
||||
a given situation. Furthermore, `{Self}` will substitute to the type (in this
|
||||
case, `bool`) that we tried to use.
|
||||
instantiation with the actual types (using the regular format string syntax) in
|
||||
a given situation. Furthermore, `{Self}` will be instantiated to the type (in
|
||||
this case, `bool`) that we tried to use.
|
||||
|
||||
This error appears when the curly braces do not contain an identifier. Please
|
||||
add one of the same name as a type parameter. If you intended to use literal
|
||||
|
|
|
@ -12,12 +12,12 @@ fn together_we_will_rule_the_galaxy(son: &A) {}
|
|||
```
|
||||
|
||||
A trait object is defined over a single, fully-defined trait. With a regular
|
||||
default parameter, this parameter can just be substituted in. However, if the
|
||||
default parameter, this parameter can just be instantiated in. However, if the
|
||||
default parameter is `Self`, the trait changes for each concrete type; i.e.
|
||||
`i32` will be expected to implement `A<i32>`, `bool` will be expected to
|
||||
implement `A<bool>`, etc... These types will not share an implementation of a
|
||||
fully-defined trait; instead they share implementations of a trait with
|
||||
different parameters substituted in for each implementation. This is
|
||||
different parameters instantiated in for each implementation. This is
|
||||
irreconcilable with what we need to make a trait object work, and is thus
|
||||
disallowed. Making the trait concrete by explicitly specifying the value of the
|
||||
defaulted parameter will fix this issue. Fixed example:
|
||||
|
|
|
@ -14,7 +14,7 @@ let _ = foo::<'static>;
|
|||
|
||||
The type of a concrete instance of a generic function is universally quantified
|
||||
over late-bound lifetime parameters. This is because we want the function to
|
||||
work for any lifetime substituted for the late-bound lifetime parameter, no
|
||||
work for any lifetime instantiated for the late-bound lifetime parameter, no
|
||||
matter where the function is called. Consequently, it doesn't make sense to
|
||||
specify arguments for late-bound lifetime parameters, since they are not
|
||||
resolved until the function's call site(s).
|
||||
|
@ -56,7 +56,7 @@ let bar_fn3 = bar::<Bar>; // OK
|
|||
|
||||
In the definition of `bar`, the lifetime parameter `'a` is late-bound, while
|
||||
`'b` is early-bound. This is reflected in the type annotation for `bar_fn`,
|
||||
where `'a` is universally quantified and `'b` is substituted by a specific
|
||||
where `'a` is universally quantified and `'b` is instantiated with a specific
|
||||
lifetime. It is not allowed to explicitly specify early-bound lifetime
|
||||
arguments when late-bound lifetime parameters are present (as for `bar_fn2`,
|
||||
see [issue #42868](https://github.com/rust-lang/rust/issues/42868)), although
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue