Skip to content

Commit

Permalink
More lints
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Dec 3, 2024
1 parent a2d9bbe commit 4921619
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion crates/rustc_utils/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ mod test {
}
}

let cache = RecursiveUse(Default::default());
let cache = RecursiveUse(Cache::default());

assert_eq!(cache.get_infinite_recursion(60), 42);
assert_eq!(cache.get_safe_recursion(5), 15);
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_utils/src/hir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ mod test {

#[test]
fn test_ty_ext() {
let input = r#"
let input = r"
fn main() {
let x = &mut 0;
let y = 0;
}"#;
}";

test_utils::compile_body(input, |tcx, _, body| {
let body = &body.body;
Expand Down
16 changes: 8 additions & 8 deletions crates/rustc_utils/src/mir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ mod test {

#[test]
fn test_body_ext() {
let input = r#"
fn foobar<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
if *x > 0 {
return x;
}
y
}"#;
let input = r"
fn foobar<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
if *x > 0 {
return x;
}
y
}";

test_utils::compile_body(input, |_, _, body| {
let body = &body.body;
Expand Down
16 changes: 8 additions & 8 deletions crates/rustc_utils/src/mir/control_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ mod test {

#[test]
fn test_control_dependencies() {
let input = r#"
fn main() {
let mut x = 1;
x = 2;
if true { x = 3; }
for _ in 0 .. 1 { x = 4; }
x = 5;
}"#;
let input = r"
fn main() {
let mut x = 1;
x = 2;
if true { x = 3; }
for _ in 0 .. 1 { x = 4; }
x = 5;
}";
test_utils::compile_body(input, move |tcx, _, body_with_facts| {
let body = &body_with_facts.body;
let control_deps = body.control_dependencies();
Expand Down
13 changes: 6 additions & 7 deletions crates/rustc_utils/src/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,15 @@ mod test {

#[test]
fn test_place_arg_direct() {
let input = r#"
let input = r"
fn foobar(x: &i32) {
let y = 1;
let z = &y;
let k = Box::new(*x);
let ref_k = &k;
let box_ref = Box::new(x);
}
"#;
";
test_utils::compile_body(input, |tcx, _, body_with_facts| {
let body = &body_with_facts.body;
let name_map = body.debug_info_name_map();
Expand Down Expand Up @@ -706,16 +706,15 @@ fn foobar(x: &i32) {

#[test]
fn test_place_to_string() {
let input = r#"
let input = r"
struct Point { x: usize, y: usize }
fn main() {
let x = (0, 0);
let y = Some(1);
let z = &[Some((0, 1))];
let w = (&y,);
let p = &Point { x: 0, y: 0 };
}
"#;
}";
test_utils::compile_body(input, |tcx, _, body_with_facts| {
let body = &body_with_facts.body;
let p = Placer::new(tcx, body);
Expand Down Expand Up @@ -753,12 +752,12 @@ fn main() {

#[test]
fn test_place_visitors() {
let input = r#"
let input = r"
fn main() {
let x = 0;
let y = (0, &x);
}
"#;
";
fn callback<'tcx>(
tcx: TyCtxt<'tcx>,
body_id: BodyId,
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_utils/src/source_map/find_bodies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod test {

#[test]
fn test_find_bodies() {
let input = r#"
let input = r"
// Ignore constants
const C: usize = 0;
Expand All @@ -91,7 +91,7 @@ macro_rules! m {
// Ignore macro-generated bodies
m!{}
"#;
";
test_utils::CompileBuilder::new(input).compile(|CompileResult { tcx }| {
assert_eq!(find_bodies(tcx).len(), 3);
});
Expand Down
10 changes: 5 additions & 5 deletions crates/rustc_utils/src/source_map/spanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mod test {
&["w.0"],
&["w.0"],
];
for (input_span, desired) in spans.into_iter().zip(expected.into_iter()) {
for (input_span, desired) in spans.into_iter().zip(expected) {
let outputs = spanner.span_to_places(input_span);
let snippets = outputs
.into_iter()
Expand All @@ -298,8 +298,8 @@ mod test {
}

fn compare_sets(desired: &HashSet<impl AsRef<str>>, actual: &HashSet<impl AsRef<str>>) {
let desired = desired.iter().map(|s| s.as_ref()).collect::<HashSet<_>>();
let actual = actual.iter().map(|s| s.as_ref()).collect::<HashSet<_>>();
let desired = desired.iter().map(AsRef::as_ref).collect::<HashSet<_>>();
let actual = actual.iter().map(AsRef::as_ref).collect::<HashSet<_>>();
let missing_desired = &desired - &actual;
let missing_actual = &actual - &desired;

Expand All @@ -315,7 +315,7 @@ mod test {

#[test]
fn test_location_to_spans() {
let src = r#"fn foo() {
let src = r"fn foo() {
let mut x: i32 = 1;
let y = x + 2;
let w = if true {
Expand All @@ -329,7 +329,7 @@ mod test {
let q = x
.leading_ones()
.trailing_zeros();
}"#;
}";

// This affects source mapping, and this feature is primarily used by Flowistry, so
// we enable MIR simplification for consistency with Flowistry.
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_utils/src/source_map/spanner/span_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod test {
.map(|(_, t)| t)
.copied()
.collect::<Vec<_>>();
result.sort();
result.sort_unstable();
result
};

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_utils/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ mod test {
end: BytePos(3),
filename: *filename,
},
])
]);
});
}
}

0 comments on commit 4921619

Please sign in to comment.