parse const trait Trait

This commit is contained in:
Deadbeef
2025-07-13 16:49:19 +08:00
parent f8f6997469
commit 69326878ee
94 changed files with 365 additions and 299 deletions

View File

@@ -453,7 +453,7 @@ pub fn report_dyn_incompatibility<'tcx>(
let trait_str = tcx.def_path_str(trait_def_id);
let trait_span = tcx.hir_get_if_local(trait_def_id).and_then(|node| match node {
hir::Node::Item(item) => match item.kind {
hir::ItemKind::Trait(_, _, ident, ..) | hir::ItemKind::TraitAlias(ident, _, _) => {
hir::ItemKind::Trait(_, _, _, ident, ..) | hir::ItemKind::TraitAlias(ident, _, _) => {
Some(ident.span)
}
_ => unreachable!(),

View File

@@ -267,7 +267,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let node = self.tcx.hir_node_by_def_id(body_id);
match node {
hir::Node::Item(hir::Item {
kind: hir::ItemKind::Trait(_, _, ident, generics, bounds, _),
kind: hir::ItemKind::Trait(_, _, _, ident, generics, bounds, _),
..
}) if self_ty == self.tcx.types.self_param => {
assert!(param_ty);
@@ -330,7 +330,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
hir::Node::Item(hir::Item {
kind:
hir::ItemKind::Trait(_, _, _, generics, ..)
hir::ItemKind::Trait(_, _, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. }),
..
}) if projection.is_some() => {
@@ -354,7 +354,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::Trait(_, _, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. })
| hir::ItemKind::Fn { generics, .. }
| hir::ItemKind::TyAlias(_, generics, _)
@@ -414,7 +414,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::Trait(_, _, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. })
| hir::ItemKind::Fn { generics, .. }
| hir::ItemKind::TyAlias(_, generics, _)
@@ -3436,7 +3436,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let mut is_auto_trait = false;
match tcx.hir_get_if_local(data.impl_or_alias_def_id) {
Some(Node::Item(hir::Item {
kind: hir::ItemKind::Trait(is_auto, _, ident, ..),
kind: hir::ItemKind::Trait(_, is_auto, _, ident, ..),
..
})) => {
// FIXME: we should do something else so that it works even on crate foreign

View File

@@ -534,7 +534,7 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
match self.tcx.parent_hir_node(self.tcx.local_def_id_to_hir_id(anon_reg.scope))
{
hir::Node::Item(hir::Item {
kind: hir::ItemKind::Trait(_, _, _, generics, ..),
kind: hir::ItemKind::Trait(_, _, _, _, generics, ..),
..
})
| hir::Node::Item(hir::Item {