Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support stable rustc #107

Merged
merged 3 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tempfile = { version = "3.0", optional = true }
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
tester = { version = "0.4", optional = true }

[target."cfg(unix)".dependencies]
libc = "0.2"
Expand All @@ -34,3 +35,4 @@ winapi = { version = "0.3", features = ["winerror"] }
[features]
tmp = ["tempfile"]
norustc = []
stable = ["norustc", "tester"]
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ environment:
CHANNEL: nightly
- TARGET: x86_64-pc-windows-msvc
CHANNEL: nightly
- TARGET: x86_64-pc-windows-gnu
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable

install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs
Expand All @@ -15,8 +19,7 @@ install:
build: false

test_script:
- cargo build
- cargo build --features norustc
- if %CHANNEL%==stable (cargo build --features stable) else (cargo build)

branches:
only:
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#![crate_type = "lib"]

#![cfg_attr(not(feature = "norustc"), feature(rustc_private))]
#![feature(test)]
#![feature(slice_rotate)]
#![cfg_attr(not(feature = "stable"), feature(test))]
#![cfg_attr(not(feature = "stable"), feature(slice_rotate))]

#![deny(unused_imports)]

Expand Down Expand Up @@ -272,6 +272,8 @@ pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn
let config = config.clone();
let testpaths = testpaths.clone();
test::DynTestFn(Box::new(move || {
#[cfg(feature = "stable")]
let config = config.clone(); // FIXME: why is this needed?
runtest::run(config, &testpaths)
}))
}
Expand Down
16 changes: 16 additions & 0 deletions src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,11 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
*skipped += data.len();
if data.len() <= TAIL_LEN {
tail[..data.len()].copy_from_slice(data);
#[cfg(not(feature = "stable"))]
tail.rotate_left(data.len());
// FIXME: Remove this when rotate_left is stable in 1.26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is much more clear, thank you.

#[cfg(feature = "stable")]
rotate_left(tail, data.len());
} else {
tail.copy_from_slice(&data[(data.len() - TAIL_LEN)..]);
}
Expand Down Expand Up @@ -2649,3 +2653,15 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
stderr: stderr.into_bytes(),
})
}

// FIXME: Remove this when rotate_left is stable in 1.26
#[cfg(feature = "stable")]
fn rotate_left<T>(slice: &mut [T], places: usize) {
// Rotation can be implemented by reversing the slice,
// splitting the slice in two, and then reversing the
// two sub-slices.
slice.reverse();
let (a, b) = slice.split_at_mut(places);
a.reverse();
b.reverse();
}
3 changes: 3 additions & 0 deletions test-project/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ authors = ["Thomas Jespersen <laumann.thomas@gmail.com>"]
[dev-dependencies.compiletest_rs]
path = ".."
features = ["tmp"]

[features]
stable = ["compiletest_rs/stable"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is how to reference features from dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer!