mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
Pass the target crate in HirFormatter
This is required to format evaluated consts, because we need trait env, and it needs the crate (currently it uses the last crate in topological order, which is wrong, the next commit will fix that).
This commit is contained in:
parent
1cd9e683e8
commit
2fc0dc0f13
62 changed files with 842 additions and 517 deletions
|
|
@ -14,6 +14,7 @@ use intern::{sym, Symbol};
|
|||
use stdx::never;
|
||||
|
||||
use crate::{
|
||||
display::DisplayTarget,
|
||||
error_lifetime,
|
||||
mir::eval::{
|
||||
pad16, Address, AdtId, Arc, BuiltinType, Evaluator, FunctionId, HasModule, HirDisplay,
|
||||
|
|
@ -835,8 +836,7 @@ impl Evaluator<'_> {
|
|||
// render full paths.
|
||||
Err(_) => {
|
||||
let krate = locals.body.owner.krate(self.db.upcast());
|
||||
let edition = self.db.crate_graph()[krate].edition;
|
||||
ty.display(self.db, edition).to_string()
|
||||
ty.display(self.db, DisplayTarget::from_crate(self.db, krate)).to_string()
|
||||
}
|
||||
};
|
||||
let len = ty_name.len();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use span::{Edition, EditionedFileId};
|
|||
use syntax::{TextRange, TextSize};
|
||||
use test_fixture::WithFixture;
|
||||
|
||||
use crate::display::DisplayTarget;
|
||||
use crate::{db::HirDatabase, mir::MirLowerError, test_db::TestDB, Interner, Substitution};
|
||||
|
||||
use super::{interpret_mir, MirEvalError};
|
||||
|
|
@ -67,7 +68,9 @@ fn check_pass_and_stdio(
|
|||
let span_formatter = |file, range: TextRange| {
|
||||
format!("{:?} {:?}..{:?}", file, line_index(range.start()), line_index(range.end()))
|
||||
};
|
||||
e.pretty_print(&mut err, &db, span_formatter, Edition::CURRENT).unwrap();
|
||||
let krate = db.module_for_file(file_id).krate();
|
||||
e.pretty_print(&mut err, &db, span_formatter, DisplayTarget::from_crate(&db, krate))
|
||||
.unwrap();
|
||||
panic!("Error in interpreting: {err}");
|
||||
}
|
||||
Ok((stdout, stderr)) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue