Skip to content

Commit de8b9e3

Browse files
committed
MVP of tidy watcher
1 parent 46455dc commit de8b9e3

File tree

37 files changed

+276
-8
lines changed

37 files changed

+276
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5463,6 +5463,7 @@ dependencies = [
54635463
"cargo_metadata 0.15.4",
54645464
"ignore",
54655465
"lazy_static",
5466+
"md-5",
54665467
"miropt-test-tools",
54675468
"regex",
54685469
"semver",

compiler/rustc_ast/src/token.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl Lit {
104104
}
105105
}
106106

107+
// tidy-ticket-ast-from_token
107108
/// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation.
108109
pub fn from_token(token: &Token) -> Option<Lit> {
109110
match token.uninterpolate().kind {
@@ -118,6 +119,7 @@ impl Lit {
118119
_ => None,
119120
}
120121
}
122+
// tidy-ticket-ast-from_token
121123
}
122124

123125
impl fmt::Display for Lit {
@@ -571,6 +573,7 @@ impl Token {
571573
///
572574
/// In other words, would this token be a valid start of `parse_literal_maybe_minus`?
573575
///
576+
// tidy-ticket-ast-can_begin_literal_maybe_minus
574577
/// Keep this in sync with and `Lit::from_token`, excluding unary negation.
575578
pub fn can_begin_literal_maybe_minus(&self) -> bool {
576579
match self.uninterpolate().kind {
@@ -590,6 +593,7 @@ impl Token {
590593
_ => false,
591594
}
592595
}
596+
// tidy-ticket-ast-can_begin_literal_maybe_minus
593597

594598
/// A convenience function for matching on identifiers during parsing.
595599
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token

compiler/rustc_builtin_macros/src/assert/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
290290
}
291291
// Expressions that are not worth or can not be captured.
292292
//
293+
// tidy-ticket-all-expr-kinds
293294
// Full list instead of `_` to catch possible future inclusions and to
294295
// sync with the `rfc-2011-nicer-assert-messages/all-expr-kinds.rs` test.
295296
ExprKind::Assign(_, _, _)
@@ -321,6 +322,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
321322
| ExprKind::Yeet(_)
322323
| ExprKind::Become(_)
323324
| ExprKind::Yield(_) => {}
325+
// tidy-ticket-all-expr-kinds
324326
}
325327
}
326328

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
711711
}
712712
}
713713

714+
// tidy-ticket-short_description
714715
/// Generate a short description of this work item suitable for use as a thread name.
715716
fn short_description(&self) -> String {
716717
// `pthread_setname()` on *nix ignores anything beyond the first 15
@@ -758,6 +759,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
758759
WorkItem::LTO(m) => desc("lto", "LTO module", m.name()),
759760
}
760761
}
762+
// tidy-ticket-short_description
761763
}
762764

763765
/// A result produced by the backend.

compiler/rustc_const_eval/src/interpret/projection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ where
167167
None => {
168168
// For unsized types with an extern type tail we perform no adjustments.
169169
// NOTE: keep this in sync with `PlaceRef::project_field` in the codegen backend.
170+
// FIXME: that one? compiler/rustc_codegen_ssa/src/mir/place.rs
170171
assert!(matches!(base_meta, MemPlaceMeta::None));
171172
(base_meta, offset)
172173
}

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
511511
Ok(true)
512512
}
513513
ty::Float(_) | ty::Int(_) | ty::Uint(_) => {
514+
// tidy-ticket-try_visit_primitive
514515
// NOTE: Keep this in sync with the array optimization for int/float
515516
// types below!
516517
self.read_scalar(
@@ -522,6 +523,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
522523
},
523524
)?;
524525
Ok(true)
526+
// tidy-ticket-try_visit_primitive
525527
}
526528
ty::RawPtr(..) => {
527529
let place =
@@ -784,6 +786,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
784786
}
785787
};
786788

