diff --git a/.github/scripts/run_rustc_tests.sh b/.github/scripts/run_rustc_tests.sh index b565f50..a967dac 100755 --- a/.github/scripts/run_rustc_tests.sh +++ b/.github/scripts/run_rustc_tests.sh @@ -104,6 +104,8 @@ function run_tests() { --target=${HOST} \ --llvm-filecheck="${FILE_CHECK}" \ --channel=nightly \ + --git-repository="rust-lang/project-stable-mir" \ + --nightly-branch="main" \ --target-rustcflags="--smir-check" \ --host-rustcflags="--smir-check" done diff --git a/tests/fixme/associated-items/methods.stderr b/tests/fixme/associated-items/methods.stderr deleted file mode 100644 index d71979f..0000000 --- a/tests/fixme/associated-items/methods.stderr +++ /dev/null @@ -1,2 +0,0 @@ -Test sanity_checks::test_traits: Failed: - - Failed to find trait definition: `` diff --git a/tests/fixme/associated-items/methods.rs b/tests/sanity-checks/associated-items/methods.rs similarity index 100% rename from tests/fixme/associated-items/methods.rs rename to tests/sanity-checks/associated-items/methods.rs diff --git a/tools/test-drive/Cargo.toml b/tools/test-drive/Cargo.toml index 12b88aa..b5b27f0 100644 --- a/tools/test-drive/Cargo.toml +++ b/tools/test-drive/Cargo.toml @@ -4,9 +4,17 @@ description = "A rustc wrapper that can be used to test stable-mir on a crate" version = "0.0.0" edition = "2021" -[dependencies] - [package.metadata.rust-analyzer] # This crate uses #[feature(rustc_private)]. # See https://github.com/rust-analyzer/rust-analyzer/pull/7891 rustc_private = true + +[features] +clion = ["rustc_smir", "stable_mir"] + +[target.'cfg(unix)'.dependencies] +# Adjust the path here to point to a local copy of the rust compiler. +# The best way is to use the rustup path. Replace with the +# proper name to your toolchain. +rustc_smir = { path = "/home/ANT.AMAZON.COM/celinval/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/rustc-src/rust/compiler/rustc_smir", optional = true} +stable_mir = { path = "/home/ANT.AMAZON.COM/celinval/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/rustc-src/rust/compiler/stable_mir", optional = true} diff --git a/tools/test-drive/src/main.rs b/tools/test-drive/src/main.rs index 19084c3..cacae85 100644 --- a/tools/test-drive/src/main.rs +++ b/tools/test-drive/src/main.rs @@ -2,17 +2,15 @@ #![feature(rustc_private)] #![feature(assert_matches)] -#![feature(result_option_inspect)] mod sanity_checks; extern crate rustc_driver; extern crate rustc_interface; -extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; extern crate stable_mir; -use rustc_middle::ty::TyCtxt; use rustc_smir::{run, rustc_internal}; use stable_mir::CompilerError; use std::ops::ControlFlow; @@ -50,9 +48,9 @@ fn main() -> ExitCode { smir_args.contains(&FIXME_ARG.to_string()), Ordering::Relaxed, ); - run!(rustc_args, tcx, test_stable_mir(tcx)) + run!(rustc_args, test_stable_mir) } else { - run!(rustc_args, ControlFlow::<()>::Continue(())) + run!(rustc_args, || ControlFlow::<()>::Continue(())) }; if result.is_ok() || matches!(result, Err(CompilerError::Skipped)) { ExitCode::SUCCESS @@ -78,7 +76,7 @@ fn info(msg: String) { /// This function invoke other tests and process their results. /// Tests should avoid panic, -fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { +fn test_stable_mir() -> ControlFlow<()> { let mut results = Vec::from(run_tests![ sanity_checks::test_entry_fn, sanity_checks::test_all_fns, diff --git a/tools/test-drive/src/sanity_checks.rs b/tools/test-drive/src/sanity_checks.rs index 106fd7f..aae7fc9 100644 --- a/tools/test-drive/src/sanity_checks.rs +++ b/tools/test-drive/src/sanity_checks.rs @@ -4,6 +4,7 @@ //! These checks should only depend on StableMIR APIs. See other modules for tests that compare //! the result between StableMIR and internal APIs. use crate::TestResult; +use stable_mir::ty::{ImplDef, TraitDef}; use stable_mir::{self, mir, mir::MirVisitor, ty, CrateDef}; use std::collections::HashSet; use std::fmt::Debug; @@ -60,24 +61,12 @@ pub fn test_all_fns() -> TestResult { Ok(()) } -/// Using these structures will always follow calls to get more details about those structures. -/// Unless user is trying to find a specific type, this will get repetitive. +/// Test that we can retrieve information about the trait declaration for every trait implementation. pub fn test_traits() -> TestResult { - // FIXME: All trait declarations only return local traits. - // See https://github.com/rust-lang/project-stable-mir/issues/37 - let all_traits = stable_mir::all_trait_decls(); - for trait_decl in all_traits.iter().map(stable_mir::trait_decl) { - // Can't compare trait_decl, so just compare a field for now. - check_equal( - stable_mir::trait_decl(&trait_decl.def_id).specialization_kind, - trait_decl.specialization_kind, - "external crate mismatch", - )?; - } - + let all_traits = HashSet::::from_iter(stable_mir::all_trait_decls().into_iter()); for trait_impl in stable_mir::all_trait_impls() .iter() - .map(stable_mir::trait_impl) + .map(ImplDef::trait_impl) { check( all_traits.contains(&trait_impl.value.def_id),