@@ -2411,7 +2411,7 @@ impl Local {
24112411#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
24122412pub struct DeriveHelper {
24132413 pub ( crate ) derive : MacroId ,
2414- pub ( crate ) idx : usize ,
2414+ pub ( crate ) idx : u32 ,
24152415}
24162416
24172417impl DeriveHelper {
@@ -2421,15 +2421,18 @@ impl DeriveHelper {
24212421
24222422 pub fn name ( & self , db : & dyn HirDatabase ) -> Name {
24232423 match self . derive {
2424- MacroId :: Macro2Id ( it) => {
2425- db. macro2_data ( it) . helpers . as_deref ( ) . and_then ( |it| it. get ( self . idx ) ) . cloned ( )
2426- }
2424+ MacroId :: Macro2Id ( it) => db
2425+ . macro2_data ( it)
2426+ . helpers
2427+ . as_deref ( )
2428+ . and_then ( |it| it. get ( self . idx as usize ) )
2429+ . cloned ( ) ,
24272430 MacroId :: MacroRulesId ( _) => None ,
24282431 MacroId :: ProcMacroId ( proc_macro) => db
24292432 . proc_macro_data ( proc_macro)
24302433 . helpers
24312434 . as_deref ( )
2432- . and_then ( |it| it. get ( self . idx ) )
2435+ . and_then ( |it| it. get ( self . idx as usize ) )
24332436 . cloned ( ) ,
24342437 }
24352438 . unwrap_or_else ( || Name :: missing ( ) )
@@ -2440,7 +2443,7 @@ impl DeriveHelper {
24402443#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
24412444pub struct BuiltinAttr {
24422445 krate : Option < CrateId > ,
2443- idx : usize ,
2446+ idx : u32 ,
24442447}
24452448
24462449impl BuiltinAttr {
@@ -2449,37 +2452,38 @@ impl BuiltinAttr {
24492452 if let builtin @ Some ( _) = Self :: builtin ( name) {
24502453 return builtin;
24512454 }
2452- let idx = db. crate_def_map ( krate. id ) . registered_attrs ( ) . iter ( ) . position ( |it| it == name) ?;
2455+ let idx =
2456+ db. crate_def_map ( krate. id ) . registered_attrs ( ) . iter ( ) . position ( |it| it == name) ? as u32 ;
24532457 Some ( BuiltinAttr { krate : Some ( krate. id ) , idx } )
24542458 }
24552459
24562460 fn builtin ( name : & str ) -> Option < Self > {
24572461 hir_def:: builtin_attr:: INERT_ATTRIBUTES
24582462 . iter ( )
24592463 . position ( |tool| tool. name == name)
2460- . map ( |idx| BuiltinAttr { krate : None , idx } )
2464+ . map ( |idx| BuiltinAttr { krate : None , idx : idx as u32 } )
24612465 }
24622466
24632467 pub fn name ( & self , db : & dyn HirDatabase ) -> SmolStr {
24642468 // FIXME: Return a `Name` here
24652469 match self . krate {
2466- Some ( krate) => db. crate_def_map ( krate) . registered_attrs ( ) [ self . idx ] . clone ( ) ,
2467- None => SmolStr :: new ( hir_def:: builtin_attr:: INERT_ATTRIBUTES [ self . idx ] . name ) ,
2470+ Some ( krate) => db. crate_def_map ( krate) . registered_attrs ( ) [ self . idx as usize ] . clone ( ) ,
2471+ None => SmolStr :: new ( hir_def:: builtin_attr:: INERT_ATTRIBUTES [ self . idx as usize ] . name ) ,
24682472 }
24692473 }
24702474
24712475 pub fn template ( & self , _: & dyn HirDatabase ) -> Option < AttributeTemplate > {
24722476 match self . krate {
24732477 Some ( _) => None ,
2474- None => Some ( hir_def:: builtin_attr:: INERT_ATTRIBUTES [ self . idx ] . template ) ,
2478+ None => Some ( hir_def:: builtin_attr:: INERT_ATTRIBUTES [ self . idx as usize ] . template ) ,
24752479 }
24762480 }
24772481}
24782482
24792483#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
24802484pub struct ToolModule {
24812485 krate : Option < CrateId > ,
2482- idx : usize ,
2486+ idx : u32 ,
24832487}
24842488
24852489impl ToolModule {
@@ -2488,22 +2492,23 @@ impl ToolModule {
24882492 if let builtin @ Some ( _) = Self :: builtin ( name) {
24892493 return builtin;
24902494 }
2491- let idx = db. crate_def_map ( krate. id ) . registered_tools ( ) . iter ( ) . position ( |it| it == name) ?;
2495+ let idx =
2496+ db. crate_def_map ( krate. id ) . registered_tools ( ) . iter ( ) . position ( |it| it == name) ? as u32 ;
24922497 Some ( ToolModule { krate : Some ( krate. id ) , idx } )
24932498 }
24942499
24952500 fn builtin ( name : & str ) -> Option < Self > {
24962501 hir_def:: builtin_attr:: TOOL_MODULES
24972502 . iter ( )
24982503 . position ( |& tool| tool == name)
2499- . map ( |idx| ToolModule { krate : None , idx } )
2504+ . map ( |idx| ToolModule { krate : None , idx : idx as u32 } )
25002505 }
25012506
25022507 pub fn name ( & self , db : & dyn HirDatabase ) -> SmolStr {
25032508 // FIXME: Return a `Name` here
25042509 match self . krate {
2505- Some ( krate) => db. crate_def_map ( krate) . registered_tools ( ) [ self . idx ] . clone ( ) ,
2506- None => SmolStr :: new ( hir_def:: builtin_attr:: TOOL_MODULES [ self . idx ] ) ,
2510+ Some ( krate) => db. crate_def_map ( krate) . registered_tools ( ) [ self . idx as usize ] . clone ( ) ,
2511+ None => SmolStr :: new ( hir_def:: builtin_attr:: TOOL_MODULES [ self . idx as usize ] ) ,
25072512 }
25082513 }
25092514}
@@ -2831,7 +2836,7 @@ impl Impl {
28312836 }
28322837}
28332838
2834- #[ derive( Clone , PartialEq , Eq , Debug ) ]
2839+ #[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
28352840pub struct TraitRef {
28362841 env : Arc < TraitEnvironment > ,
28372842 trait_ref : hir_ty:: TraitRef ,
0 commit comments