789+
// tidy-ticket-visit_value
787790
// Optimization: we just check the entire range at once.
788791
// NOTE: Keep this in sync with the handling of integer and float
789792
// types above, in `visit_primitive`.
@@ -820,6 +823,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
820823
}
821824
}
822825
}
826+
// tidy-ticket-visit_value
823827
}
824828
// Fast path for arrays and slices of ZSTs. We only need to check a single ZST element
825829
// of an array and not all of them, because there's only a single value of a specific

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ bitflags::bitflags! {
125125
}
126126
}
127127

128+
// tidy-ticket-self-profile-events
128129
// keep this in sync with the `-Z self-profile-events` help message in rustc_session/options.rs
129130
const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
130131
("none", EventFilter::empty()),
@@ -142,6 +143,7 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
142143
("incr-result-hashing", EventFilter::INCR_RESULT_HASHING),
143144
("artifact-sizes", EventFilter::ARTIFACT_SIZES),
144145
];
146+
// tidy-ticket-self-profile-events
145147

146148
/// Something that uniquely identifies a query invocation.
147149
pub struct QueryInvocationId(pub u32);

compiler/rustc_errors/src/json.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ struct FutureIncompatReport {
322322
future_incompat_report: Vec<FutureBreakageItem>,
323323
}
324324

325+
// tidy-ticket-UnusedExterns
326+
// FIXME: where it located in cargo?
325327
// NOTE: Keep this in sync with the equivalent structs in rustdoc's
326328
// doctest component (as well as cargo).
327329
// We could unify this struct the one in rustdoc but they have different
@@ -333,6 +335,7 @@ struct UnusedExterns<'a, 'b, 'c> {
333335
/// List of unused externs by their names.
334336
unused_extern_names: &'b [&'c str],
335337
}
338+
// tidy-ticket-UnusedExterns
336339

337340
impl Diagnostic {
338341
fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
119119
visitor.cx.var_parent = visitor.cx.parent;
120120

121121
{
122+
// FIXME: sync with exactly where?
122123
// This block should be kept approximately in sync with
123124
// `intravisit::walk_block`. (We manually walk the block, rather
124125
// than call `walk_block`, in order to maintain precise

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,12 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
206206
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
207207
});
208208

209+
// tidy-ticket-sess-time-item_types_checking
209210
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
210211
tcx.sess.time("item_types_checking", || {
211212
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
212213
});
214+
// tidy-ticket-sess-time-item_types_checking
213215

214216
// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
215217
// only actually get emitted in `check_mod_item_types`.

compiler/rustc_middle/src/ty/util.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ impl<'tcx> TyCtxt<'tcx> {
653653
&& !self.is_foreign_item(def_id)
654654
}
655655

656+
// tidy-ticket-thread_local_ptr_ty
656657
/// Returns the type a reference to the thread local takes in MIR.
657658
pub fn thread_local_ptr_ty(self, def_id: DefId) -> Ty<'tcx> {
658659
let static_ty = self.type_of(def_id).instantiate_identity();
@@ -665,6 +666,7 @@ impl<'tcx> TyCtxt<'tcx> {
665666
Ty::new_imm_ref(self, self.lifetimes.re_static, static_ty)
666667
}
667668
}
669+
// tidy-ticket-thread_local_ptr_ty
668670

669671
/// Get the type of the pointer to the static that we use in MIR.
670672
pub fn static_ptr_ty(self, def_id: DefId) -> Ty<'tcx> {
@@ -674,7 +676,9 @@ impl<'tcx> TyCtxt<'tcx> {
674676
self.type_of(def_id).instantiate_identity(),
675677
);
676678

679+
// tidy-ticket-static_ptr_ty
677680
// Make sure that accesses to unsafe statics end up using raw pointers.
681+
// FIXME: should it said sync with thread_local_ptr_ty?
678682
// For thread-locals, this needs to be kept in sync with `Rvalue::ty`.
679683
if self.is_mutable_static(def_id) {
680684
Ty::new_mut_ptr(self, static_ty)
@@ -683,6 +687,7 @@ impl<'tcx> TyCtxt<'tcx> {
683687
} else {
684688
Ty::new_imm_ref(self, self.lifetimes.re_erased, static_ty)
685689
}
690+
// tidy-ticket-static_ptr_ty
686691
}
687692

688693
/// Return the set of types that should be taken into account when checking

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ impl<'tcx> Constructor<'tcx> {
703703
}
704704
}
705705

706+
// tidy-ticket-arity
706707
/// The number of fields for this constructor. This must be kept in sync with
707708
/// `Fields::wildcards`.
708709
pub(super) fn arity(&self, pcx: &PatCtxt<'_, '_, 'tcx>) -> usize {
@@ -736,6 +737,7 @@ impl<'tcx> Constructor<'tcx> {
736737
Or => bug!("The `Or` constructor doesn't have a fixed arity"),
737738
}
738739
}
740+
// tidy-ticket-arity
739741

740742
/// Some constructors (namely `Wildcard`, `IntRange` and `Slice`) actually stand for a set of
741743
/// actual constructors (like variants, integers or fixed-sized slices). When specializing for
@@ -1305,6 +1307,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
13051307
})
13061308
}
13071309

1310+
// tidy-ticket-wildcards
13081311
/// Creates a new list of wildcard fields for a given constructor. The result must have a
13091312
/// length of `constructor.arity()`.
13101313
#[instrument(level = "trace")]
@@ -1351,6 +1354,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
13511354
debug!(?ret);
13521355
ret
13531356
}
1357+
// tidy-ticket-wildcards
13541358

13551359
/// Returns the list of patterns.
13561360
pub(super) fn iter_patterns<'a>(

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,16 @@ fn merge_codegen_units<'tcx>(
472472
codegen_units.sort_by_key(|cgu| cmp::Reverse(cgu.size_estimate()));
473473
let num_digits = codegen_units.len().ilog10() as usize + 1;
474474
for (index, cgu) in codegen_units.iter_mut().enumerate() {
475+
// tidy-ticket-short_description
476+
// FIXME: is it sync?
475477
// Note: `WorkItem::short_description` depends on this name ending
476478
// with `-cgu.` followed by a numeric suffix. Please keep it in
477479
// sync with this code.
478480
let suffix = format!("{index:0num_digits$}");
479481
let numbered_codegen_unit_name =
480482
cgu_name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(suffix));
481483
cgu.set_name(numbered_codegen_unit_name);
484+
// tidy-ticket-short_description
482485
}
483486
}
484487
}

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ impl<'a> Parser<'a> {
20872087
}
20882088
}
20892089

2090+
// tidy-ticket-rustc_parse-can_begin_literal_maybe_minus
20902091
/// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
20912092
/// Keep this in sync with `Token::can_begin_literal_maybe_minus`.
20922093
pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
@@ -2103,6 +2104,7 @@ impl<'a> Parser<'a> {
21032104
Ok(expr)
21042105
}
21052106
}
2107+
// tidy-ticket-rustc_parse-can_begin_literal_maybe_minus
21062108

