mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-14 17:59:56 +00:00
fix: preserve where clause in delegate method
This commit is contained in:
parent
934358e95c
commit
f4349ff26e
1 changed files with 48 additions and 1 deletions
|
|
@ -134,7 +134,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'
|
||||||
vis,
|
vis,
|
||||||
fn_name,
|
fn_name,
|
||||||
type_params,
|
type_params,
|
||||||
None,
|
method_source.where_clause(),
|
||||||
params,
|
params,
|
||||||
body,
|
body,
|
||||||
ret_type,
|
ret_type,
|
||||||
|
|
@ -464,6 +464,53 @@ impl Person {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_preserve_where_clause() {
|
||||||
|
check_assist(
|
||||||
|
generate_delegate_methods,
|
||||||
|
r#"
|
||||||
|
struct Inner<T>(T);
|
||||||
|
impl<T> Inner<T> {
|
||||||
|
fn get(&self) -> T
|
||||||
|
where
|
||||||
|
T: Copy,
|
||||||
|
T: PartialEq,
|
||||||
|
{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct<T> {
|
||||||
|
$0field: Inner<T>,
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct Inner<T>(T);
|
||||||
|
impl<T> Inner<T> {
|
||||||
|
fn get(&self) -> T
|
||||||
|
where
|
||||||
|
T: Copy,
|
||||||
|
T: PartialEq,
|
||||||
|
{
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct<T> {
|
||||||
|
field: Inner<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Struct<T> {
|
||||||
|
$0fn get(&self) -> T where
|
||||||
|
T: Copy,
|
||||||
|
T: PartialEq, {
|
||||||
|
self.field.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fixes_basic_self_references() {
|
fn test_fixes_basic_self_references() {
|
||||||
check_assist(
|
check_assist(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue