mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 15:47:31 +00:00
Merge #7260
7260: Render Fn* trait objects and impl types as rust does r=matklad a=Veykril Also fixes raw ptr impl types being rendered ambiguously with multiple predicates. This moves out the `FamousDefs::Fixture` into its own file as well, cause I figured it is big enough to get its own file at this point + we also get highlighting this way when editing it. Fixes #3012 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
39167b97d8
7 changed files with 254 additions and 119 deletions
|
@ -1398,6 +1398,43 @@ fn main() {
|
|||
Foo::bar(&Foo);
|
||||
//^^^^ self
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fn_hints() {
|
||||
check(
|
||||
r#"
|
||||
trait Sized {}
|
||||
|
||||
fn foo() -> impl Fn() { loop {} }
|
||||
fn foo1() -> impl Fn(f64) { loop {} }
|
||||
fn foo2() -> impl Fn(f64, f64) { loop {} }
|
||||
fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
|
||||
fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
|
||||
fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
|
||||
|
||||
fn main() {
|
||||
let foo = foo();
|
||||
// ^^^ impl Fn()
|
||||
let foo = foo1();
|
||||
// ^^^ impl Fn(f64)
|
||||
let foo = foo2();
|
||||
// ^^^ impl Fn(f64, f64)
|
||||
let foo = foo3();
|
||||
// ^^^ impl Fn(f64, f64) -> u32
|
||||
let foo = foo4();
|
||||
// ^^^ &dyn Fn(f64, f64) -> u32
|
||||
let foo = foo5();
|
||||
// ^^^ &dyn Fn(&dyn Fn(f64, f64) -> u32, f64) -> u32
|
||||
let foo = foo6();
|
||||
// ^^^ impl Fn(f64, f64) -> u32 + Sized
|
||||
let foo = foo7();
|
||||
// ^^^ *const (impl Fn(f64, f64) -> u32 + Sized)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue