From a35ff6edf44519cc3b07869d8e5754c607b913cd Mon Sep 17 00:00:00 2001 From: GrayJack Date: Wed, 21 Oct 2020 01:54:51 -0300 Subject: [PATCH] Add tests for callable modifier --- .../test_data/highlighting.html | 19 +++++++++++++++++++ crates/ide/src/syntax_highlighting/tests.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index 0bb0928e44..0cb84866d6 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -44,6 +44,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd pub trait Copy {} } +pub mod ops { + #[lang = "fn_once"] + pub trait FnOnce<Args> {} + + #[lang = "fn_mut"] + pub trait FnMut<Args>: FnOnce<Args> {} + + #[lang = "fn"] + pub trait Fn<Args>: FnMut<Args> {} +} + struct Foo { pub x: i32, @@ -99,6 +110,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd foo::<'a, i32>() } +use ops::Fn; +fn baz<F: Fn() -> ()>(f: F) { + f() +} + macro_rules! def_fn { ($($tt:tt)*) => {$($tt)*} } @@ -157,6 +173,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd copy.quop(); copy.qux(); copy.baz(copy); + + let a = |x| x; + let bar = Foo::baz; } enum Option<T> { diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 126363b8be..da20c300e2 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -18,6 +18,17 @@ pub mod marker { pub trait Copy {} } +pub mod ops { + #[lang = "fn_once"] + pub trait FnOnce {} + + #[lang = "fn_mut"] + pub trait FnMut: FnOnce {} + + #[lang = "fn"] + pub trait Fn: FnMut {} +} + struct Foo { pub x: i32, @@ -73,6 +84,11 @@ fn foo<'a, T>() -> T { foo::<'a, i32>() } +use ops::Fn; +fn baz ()>(f: F) { + f() +} + macro_rules! def_fn { ($($tt:tt)*) => {$($tt)*} } @@ -131,6 +147,9 @@ fn main() { copy.quop(); copy.qux(); copy.baz(copy); + + let a = |x| x; + let bar = Foo::baz; } enum Option {