Skip to content

trait_impl_redundant_assoc_item fails if the files is a macro file #16269

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
saiintbrisson opened this issue Jan 5, 2024 · 0 comments · Fixed by #16223
Closed

trait_impl_redundant_assoc_item fails if the files is a macro file #16269

saiintbrisson opened this issue Jan 5, 2024 · 0 comments · Fixed by #16223
Labels
C-bug Category: bug

Comments

@saiintbrisson
Copy link
Contributor

saiintbrisson commented Jan 5, 2024

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()),
),
)

@saiintbrisson saiintbrisson added the C-bug Category: bug label Jan 5, 2024
@saiintbrisson saiintbrisson changed the title trait_impl_reduntant_assoc_item fails if the files is a macro file trait_impl_redundant_assoc_item fails if the files is a macro file Jan 5, 2024
@bors bors closed this as completed in 2980d54 Jan 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant