mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Don't HirDisplay unknown types when displaying for source
This commit is contained in:
parent
91bf15a2f5
commit
69b78edb5e
2 changed files with 34 additions and 1 deletions
|
@ -781,6 +781,31 @@ impl Test for () {
|
|||
${0:todo!()}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_generic_type() {
|
||||
check_assist(
|
||||
add_missing_impl_members,
|
||||
r#"
|
||||
trait Foo<BAR> {
|
||||
fn foo(&self, bar: BAR);
|
||||
}
|
||||
impl Foo for () {
|
||||
<|>
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
trait Foo<BAR> {
|
||||
fn foo(&self, bar: BAR);
|
||||
}
|
||||
impl Foo for () {
|
||||
fn foo(&self, bar: BAR) {
|
||||
${0:todo!()}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ impl DisplayTarget {
|
|||
#[derive(Debug)]
|
||||
pub enum DisplaySourceCodeError {
|
||||
PathNotFound,
|
||||
UnknownType,
|
||||
}
|
||||
|
||||
pub enum HirDisplayError {
|
||||
|
@ -558,7 +559,14 @@ impl HirDisplay for Ty {
|
|||
}
|
||||
};
|
||||
}
|
||||
Ty::Unknown => write!(f, "{{unknown}}")?,
|
||||
Ty::Unknown => {
|
||||
if f.display_target.is_source_code() {
|
||||
return Err(HirDisplayError::DisplaySourceCodeError(
|
||||
DisplaySourceCodeError::UnknownType,
|
||||
));
|
||||
}
|
||||
write!(f, "{{unknown}}")?;
|
||||
}
|
||||
Ty::Infer(..) => write!(f, "_")?,
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue