From 9e9dc8d9c0f296949b920c84a157158aa46c56ce Mon Sep 17 00:00:00 2001 From: Ben Reeves Date: Sun, 11 Sep 2022 22:35:56 -0500 Subject: [PATCH 1/4] Allow user to specify which ICEs to test on the command line. Some of the ICEs take an extraordinary amount of time to run on my machine. So I just added the ability to optionally filter down to one or more specific ICEs. --- README.md | 5 +++-- labeler/src/main.rs | 2 +- src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++------ src/main.rs | 3 ++- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7e0a9140..50336f58 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,10 @@ Contributing to Glacier is fairly easy: 1. Check out [this list][ices] of bugs on the Rust issue tracker. 2. Pick one. -3. Create a file in `ices/` with the same digit as the bug. +3. Create a file in `ices/` with the same number as the issue reporting the ICE. 4. Copy the code that causes the ICE into your new file. -5. (optional) Verify it works by running `rustup update nightly`, then `cargo run` to run the tests. +5. (optional) Verify it works by running `rustup update nightly`, then + `cargo run NUMBER` to run your ICE. 6. Send a pull request! Note: Running this on Windows may give false positives and report some ICEs as fixed, diff --git a/labeler/src/main.rs b/labeler/src/main.rs index 302702ec..581bd5a6 100644 --- a/labeler/src/main.rs +++ b/labeler/src/main.rs @@ -10,7 +10,7 @@ fn main() { let mut tested_issue_list = glacier::discover("./ices") .unwrap() .into_iter() - .map(|ice| ice.id()) + .map(|ice| ice.id().0) .collect::>(); tested_issue_list.sort_unstable(); tested_issue_list.dedup(); diff --git a/src/lib.rs b/src/lib.rs index f6cb24a6..31ac1016 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ impl ICE { Ok(Self { path, mode }) } - pub fn id(&self) -> usize { + pub fn id(&self) -> IssueId { let s = self .path .file_stem() @@ -43,7 +43,7 @@ impl ICE { .unwrap(); // Some files have names like 123-1.rs; only get the first part of it let s = s.split('-').next().unwrap(); - s.parse().unwrap() + IssueId(s.parse().unwrap()) } fn test(self) -> Result { @@ -80,6 +80,29 @@ impl ICE { } } +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct IssueId(pub usize); + +/// Filters which ICEs should be tested. +#[derive(Default)] +pub struct Filter { + ids: Vec, +} + +impl Filter { + pub fn try_from_args(args: std::env::Args) -> Result { + let ids = args + .skip(1) + .map(|arg| Ok(IssueId(arg.parse()?))) + .collect::>()?; + Ok(Self { ids }) + } + + pub fn matches(&self, ice: &ICE) -> bool { + self.ids.is_empty() || self.ids.contains(&ice.id()) + } +} + #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Outcome { NoError, @@ -200,7 +223,9 @@ pub fn discover(dir: &str) -> Result> { Ok(ices) } -pub fn test_all() -> Result>> { +pub fn test_all_matching_filter( + filter: &Filter, +) -> Result>> { env::set_var("RUSTUP_TOOLCHAIN", "nightly"); let output = Command::new("rustc").arg("--version").output()?; @@ -209,13 +234,21 @@ pub fn test_all() -> Result = all_ices + .into_iter() + .filter(|ice| filter.matches(ice)) + .collect(); eprintln!( "running {} tests for {}", - ices.len(), + ices_to_test.len(), String::from_utf8_lossy(&output.stdout) ); - Ok(ices.into_par_iter().map(|ice| ice.test())) + Ok(ices_to_test.into_par_iter().map(|ice| ice.test())) +} + +pub fn test_all() -> Result>> { + test_all_matching_filter(&Filter::default()) } diff --git a/src/main.rs b/src/main.rs index 725a7817..2e8e4099 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,8 @@ use glacier::{Outcome, TestResult}; use rayon::prelude::*; fn main() -> Result<()> { - let failed = glacier::test_all()? + let filter = glacier::Filter::try_from_args(std::env::args())?; + let failed = glacier::test_all_matching_filter(&filter)? .filter(|res| { if let Ok(test) = res { eprint!("{}", test.outcome_token()); From 09ccc5c1f00a1eed1aef0953be4aa4efe4386d7f Mon Sep 17 00:00:00 2001 From: Ben Reeves Date: Sun, 11 Sep 2022 22:41:03 -0500 Subject: [PATCH 2/4] Add two ICEs for issue 101696 Tracks https://github.com/rust-lang/rust/issues/101696 --- ices/101696-1.rs | 34 ++++++++++++++++++++++++++++++++++ ices/101696-2.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 ices/101696-1.rs create mode 100644 ices/101696-2.rs diff --git a/ices/101696-1.rs b/ices/101696-1.rs new file mode 100644 index 00000000..b4995f8b --- /dev/null +++ b/ices/101696-1.rs @@ -0,0 +1,34 @@ +use std::marker::PhantomData; + +#[derive(Default)] +struct MyType<'a> { + field: usize, + _phantom: PhantomData<&'a ()>, +} + +#[derive(Default)] +struct MyTypeVariant<'a> { + field: usize, + _phantom: PhantomData<&'a ()>, +} + +trait AsVariantTrait { + type Type; +} + +impl<'a> AsVariantTrait for MyType<'a> { + type Type = MyTypeVariant<'a>; +} + +type Variant = ::Type; + +fn foo(f: F) { + let input = T::default(); + f(input); +} + +fn main() { + foo(|a: Variant| { + a.field; + }); +} diff --git a/ices/101696-2.rs b/ices/101696-2.rs new file mode 100644 index 00000000..59a6711a --- /dev/null +++ b/ices/101696-2.rs @@ -0,0 +1,32 @@ +use std::marker::PhantomData; + +#[derive(Default)] +struct MyType<'a> { + field: usize, + _phantom: PhantomData<&'a ()>, +} + +#[derive(Default)] +struct MyTypeVariant<'a> { + field: usize, + _phantom: PhantomData<&'a ()>, +} + +trait AsVariantTrait { + type Type; +} + +impl<'a> AsVariantTrait for MyType<'a> { + type Type = MyTypeVariant<'a>; +} + +fn foo(f: F) { + let input = T::default(); + f(input); +} + +fn main() { + foo(|a: ::Type| { + a.field; + }); +} From d951f8aace06ed484675e20999e5f1b7e4cb676b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 24 Jun 2023 14:49:20 +0900 Subject: [PATCH 3/4] Revert "Add two ICEs for issue 101696" This reverts commit 09ccc5c1f00a1eed1aef0953be4aa4efe4386d7f. --- ices/101696-1.rs | 34 ---------------------------------- ices/101696-2.rs | 32 -------------------------------- 2 files changed, 66 deletions(-) delete mode 100644 ices/101696-1.rs delete mode 100644 ices/101696-2.rs diff --git a/ices/101696-1.rs b/ices/101696-1.rs deleted file mode 100644 index b4995f8b..00000000 --- a/ices/101696-1.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::marker::PhantomData; - -#[derive(Default)] -struct MyType<'a> { - field: usize, - _phantom: PhantomData<&'a ()>, -} - -#[derive(Default)] -struct MyTypeVariant<'a> { - field: usize, - _phantom: PhantomData<&'a ()>, -} - -trait AsVariantTrait { - type Type; -} - -impl<'a> AsVariantTrait for MyType<'a> { - type Type = MyTypeVariant<'a>; -} - -type Variant = ::Type; - -fn foo(f: F) { - let input = T::default(); - f(input); -} - -fn main() { - foo(|a: Variant| { - a.field; - }); -} diff --git a/ices/101696-2.rs b/ices/101696-2.rs deleted file mode 100644 index 59a6711a..00000000 --- a/ices/101696-2.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::marker::PhantomData; - -#[derive(Default)] -struct MyType<'a> { - field: usize, - _phantom: PhantomData<&'a ()>, -} - -#[derive(Default)] -struct MyTypeVariant<'a> { - field: usize, - _phantom: PhantomData<&'a ()>, -} - -trait AsVariantTrait { - type Type; -} - -impl<'a> AsVariantTrait for MyType<'a> { - type Type = MyTypeVariant<'a>; -} - -fn foo(f: F) { - let input = T::default(); - f(input); -} - -fn main() { - foo(|a: ::Type| { - a.field; - }); -} From 37f9de251184ad54c57a1a675091d041556687c6 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 24 Jun 2023 14:50:03 +0900 Subject: [PATCH 4/4] Tweak wording Signed-off-by: Yuki Okushi --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50336f58..d53a5d03 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Contributing to Glacier is fairly easy: 3. Create a file in `ices/` with the same number as the issue reporting the ICE. 4. Copy the code that causes the ICE into your new file. 5. (optional) Verify it works by running `rustup update nightly`, then - `cargo run NUMBER` to run your ICE. + `cargo run $ISSUE_NUMBER` to run your ICE. 6. Send a pull request! Note: Running this on Windows may give false positives and report some ICEs as fixed,