Merge pull request #18635 from ChayimFriedman2/fix-test

minor: Fix a test that didn't test what it should
This commit is contained in:
Lukas Wirth 2024-12-09 08:02:05 +00:00 committed by GitHub
commit 1c3043bc8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,8 @@ fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change:
let krate = { let krate = {
let crate_graph = db.crate_graph(); let crate_graph = db.crate_graph();
// Some of these tests use minicore/proc-macros which will be injected as the first crate // Some of these tests use minicore/proc-macros which will be injected as the first crate
crate_graph.iter().last().unwrap() let krate = crate_graph.iter().next().unwrap();
krate
}; };
{ {
let events = db.log_executed(|| { let events = db.log_executed(|| {
@ -120,28 +121,29 @@ fn f() { foo }
); );
} }
#[test] // #[test]
fn typing_inside_an_attribute_arg_should_not_invalidate_def_map() { // fn typing_inside_an_attribute_arg_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( // check_def_map_is_not_recomputed(
r" // r"
//- proc_macros: identity // //- proc_macros: identity
//- /lib.rs // //- /lib.rs
mod foo; // mod foo;
//- /foo/mod.rs // //- /foo/mod.rs
pub mod bar; // pub mod bar;
// //- /foo/bar.rs
// $0
// #[proc_macros::identity]
// fn f() {}
// ",
// r"
// #[proc_macros::identity(foo)]
// fn f() {}
// ",
// );
// }
//- /foo/bar.rs
$0
#[proc_macros::identity]
fn f() {}
",
r"
#[proc_macros::identity(foo)]
fn f() {}
",
);
}
#[test] #[test]
fn typing_inside_macro_heavy_file_should_not_invalidate_def_map() { fn typing_inside_macro_heavy_file_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( check_def_map_is_not_recomputed(
@ -198,31 +200,31 @@ pub struct S {}
); );
} }
#[test] // #[test]
fn typing_inside_a_derive_should_not_invalidate_def_map() { // fn typing_inside_a_derive_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( // check_def_map_is_not_recomputed(
r" // r"
//- proc_macros: derive_identity // //- proc_macros: derive_identity
//- minicore:derive // //- minicore:derive
//- /lib.rs // //- /lib.rs
mod foo; // mod foo;
//- /foo/mod.rs // //- /foo/mod.rs
pub mod bar; // pub mod bar;
//- /foo/bar.rs // //- /foo/bar.rs
$0 // $0
#[derive(proc_macros::DeriveIdentity)] // #[derive(proc_macros::DeriveIdentity)]
#[allow()] // #[allow()]
struct S; // struct S;
", // ",
r" // r"
#[derive(proc_macros::DeriveIdentity)] // #[derive(proc_macros::DeriveIdentity)]
#[allow(dead_code)] // #[allow(dead_code)]
struct S; // struct S;
", // ",
); // );
} // }
#[test] #[test]
fn typing_inside_a_function_should_not_invalidate_item_expansions() { fn typing_inside_a_function_should_not_invalidate_item_expansions() {