Skip to content

Commit

Permalink
rustc_span: Reorder some ExpnData fields in accordance with comments
Browse files Browse the repository at this point in the history
A drive-by change.
  • Loading branch information
petrochenkov committed Jul 10, 2021
1 parent ece6f68 commit 4ba91a0
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,31 +709,6 @@ pub struct ExpnData {
/// call_site span would have its own ExpnData, with the call_site
/// pointing to the `foo!` invocation.
pub call_site: Span,

// --- The part specific to the macro/desugaring definition.
// --- It may be reasonable to share this part between expansions with the same definition,
// --- but such sharing is known to bring some minor inconveniences without also bringing
// --- noticeable perf improvements (PR #62898).
/// The span of the macro definition (possibly dummy).
/// This span serves only informational purpose and is not used for resolution.
pub def_site: Span,
/// List of `#[unstable]`/feature-gated features that the macro is allowed to use
/// internally without forcing the whole crate to opt-in
/// to them.
pub allow_internal_unstable: Option<Lrc<[Symbol]>>,
/// Whether the macro is allowed to use `unsafe` internally
/// even if the user crate has `#![forbid(unsafe_code)]`.
pub allow_internal_unsafe: bool,
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`)
/// for a given macro.
pub local_inner_macros: bool,
/// Edition of the crate in which the macro is defined.
pub edition: Edition,
/// The `DefId` of the macro being invoked,
/// if this `ExpnData` corresponds to a macro invocation
pub macro_def_id: Option<DefId>,
/// The normal module (`mod`) in which the expanded macro was defined.
pub parent_module: Option<DefId>,
/// The crate that originally created this `ExpnData`. During
/// metadata serialization, we only encode `ExpnData`s that were
/// created locally - when our serialized metadata is decoded,
Expand All @@ -748,7 +723,6 @@ pub struct ExpnData {
// be considered equivalent.
#[stable_hasher(ignore)]
orig_id: Option<u32>,

/// Used to force two `ExpnData`s to have different `Fingerprint`s.
/// Due to macro expansion, it's possible to end up with two `ExpnId`s
/// that have identical `ExpnData`s. This violates the contract of `HashStable`
Expand All @@ -760,6 +734,31 @@ pub struct ExpnData {
/// `ExpnId`s would end up with the same `Fingerprint`. Since `ExpnData` includes
/// a `krate` field, this value only needs to be unique within a single crate.
disambiguator: u32,

// --- The part specific to the macro/desugaring definition.
// --- It may be reasonable to share this part between expansions with the same definition,
// --- but such sharing is known to bring some minor inconveniences without also bringing
// --- noticeable perf improvements (PR #62898).
/// The span of the macro definition (possibly dummy).
/// This span serves only informational purpose and is not used for resolution.
pub def_site: Span,
/// List of `#[unstable]`/feature-gated features that the macro is allowed to use
/// internally without forcing the whole crate to opt-in
/// to them.
pub allow_internal_unstable: Option<Lrc<[Symbol]>>,
/// Whether the macro is allowed to use `unsafe` internally
/// even if the user crate has `#![forbid(unsafe_code)]`.
pub allow_internal_unsafe: bool,
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`)
/// for a given macro.
pub local_inner_macros: bool,
/// Edition of the crate in which the macro is defined.
pub edition: Edition,
/// The `DefId` of the macro being invoked,
/// if this `ExpnData` corresponds to a macro invocation
pub macro_def_id: Option<DefId>,
/// The normal module (`mod`) in which the expanded macro was defined.
pub parent_module: Option<DefId>,
}

// These would require special handling of `orig_id`.
Expand Down

0 comments on commit 4ba91a0

Please sign in to comment.