mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
test: add tests for keeping attrs in assist 'generate_delegate_trait'
This commit is contained in:
parent
faea7fca01
commit
5c9ce7b11f
@ -1716,4 +1716,65 @@ impl some_module::SomeTrait for B {
|
|||||||
}"#,
|
}"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fn_with_attrs() {
|
||||||
|
check_assist(
|
||||||
|
generate_delegate_trait,
|
||||||
|
r#"
|
||||||
|
struct A;
|
||||||
|
|
||||||
|
trait T {
|
||||||
|
#[cfg(test)]
|
||||||
|
fn f(&self, a: u32);
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn f(&self, a: bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl T for A {
|
||||||
|
#[cfg(test)]
|
||||||
|
fn f(&self, a: u32) {}
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn f(&self, a: bool) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct B {
|
||||||
|
a$0: A,
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct A;
|
||||||
|
|
||||||
|
trait T {
|
||||||
|
#[cfg(test)]
|
||||||
|
fn f(&self, a: u32);
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn f(&self, a: bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl T for A {
|
||||||
|
#[cfg(test)]
|
||||||
|
fn f(&self, a: u32) {}
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn f(&self, a: bool) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct B {
|
||||||
|
a: A,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl T for B {
|
||||||
|
#[cfg(test)]
|
||||||
|
fn f(&self, a: u32) {
|
||||||
|
<A as T>::f(&self.a, a)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
fn f(&self, a: bool) {
|
||||||
|
<A as T>::f(&self.a, a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user