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

Fix compilation after changes to trait and run #60

Merged
merged 1 commit into from
Jan 26, 2024
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 .github/scripts/run_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/fixme/associated-items/methods.stderr

This file was deleted.

10 changes: 4 additions & 6 deletions tools/test-drive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
19 changes: 4 additions & 15 deletions tools/test-drive/src/sanity_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<TraitDef>::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),
Expand Down
Loading