Skip to content

Commit

Permalink
Fix compilation after changes to trait and run
Browse files Browse the repository at this point in the history
The following PRs needed to be addressed:
  - rust-lang/rust#119833
  - rust-lang/rust#119790

Note that the rustc tests are no longer passing, but the failures
are unrelated to these changes and need further investigation.
  • Loading branch information
celinval authored and oli-obk committed Jan 26, 2024
1 parent 8ec26c6 commit 801f474
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
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.

File renamed without changes.
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

0 comments on commit 801f474

Please sign in to comment.