diff --git a/Cargo.toml b/Cargo.toml index cd88aa4c..6a1fae5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ smallvec = "0.4.3" [build-dependencies] syn = "0.11" quote = "0.3" +rustc_version = "0.2" [features] bench = [] diff --git a/build.rs b/build.rs index 322c1790..5a38e896 100644 --- a/build.rs +++ b/build.rs @@ -4,6 +4,7 @@ extern crate quote; extern crate syn; +extern crate rustc_version; use std::env; use std::path::Path; @@ -33,6 +34,18 @@ mod codegen { } fn main() { + let rustc = rustc_version::version_meta().unwrap(); + let commit_date = match rustc.commit_date { + Some(ref s) => &**s, + None => "unknown", // Sorts after a date + }; + if (rustc.semver.major, rustc.semver.minor, rustc.semver.patch, commit_date) >= + (1, 23, 0, "2017-11-20") + { + // https://github.com/rust-lang/rust/pull/45225 + println!("cargo:rustc-cfg=rustc_has_pr45225") + } + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let tokenizer_rs = Path::new(&manifest_dir).join("src/tokenizer.rs"); codegen::main(&tokenizer_rs); diff --git a/macros/lib.rs b/macros/lib.rs index 80d3e545..d530dd47 100644 --- a/macros/lib.rs +++ b/macros/lib.rs @@ -8,7 +8,7 @@ extern crate proc_macro; #[macro_use] extern crate quote; extern crate syn; -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; define_proc_macros! { /// Input: the arms of a `match` expression. diff --git a/src/nth.rs b/src/nth.rs index ea0b9e54..b3a6a600 100644 --- a/src/nth.rs +++ b/src/nth.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; use super::{Token, Parser, ParserInput, BasicParseError}; diff --git a/src/parser.rs b/src/parser.rs index faaa773b..76736a85 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -5,7 +5,7 @@ use cow_rc_str::CowRcStr; use smallvec::SmallVec; use std::ops::Range; -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; use std::ops::BitOr; use tokenizer::{Token, Tokenizer, SourcePosition, SourceLocation}; diff --git a/src/rules_and_declarations.rs b/src/rules_and_declarations.rs index 32072094..f12330de 100644 --- a/src/rules_and_declarations.rs +++ b/src/rules_and_declarations.rs @@ -6,7 +6,7 @@ use cow_rc_str::CowRcStr; use parser::{parse_until_before, parse_until_after, parse_nested_block, ParserState}; -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; use super::{Token, Parser, Delimiter, ParseError, BasicParseError, BasicParseErrorKind}; /// Parse `!important`. diff --git a/src/serializer.rs b/src/serializer.rs index ecab8928..1a737946 100644 --- a/src/serializer.rs +++ b/src/serializer.rs @@ -4,7 +4,7 @@ use dtoa_short::{self, Notation}; use itoa; -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; use std::fmt::{self, Write}; use std::io; use std::str; diff --git a/src/size_of_tests.rs b/src/size_of_tests.rs index de81172d..b07abc07 100644 --- a/src/size_of_tests.rs +++ b/src/size_of_tests.rs @@ -37,10 +37,10 @@ size_of_test!(std_cow_str, Cow<'static, str>, 32); size_of_test!(cow_rc_str, CowRcStr, 16); size_of_test!(tokenizer, ::tokenizer::Tokenizer, 72); -size_of_test!(parser_input, ::parser::ParserInput, 144); +size_of_test!(parser_input, ::parser::ParserInput, if cfg!(rustc_has_pr45225) { 136 } else { 144 }); size_of_test!(parser, ::parser::Parser, 16); size_of_test!(source_position, ::SourcePosition, 8); size_of_test!(parser_state, ::ParserState, 24); size_of_test!(basic_parse_error, ::BasicParseError, 48); -size_of_test!(parse_error_lower_bound, ::ParseError<()>, 56); +size_of_test!(parse_error_lower_bound, ::ParseError<()>, if cfg!(rustc_has_pr45225) { 48 } else { 56 }); diff --git a/src/tokenizer.rs b/src/tokenizer.rs index e5fb9b0a..a74d7c2f 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -6,7 +6,7 @@ use std::ops::Range; use std::char; -use std::ascii::AsciiExt; +#[allow(unused_imports)] use std::ascii::AsciiExt; use std::i32; use parser::ParserState;