From 651a245bd5f9d3792d255240eccb60f4892fdb40 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 25 Sep 2017 19:31:46 -0700 Subject: [PATCH] Update codegen for 2017-09-25 nightly. --- codegen/build.rs | 2 +- codegen/src/parser/uri_macro.rs | 2 +- codegen/src/utils/span_ext.rs | 34 ++++++++++++++------------------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/codegen/build.rs b/codegen/build.rs index a90e8eb9..de393f85 100644 --- a/codegen/build.rs +++ b/codegen/build.rs @@ -8,7 +8,7 @@ use yansi::Color::{Red, Yellow, Blue, White}; use version_check::{supports_features, is_min_version, is_min_date}; // Specifies the minimum nightly version needed to compile Rocket's codegen. -const MIN_DATE: &'static str = "2017-09-19"; +const MIN_DATE: &'static str = "2017-09-25"; const MIN_VERSION: &'static str = "1.22.0-nightly"; fn main() { diff --git a/codegen/src/parser/uri_macro.rs b/codegen/src/parser/uri_macro.rs index 72849073..b1620962 100644 --- a/codegen/src/parser/uri_macro.rs +++ b/codegen/src/parser/uri_macro.rs @@ -137,7 +137,7 @@ impl UriParams { })?; // Set the end of the args_span to be the end of the args. - args_span.hi = parser.prev_span.hi; + args_span = args_span.with_hi(parser.prev_span.hi()); // A 'colon' was used but there are no arguments. if arguments.is_empty() { diff --git a/codegen/src/utils/span_ext.rs b/codegen/src/utils/span_ext.rs index 1564df3c..0a052973 100644 --- a/codegen/src/utils/span_ext.rs +++ b/codegen/src/utils/span_ext.rs @@ -24,39 +24,33 @@ pub trait SpanExt { } impl SpanExt for Span { - fn trim_left(mut self, length: usize) -> Span { - self.lo = self.lo + BytePos(length as u32); - self + fn trim_left(self, length: usize) -> Span { + self.with_lo(self.lo() + BytePos(length as u32)) } - fn trim_right(mut self, length: usize) -> Span { - self.hi = self.hi - BytePos(length as u32); - self + fn trim_right(self, length: usize) -> Span { + self.with_hi(self.hi() - BytePos(length as u32)) } - fn shorten_to(mut self, to_length: usize) -> Span { - self.hi = self.lo + BytePos(to_length as u32); - self + fn shorten_to(self, to_length: usize) -> Span { + self.with_hi(self.lo() + BytePos(to_length as u32)) } - fn shorten_upto(mut self, length: usize) -> Span { - self.lo = self.hi - BytePos(length as u32); - self + fn shorten_upto(self, length: usize) -> Span { + self.with_lo(self.hi() - BytePos(length as u32)) } - fn trim(mut self, length: u32) -> Span { - self.lo = self.lo + BytePos(length); - self.hi = self.hi - BytePos(length); - self + fn trim(self, length: u32) -> Span { + self.with_lo(self.lo() + BytePos(length)) + .with_hi(self.hi() - BytePos(length)) } fn wrap(self, node: T) -> Spanned { Spanned { node: node, span: self } } - fn expand(mut self, left: usize, right: usize) -> Span { - self.lo = self.lo + BytePos(left as u32); - self.hi = self.lo + BytePos(right as u32); - self + fn expand(self, left: usize, right: usize) -> Span { + self.with_lo(self.lo() + BytePos(left as u32)) + .with_hi(self.lo() + BytePos(right as u32)) } }