pub struct BodySource(/* private fields */);Expand description
Where a merged declaration body’s spans index into (#868).
A declaration written in the file being compiled spans into that file’s
own NamedSource, which every lowering/type stage already threads as its
ambient src — those entries carry BodySource::own. An instantiated
include merges a dependency’s declaration bodies into the importer’s IR
(merge_dependency); those bodies keep the dependency’s byte offsets, so
they carry BodySource::dependency naming the dependency file. Rendering
a diagnostic for such a body against the importer’s source produces an
out-of-bounds (or simply wrong) label; BodySource::resolve hands back
the correct source to anchor against.
Implementations§
Source§impl BodySource
impl BodySource
Sourcepub const fn own() -> Self
pub const fn own() -> Self
The declaration belongs to the file being compiled; its span indexes
into the ambient src threaded through the pipeline.
Sourcepub const fn dependency(src: NamedSource<Arc<String>>) -> Self
pub const fn dependency(src: NamedSource<Arc<String>>) -> Self
The declaration was merged from a dependency body whose spans index
into src.
Sourcepub fn resolve<'a>(
&'a self,
default: &'a NamedSource<Arc<String>>,
) -> &'a NamedSource<Arc<String>>
pub fn resolve<'a>( &'a self, default: &'a NamedSource<Arc<String>>, ) -> &'a NamedSource<Arc<String>>
Resolve the source the span should render against, falling back to the
ambient default source for declarations native to the compiled file.
Sourcepub fn or_dependency(self, dep_src: &NamedSource<Arc<String>>) -> Self
pub fn or_dependency(self, dep_src: &NamedSource<Arc<String>>) -> Self
Carry an already-merged provenance forward, or attribute a still-native
body to dep_src as it crosses one merge boundary (#868).
A dependency’s own declarations carry BodySource::own until they are
merged, at which point their spans become foreign to the importer and
must name dep_src. A body already tagged with a deeper dependency
source (a transitively-merged include) keeps that attribution.
Trait Implementations§
Source§impl Clone for BodySource
impl Clone for BodySource
Source§fn clone(&self) -> BodySource
fn clone(&self) -> BodySource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more