mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
internal: switch some tests to minicore
This commit is contained in:
parent
0475201538
commit
7ebac5e54c
3 changed files with 75 additions and 62 deletions
|
@ -426,15 +426,15 @@ fn coerce_autoderef() {
|
||||||
#[test]
|
#[test]
|
||||||
fn coerce_autoderef_generic() {
|
fn coerce_autoderef_generic() {
|
||||||
check_infer_with_mismatches(
|
check_infer_with_mismatches(
|
||||||
r"
|
r#"
|
||||||
struct Foo;
|
struct Foo;
|
||||||
fn takes_ref<T>(x: &T) -> T { *x }
|
fn takes_ref<T>(x: &T) -> T { *x }
|
||||||
fn test() {
|
fn test() {
|
||||||
takes_ref(&Foo);
|
takes_ref(&Foo);
|
||||||
takes_ref(&&Foo);
|
takes_ref(&&Foo);
|
||||||
takes_ref(&&&Foo);
|
takes_ref(&&&Foo);
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
expect![[r"
|
expect![[r"
|
||||||
28..29 'x': &T
|
28..29 'x': &T
|
||||||
40..46 '{ *x }': T
|
40..46 '{ *x }': T
|
||||||
|
@ -464,30 +464,29 @@ fn coerce_autoderef_generic() {
|
||||||
fn coerce_autoderef_block() {
|
fn coerce_autoderef_block() {
|
||||||
check_infer_with_mismatches(
|
check_infer_with_mismatches(
|
||||||
r#"
|
r#"
|
||||||
struct String {}
|
//- minicore: deref
|
||||||
#[lang = "deref"]
|
struct String {}
|
||||||
trait Deref { type Target; }
|
impl core::ops::Deref for String { type Target = str; }
|
||||||
impl Deref for String { type Target = str; }
|
fn takes_ref_str(x: &str) {}
|
||||||
fn takes_ref_str(x: &str) {}
|
fn returns_string() -> String { loop {} }
|
||||||
fn returns_string() -> String { loop {} }
|
fn test() {
|
||||||
fn test() {
|
|
||||||
takes_ref_str(&{ returns_string() });
|
takes_ref_str(&{ returns_string() });
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r"
|
expect![[r#"
|
||||||
126..127 'x': &str
|
90..91 'x': &str
|
||||||
135..137 '{}': ()
|
99..101 '{}': ()
|
||||||
168..179 '{ loop {} }': String
|
132..143 '{ loop {} }': String
|
||||||
170..177 'loop {}': !
|
134..141 'loop {}': !
|
||||||
175..177 '{}': ()
|
139..141 '{}': ()
|
||||||
190..235 '{ ... }); }': ()
|
154..199 '{ ... }); }': ()
|
||||||
196..209 'takes_ref_str': fn takes_ref_str(&str)
|
160..173 'takes_ref_str': fn takes_ref_str(&str)
|
||||||
196..232 'takes_...g() })': ()
|
160..196 'takes_...g() })': ()
|
||||||
210..231 '&{ ret...ng() }': &String
|
174..195 '&{ ret...ng() }': &String
|
||||||
211..231 '{ retu...ng() }': String
|
175..195 '{ retu...ng() }': String
|
||||||
213..227 'returns_string': fn returns_string() -> String
|
177..191 'returns_string': fn returns_string() -> String
|
||||||
213..229 'return...ring()': String
|
177..193 'return...ring()': String
|
||||||
"]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -780,10 +780,7 @@ fn test() { (&S).foo(); }
|
||||||
fn method_resolution_unsize_array() {
|
fn method_resolution_unsize_array() {
|
||||||
check_types(
|
check_types(
|
||||||
r#"
|
r#"
|
||||||
#[lang = "slice"]
|
//- minicore: slice
|
||||||
impl<T> [T] {
|
|
||||||
fn len(&self) -> usize { loop {} }
|
|
||||||
}
|
|
||||||
fn test() {
|
fn test() {
|
||||||
let a = [1, 2, 3];
|
let a = [1, 2, 3];
|
||||||
a.len();
|
a.len();
|
||||||
|
@ -1178,11 +1175,7 @@ fn main() {
|
||||||
fn autoderef_visibility_field() {
|
fn autoderef_visibility_field() {
|
||||||
check_infer(
|
check_infer(
|
||||||
r#"
|
r#"
|
||||||
#[lang = "deref"]
|
//- minicore: deref
|
||||||
pub trait Deref {
|
|
||||||
type Target;
|
|
||||||
fn deref(&self) -> &Self::Target;
|
|
||||||
}
|
|
||||||
mod a {
|
mod a {
|
||||||
pub struct Foo(pub char);
|
pub struct Foo(pub char);
|
||||||
pub struct Bar(i32);
|
pub struct Bar(i32);
|
||||||
|
@ -1191,7 +1184,7 @@ mod a {
|
||||||
Self(0)
|
Self(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl super::Deref for Bar {
|
impl core::ops::Deref for Bar {
|
||||||
type Target = Foo;
|
type Target = Foo;
|
||||||
fn deref(&self) -> &Foo {
|
fn deref(&self) -> &Foo {
|
||||||
&Foo('z')
|
&Foo('z')
|
||||||
|
@ -1205,22 +1198,21 @@ mod b {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
67..71 'self': &Self
|
107..138 '{ ... }': Bar
|
||||||
200..231 '{ ... }': Bar
|
121..125 'Self': Bar(i32) -> Bar
|
||||||
214..218 'Self': Bar(i32) -> Bar
|
121..128 'Self(0)': Bar
|
||||||
214..221 'Self(0)': Bar
|
126..127 '0': i32
|
||||||
219..220 '0': i32
|
226..230 'self': &Bar
|
||||||
315..319 'self': &Bar
|
240..273 '{ ... }': &Foo
|
||||||
329..362 '{ ... }': &Foo
|
254..263 '&Foo('z')': &Foo
|
||||||
343..352 '&Foo('z')': &Foo
|
255..258 'Foo': Foo(char) -> Foo
|
||||||
344..347 'Foo': Foo(char) -> Foo
|
255..263 'Foo('z')': Foo
|
||||||
344..352 'Foo('z')': Foo
|
259..262 ''z'': char
|
||||||
348..351 ''z'': char
|
303..350 '{ ... }': ()
|
||||||
392..439 '{ ... }': ()
|
317..318 'x': char
|
||||||
406..407 'x': char
|
321..339 'super:...r::new': fn new() -> Bar
|
||||||
410..428 'super:...r::new': fn new() -> Bar
|
321..341 'super:...:new()': Bar
|
||||||
410..430 'super:...:new()': Bar
|
321..343 'super:...ew().0': char
|
||||||
410..432 'super:...ew().0': char
|
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
//!
|
//!
|
||||||
//! Available flags:
|
//! Available flags:
|
||||||
//! sized:
|
//! sized:
|
||||||
|
//! slice:
|
||||||
//! unsize: sized
|
//! unsize: sized
|
||||||
|
//! deref: sized
|
||||||
//! coerce_unsized: unsize
|
//! coerce_unsized: unsize
|
||||||
|
|
||||||
pub mod marker {
|
pub mod marker {
|
||||||
|
@ -27,8 +29,8 @@ pub mod marker {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod ops {
|
pub mod ops {
|
||||||
mod unsize {
|
|
||||||
// region:coerce_unsized
|
// region:coerce_unsized
|
||||||
|
mod unsize {
|
||||||
use crate::marker::Unsize;
|
use crate::marker::Unsize;
|
||||||
|
|
||||||
#[lang = "coerce_unsized"]
|
#[lang = "coerce_unsized"]
|
||||||
|
@ -45,12 +47,32 @@ pub mod ops {
|
||||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
|
||||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
|
||||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
|
||||||
// endregion:coerce_unsized
|
|
||||||
}
|
}
|
||||||
|
pub use self::unsize::CoerceUnsized;
|
||||||
|
// endregion:coerce_unsized
|
||||||
|
|
||||||
pub use self::unsize::CoerceUnsized; // :coerce_unsized
|
// region:deref
|
||||||
|
mod deref {
|
||||||
|
#[lang = "deref"]
|
||||||
|
pub trait Deref {
|
||||||
|
#[lang = "deref_target"]
|
||||||
|
type Target: ?Sized;
|
||||||
|
fn deref(&self) -> &Self::Target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub use self::deref::Deref;
|
||||||
|
// endregion:deref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// region:slice
|
||||||
|
pub mod slice {
|
||||||
|
#[lang = "slice"]
|
||||||
|
impl<T> [T] {
|
||||||
|
pub fn len(&self) -> usize { loop {} }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion:slice
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub mod v1 {
|
pub mod v1 {
|
||||||
pub use crate::marker::Sized; // :sized
|
pub use crate::marker::Sized; // :sized
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue