Merge pull request #23 from jethrogb/fix-old-versions

Parse mapping.rs manually, fix CI versions.
This commit is contained in:
jethrogb 2019-04-30 18:39:00 -07:00 committed by GitHub
commit 83eeab3405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 45 deletions

View File

@ -9,7 +9,7 @@ branches:
language: rust
dist: xenial
rust:
- nightly-2015-05-01 # see ct.sh for more versions
- nightly-2016-03-11 # see ct.sh for more versions
env:
- RUST_BACKTRACE=1
before_script:

View File

@ -4,35 +4,45 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::ops::{Neg,Sub};
/*
* Let me explain this hack. For the sync shell script it's easiest if every
* line in mapping.rs looks exactly the same. This means that specifying an
* array literal is not possible. include!() can only expand to expressions, so
* just specifying the contents of an array is also not possible.
*
* This leaves us with trying to find an expression in which every line looks
* the same. This can be done using the `-` operator. This can be a unary
* operator (first thing on the first line), or a binary operator (later
* lines). That is exactly what's going on here, and Neg and Sub simply build a
* vector of the operangs.
*/
struct Mapping(&'static str,&'static str);
impl Neg for Mapping {
type Output = Vec<Mapping>;
fn neg(self) -> Vec<Mapping> {
vec![self.into()]
}
}
fn parse_mappings(mut mappings: &'static str) -> Vec<Mapping> {
// FIXME: The format used here used to be parsed directly by rustc, which
// is why it's kind of weird. It should be changed to a saner format.
impl Sub<Mapping> for Vec<Mapping> {
type Output=Vec<Mapping>;
fn sub(mut self, rhs: Mapping) -> Vec<Mapping> {
self.push(rhs.into());
self
const P1: &'static str = r#"-Mapping(""#;
const P2: &'static str = r#"",""#; ;
const P3: &'static str = "\")\n";
trait TakePrefix: Sized {
fn take_prefix(&mut self, mid: usize) -> Self;
}
impl<'a> TakePrefix for &'a str {
fn take_prefix(&mut self, mid: usize) -> Self {
let prefix = &self[..mid];
*self = &self[mid..];
prefix
}
}
let mut result = Vec::with_capacity( mappings.len() / (P1.len()+40+P2.len()+40+P3.len()) );
while mappings.len() != 0 {
match (
mappings.take_prefix(P1.len()),
mappings.take_prefix(40),
mappings.take_prefix(P2.len()),
mappings.take_prefix(40),
mappings.take_prefix(P3.len()),
) {
(P1, hash1, P2, hash2, P3) => result.push(Mapping(hash1, hash2)),
_ => panic!("Invalid input in mappings"),
}
}
result
}
fn main() {
@ -42,8 +52,8 @@ fn main() {
Ok(c) => c,
Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"),
Err(env::VarError::NotPresent) => {
let mappings=include!("mapping.rs");
let mappings=parse_mappings(include_str!("mapping.rs"));
let compiler=ver.commit_hash.expect("Couldn't determine compiler version");
mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned()
}

33
ct.sh
View File

@ -1,21 +1,24 @@
#!/bin/bash -e
# Old versions should come first so we go from oldest Cargo.lock version to
# newest when building.
RUST_VERSIONS=$(awk '{print $1}' <<EOF
nightly-2019-04-27 # core_io release
nightly-2018-08-14 # edge case: old features disallowed
nightly-2018-08-06 # edge case: old features allowed
nightly-2018-03-07 # core_io release
nightly-2018-01-02 # edge case: memchr in core
nightly-2018-01-01 # edge case: no memchr in core
nightly-2017-06-16 # edge case: no collections crate
nightly-2017-06-15 # edge case: collections crate
nightly-2017-04-09 # core_io release
nightly-2017-03-04 # edge case: std_unicode crate
nightly-2017-03-03 # edge case: rustc_unicode crate
nightly-2017-01-18 # edge case: rustc_unicode crate
nightly-2016-12-05 # edge case: no unicode crate
nightly-2016-10-28 # core_io release
nightly-2016-03-11 # first supported version
nightly-2016-07-07 # core_io release
nightly-2015-05-01 # some old version
nightly-2016-10-28 # core_io release
nightly-2016-12-05 # edge case: no unicode crate
nightly-2017-01-18 # edge case: rustc_unicode crate
nightly-2017-03-03 # edge case: rustc_unicode crate
nightly-2017-03-04 # edge case: std_unicode crate
nightly-2017-04-09 # core_io release
nightly-2017-06-15 # edge case: collections crate
nightly-2017-06-16 # edge case: no collections crate
nightly-2018-01-01 # edge case: no memchr in core
nightly-2018-01-02 # edge case: memchr in core
nightly-2018-03-07 # core_io release
nightly-2018-08-06 # edge case: old features allowed
nightly-2018-08-14 # edge case: old features disallowed
nightly-2019-04-27 # core_io release
EOF
)

View File

@ -3,9 +3,9 @@
//! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html)
//! for a full description of the functionality.
#![allow(stable_features,unused_features)]
#![feature(question_mark,const_fn,copy_from_slice,non_exhaustive,
bind_by_move_pattern_guards,try_from,str_internals,align_offset,doc_spotlight,
slice_internals)]
#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,
str_char,try_from,str_internals,align_offset,doc_spotlight,
slice_internals,non_exhaustive,bind_by_move_pattern_guards)]
#![no_std]
#[cfg_attr(feature="collections",macro_use)]