-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidy watcher #114209
base: master
Are you sure you want to change the base?
tidy watcher #114209
Conversation
This comment has been minimized.
This comment has been minimized.
8b8f8f8
to
434286f
Compare
Added few more entries a49ed53, but i don't know if all of them actually sync as of now, this should be reviewed. |
a49ed53
to
ca2cbb3
Compare
☔ The latest upstream changes (presumably #114294) made this pull request unmergeable. Please resolve the merge conflicts. |
ca2cbb3
to
3f2a374
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #115795) made this pull request unmergeable. Please resolve the merge conflicts. |
3f2a374
to
e4c6a7c
Compare
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes might have occurred in exhaustiveness checking cc @Nadrieril Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
Okay. Implementation is trivial, but most of asserted pieces of code in compiler, so r? compiler. Didn't checked if current state is sync, as i don't always understand whats functions do. |
@@ -149,6 +149,7 @@ where | |||
None => { | |||
// For unsized types with an extern type tail we perform no adjustments. | |||
// NOTE: keep this in sync with `PlaceRef::project_field` in the codegen backend. | |||
// FIXME: that one? compiler/rustc_codegen_ssa/src/mir/place.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically this:
rust/compiler/rustc_codegen_ssa/src/mir/place.rs
Lines 148 to 154 in 79bfd93
_ if self.llextra.is_none() => { | |
debug!( | |
"unsized field `{}`, of `{:?}` has no metadata for adjustment", | |
ix, self.llval | |
); | |
return simple(); | |
} |
I don't see how an automatic checker can help here. This is about keeping the semantics in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just run over codebase, found few comments like "keep in sync with" and wrapped them in tags. Of course this check can't say if two places is valid, only ping author to give it chance to check things manually.
This needs to give very clear guidance on what I should do now, otherwise it will be very frustrating. |
It slightly more descriptive, forgot to update first message, but can be improved. |
@@ -1144,6 +1150,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { | |||
}) | |||
} | |||
|
|||
// tidy-ticket-wildcards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected that we reuse the tag for all the places that need to be in sync. E.g. if I modify wildcards()
here and not arity()
, it would ping me "you should also check arity
".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added grouping for tags, should write
tidy error: hash for tag `tidy-ticket-ast-from_token` in path `compiler/rustc_ast/src/token.rs` mismatch:
actual: `eecacc0fe4c615f7c71409c3ebfcff80`, expected: `70666de80ab0194a67524deeda3c01b8`
Verify that tags `["tidy-ticket-ast-from_token", "tidy-ticket-ast-can_begin_literal_maybe_minus", "tidy-ticket-rustc_p
arse-can_begin_literal_maybe_minus"]` in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Could you make it explain what it's about for those who don't know? Something like: "the code block tagged with tidy-ticket-ast-from_token
has changed. It's likely that code blocks with the following tags need to be changed too. Once that is done, run tidy
again with the --blessed
flag to update the hashes. The related tags are ["tidy-ticket-ast-from_token", "tidy-ticket-ast-can_begin_literal_maybe_minus", "tidy-ticket-rustc_parse-can_begin_literal_maybe_minus"]
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tidy-keep-sync-with=
and updated error message with parts from your suggestion.
The tag should have a name that explains what it's for if we encounter it in code. Something like |
e4c6a7c
to
fa7b8ae
Compare
Don't want to implement smarter parsing for tags (at least for now), can just make it longer, like Anyway, accidental removing of tag from code will enrage tidy, which will say something special about it. |
You don't need to do any parsing, just allow "=" in the list of allowed symbols in a tag. I just think it's more legible |
You might want to wait and see if compiler contributors actually want this before investing more time in it though. As far as I am concerned this adds unnecessary friction; I'm waiting to hear from ppl who work on files where this would be helpful. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Re-nominating this PR for T-compiler triage meeting to gauge team interest. Notes for T-compiler triage meetingThis experimental PR proposes a tidy watcher mechanism which is intended to check if pieces of code between multiple locations are kept in sync properly by comparing their hashes.
How does the team feel about such a mechanism:
Known implementation limitations and concerns (as of writing this comment)
@rustbot label +I-compiler-nominated +S-waiting-on-team -S-waiting-on-author Also cc @rust-lang/bootstrap because this concerns tidy which we (T-bootstrap) maintain. |
This PR was already discussed: https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-10-26/near/398708149, so i need rebase this stuff and reread it again. |
0b311d0
to
429ca32
Compare
Some changes occurred in cfg and check-cfg configuration cc @Urgau Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in coverage instrumentation. cc @Zalathar |
Is there any way this could be automated? Currently this all seems somewhat tedious to use. |
Okay, rebased. Current state: rebased with almost mindlessly reapplied checks (so need to review if linked pieces of code actually sync) and added more fixme's to sync more codepieces.
Yes, i'm thinking about way to implement |
There exist https://github.com/stepchowfun/tagref with somehow similar idea, but looks like it can only check existence of tag links, not content. |
@@ -109,6 +109,7 @@ fn coverage_ids_info<'tcx>( | |||
// to any particular point in the control-flow graph. | |||
// (Keep this in sync with the injection of `ExpressionUsed` | |||
// statements in the `InstrumentCoverage` MIR pass.) | |||
// FIXME: sync me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a semantic sync rather than a data sync, and violating it would cause a bunch of tests to break, so it's probably not worth the hassle of adding sync-check tags here.
impl bless
Okay, bless works; but saving state into json still ugly. |
This comment has been minimized.
This comment has been minimized.
@@ -176,6 +176,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { | |||
// | |||
// NOTE: These insertions should be kept in sync with | |||
// `CheckCfg::fill_well_known` below. | |||
// FIXME: sync me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default_configuration
and CheckCfg::fill_well_known
are loosely synced, there are some cfgs in default_configuration
like emscripten_wasm_eh
that shouldn't be in CheckCfg::fill_well_known
and the inverse is also for some cfgs (miri
, rustfmt
, ...).
Is it possible to still apply this tidy annotation in that case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr/feature can only assert that some spans unchanged, nothing more. It's up to author/reviewer check actual content. Should i wrap entire default_configuration/fill_well_known fns?
This PR modifies If appropriate, please update |
// tidy-keep-sync-with=tidy-ticket-sess-time-item_types_checking | ||
// NOTE: These are copy/pasted from typeck/lib.rs and should be kept in sync with those changes. | ||
let _ = tcx.sess.time("wf_checking", || { | ||
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module)) | ||
}); | ||
// tidy-keep-sync-with=tidy-ticket-sess-time-item_types_checking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks clearly desynced (or not), only similar thing is
rust/compiler/rustc_hir_analysis/src/lib.rs
Lines 140 to 151 in 8e59cf9
tcx.sess.time("coherence_checking", || { | |
tcx.hir().par_for_each_module(|module| { | |
let _ = tcx.ensure().check_mod_type_wf(module); | |
}); | |
for &trait_def_id in tcx.all_local_trait_impls(()).keys() { | |
let _ = tcx.ensure().coherent_trait(trait_def_id); | |
} | |
// these queries are executed for side-effects (error reporting): | |
let _ = tcx.ensure().crate_inherent_impls_validity_check(()); | |
let _ = tcx.ensure().crate_inherent_impls_overlap_check(()); | |
}); |
☔ The latest upstream changes (presumably #135678) made this pull request unmergeable. Please resolve the merge conflicts. |
MVP of tidy watcher:
Allows to check that changes to some pieces of text synced in different files (or at least warn about it). Should resolve situations like: "Oh no, I've changed that constant here and here, but forgot to update it in other 3 places."
Current state is very MVP'ish, so it simply works and nothing more, posted to get some feedback.
Usage: wrap text that need to be synced with arbitrarily chosen tags:
some.rs:
some.sh:
and add them to
watcher.rs
in tidy, adding into one group:If hashes differs, actual and expected ones will be printed:
Added few
sync me
commented code as examples.--bless
implemented, but i don't like currentjson
config, it's huge.r? @ghost