Skip to content

trait_impl_redundant_assoc_item fails if the files is a macro file #16269

Closed
@saiintbrisson

Description

@saiintbrisson

PR #15990 introduced a bug when unwrapping this file_id:

FileRange { file_id: d.file_id.file_id().unwrap(), range: diagnostic_range },

The function returns None if the file is a macro file:

#[inline]
pub fn file_id(self) -> Option<FileId> {
match self.0 & Self::MACRO_FILE_TAG_MASK {
0 => Some(FileId::from_raw(self.0)),
_ => None,
}
}

Maybe changing it to something like trait_impl_missing_assoc_item will work?

Diagnostic::new(
DiagnosticCode::RustcHardError("E0046"),
format!("not all trait items implemented, missing: {missing}"),
adjusted_display_range::<ast::Impl>(
ctx,
InFile { file_id: d.file_id, value: d.impl_.syntax_node_ptr() },
&|impl_| impl_.trait_().map(|t| t.syntax().text_range()),
),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions