1
Fork 0

Auto merge of #127042 - GrigorenkoPV:derivative, r=compiler-errors

Switch from `derivative` to `derive-where`

This is a part of the effort to get rid of `syn 1.*` in compiler's dependencies: #109302

Derivative has not been maintained in nearly 3 years[^1]. It also depends on `syn 1.*`.

This PR replaces `derivative` with `derive-where`[^2], a not dead alternative, which uses `syn 2.*`.

A couple of `Debug` formats have changed around the skipped fields[^3], but I doubt this is an issue.

[^1]: https://github.com/mcarton/rust-derivative/issues/117
[^2]: https://lib.rs/crates/derive-where
[^3]: See the changes in `tests/ui`
This commit is contained in:
bors 2024-07-25 22:50:58 +00:00
commit 2f26b2a99a
35 changed files with 192 additions and 462 deletions

View file

@ -38,6 +38,7 @@
// this crate without this line making `rustc_span` available.
extern crate self as rustc_span;
use derive_where::derive_where;
use rustc_data_structures::{outline, AtomicRef};
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::opaque::{FileEncoder, MemDecoder};
@ -467,18 +468,18 @@ impl FileName {
/// `SpanData` is public because `Span` uses a thread-local interner and can't be
/// sent to other threads, but some pieces of performance infra run in a separate thread.
/// Using `Span` is generally preferred.
#[derive(Clone, Copy, Hash, PartialEq, Eq, derivative::Derivative)]
#[derivative(PartialOrd, Ord)]
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
#[derive_where(PartialOrd, Ord)]
pub struct SpanData {
pub lo: BytePos,
pub hi: BytePos,
/// Information about where the macro came from, if this piece of
/// code was created by a macro expansion.
#[derivative(PartialOrd = "ignore", Ord = "ignore")]
#[derive_where(skip)]
// `SyntaxContext` does not implement `Ord`.
// The other fields are enough to determine in-file order.
pub ctxt: SyntaxContext,
#[derivative(PartialOrd = "ignore", Ord = "ignore")]
#[derive_where(skip)]
// `LocalDefId` does not implement `Ord`.
// The other fields are enough to determine in-file order.
pub parent: Option<LocalDefId>,