@@ -25,7 +25,7 @@ use rustc_hir::{
25
25
use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
26
26
use rustc_middle:: hir:: nested_filter;
27
27
use 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 } ;
29
29
use rustc_semver:: RustcVersion ;
30
30
use rustc_session:: { declare_lint_pass, declare_tool_lint, impl_lint_pass} ;
31
31
use rustc_span:: source_map:: Spanned ;
@@ -934,7 +934,16 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
934
934
// implementations of native types. Check lang items.
935
935
let path_syms: Vec < _ > = path. iter ( ) . map ( |p| Symbol :: intern ( p) ) . collect ( ) ;
936
936
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) {
938
947
let lang_item_path = cx. get_def_path ( * item_def_id) ;
939
948
if path_syms. starts_with ( & lang_item_path) {
940
949
if let [ item] = & path_syms[ lang_item_path. len ( ) ..] {
0 commit comments