tamer: span (DUMMY_SPAN): New constant

Rather than having to use lazy_static! in all these tests, we can derive an
unlimited number of dummy spans from this one using e.g. `offset_add`.
main
Mike Gerwitz 2021-10-11 10:29:07 -04:00
parent cf239531e0
commit cde08b125c
2 changed files with 11 additions and 0 deletions

View File

@ -372,6 +372,16 @@ impl From<Span> for (Span, Span) {
}
}
/// A dummy span that can be used in contexts where a span is expected but
/// is not important.
///
/// This is intended primarily for tests;
/// you should always use an appropriate span to permit sensible error
/// messages and source analysis.
///
/// Additional dummy spans can be derived from this one.
pub const DUMMY_SPAN: Span = Span::st_ctx(crate::sym::st16::CTX_DUMMY);
/// Context for byte offsets (e.g. a source file).
///
/// A context is lifetime-free and [`Copy`]-able,

View File

@ -461,6 +461,7 @@ pub mod st16 {
<u16>;
// Special contexts.
CTX_DUMMY: ctx "#!DUMMY",
CTX_LINKER: ctx "#!LINKER",
// [Symbols will be added here as they are needed.]