diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-08-15 18:13:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-15 18:13:28 -0400 |
| commit | 2b1a288dfc5a2cce12b8c1a2eef22f89d894c094 (patch) | |
| tree | 3209bcfa71772aeb8fc4294944742f4a91c3ed10 /compiler/rustc_llvm/llvm-wrapper/Linker.cpp | |
| parent | d077146a15fd1f31c30fbb37cec70e2325a05adf (diff) | |
| parent | 1f3a7471bfb05a5fd76309545de0412d265e28be (diff) | |
| download | rust-2b1a288dfc5a2cce12b8c1a2eef22f89d894c094.tar.gz rust-2b1a288dfc5a2cce12b8c1a2eef22f89d894c094.zip | |
Rollup merge of #144922 - Kobzol:derive-from, r=nnethercote
Implement `#[derive(From)]` Implements the `#[derive(From)]` feature ([tracking issue](https://github.com/rust-lang/rust/issues/144889), [RFC](https://github.com/rust-lang/rfcs/pull/3809)). It allows deriving the `From` impl on structs and tuple structs with exactly one field. Some implementation notes: - I wasn't exactly sure which spans to use in the derive generating code, so I just used `span` everywhere. I don't know if it's the Right Thing To Do. In particular the errors when `#[derive(From)]` is used on a struct with an unsized field are weirdly duplicated. - I had to solve an import stability problem, where if I just added the unstable `macro From` to `core::convert`, previously working code like `use std::convert::From` would suddenly require an unstable feature gate, because rustc would think that you're trying to import the unstable macro. `@petrochenkov` suggested that I add the macro the the core prelude instead. This has worked well, although it only works in edition 2021+. Not sure if I botched the prelude somehow and it should live elsewhere (?). - I had to add `Ty::AstTy`, because the `from` function receives an argument with the type of the single field, and the existing variants of the `Ty` enum couldn't represent an arbitrary type.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/Linker.cpp')
0 files changed, 0 insertions, 0 deletions
