mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Add a test
This commit is contained in:
parent
b7596d2483
commit
9a72b7bccd
1 changed files with 39 additions and 23 deletions
|
@ -228,6 +228,8 @@ fn hint_iterator(
|
|||
_ => None,
|
||||
})?;
|
||||
if let Some(ty) = ty.normalize_trait_assoc_type(db, iter_trait, &[], assoc_type_item) {
|
||||
// TODO kb also check for the iterator impls for this ty
|
||||
dbg!(ty.display(db).to_string());
|
||||
const LABEL_START: &str = "impl Iterator<Item = ";
|
||||
const LABEL_END: &str = ">";
|
||||
|
||||
|
@ -1002,18 +1004,6 @@ fn main() {
|
|||
|
||||
println!("Unit expr");
|
||||
}
|
||||
|
||||
//- /alloc.rs crate:alloc deps:core
|
||||
mod collections {
|
||||
struct Vec<T> {}
|
||||
impl<T> Vec<T> {
|
||||
fn new() -> Self { Vec {} }
|
||||
fn push(&mut self, t: T) { }
|
||||
}
|
||||
impl<T> IntoIterator for Vec<T> {
|
||||
type Item=T;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -1043,17 +1033,6 @@ fn main() {
|
|||
//^ &str
|
||||
}
|
||||
}
|
||||
//- /alloc.rs crate:alloc deps:core
|
||||
mod collections {
|
||||
struct Vec<T> {}
|
||||
impl<T> Vec<T> {
|
||||
fn new() -> Self { Vec {} }
|
||||
fn push(&mut self, t: T) { }
|
||||
}
|
||||
impl<T> IntoIterator for Vec<T> {
|
||||
type Item=T;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -1183,4 +1162,41 @@ fn main() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shorten_iterators_in_associated_params() {
|
||||
check_with_config(
|
||||
InlayHintsConfig {
|
||||
parameter_hints: false,
|
||||
type_hints: true,
|
||||
chaining_hints: true,
|
||||
max_length: None,
|
||||
},
|
||||
r#"
|
||||
use core::iter;
|
||||
|
||||
pub struct SomeIter<T> {}
|
||||
|
||||
impl<T> SomeIter<T> {
|
||||
pub fn new() -> Self { SomeIter {} }
|
||||
pub fn push(&mut self, t: T) {}
|
||||
}
|
||||
|
||||
impl<T> Iterator for SomeIter<T> {
|
||||
type Item = T;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut some_iter = SomeIter::new();
|
||||
//^^^^^^^^^^^^^ SomeIter<Take<Repeat<i32>>>
|
||||
some_iter.push(iter::repeat(2).take(2));
|
||||
let zz = some_iter.take(2);
|
||||
//^^ impl Iterator<Item = Take<Repeat<i32>>>
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue