mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 17:42:47 +00:00
Merge #1514
1514: Better completions for floating point primitive types r=flodiebold a=marcogroppo After #1499 completions for (some of) the inherent methods of `f32` and `f64` are now working. Unfortunately during method resolution we were only looking for the `f32` and `f64` language items defined in `libcore` and we were ignoring the methods defined in `libstd`. This PR fixes this issue. Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
This commit is contained in:
commit
ecdc6cdce9
@ -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<ArrayV
|
||||
TypeCtor::Adt(def_id) => 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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user