Skip to content

Panic when computing missing fields diagnostic with raw ident fields #8680

@jonas-schievink

Description

@jonas-schievink

Attempting to request the missing fields assist in this code results in a panic:

rohs::encode_message(&Command::InitCommand(InitCommand {
    $0            
}));

Where InitCommand is defined as

struct InitCommand {
    r#type: FwType,
    app_size: u32,
}

Panic:

thread '<unnamed>' panicked at 'Failed to make ast node `syntax::ast::generated::nodes::NameRef` from text fn f() { type; }', crates/syntax/src/ast/make.rs:564:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:435:5
   2: syntax::ast::make::ast_from_text
   3: syntax::ast::make::name_ref
   4: <hir_ty::diagnostics::MissingFields as ide::diagnostics::fixes::DiagnosticWithFix>::fix
   5: ide::diagnostics::diagnostic_with_fix
   6: hir_expand::diagnostics::DiagnosticSinkBuilder::on::{{closure}}
   7: hir_expand::diagnostics::DiagnosticSink::_push
   8: hir_ty::diagnostics::expr::ExprValidator::validate_body
   9: hir_ty::diagnostics::validate_body
  10: hir::Function::diagnostics
  11: hir::Module::diagnostics
  12: hir::Module::diagnostics
  13: ide::diagnostics::diagnostics
  14: ide::Analysis::assists_with_fixes::{{closure}}
  15: std::panicking::try
  16: ide::Analysis::assists_with_fixes
  17: rust_analyzer::handlers::handle_code_action
  18: <F as threadpool::FnBox>::call_box

Metadata

Metadata

Labels

A-diagnosticsdiagnostics / error reportingBroken WindowBugs / technical debt to be addressed immediatelyE-has-instructionsIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions