Skip to content

Commit 884e375

Browse files
committed
Add test verifying that changing comments recompiles dependents
1 parent 4e97337 commit 884e375

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
436436
assert!(
437437
last_pos <= position,
438438
"make sure that the calls to `lazy*` \
439-
are in the same order as the metadata fields",
439+
are in the same order as the metadata fields",
440440
);
441441
position.get() - last_pos.get()
442442
}
@@ -1711,7 +1711,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17111711

17121712
record_array!(self.tables.module_children_non_reexports[def_id] <-
17131713
module_children.iter().filter(|child| child.reexport_chain.is_empty())
1714-
.map(|child| child.res.def_id().index));
1714+
.map(|child| child.res.def_id().index));
17151715

17161716
record_defaulted_array!(self.tables.module_children_reexports[def_id] <-
17171717
module_children.iter().filter(|child| !child.reexport_chain.is_empty()));
@@ -1760,7 +1760,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17601760
if matches!(rpitit_info, ty::ImplTraitInTraitData::Trait { .. }) {
17611761
record_array!(
17621762
self.tables.assumed_wf_types_for_rpitit[def_id]
1763-
<- self.tcx.assumed_wf_types_for_rpitit(def_id)
1763+
<- self.tcx.assumed_wf_types_for_rpitit(def_id)
17641764
);
17651765
self.encode_precise_capturing_args(def_id);
17661766
}
@@ -1843,7 +1843,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18431843
for &local_def_id in tcx.mir_keys(()) {
18441844
if let DefKind::AssocFn | DefKind::Fn = tcx.def_kind(local_def_id) {
18451845
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
1846-
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
1846+
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
18471847
}
18481848
}
18491849
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_name = "foo"]
2+
#![crate_type = "lib"]
3+
// bbb
4+
pub struct Foo;
5+
6+
impl Foo {
7+
pub fn bar(self: Foo) {}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_name = "foo"]
2+
#![crate_type = "lib"]
3+
// aaa
4+
pub struct Foo;
5+
6+
impl Foo {
7+
pub fn bar(self: Foo) {}
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// tests that we can reuse an existing rlib instead of rebuilding
2+
// when changin a non-doc comments in a file
3+
use run_make_support::{rfs, rustc};
4+
use std::path::Path;
5+
use std::hash::{Hash, Hasher};
6+
7+
fn main() {
8+
let before = check_and_hash("before.rs");
9+
let after = check_and_hash("after.rs");
10+
dbg!(before, after);
11+
assert_eq!(before, after);
12+
}
13+
14+
fn check_and_hash<P>(filename: P) -> u64
15+
where
16+
P: AsRef<Path>,
17+
{
18+
rfs::rename(filename, "foo.rs");
19+
rustc().input("foo.rs").emit("metadata").run();
20+
// hash the output
21+
let bytes = rfs::read("libfoo.rmeta");
22+
let mut hasher = std::hash::DefaultHasher::new();
23+
bytes.hash(&mut hasher);
24+
hasher.finish()
25+
}

0 commit comments

Comments
 (0)