From 90331ea0350eaea281d35bd0aa13df7f20a8600d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 11 Jun 2020 16:22:31 +0200 Subject: Make known paths use `core` instead of `std` --- crates/ra_hir_ty/src/expr.rs | 10 ++++++---- crates/ra_hir_ty/src/infer.rs | 16 ++++++++-------- crates/ra_hir_ty/src/tests/simple.rs | 4 ++-- crates/ra_hir_ty/src/tests/traits.rs | 30 ++++++++++++++++-------------- 4 files changed, 32 insertions(+), 28 deletions(-) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index f04968e14..7db928dde 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -226,17 +226,19 @@ impl<'a, 'b> ExprValidator<'a, 'b> { None => return, }; - let std_result_path = path![std::result::Result]; + let core_result_path = path![core::result::Result]; let resolver = self.func.resolver(db.upcast()); - let std_result_enum = match resolver.resolve_known_enum(db.upcast(), &std_result_path) { + let core_result_enum = match resolver.resolve_known_enum(db.upcast(), &core_result_path) { Some(it) => it, _ => return, }; - let std_result_ctor = TypeCtor::Adt(AdtId::EnumId(std_result_enum)); + let core_result_ctor = TypeCtor::Adt(AdtId::EnumId(core_result_enum)); let params = match &mismatch.expected { - Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &std_result_ctor => parameters, + Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &core_result_ctor => { + parameters + } _ => return, }; diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index f965eb2b5..3719f76a6 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -555,13 +555,13 @@ impl<'a> InferenceContext<'a> { } fn resolve_into_iter_item(&self) -> Option { - let path = path![std::iter::IntoIterator]; + let path = path![core::iter::IntoIterator]; let trait_ = self.resolver.resolve_known_trait(self.db.upcast(), &path)?; self.db.trait_data(trait_).associated_type_by_name(&name![Item]) } fn resolve_ops_try_ok(&self) -> Option { - let path = path![std::ops::Try]; + let path = path![core::ops::Try]; let trait_ = self.resolver.resolve_known_trait(self.db.upcast(), &path)?; self.db.trait_data(trait_).associated_type_by_name(&name![Ok]) } @@ -587,37 +587,37 @@ impl<'a> InferenceContext<'a> { } fn resolve_range_full(&self) -> Option { - let path = path![std::ops::RangeFull]; + let path = path![core::ops::RangeFull]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } fn resolve_range(&self) -> Option { - let path = path![std::ops::Range]; + let path = path![core::ops::Range]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } fn resolve_range_inclusive(&self) -> Option { - let path = path![std::ops::RangeInclusive]; + let path = path![core::ops::RangeInclusive]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } fn resolve_range_from(&self) -> Option { - let path = path![std::ops::RangeFrom]; + let path = path![core::ops::RangeFrom]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } fn resolve_range_to(&self) -> Option { - let path = path![std::ops::RangeTo]; + let path = path![core::ops::RangeTo]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } fn resolve_range_to_inclusive(&self) -> Option { - let path = path![std::ops::RangeToInclusive]; + let path = path![core::ops::RangeToInclusive]; let struct_ = self.resolver.resolve_known_struct(self.db.upcast(), &path)?; Some(struct_.into()) } diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index 8a5031756..37659cd02 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -95,7 +95,7 @@ fn foo() { fn infer_ranges() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core fn test() { let a = ..; let b = 1..; @@ -108,7 +108,7 @@ fn test() { t<|>; } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use prelude::*; mod prelude {} diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 133fb5f39..e81193a3c 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -10,7 +10,7 @@ use super::{infer, infer_with_mismatches, type_at, type_at_pos}; fn infer_await() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core struct IntFuture; @@ -24,7 +24,7 @@ fn test() { v<|>; } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use future::*; mod future { #[lang = "future_trait"] @@ -42,7 +42,7 @@ mod future { fn infer_async() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core async fn foo() -> u64 { 128 @@ -54,7 +54,7 @@ fn test() { v<|>; } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use future::*; mod future { #[lang = "future_trait"] @@ -72,7 +72,7 @@ mod future { fn infer_desugar_async() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core async fn foo() -> u64 { 128 @@ -83,7 +83,7 @@ fn test() { r<|>; } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use future::*; mod future { trait Future { @@ -100,7 +100,7 @@ mod future { fn infer_try() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core fn test() { let r: Result = Result::Ok(1); @@ -108,7 +108,7 @@ fn test() { v<|>; } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use ops::*; mod ops { @@ -140,9 +140,9 @@ mod result { fn infer_for_loop() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core,alloc -use std::collections::Vec; +use alloc::collections::Vec; fn test() { let v = Vec::new(); @@ -152,7 +152,7 @@ fn test() { } } -//- /std.rs crate:std +//- /core.rs crate:core #[prelude_import] use iter::*; mod iter { @@ -161,6 +161,8 @@ mod iter { } } +//- /alloc.rs crate:alloc deps:core + mod collections { struct Vec {} impl Vec { @@ -168,7 +170,7 @@ mod collections { fn push(&mut self, t: T) { } } - impl crate::iter::IntoIterator for Vec { + impl IntoIterator for Vec { type Item=T; } } @@ -2846,12 +2848,12 @@ fn test() { fn integer_range_iterate() { let t = type_at( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core fn test() { for x in 0..100 { x<|>; } } -//- /std.rs crate:std +//- /core.rs crate:core pub mod ops { pub struct Range { pub start: Idx, -- cgit v1.2.3