mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Merge #11826
11826: Revert "Emit #[must_use] in Generate new assist" r=lnicola a=lnicola CC https://github.com/rust-analyzer/rust-analyzer/pull/11737#issuecomment-1079740305 Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
630d85f8d1
2 changed files with 1 additions and 21 deletions
|
@ -23,7 +23,6 @@ use crate::{
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// impl<T: Clone> Ctx<T> {
|
// impl<T: Clone> Ctx<T> {
|
||||||
// #[must_use]
|
|
||||||
// fn $0new(data: T) -> Self { Self { data } }
|
// fn $0new(data: T) -> Self { Self { data } }
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
|
@ -55,13 +54,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
||||||
.format(", ");
|
.format(", ");
|
||||||
let fields = field_list.fields().filter_map(|f| f.name()).format(", ");
|
let fields = field_list.fields().filter_map(|f| f.name()).format(", ");
|
||||||
|
|
||||||
format_to!(
|
format_to!(buf, " {}fn new({}) -> Self {{ Self {{ {} }} }}", vis, params, fields);
|
||||||
buf,
|
|
||||||
" #[must_use]\n {}fn new({}) -> Self {{ Self {{ {} }} }}",
|
|
||||||
vis,
|
|
||||||
params,
|
|
||||||
fields
|
|
||||||
);
|
|
||||||
|
|
||||||
let start_offset = impl_def
|
let start_offset = impl_def
|
||||||
.and_then(|impl_def| find_impl_block_start(impl_def, &mut buf))
|
.and_then(|impl_def| find_impl_block_start(impl_def, &mut buf))
|
||||||
|
@ -97,7 +90,6 @@ struct Foo {$0}
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -111,7 +103,6 @@ struct Foo<T: Clone> {$0}
|
||||||
struct Foo<T: Clone> {}
|
struct Foo<T: Clone> {}
|
||||||
|
|
||||||
impl<T: Clone> Foo<T> {
|
impl<T: Clone> Foo<T> {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -125,7 +116,6 @@ struct Foo<'a, T: Foo<'a>> {$0}
|
||||||
struct Foo<'a, T: Foo<'a>> {}
|
struct Foo<'a, T: Foo<'a>> {}
|
||||||
|
|
||||||
impl<'a, T: Foo<'a>> Foo<'a, T> {
|
impl<'a, T: Foo<'a>> Foo<'a, T> {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -139,7 +129,6 @@ struct Foo { baz: String $0}
|
||||||
struct Foo { baz: String }
|
struct Foo { baz: String }
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new(baz: String) -> Self { Self { baz } }
|
fn $0new(baz: String) -> Self { Self { baz } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -153,7 +142,6 @@ struct Foo { baz: String, qux: Vec<i32> $0}
|
||||||
struct Foo { baz: String, qux: Vec<i32> }
|
struct Foo { baz: String, qux: Vec<i32> }
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new(baz: String, qux: Vec<i32>) -> Self { Self { baz, qux } }
|
fn $0new(baz: String, qux: Vec<i32>) -> Self { Self { baz, qux } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -171,7 +159,6 @@ struct Foo { pub baz: String, pub qux: Vec<i32> $0}
|
||||||
struct Foo { pub baz: String, pub qux: Vec<i32> }
|
struct Foo { pub baz: String, pub qux: Vec<i32> }
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new(baz: String, qux: Vec<i32>) -> Self { Self { baz, qux } }
|
fn $0new(baz: String, qux: Vec<i32>) -> Self { Self { baz, qux } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -191,7 +178,6 @@ impl Foo {}
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -209,7 +195,6 @@ impl Foo {
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
|
|
||||||
fn qux(&self) {}
|
fn qux(&self) {}
|
||||||
|
@ -233,7 +218,6 @@ impl Foo {
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
fn $0new() -> Self { Self { } }
|
fn $0new() -> Self { Self { } }
|
||||||
|
|
||||||
fn qux(&self) {}
|
fn qux(&self) {}
|
||||||
|
@ -256,7 +240,6 @@ pub struct Foo {$0}
|
||||||
pub struct Foo {}
|
pub struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
pub fn $0new() -> Self { Self { } }
|
pub fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -270,7 +253,6 @@ pub(crate) struct Foo {$0}
|
||||||
pub(crate) struct Foo {}
|
pub(crate) struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[must_use]
|
|
||||||
pub(crate) fn $0new() -> Self { Self { } }
|
pub(crate) fn $0new() -> Self { Self { } }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -366,7 +348,6 @@ pub struct Source<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Source<T> {
|
impl<T> Source<T> {
|
||||||
#[must_use]
|
|
||||||
pub fn $0new(file_id: HirFileId, ast: T) -> Self { Self { file_id, ast } }
|
pub fn $0new(file_id: HirFileId, ast: T) -> Self { Self { file_id, ast } }
|
||||||
|
|
||||||
pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> {
|
pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> {
|
||||||
|
|
|
@ -1139,7 +1139,6 @@ struct Ctx<T: Clone> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Clone> Ctx<T> {
|
impl<T: Clone> Ctx<T> {
|
||||||
#[must_use]
|
|
||||||
fn $0new(data: T) -> Self { Self { data } }
|
fn $0new(data: T) -> Self { Self { data } }
|
||||||
}
|
}
|
||||||
"#####,
|
"#####,
|
||||||
|
|
Loading…
Reference in a new issue