Skip to content

v0.8.2

@magiclen magiclen tagged this 08 Nov 03:09
Generated locals such as `other`, `source` and `state` resolved to any
constant, unit struct or static of the same name at the derive site, which
turned a parameter or a pattern into a constant pattern. They are named
`educe__*` now and avoid every identifier of the input. Each impl sits in an
anonymous constant that imports `core::mem::drop` under those names, so a
binding shadows a function instead of a constant the input cannot show, such
as one from a glob import. One more constant uses every alias, because
`allow(unused_imports)` is rejected under a `forbid` in the user's crate.
When the input calls a macro, the names get an input-specific prefix, so the
aliases cannot hide a name the macro output refers to; a `!` in a doc comment
does not count as a call.

The aliases cost expansion time: 600 enums deriving seven traits take about
30% longer to check than with 0.8.1.

`Box<[T]>` forwarded `Clone` to `[T]`, which is never `Clone`, so the derived
impl never applied; it requires `T: Clone` now. For `Default`, `Box`, `Rc`
and `Arc` of a slice need no bound at all. A trait object or a `?Sized`
pointee parameter gets the whole-type predicate, unless a custom clone method
or default expression may rely on the forwarded bound. `Weak` stays
unconditional for `Default` unless its pointee uses a `?Sized` parameter, in
which case it gets `Weak<T>: Default`.

A union `Clone` also takes the predicates of `Copy(bound(*))` or
`Copy(bound(...))`, because its body copies the whole value. `Self` in an
`Into` target type is the source type in a generated `From` impl. A suffixed
literal of another type, such as `Default = 11u8` on a `u16` field, goes
through `Into::into` instead of being pasted in.

Enum `Deref` and `DerefMut` name `<Self as Deref>::Target`, so a variant
called `Target` is not ambiguous, `Debug` calls `::core::stringify!`, and the
helpers write `?::core::marker::Sized`, so a local macro or a shadowed
prelude cannot break them. Discriminant offsets no longer use a local that a
constant could capture.

The union examples in the documentation construct values now, with
`#[repr(C)]` and `[u8; 4]` fields, so their doctests run without reading
uninitialized bytes.
Assets 2
Loading