@@ -81,7 +81,7 @@ pub struct IncompatibleMsrv {
8181 msrv : Msrv ,
8282 availability_cache : FxHashMap < ( DefId , bool ) , Availability > ,
8383 check_in_tests : bool ,
84- core_crate : Option < CrateNum > ,
84+ stdlib_crates : Vec < CrateNum > ,
8585
8686 // The most recently called path. Used to skip checking the path after it's
8787 // been checked when visiting the call expression.
@@ -96,11 +96,15 @@ impl IncompatibleMsrv {
9696 msrv : conf. msrv ,
9797 availability_cache : FxHashMap :: default ( ) ,
9898 check_in_tests : conf. check_incompatible_msrv_in_tests ,
99- core_crate : tcx
99+ stdlib_crates : tcx
100100 . crates ( ( ) )
101101 . iter ( )
102- . find ( |krate| tcx. crate_name ( * * krate) == sym:: core)
103- . copied ( ) ,
102+ . filter ( |krate| {
103+ let name = tcx. crate_name ( * * krate) ;
104+ name == sym:: core || name == sym:: alloc || name == sym:: std
105+ } )
106+ . copied ( )
107+ . collect ( ) ,
104108 called_path : None ,
105109 }
106110 }
@@ -162,10 +166,14 @@ impl IncompatibleMsrv {
162166 // Intentionally not using `.from_expansion()`, since we do still care about macro expansions
163167 return ;
164168 }
165- // Functions coming from `core` while expanding a macro such as `assert*!()` get to cheat too: the
166- // macros may have existed prior to the checked MSRV, but their expansion with a recent compiler
167- // might use recent functions or methods. Compiling with an older compiler would not use those.
168- if Some ( def_id. krate ) == self . core_crate && expn_data. macro_def_id . map ( |did| did. krate ) == self . core_crate {
169+ // Functions coming from standard library crates while expanding a macro such as
170+ // `assert*!()` get to cheat too: the macros may have existed prior to the checked MSRV, but
171+ // their expansion with a recent compiler might use recent functions or methods. Compiling
172+ // with an older compiler would not use those.
173+ if self . stdlib_crates . contains ( & def_id. krate )
174+ && let Some ( did) = expn_data. macro_def_id
175+ && self . stdlib_crates . contains ( & did. krate )
176+ {
169177 return ;
170178 }
171179
0 commit comments