internal: switch some tests to minicore
This commit is contained in:
parent
7b4f5c0262
commit
9b3aa591cd
3 changed files with 50 additions and 17 deletions
|
|
@ -434,7 +434,6 @@ fn get_callable(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use expect_test::{expect, Expect};
|
||||
use ide_db::helpers::FamousDefs;
|
||||
use test_utils::extract_annotations;
|
||||
|
||||
use crate::{fixture, inlay_hints::InlayHintsConfig};
|
||||
|
|
@ -487,8 +486,6 @@ mod tests {
|
|||
}
|
||||
|
||||
fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) {
|
||||
let ra_fixture =
|
||||
format!("//- /main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE);
|
||||
let (analysis, file_id) = fixture::file(&ra_fixture);
|
||||
let expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
|
||||
let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap();
|
||||
|
|
@ -498,8 +495,6 @@ mod tests {
|
|||
}
|
||||
|
||||
fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
|
||||
let ra_fixture =
|
||||
format!("//- /main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE);
|
||||
let (analysis, file_id) = fixture::file(&ra_fixture);
|
||||
let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap();
|
||||
expect.assert_debug_eq(&inlay_hints)
|
||||
|
|
@ -823,6 +818,7 @@ fn main() {
|
|||
fn shorten_iterators_in_associated_params() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: iterator
|
||||
use core::iter;
|
||||
|
||||
pub struct SomeIter<T> {}
|
||||
|
|
@ -875,7 +871,7 @@ fn main() {
|
|||
fn fn_hints() {
|
||||
check_types(
|
||||
r#"
|
||||
trait Sized {}
|
||||
//- minicore: fn, sized
|
||||
|
||||
fn foo() -> impl Fn() { loop {} }
|
||||
fn foo1() -> impl Fn(f64) { loop {} }
|
||||
|
|
@ -1073,6 +1069,7 @@ fn main() {
|
|||
fn complete_for_hint() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: iterator
|
||||
pub struct Vec<T> {}
|
||||
|
||||
impl<T> Vec<T> {
|
||||
|
|
@ -1129,6 +1126,7 @@ fn main() {
|
|||
fn shorten_iterator_hints() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: iterator
|
||||
use core::iter;
|
||||
|
||||
struct MyIter;
|
||||
|
|
@ -1230,12 +1228,12 @@ fn main() {
|
|||
expect![[r#"
|
||||
[
|
||||
InlayHint {
|
||||
range: 148..173,
|
||||
range: 147..172,
|
||||
kind: ChainingHint,
|
||||
label: "B",
|
||||
},
|
||||
InlayHint {
|
||||
range: 148..155,
|
||||
range: 147..154,
|
||||
kind: ChainingHint,
|
||||
label: "A",
|
||||
},
|
||||
|
|
@ -1290,12 +1288,12 @@ fn main() {
|
|||
expect![[r#"
|
||||
[
|
||||
InlayHint {
|
||||
range: 144..191,
|
||||
range: 143..190,
|
||||
kind: ChainingHint,
|
||||
label: "C",
|
||||
},
|
||||
InlayHint {
|
||||
range: 144..180,
|
||||
range: 143..179,
|
||||
kind: ChainingHint,
|
||||
label: "B",
|
||||
},
|
||||
|
|
@ -1335,12 +1333,12 @@ fn main() {
|
|||
expect![[r#"
|
||||
[
|
||||
InlayHint {
|
||||
range: 247..284,
|
||||
range: 246..283,
|
||||
kind: ChainingHint,
|
||||
label: "B<X<i32, bool>>",
|
||||
},
|
||||
InlayHint {
|
||||
range: 247..266,
|
||||
range: 246..265,
|
||||
kind: ChainingHint,
|
||||
label: "A<X<i32, bool>>",
|
||||
},
|
||||
|
|
@ -1359,6 +1357,7 @@ fn main() {
|
|||
max_length: None,
|
||||
},
|
||||
r#"
|
||||
//- minicore: iterator
|
||||
use core::iter;
|
||||
|
||||
struct MyIter;
|
||||
|
|
@ -1381,22 +1380,22 @@ fn main() {
|
|||
expect![[r#"
|
||||
[
|
||||
InlayHint {
|
||||
range: 175..242,
|
||||
range: 174..241,
|
||||
kind: ChainingHint,
|
||||
label: "impl Iterator<Item = ()>",
|
||||
},
|
||||
InlayHint {
|
||||
range: 175..225,
|
||||
range: 174..224,
|
||||
kind: ChainingHint,
|
||||
label: "impl Iterator<Item = ()>",
|
||||
},
|
||||
InlayHint {
|
||||
range: 175..207,
|
||||
range: 174..206,
|
||||
kind: ChainingHint,
|
||||
label: "impl Iterator<Item = ()>",
|
||||
},
|
||||
InlayHint {
|
||||
range: 175..190,
|
||||
range: 174..189,
|
||||
kind: ChainingHint,
|
||||
label: "&mut MyIter",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ impl Fixture {
|
|||
let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
|
||||
|
||||
let path = components[0].to_string();
|
||||
assert!(path.starts_with('/'));
|
||||
assert!(path.starts_with('/'), "fixture path does not start with `/`: {:?}", path);
|
||||
|
||||
let mut krate = None;
|
||||
let mut deps = Vec::new();
|
||||
|
|
|
|||
|
|
@ -228,6 +228,28 @@ pub mod iter {
|
|||
}
|
||||
pub use self::adapters::Take;
|
||||
|
||||
mod sources {
|
||||
mod repeat {
|
||||
pub fn repeat<T>(elt: T) -> Repeat<T> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub struct Repeat<A> {
|
||||
element: A,
|
||||
}
|
||||
|
||||
impl<A> Iterator for Repeat<A> {
|
||||
type Item = A;
|
||||
|
||||
fn next(&mut self) -> Option<A> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use self::repeat::{repeat, Repeat};
|
||||
}
|
||||
pub use self::sources::{repeat, Repeat};
|
||||
|
||||
mod traits {
|
||||
mod iterator {
|
||||
use super::super::Take;
|
||||
|
|
@ -242,6 +264,18 @@ pub mod iter {
|
|||
fn take(self, n: usize) -> crate::iter::Take<Self> {
|
||||
loop {}
|
||||
}
|
||||
fn by_ref(&mut self) -> &mut Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self
|
||||
}
|
||||
}
|
||||
impl<I: Iterator + ?Sized> Iterator for &mut I {
|
||||
type Item = I::Item;
|
||||
fn next(&mut self) -> Option<I::Item> {
|
||||
(**self).next()
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use self::iterator::Iterator;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue