mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
parent
0a4239a815
commit
b60a29ca94
6 changed files with 12 additions and 13 deletions
|
@ -73,7 +73,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
|
|||
|
||||
let generate_fill_expr = |ty: &Type| match ctx.config.expr_fill_default {
|
||||
crate::ExprFillDefaultMode::Todo => Some(make::ext::expr_todo()),
|
||||
crate::ExprFillDefaultMode::DefaultImpl => {
|
||||
crate::ExprFillDefaultMode::Default => {
|
||||
let default_constr = get_default_constructor(ctx, d, ty);
|
||||
match default_constr {
|
||||
Some(default_constr) => Some(default_constr),
|
||||
|
@ -159,7 +159,6 @@ fn get_default_constructor(
|
|||
if let AssocItem::Function(func) = assoc_item {
|
||||
if func.name(ctx.sema.db) == known::new
|
||||
&& func.assoc_fn_params(ctx.sema.db).is_empty()
|
||||
&& func.self_param(ctx.sema.db).is_none()
|
||||
{
|
||||
return Some(());
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ pub enum Severity {
|
|||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ExprFillDefaultMode {
|
||||
Todo,
|
||||
DefaultImpl,
|
||||
Default,
|
||||
}
|
||||
impl Default for ExprFillDefaultMode {
|
||||
fn default() -> Self {
|
||||
|
|
|
@ -37,7 +37,7 @@ fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
|
|||
|
||||
let (db, file_position) = RootDatabase::with_position(ra_fixture_before);
|
||||
let mut conf = DiagnosticsConfig::default();
|
||||
conf.expr_fill_default = ExprFillDefaultMode::DefaultImpl;
|
||||
conf.expr_fill_default = ExprFillDefaultMode::Default;
|
||||
let diagnostic =
|
||||
super::diagnostics(&db, &conf, &AssistResolveStrategy::All, file_position.file_id)
|
||||
.pop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue