Fix recursive_adt fixture

This commit is contained in:
Lukas Wirth 2024-09-03 12:50:24 +02:00
parent 6a2b8270c9
commit 1cdc34fa4a
2 changed files with 8 additions and 6 deletions

View file

@ -95,7 +95,8 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) {
fn pretty_print_err(e: ConstEvalError, db: TestDB) -> String { fn pretty_print_err(e: ConstEvalError, db: TestDB) -> String {
let mut err = String::new(); let mut err = String::new();
let span_formatter = |file, range| format!("{file:?} {range:?}"); let span_formatter = |file, range| format!("{file:?} {range:?}");
let edition = db.crate_graph()[db.test_crate()].edition; let edition =
db.crate_graph()[*db.crate_graph().crates_in_topological_order().last().unwrap()].edition;
match e { match e {
ConstEvalError::MirLowerError(e) => e.pretty_print(&mut err, &db, span_formatter, edition), ConstEvalError::MirLowerError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
ConstEvalError::MirEvalError(e) => e.pretty_print(&mut err, &db, span_formatter, edition), ConstEvalError::MirEvalError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
@ -2896,7 +2897,7 @@ fn recursive_adt() {
{ {
const VARIANT_TAG_TREE: TagTree = TagTree::Choice( const VARIANT_TAG_TREE: TagTree = TagTree::Choice(
&[ &[
TagTree::Leaf, TAG_TREE,
], ],
); );
VARIANT_TAG_TREE VARIANT_TAG_TREE
@ -2905,6 +2906,6 @@ fn recursive_adt() {
TAG_TREE TAG_TREE
}; };
"#, "#,
|e| matches!(e, ConstEvalError::MirEvalError(MirEvalError::StackOverflow)), |e| matches!(e, ConstEvalError::MirLowerError(MirLowerError::Loop)),
); );
} }

View file

@ -51,7 +51,7 @@ mod test_db;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use std::{collections::hash_map::Entry, hash::Hash}; use std::hash::Hash;
use base_db::ra_salsa::InternValueTrivial; use base_db::ra_salsa::InternValueTrivial;
use chalk_ir::{ use chalk_ir::{
@ -62,10 +62,11 @@ use chalk_ir::{
use either::Either; use either::Either;
use hir_def::{hir::ExprId, type_ref::Rawness, CallableDefId, GeneralConstId, TypeOrConstParamId}; use hir_def::{hir::ExprId, type_ref::Rawness, CallableDefId, GeneralConstId, TypeOrConstParamId};
use hir_expand::name::Name; use hir_expand::name::Name;
use indexmap::{map::Entry, IndexMap};
use intern::{sym, Symbol}; use intern::{sym, Symbol};
use la_arena::{Arena, Idx}; use la_arena::{Arena, Idx};
use mir::{MirEvalError, VTableMap}; use mir::{MirEvalError, VTableMap};
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use span::Edition; use span::Edition;
use syntax::ast::{make, ConstArg}; use syntax::ast::{make, ConstArg};
use traits::FnTrait; use traits::FnTrait;
@ -196,7 +197,7 @@ pub enum MemoryMap {
#[derive(Debug, Default, Clone, PartialEq, Eq)] #[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct ComplexMemoryMap { pub struct ComplexMemoryMap {
memory: FxHashMap<usize, Box<[u8]>>, memory: IndexMap<usize, Box<[u8]>, FxBuildHasher>,
vtable: VTableMap, vtable: VTableMap,
} }