Update codegen for 2017-09-25 nightly.

This commit is contained in:
Sergio Benitez 2017-09-25 19:31:46 -07:00
parent 805b24e60a
commit 9f4daf4474
4 changed files with 17 additions and 26 deletions

View File

@ -8,8 +8,8 @@ use yansi::Color::{Red, Yellow, Blue, White};
use version_check::{supports_features, is_min_version, is_min_date}; use version_check::{supports_features, is_min_version, is_min_date};
// Specifies the minimum nightly version needed to compile Rocket's codegen. // Specifies the minimum nightly version needed to compile Rocket's codegen.
const MIN_DATE: &'static str = "2017-08-10"; const MIN_DATE: &'static str = "2017-09-25";
const MIN_VERSION: &'static str = "1.21.0-nightly"; const MIN_VERSION: &'static str = "1.22.0-nightly";
fn main() { fn main() {
let ok_channel = supports_features(); let ok_channel = supports_features();

View File

@ -144,10 +144,8 @@
#![allow(deprecated)] #![allow(deprecated)]
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate rustc;
extern crate syntax; extern crate syntax;
extern crate syntax_ext; extern crate syntax_ext;
extern crate syntax_pos;
extern crate rustc_plugin; extern crate rustc_plugin;
extern crate rocket; extern crate rocket;

View File

@ -1,8 +1,8 @@
use syntax::ast::Ident; use syntax::ast::Ident;
use syntax::ext::base::ExtCtxt; use syntax::ext::base::ExtCtxt;
use syntax::codemap::{Span, Spanned, BytePos}; use syntax::codemap::{Span, Spanned};
use utils::span; use utils::{span, SpanExt};
#[derive(Debug)] #[derive(Debug)]
pub enum Param { pub enum Param {
@ -67,13 +67,11 @@ impl<'s, 'a, 'c> Iterator for ParamIter<'s, 'a, 'c> {
(false, full_param) (false, full_param)
}; };
let mut param_span = self.span; let param_span = self.span.trim_left(start).shorten_to(end + 1);
param_span.lo = self.span.lo + BytePos(start as u32);
param_span.hi = self.span.lo + BytePos((end + 1) as u32);
// Advance the string and span. // Advance the string and span.
self.string = &self.string[(end + 1)..]; self.string = &self.string[(end + 1)..];
self.span.lo = self.span.lo + BytePos((end + 1) as u32); self.span = self.span.trim_left(end + 1);
let spanned_ident = span(Ident::from_str(param), param_span); let spanned_ident = span(Ident::from_str(param), param_span);
if is_many { if is_many {

View File

@ -18,29 +18,24 @@ pub trait SpanExt {
} }
impl SpanExt for Span { impl SpanExt for Span {
fn trim_left(mut self, length: usize) -> Span { fn trim_left(self, length: usize) -> Span {
self.lo = self.lo + BytePos(length as u32); self.with_lo(self.lo() + BytePos(length as u32))
self
} }
fn trim_right(mut self, length: usize) -> Span { fn trim_right(self, length: usize) -> Span {
self.hi = self.hi - BytePos(length as u32); self.with_hi(self.hi() - BytePos(length as u32))
self
} }
fn shorten_to(mut self, to_length: usize) -> Span { fn shorten_to(self, to_length: usize) -> Span {
self.hi = self.lo + BytePos(to_length as u32); self.with_hi(self.lo() + BytePos(to_length as u32))
self
} }
fn shorten_upto(mut self, length: usize) -> Span { fn shorten_upto(self, length: usize) -> Span {
self.lo = self.hi - BytePos(length as u32); self.with_lo(self.hi() - BytePos(length as u32))
self
} }
fn trim(mut self, length: u32) -> Span { fn trim(self, length: u32) -> Span {
self.lo = self.lo + BytePos(length); self.with_lo(self.lo() + BytePos(length))
self.hi = self.hi - BytePos(length); .with_hi(self.hi() - BytePos(length))
self
} }
} }