mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Accept ambiguous unsize coercion only if it has definite guidance.
This commit is contained in:
parent
e89ad9f345
commit
de074fe636
2 changed files with 17 additions and 4 deletions
|
@ -575,11 +575,11 @@ impl<'a> InferenceContext<'a> {
|
|||
},
|
||||
);
|
||||
}
|
||||
Solution::Ambig(guidance) => {
|
||||
if let Guidance::Definite(subst) = guidance {
|
||||
canonicalized.apply_solution(&mut self.table, subst);
|
||||
}
|
||||
Solution::Ambig(Guidance::Definite(subst)) => {
|
||||
canonicalized.apply_solution(&mut self.table, subst)
|
||||
}
|
||||
// FIXME: should we accept ambiguous results here?
|
||||
_ => return Err(TypeError),
|
||||
};
|
||||
let unsize =
|
||||
Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), target: to_ty.clone() };
|
||||
|
|
|
@ -559,3 +559,16 @@ fn test() {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coerce_type_var() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: from, coerce_unsized
|
||||
fn test() {
|
||||
let x = ();
|
||||
let _: &() = &x.into();
|
||||
} //^^^^^^^^ ()
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue