Make known paths use core instead of std
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -555,13 +555,13 @@ impl<'a> InferenceContext<'a> {
|
||||
}
|
||||
|
||||
fn resolve_into_iter_item(&self) -> Option<TypeAliasId> {
|
||||
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<TypeAliasId> {
|
||||
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<AdtId> {
|
||||
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<AdtId> {
|
||||
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<AdtId> {
|
||||
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<AdtId> {
|
||||
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<AdtId> {
|
||||
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<AdtId> {
|
||||
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())
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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<i32, u64> = 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<T> {}
|
||||
impl<T> Vec<T> {
|
||||
@@ -168,7 +170,7 @@ mod collections {
|
||||
fn push(&mut self, t: T) { }
|
||||
}
|
||||
|
||||
impl<T> crate::iter::IntoIterator for Vec<T> {
|
||||
impl<T> IntoIterator for Vec<T> {
|
||||
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<Idx> {
|
||||
pub start: Idx,
|
||||
|
||||
Reference in New Issue
Block a user