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 6 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
4 changes: 4 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5367,10 +5367,14 @@ dependencies = [
"cargo_metadata 0.19.1",
"fluent-syntax",
"ignore",
"md-5",
"miropt-test-tools",
"regex",
"rustc-hash 2.1.0",
"semver",
"serde",
"serde_derive",
"serde_json",
"similar",
"termcolor",
"walkdir",
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 @@ -209,6 +209,7 @@ impl Lit {
}
}

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

impl fmt::Display for Lit {
Expand Down Expand Up @@ -748,6 +750,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 @@ -774,6 +777,7 @@ impl Token {
_ => false,
}
}
// tidy-keep-sync-with=tidy-ticket-ast-can_begin_literal_maybe_minus

pub fn can_begin_string_literal(&self) -> bool {
match self.uninterpolate().kind {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,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 @@ -323,7 +324,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
| ExprKind::Yeet(_)
| ExprKind::Become(_)
| ExprKind::Yield(_)
| ExprKind::UnsafeBinderCast(..) => {}
| ExprKind::UnsafeBinderCast(..) => {} // 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 @@ -742,6 +742,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 @@ -789,6 +790,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_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
//
// This exception needs to be kept in sync with allowing
// `#[target_feature]` on `main` and `start`.
// FIXME: sync me
} else if !tcx.features().target_feature_11() {
feature_err(
&tcx.sess,
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 @@ -707,6 +707,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
interp_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 @@ -722,6 +723,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
self.add_data_range_place(value);
}
interp_ok(true)
// tidy-keep-sync-with=tidy-ticket-try_visit_primitive
}
ty::RawPtr(..) => {
let place = self.deref_pointer(value, ExpectedKind::RawPtr)?;
Expand Down Expand Up @@ -1188,9 +1190,10 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
}
};

// 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 @@ -1230,6 +1233,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
// Also, mark this as containing data, not padding.
self.add_data_range(mplace.ptr(), size);
}
// 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 @@ -126,6 +126,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 @@ -143,6 +144,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
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3188,6 +3188,7 @@ fn num_decimal_digits(num: usize) -> usize {

// We replace some characters so the CLI output is always consistent and underlines aligned.
// Keep the following list in sync with `rustc_span::char_width`.
// FIXME: sync me
const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
// In terminals without Unicode support the following will be garbled, but in *all* terminals
// the underlying codepoint will be as well. We could gate this replacement behind a "unicode
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 @@ -275,6 +275,8 @@ struct FutureIncompatReport<'a> {
future_incompat_report: Vec<FutureBreakageItem<'a>>,
}

// 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 @@ -286,6 +288,7 @@ struct UnusedExterns<'a> {
/// List of unused externs by their names.
unused_extern_names: &'a [&'a str],
}
// tidy-keep-sync-with=tidy-ticket-UnusedExterns

impl Diagnostic {
/// Converts from `rustc_errors::DiagInner` to `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 @@ -116,6 +116,7 @@ fn resolve_block<'tcx>(visitor: &mut ScopeResolutionVisitor<'tcx>, blk: &'tcx hi
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_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub fn walk_native_lib_search_dirs<R>(
f(&sess.target_tlib_path.dir.join("self-contained"), false)?;
}

// tidy-keep-sync-with=tidy-ticket-copy_third_party_objects
// Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
// library directory instead of the self-contained directories.
// Sanitizer libraries have the same issue and are also linked by name on Apple targets.
Expand Down Expand Up @@ -76,6 +77,7 @@ pub fn walk_native_lib_search_dirs<R>(
}

ControlFlow::Continue(())
// tidy-keep-sync-with=tidy-ticket-copy_third_party_objects
}

pub fn try_find_native_static_library(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ macro_rules! define_dep_nodes {
// struct, and there we can take advantage of the unused bits in the u16.
#[allow(non_camel_case_types)]
#[repr(u16)] // Must be kept in sync with the inner type of `DepKind`.
// FIXME: sync me
enum DepKindDefs {
$( $( #[$attr] )* $variant),*
}
Expand All @@ -96,6 +97,7 @@ macro_rules! define_dep_nodes {

$(
// The `as u16` cast must be kept in sync with the inner type of `DepKind`.
// FIXME: sync me
pub const $variant: DepKind = DepKind::new(DepKindDefs::$variant as u16);
)*
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ impl UnwindAction {

impl UnwindTerminateReason {
pub fn as_str(self) -> &'static str {
// tidy-keep-sync-with=tidy-tidy-ticket-panic-message
// Keep this in sync with the messages in `core/src/panicking.rs`.
match self {
UnwindTerminateReason::Abi => "panic in a function that cannot unwind",
UnwindTerminateReason::InCleanup => "panic in a destructor during cleanup",
}
// tidy-keep-sync-with=tidy-tidy-ticket-panic-message
}

/// A short representation of this used for MIR printing.
Expand Down Expand Up @@ -304,6 +306,7 @@ impl<O> AssertKind<O> {
/// `AssertKind::panic_function` and the lang items mentioned in its docs).
/// Note that we deliberately show more details here than we do at runtime, such as the actual
/// numbers that overflowed -- it is much easier to do so here than at runtime.
// FIXME: sync me
pub fn diagnostic_message(&self) -> DiagMessage {
use AssertKind::*;

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ impl<'tcx> Instance<'tcx> {

#[inline(always)]
// Keep me in sync with try_instantiate_mir_and_normalize_erasing_regions
// FIXME: sync me
pub fn instantiate_mir_and_normalize_erasing_regions<T>(
&self,
tcx: TyCtxt<'tcx>,
Expand All @@ -918,6 +919,7 @@ impl<'tcx> Instance<'tcx> {

#[inline(always)]
// Keep me in sync with instantiate_mir_and_normalize_erasing_regions
// FIXME: sync me
pub fn try_instantiate_mir_and_normalize_erasing_regions<T>(
&self,
tcx: TyCtxt<'tcx>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl<'tcx> Predicate<'tcx> {
/// unsoundly accept some programs. See #91068.
#[inline]
pub fn allow_normalization(self) -> bool {
// FIXME: sync me
// Keep this in sync with the one in `rustc_type_ir::inherent`!
match self.kind().skip_binder() {
PredicateKind::Clause(ClauseKind::WellFormed(_))
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 @@ -693,6 +693,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 @@ -705,14 +706,17 @@ 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, typing_env: ty::TypingEnv<'tcx>) -> Ty<'tcx> {
// Make sure that any constants in the static's type are evaluated.
let static_ty =
self.normalize_erasing_regions(typing_env, 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 @@ -721,6 +725,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
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/coverage/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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.

if let MappingKind::Code(CovTerm::Expression(id)) = mapping.kind {
expressions_seen.remove(id);
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/mentioned_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl<'tcx> crate::MirPass<'tcx> for MentionedItems {
// visiting the exact same places but then instead of monomorphizing and creating `MonoItems`, we
// have to remain generic and just recording the relevant information in `mentioned_items`, where it
// will then be monomorphized later during "mentioned items" collection.
// FIXME: sync me
impl<'tcx> Visitor<'tcx> for MentionedItemsVisitor<'_, 'tcx> {
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
self.super_terminator(terminator, location);
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 @@ -488,13 +488,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
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ where
}
}

// 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<I: Interner>(
cx: I,
Expand Down Expand Up @@ -393,6 +394,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
}
}
}
// tidy-keep-sync-with=tidy-ticket-extract_tupled_inputs_and_output_from_callable

/// Relevant types for an async callable, including its inputs, output,
/// and the return type you get from awaiting the output.
Expand Down Expand Up @@ -712,6 +714,7 @@ pub(in crate::solve) fn extract_fn_def_from_const_callable<I: Interner>(
}
}

// tidy-keep-sync-with=tidy-ticket-evaluate_host_effect_for_destruct_goal
// NOTE: Keep this in sync with `evaluate_host_effect_for_destruct_goal` in
// the old solver, for as long as that exists.
pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
Expand Down Expand Up @@ -789,6 +792,7 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
}
}
}
// tidy-keep-sync-with=tidy-ticket-evaluate_host_effect_for_destruct_goal

/// 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_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,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 Down Expand Up @@ -2216,6 +2217,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
3 changes: 3 additions & 0 deletions compiler/rustc_pattern_analysis/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,14 @@ impl<Cx: PatCx> Constructor<Cx> {
}
}

// tidy-keep-sync-with=tidy-ticket-arity
/// The number of fields for this constructor. This must be kept in sync with
/// `Fields::wildcards`.
// FIXME: this comment long ago desynced
pub(crate) fn arity(&self, cx: &Cx, ty: &Cx::Ty) -> usize {
cx.ctor_arity(self, ty)
}
// tidy-keep-sync-with=tidy-ticket-arity

/// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
/// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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 ?

Copy link
Contributor Author

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?


if sess.opts.debug_assertions {
ins_none!(sym::debug_assertions);
Expand Down Expand Up @@ -334,6 +335,7 @@ impl CheckCfg {
// The exceptions are where control flow forces things out of order.
//
// NOTE: This should be kept in sync with `default_configuration`.
// FIXME: what exactly sync there?
// Note that symbols inserted conditionally in `default_configuration`
// are inserted unconditionally here.
//
Expand Down
Loading
Loading