From 95d78a8d8d3bcb25ff7073c849824985b196c651 Mon Sep 17 00:00:00 2001 From: Marco Groppo Date: Mon, 8 Jul 2019 20:37:29 +0200 Subject: Look for the fXX_runtime lang items during method resolution. --- crates/ra_hir/src/ty/method_resolution.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/ty/method_resolution.rs') diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 76ace66ea..f65ad08a8 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -14,7 +14,7 @@ use crate::{ nameres::CrateModuleId, resolve::Resolver, traits::TraitItem, - ty::primitive::{UncertainFloatTy, UncertainIntTy}, + ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, ty::{Ty, TypeCtor}, Crate, Function, HirDatabase, Module, Name, Trait, }; @@ -132,9 +132,11 @@ fn def_crates(db: &impl HirDatabase, cur_crate: Crate, ty: &Ty) -> Option Some(std::iter::once(def_id.krate(db)?).collect()), TypeCtor::Bool => lang_item_crate!(db, cur_crate, "bool"), TypeCtor::Char => lang_item_crate!(db, cur_crate, "char"), - TypeCtor::Float(UncertainFloatTy::Known(f)) => { - lang_item_crate!(db, cur_crate, f.ty_to_string()) - } + TypeCtor::Float(UncertainFloatTy::Known(f)) => match f.bitness { + // There are two lang items: one in libcore (fXX) and one in libstd (fXX_runtime) + FloatBitness::X32 => lang_item_crate!(db, cur_crate, "f32", "f32_runtime"), + FloatBitness::X64 => lang_item_crate!(db, cur_crate, "f64", "f64_runtime"), + }, TypeCtor::Int(UncertainIntTy::Known(i)) => { lang_item_crate!(db, cur_crate, i.ty_to_string()) } -- cgit v1.2.3