diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-08 20:18:49 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-08 20:18:49 +0100 |
commit | ecdc6cdce997c6ae251dbda2066de929f9d49c49 (patch) | |
tree | 74f668500a59141777ded421239b0da33f4853c3 /crates/ra_hir/src/ty | |
parent | 32100022010ecfefd1ea06caa71d1a508d2eb75d (diff) | |
parent | 95d78a8d8d3bcb25ff7073c849824985b196c651 (diff) |
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 <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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::{ | |||
14 | nameres::CrateModuleId, | 14 | nameres::CrateModuleId, |
15 | resolve::Resolver, | 15 | resolve::Resolver, |
16 | traits::TraitItem, | 16 | traits::TraitItem, |
17 | ty::primitive::{UncertainFloatTy, UncertainIntTy}, | 17 | ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, |
18 | ty::{Ty, TypeCtor}, | 18 | ty::{Ty, TypeCtor}, |
19 | Crate, Function, HirDatabase, Module, Name, Trait, | 19 | Crate, Function, HirDatabase, Module, Name, Trait, |
20 | }; | 20 | }; |
@@ -132,9 +132,11 @@ fn def_crates(db: &impl HirDatabase, cur_crate: Crate, ty: &Ty) -> Option<ArrayV | |||
132 | TypeCtor::Adt(def_id) => Some(std::iter::once(def_id.krate(db)?).collect()), | 132 | TypeCtor::Adt(def_id) => Some(std::iter::once(def_id.krate(db)?).collect()), |
133 | TypeCtor::Bool => lang_item_crate!(db, cur_crate, "bool"), | 133 | TypeCtor::Bool => lang_item_crate!(db, cur_crate, "bool"), |
134 | TypeCtor::Char => lang_item_crate!(db, cur_crate, "char"), | 134 | TypeCtor::Char => lang_item_crate!(db, cur_crate, "char"), |
135 | TypeCtor::Float(UncertainFloatTy::Known(f)) => { | 135 | TypeCtor::Float(UncertainFloatTy::Known(f)) => match f.bitness { |
136 | lang_item_crate!(db, cur_crate, f.ty_to_string()) | 136 | // There are two lang items: one in libcore (fXX) and one in libstd (fXX_runtime) |
137 | } | 137 | FloatBitness::X32 => lang_item_crate!(db, cur_crate, "f32", "f32_runtime"), |
138 | FloatBitness::X64 => lang_item_crate!(db, cur_crate, "f64", "f64_runtime"), | ||
139 | }, | ||
138 | TypeCtor::Int(UncertainIntTy::Known(i)) => { | 140 | TypeCtor::Int(UncertainIntTy::Known(i)) => { |
139 | lang_item_crate!(db, cur_crate, i.ty_to_string()) | 141 | lang_item_crate!(db, cur_crate, i.ty_to_string()) |
140 | } | 142 | } |