mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
tidy
This commit is contained in:
parent
f54a863965
commit
2f6923b844
2 changed files with 27 additions and 15 deletions
|
@ -363,7 +363,7 @@ impl SourceAnalyzer {
|
||||||
|
|
||||||
// [E0586] inclusive ranges must be bounded at the end
|
// [E0586] inclusive ranges must be bounded at the end
|
||||||
(RangeOp::Inclusive, None, None) => return None,
|
(RangeOp::Inclusive, None, None) => return None,
|
||||||
(RangeOp::Inclusive, Some(_), None) => return None
|
(RangeOp::Inclusive, Some(_), None) => return None,
|
||||||
};
|
};
|
||||||
self.resolver.resolve_known_struct(db.upcast(), &path)
|
self.resolver.resolve_known_struct(db.upcast(), &path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -453,71 +453,83 @@ mod tests {
|
||||||
let (analysis, position, _) = fixture::annotations(ra_fixture);
|
let (analysis, position, _) = fixture::annotations(ra_fixture);
|
||||||
let navs = analysis.goto_definition(position).unwrap().expect("no definition found").info;
|
let navs = analysis.goto_definition(position).unwrap().expect("no definition found").info;
|
||||||
assert!(navs.len() < 2, "expected single navigation target but encountered {}", navs.len());
|
assert!(navs.len() < 2, "expected single navigation target but encountered {}", navs.len());
|
||||||
let Some(target) = navs.into_iter().next() else {
|
let Some(target) = navs.into_iter().next() else {
|
||||||
panic!("expected single navigation target but encountered none");
|
panic!("expected single navigation target but encountered none");
|
||||||
};
|
};
|
||||||
assert_eq!(target.name, SmolStr::new_inline(expected_name));
|
assert_eq!(target.name, SmolStr::new_inline(expected_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range() {
|
fn goto_def_range() {
|
||||||
check_name("Range", r#"
|
check_name(
|
||||||
|
"Range",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
let x = 0.$0.1;
|
let x = 0.$0.1;
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range_from() {
|
fn goto_def_range_from() {
|
||||||
check_name("RangeFrom", r#"
|
check_name(
|
||||||
|
"RangeFrom",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
fn f(arr: &[i32]) -> &[i32] {
|
fn f(arr: &[i32]) -> &[i32] {
|
||||||
&arr[0.$0.]
|
&arr[0.$0.]
|
||||||
}
|
}
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range_inclusive() {
|
fn goto_def_range_inclusive() {
|
||||||
check_name("RangeInclusive", r#"
|
check_name(
|
||||||
|
"RangeInclusive",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
let x = 0.$0.=1;
|
let x = 0.$0.=1;
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range_full() {
|
fn goto_def_range_full() {
|
||||||
check_name("RangeFull", r#"
|
check_name(
|
||||||
|
"RangeFull",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
fn f(arr: &[i32]) -> &[i32] {
|
fn f(arr: &[i32]) -> &[i32] {
|
||||||
&arr[.$0.]
|
&arr[.$0.]
|
||||||
}
|
}
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range_to() {
|
fn goto_def_range_to() {
|
||||||
check_name("RangeTo", r#"
|
check_name(
|
||||||
|
"RangeTo",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
fn f(arr: &[i32]) -> &[i32] {
|
fn f(arr: &[i32]) -> &[i32] {
|
||||||
&arr[.$0.10]
|
&arr[.$0.10]
|
||||||
}
|
}
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_range_to_inclusive() {
|
fn goto_def_range_to_inclusive() {
|
||||||
check_name("RangeToInclusive", r#"
|
check_name(
|
||||||
|
"RangeToInclusive",
|
||||||
|
r#"
|
||||||
//- minicore: range
|
//- minicore: range
|
||||||
fn f(arr: &[i32]) -> &[i32] {
|
fn f(arr: &[i32]) -> &[i32] {
|
||||||
&arr[.$0.=10]
|
&arr[.$0.=10]
|
||||||
}
|
}
|
||||||
"#
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue