Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5463,6 +5463,7 @@ dependencies = [
"cargo_metadata 0.15.4",
"ignore",
"lazy_static",
"md-5",
"miropt-test-tools",
"regex",
"semver",
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl Lit {
}
}

// tidy-keep-sync-with=tidy-ticket-ast-from_token
/// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation.
pub fn from_token(token: &Token) -> Option<Lit> {
match token.uninterpolate().kind {
Expand All @@ -118,6 +119,7 @@ impl Lit {
_ => None,
}
}
// tidy-keep-sync-with=tidy-ticket-ast-from_token
}

impl fmt::Display for Lit {
Expand Down Expand Up @@ -571,6 +573,7 @@ impl Token {
///
/// In other words, would this token be a valid start of `parse_literal_maybe_minus`?
///
// tidy-keep-sync-with=tidy-ticket-ast-can_begin_literal_maybe_minus
/// Keep this in sync with and `Lit::from_token`, excluding unary negation.
pub fn can_begin_literal_maybe_minus(&self) -> bool {
match self.uninterpolate().kind {
Expand All @@ -590,6 +593,7 @@ impl Token {
_ => false,
}
}
// tidy-keep-sync-with=tidy-ticket-ast-can_begin_literal_maybe_minus

/// A convenience function for matching on identifiers during parsing.
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
}
// Expressions that are not worth or can not be captured.
//
// tidy-keep-sync-with=tidy-ticket-all-expr-kinds
// Full list instead of `_` to catch possible future inclusions and to
// sync with the `rfc-2011-nicer-assert-messages/all-expr-kinds.rs` test.
ExprKind::Assign(_, _, _)
Expand Down Expand Up @@ -321,6 +322,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
| ExprKind::Yeet(_)
| ExprKind::Become(_)
| ExprKind::Yield(_) => {}
// tidy-keep-sync-with=tidy-ticket-all-expr-kinds
}
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
}
}

// tidy-keep-sync-with=tidy-ticket-short_description
/// Generate a short description of this work item suitable for use as a thread name.
fn short_description(&self) -> String {
// `pthread_setname()` on *nix ignores anything beyond the first 15
Expand Down Expand Up @@ -758,6 +759,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
WorkItem::LTO(m) => desc("lto", "LTO module", m.name()),
}
}
// tidy-keep-sync-with=tidy-ticket-short_description
}

/// A result produced by the backend.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_const_eval/src/interpret/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,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
Copy link
Member

@RalfJung RalfJung Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically this:

_ 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.

Copy link
Contributor Author

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.

assert!(matches!(base_meta, MemPlaceMeta::None));
(base_meta, offset)
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
Ok(true)
}
ty::Float(_) | ty::Int(_) | ty::Uint(_) => {
// tidy-keep-sync-with=tidy-ticket-try_visit_primitive
// NOTE: Keep this in sync with the array optimization for int/float
// types below!
self.read_scalar(
Expand All @@ -522,6 +523,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
},
)?;
Ok(true)
// tidy-keep-sync-with=tidy-ticket-try_visit_primitive
}
ty::RawPtr(..) => {
let place =
Expand Down Expand Up @@ -784,9 +786,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
}
};

// tidy-keep-sync-with=tidy-ticket-visit_value
// Optimization: we just check the entire range at once.
// NOTE: Keep this in sync with the handling of integer and float
// types above, in `visit_primitive`.
// types above, in `try_visit_primitive`.
// No need for an alignment check here, this is not an actual memory access.
let alloc = self.ecx.get_ptr_alloc(mplace.ptr(), size)?.expect("we already excluded size 0");

Expand Down Expand Up @@ -820,6 +823,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
}
}
}
// tidy-keep-sync-with=tidy-ticket-visit_value
}
// Fast path for arrays and slices of ZSTs. We only need to check a single ZST element
// of an array and not all of them, because there's only a single value of a specific
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ bitflags::bitflags! {
}
}

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

/// Something that uniquely identifies a query invocation.
pub struct QueryInvocationId(pub u32);
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ struct FutureIncompatReport {
future_incompat_report: Vec<FutureBreakageItem>,
}

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

impl Diagnostic {
fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
visitor.cx.var_parent = visitor.cx.parent;

{
// FIXME: sync with exactly where?
// This block should be kept approximately in sync with
// `intravisit::walk_block`. (We manually walk the block, rather
// than call `walk_block`, in order to maintain precise
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,12 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
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
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
tcx.sess.time("item_types_checking", || {
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
});
// tidy-keep-sync-with=tidy-ticket-sess-time-item_types_checking

// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
// only actually get emitted in `check_mod_item_types`.
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ impl<'tcx> TyCtxt<'tcx> {
&& !self.is_foreign_item(def_id)
}

// tidy-keep-sync-with=tidy-ticket-thread_local_ptr_ty
/// Returns the type a reference to the thread local takes in MIR.
pub fn thread_local_ptr_ty(self, def_id: DefId) -> Ty<'tcx> {
let static_ty = self.type_of(def_id).instantiate_identity();
Expand All @@ -665,6 +666,7 @@ impl<'tcx> TyCtxt<'tcx> {
Ty::new_imm_ref(self, self.lifetimes.re_static, static_ty)
}
}
// tidy-keep-sync-with=tidy-ticket-thread_local_ptr_ty

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

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

/// Return the set of types that should be taken into account when checking
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ impl<'tcx> Constructor<'tcx> {
}
}

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

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

// tidy-keep-sync-with=tidy-ticket-wildcards
/// Creates a new list of wildcard fields for a given constructor. The result must have a
/// length of `constructor.arity()`.
#[instrument(level = "trace")]
Expand Down Expand Up @@ -1351,6 +1354,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
debug!(?ret);
ret
}
// tidy-keep-sync-with=tidy-ticket-wildcards

/// Returns the list of patterns.
pub(super) fn iter_patterns<'a>(
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,16 @@ fn merge_codegen_units<'tcx>(
codegen_units.sort_by_key(|cgu| cmp::Reverse(cgu.size_estimate()));
let num_digits = codegen_units.len().ilog10() as usize + 1;
for (index, cgu) in codegen_units.iter_mut().enumerate() {
// tidy-keep-sync-with=tidy-ticket-short_description
// FIXME: is it sync?
// Note: `WorkItem::short_description` depends on this name ending
// with `-cgu.` followed by a numeric suffix. Please keep it in
// sync with this code.
let suffix = format!("{index:0num_digits$}");
let numbered_codegen_unit_name =
cgu_name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(suffix));
cgu.set_name(numbered_codegen_unit_name);
// tidy-keep-sync-with=tidy-ticket-short_description
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ impl<'a> Parser<'a> {
}
}

// tidy-keep-sync-with=tidy-ticket-rustc_parse-can_begin_literal_maybe_minus
/// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
/// Keep this in sync with `Token::can_begin_literal_maybe_minus`.
pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
Expand All @@ -2103,6 +2104,7 @@ impl<'a> Parser<'a> {
Ok(expr)
}
}
// tidy-keep-sync-with=tidy-ticket-rustc_parse-can_begin_literal_maybe_minus

fn is_array_like_block(&mut self) -> bool {
self.look_ahead(1, |t| matches!(t.kind, TokenKind::Ident(..) | TokenKind::Literal(_)))
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ pub const fn default_lib_output() -> CrateType {

fn default_configuration(sess: &Session) -> Cfg {
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
// FIXME: what exactly sync there?
let end = &sess.target.endian;
let arch = &sess.target.arch;
let wordsz = sess.target.pointer_width.to_string();
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/config/sigpipe.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tidy-keep-sync-with=tidy-ticket-sigpipe
//! NOTE: Keep these constants in sync with `library/std/src/sys/unix/mod.rs`!

/// The default value if `#[unix_sigpipe]` is not specified. This resolves
Expand All @@ -23,3 +24,4 @@ pub const SIG_IGN: u8 = 2;
/// such as `head -n 1`.
#[allow(dead_code)]
pub const SIG_DFL: u8 = 3;
// tidy-keep-sync-with=tidy-ticket-sigpipe
9 changes: 6 additions & 3 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,12 +1779,15 @@ written to standard error output)"),
`instructions:u` (retired instructions, userspace-only)
`instructions-minus-irqs:u` (subtracting hardware interrupt counts for extra accuracy)"
),
/// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
// tidy-keep-sync-with=tidy-ticket-self-profile-events
/// keep this in sync with the event filter names in rustc_data_structures/src/profiling.rs
self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
"specify the events recorded by the self profiler;
for example: `-Z self-profile-events=default,query-keys`
all options: none, all, default, generic-activity, query-provider, query-cache-hit
query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
all options: none, all, default, generic-activity, query-provider, query-cache-hit,
query-blocked, incr-cache-load, query-keys, function-args, args, llvm, incr-result-hashing, artifact-sizes"),
// tidy-keep-sync-with=tidy-ticket-self-profile-events

share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
"make the current crate share its generic instantiations"),
show_span: Option<String> = (None, parse_opt_string, [TRACKED],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
}
}

// tidy-keep-sync-with=tidy-ticket-extract_tupled_inputs_and_output_from_callable
// Returns a binder of the tupled inputs types and output type from a builtin callable type.
pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
tcx: TyCtxt<'tcx>,
Expand All @@ -234,6 +235,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
Err(NoSolution)
}
}

// keep this in sync with assemble_fn_pointer_candidates until the old solver is removed.
ty::FnPtr(sig) => {
if sig.is_fn_trait_compatible() {
Expand Down Expand Up @@ -291,6 +293,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
}
}
}
// tidy-keep-sync-with=tidy-ticket-extract_tupled_inputs_and_output_from_callable

/// Assemble a list of predicates that would be present on a theoretical
/// user impl for an object type. These predicates must be checked any time
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ fn rematch_impl<'tcx>(
Ok(Some(ImplSource::UserDefined(ImplSourceUserDefinedData { impl_def_id, args, nested })))
}

// tidy-keep-sync-with=tidy-ticket-rematch_unsize
/// The `Unsize` trait is particularly important to coercion, so we try rematch it.
/// NOTE: This must stay in sync with `consider_builtin_unsize_candidate` in trait
/// goal assembly in the solver, both for soundness and in order to avoid ICEs.
Expand Down Expand Up @@ -377,6 +378,7 @@ fn rematch_unsize<'tcx>(
}
}
}
// tidy-keep-sync-with=tidy-ticket-rematch_unsize

fn structurally_normalize<'tcx>(
ty: Ty<'tcx>,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_trait_selection/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
}

// tidy-keep-sync-with=tidy-ticket-consider_builtin_unsize_candidate
fn consider_unsize_to_dyn_candidate(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
Expand Down Expand Up @@ -503,6 +504,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}
// tidy-keep-sync-with=tidy-ticket-consider_builtin_unsize_candidate

/// ```ignore (builtin impl example)
/// trait Trait {
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
};

let eligible = match &impl_source {
// tidy-keep-sync-with=tidy-ticket-assemble_candidates_from_impls-UserDefined
ImplSource::UserDefined(impl_data) => {
// We have to be careful when projecting out of an
// impl because of specialization. If we are not in
Expand Down Expand Up @@ -1791,6 +1792,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
}
}
}
// tidy-keep-sync-with=tidy-ticket-assemble_candidates_from_impls-UserDefined

ImplSource::Builtin(BuiltinImplSource::Misc, _) => {
// While a builtin impl may be known to exist, the associated type may not yet
// be known. Any type with multiple potential associated types is therefore
Expand Down
Loading
Loading