@@ -25,7 +25,7 @@ use rustc_hir::{
2525use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
2626use rustc_middle:: hir:: nested_filter;
2727use rustc_middle:: mir:: interpret:: ConstValue ;
28- use rustc_middle:: ty:: { self , subst:: GenericArgKind } ;
28+ use rustc_middle:: ty:: { self , fast_reject :: SimplifiedTypeGen , subst:: GenericArgKind , FloatTy } ;
2929use rustc_semver:: RustcVersion ;
3030use rustc_session:: { declare_lint_pass, declare_tool_lint, impl_lint_pass} ;
3131use rustc_span:: source_map:: Spanned ;
@@ -934,7 +934,16 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
934934 // implementations of native types. Check lang items.
935935 let path_syms: Vec < _ > = path. iter ( ) . map ( |p| Symbol :: intern ( p) ) . collect ( ) ;
936936 let lang_items = cx. tcx . lang_items ( ) ;
937- for item_def_id in lang_items. items ( ) . iter ( ) . flatten ( ) {
937+ // This list isn't complete, but good enough for our current list of paths.
938+ let incoherent_impls = [
939+ SimplifiedTypeGen :: FloatSimplifiedType ( FloatTy :: F32 ) ,
940+ SimplifiedTypeGen :: FloatSimplifiedType ( FloatTy :: F64 ) ,
941+ SimplifiedTypeGen :: SliceSimplifiedType ,
942+ SimplifiedTypeGen :: StrSimplifiedType ,
943+ ]
944+ . iter ( )
945+ . flat_map ( |& ty| cx. tcx . incoherent_impls ( ty) ) ;
946+ for item_def_id in lang_items. items ( ) . iter ( ) . flatten ( ) . chain ( incoherent_impls) {
938947 let lang_item_path = cx. get_def_path ( * item_def_id) ;
939948 if path_syms. starts_with ( & lang_item_path) {
940949 if let [ item] = & path_syms[ lang_item_path. len ( ) ..] {
0 commit comments