diff --git a/tamer/src/diagnose/report.rs b/tamer/src/diagnose/report.rs index 55580f0a..1f4f47c6 100644 --- a/tamer/src/diagnose/report.rs +++ b/tamer/src/diagnose/report.rs @@ -136,11 +136,11 @@ impl MaybeResolvedSpan { fn header(&self) -> SpanHeader { match self { Self::Resolved(rspan) => { - SpanHeader(rspan.ctx(), HeaderLineNum::Resolved(&rspan)) + SpanHeader(rspan.context(), HeaderLineNum::Resolved(&rspan)) } Self::Unresolved(span, _) => { - SpanHeader(span.ctx(), HeaderLineNum::Unresolved(*span)) + SpanHeader(span.context(), HeaderLineNum::Unresolved(*span)) } } } diff --git a/tamer/src/diagnose/resolver.rs b/tamer/src/diagnose/resolver.rs index 5e3b93e4..3fc38727 100644 --- a/tamer/src/diagnose/resolver.rs +++ b/tamer/src/diagnose/resolver.rs @@ -160,7 +160,7 @@ pub trait ResolvedSpanData { fn first_line_span(&self) -> Span; /// [`Context`] of the [`Span`] used for resolution. - fn ctx(&self) -> Context; + fn context(&self) -> Context; /// The original [`Span`] before resolution. fn unresolved_span(&self) -> Span; @@ -179,8 +179,8 @@ impl ResolvedSpanData for ResolvedSpan { self.lines.first().span } - fn ctx(&self) -> Context { - self.span.ctx() + fn context(&self) -> Context { + self.span.context() } fn unresolved_span(&self) -> Span { @@ -313,9 +313,9 @@ impl SpanResolver for BufSpanResolver { &mut self, span: Span, ) -> Result { - if self.ctx != span.ctx() { + if self.ctx != span.context() { return Err(SpanResolverError::ContextMismatch { - given: span.ctx(), + given: span.context(), expected: self.ctx, }); } @@ -521,7 +521,7 @@ impl Line { span: Span, ) -> (Vec, Span, Option) { let bytes = self.take_buf().unwrap_or(vec![]); - let span = span.ctx().span_or_zz(0, bytes.len()); + let span = span.context().span_or_zz(0, bytes.len()); (bytes, span, None) } @@ -549,7 +549,7 @@ impl Line { let offset_start = self.offset_start; let buf = self.take_buf().unwrap_or(vec![]); - let line_span = span.ctx().span_or_zz(offset_start, buf.len()); + let line_span = span.context().span_or_zz(offset_start, buf.len()); (buf, line_span, Some(column)) } @@ -671,10 +671,10 @@ impl SpanResolver for FsSpanResolver { &mut self, span: Span, ) -> Result { - let file = fs::File::open(span.ctx())?; + let file = fs::File::open(span.context())?; let mut resolver = - BufSpanResolver::new(BufReader::new(file), span.ctx()); + BufSpanResolver::new(BufReader::new(file), span.context()); // After this, // the file is dropped and the descriptor closed, @@ -699,7 +699,7 @@ where &mut self, span: Span, ) -> Result { - self.get_mut(&span.ctx()) + self.get_mut(&span.context()) .ok_or(SpanResolverError::Io(io::ErrorKind::NotFound)) .and_then(|resolver| resolver.resolve(span)) } diff --git a/tamer/src/span.rs b/tamer/src/span.rs index c0431d8b..25cb4a88 100644 --- a/tamer/src/span.rs +++ b/tamer/src/span.rs @@ -46,7 +46,7 @@ //! //! assert_eq!(2, span.offset()); //! assert_eq!(6, span.len()); -//! assert_eq!(ctx, span.ctx()); +//! assert_eq!(ctx, span.context()); //! //! // From a closed byte interval //! let spani = Span::from_byte_interval((10, 25), "some/path/bar".intern()); @@ -313,7 +313,7 @@ impl Span { /// The context to which the span applies. /// /// The context is, for example, a file. - pub fn ctx(&self) -> Context { + pub fn context(&self) -> Context { self.ctx } @@ -403,7 +403,7 @@ impl Span { /// no comparison can be made and [`None`] will be returned. pub fn relative_to(self, rel_span: Span) -> Option { // Note that this is unaligned. - if self.ctx() != rel_span.ctx() { + if self.context() != rel_span.context() { return None; } @@ -680,7 +680,10 @@ mod test { let span = ctx.span(offset, len); - assert_eq!((offset, len, ctx), (span.offset(), span.len(), span.ctx())); + assert_eq!( + (offset, len, ctx), + (span.offset(), span.len(), span.context()) + ); } #[test]