21072109
fn is_array_like_block(&mut self) -> bool {
21082110
self.look_ahead(1, |t| matches!(t.kind, TokenKind::Ident(..) | TokenKind::Literal(_)))

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ pub const fn default_lib_output() -> CrateType {
12491249

12501250
fn default_configuration(sess: &Session) -> Cfg {
12511251
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
1252+
// FIXME: what exactly sync there?
12521253
let end = &sess.target.endian;
12531254
let arch = &sess.target.arch;
12541255
let wordsz = sess.target.pointer_width.to_string();

compiler/rustc_session/src/config/sigpipe.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tidy-ticket-sigpipe
12
//! NOTE: Keep these constants in sync with `library/std/src/sys/unix/mod.rs`!
23
34
/// The default value if `#[unix_sigpipe]` is not specified. This resolves
@@ -23,3 +24,4 @@ pub const SIG_IGN: u8 = 2;
2324
/// such as `head -n 1`.
2425
#[allow(dead_code)]
2526
pub const SIG_DFL: u8 = 3;
27+
// tidy-ticket-sigpipe

compiler/rustc_session/src/options.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,12 +1779,15 @@ written to standard error output)"),
17791779
`instructions:u` (retired instructions, userspace-only)
17801780
`instructions-minus-irqs:u` (subtracting hardware interrupt counts for extra accuracy)"
17811781
),
1782-
/// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1782+
// tidy-ticket-self-profile-events
1783+
/// keep this in sync with the event filter names in rustc_data_structures/src/profiling.rs
17831784
self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
17841785
"specify the events recorded by the self profiler;
17851786
for example: `-Z self-profile-events=default,query-keys`
1786-
all options: none, all, default, generic-activity, query-provider, query-cache-hit
1787-
query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
1787+
all options: none, all, default, generic-activity, query-provider, query-cache-hit,
1788+
query-blocked, incr-cache-load, query-keys, function-args, args, llvm, incr-result-hashing, artifact-sizes"),
1789+
// tidy-ticket-self-profile-events
1790+
17881791
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
17891792
"make the current crate share its generic instantiations"),
17901793
show_span: Option<String> = (None, parse_opt_string, [TRACKED],

compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
213213
}
214214
}
215215

216+
// tidy-ticket-extract_tupled_inputs_and_output_from_callable
216217
// Returns a binder of the tupled inputs types and output type from a builtin callable type.
217218
pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
218219
tcx: TyCtxt<'tcx>,
@@ -234,6 +235,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
234235
Err(NoSolution)
235236
}
236237
}
238+
237239
// keep this in sync with assemble_fn_pointer_candidates until the old solver is removed.
238240
ty::FnPtr(sig) => {
239241
if sig.is_fn_trait_compatible() {
@@ -291,6 +293,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
291293
}
292294
}
293295
}
296+
// tidy-ticket-extract_tupled_inputs_and_output_from_callable
294297

295298
/// Assemble a list of predicates that would be present on a theoretical
296299
/// user impl for an object type. These predicates must be checked any time

compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ fn rematch_impl<'tcx>(
216216
Ok(Some(ImplSource::UserDefined(ImplSourceUserDefinedData { impl_def_id, args, nested })))
217217
}
218218

219+
// tidy-ticket-rematch_unsize
219220
/// The `Unsize` trait is particularly important to coercion, so we try rematch it.
220221
/// NOTE: This must stay in sync with `consider_builtin_unsize_candidate` in trait
221222
/// goal assembly in the solver, both for soundness and in order to avoid ICEs.
@@ -377,6 +378,7 @@ fn rematch_unsize<'tcx>(
377378
}
378379
}
379380
}
381+
// tidy-ticket-rematch_unsize
380382

381383
fn structurally_normalize<'tcx>(
382384
ty: Ty<'tcx>,

compiler/rustc_trait_selection/src/solve/trait_goals.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
463463
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
464464
}
465465

466+
// tidy-ticket-consider_builtin_unsize_candidate
466467
fn consider_unsize_to_dyn_candidate(
467468
ecx: &mut EvalCtxt<'_, 'tcx>,
468469
goal: Goal<'tcx, Self>,
@@ -503,6 +504,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
503504
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
504505
})
505506
}
507+
// tidy-ticket-consider_builtin_unsize_candidate
506508

507509
/// ```ignore (builtin impl example)
508510
/// trait Trait {

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
17411741
};
17421742

17431743
let eligible = match &impl_source {
1744+
// tidy-ticket-assemble_candidates_from_impls-UserDefined
17441745
ImplSource::UserDefined(impl_data) => {
17451746
// We have to be careful when projecting out of an
17461747
// impl because of specialization. If we are not in
@@ -1791,6 +1792,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
17911792
}
17921793
}
17931794
}
1795+
// tidy-ticket-assemble_candidates_from_impls-UserDefined
1796+
17941797
ImplSource::Builtin(BuiltinImplSource::Misc, _) => {
17951798
// While a builtin impl may be known to exist, the associated type may not yet
17961799
// be known. Any type with multiple potential associated types is therefore

0 commit comments

Comments
 (0)