diff --git a/Cargo.lock b/Cargo.lock index 85e5e6c97105c..f8e9fc88ac2e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 3b7367d1ee209..289d3a63337e2 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -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 { match token.uninterpolate().kind { @@ -223,6 +224,7 @@ impl Lit { _ => None, } } + // tidy-keep-sync-with=tidy-ticket-ast-from_token } impl fmt::Display for Lit { @@ -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 { @@ -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 { diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index bb9dc651cec25..e192ab748379f 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -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(_, _, _) @@ -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 } } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index b40bb4ed5d2ac..f63d0dd1381c7 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -742,6 +742,7 @@ impl WorkItem { } } + // 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 @@ -789,6 +790,7 @@ impl WorkItem { WorkItem::LTO(m) => desc("lto", "LTO module", m.name()), } } + // tidy-keep-sync-with=tidy-ticket-short_description } /// A result produced by the backend. diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 1daa17fbaf347..0bf97093618ca 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -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, diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index d75df1ad4425b..0b21cd8be6084 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -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( @@ -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)?; @@ -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"); @@ -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 diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 19050746c2f18..3cb52c79c974e 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -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()), @@ -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); diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index f938352820df7..e5855404a449c 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -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 diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 97df7f9265aa4..fc3bafaf07ec1 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -275,6 +275,8 @@ struct FutureIncompatReport<'a> { future_incompat_report: Vec>, } +// 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 @@ -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`. diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index 83c69dc2ef415..0629b740d3366 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -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 diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 2a1e4b261e737..05c5baff69be5 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -48,6 +48,7 @@ pub fn walk_native_lib_search_dirs( 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. @@ -76,6 +77,7 @@ pub fn walk_native_lib_search_dirs( } ControlFlow::Continue(()) + // tidy-keep-sync-with=tidy-ticket-copy_third_party_objects } pub fn try_find_native_static_library( diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index fcfc31575f8aa..14b8bed3172bf 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -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),* } @@ -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); )* } diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 473b817aed076..b8f2bee210419 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -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. @@ -304,6 +306,7 @@ impl AssertKind { /// `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::*; diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index e4ded2c30f539..8dac550f7bd15 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -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( &self, tcx: TyCtxt<'tcx>, @@ -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( &self, tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 32d6455e82557..d55c9b8376025 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -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(_)) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 75893da0e5836..799a149904517 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -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(); @@ -705,6 +706,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, typing_env: ty::TypingEnv<'tcx>) -> Ty<'tcx> { @@ -712,7 +714,9 @@ impl<'tcx> TyCtxt<'tcx> { 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) @@ -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 diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index 3e7cf8541c23a..80bf6a50d45fb 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -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 if let MappingKind::Code(CovTerm::Expression(id)) = mapping.kind { expressions_seen.remove(id); } diff --git a/compiler/rustc_mir_transform/src/mentioned_items.rs b/compiler/rustc_mir_transform/src/mentioned_items.rs index cf5c5f85a9ff6..de3a1375e1b72 100644 --- a/compiler/rustc_mir_transform/src/mentioned_items.rs +++ b/compiler/rustc_mir_transform/src/mentioned_items.rs @@ -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); diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 7b17966343084..b626eae027583 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -488,6 +488,8 @@ 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. @@ -495,6 +497,7 @@ fn merge_codegen_units<'tcx>( 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 } } } diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index 3c5d9b95e772d..cf8c23ac0f3a2 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -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( cx: I, @@ -393,6 +394,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable( } } +// 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( @@ -789,6 +792,7 @@ pub(in crate::solve) fn const_conditions_for_destruct( } } } +// 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 diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 7533e75ffe261..731ef29bd17e9 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -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> { @@ -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(_))) diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 4ce868f014f42..d7b59d9b4629d 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -782,11 +782,14 @@ impl Constructor { } } + // 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, diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index d586f913335e0..df1cf62a6f6eb 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -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 if sess.opts.debug_assertions { ins_none!(sym::debug_assertions); @@ -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. // diff --git a/compiler/rustc_session/src/config/sigpipe.rs b/compiler/rustc_session/src/config/sigpipe.rs index 1830ee034855b..c08c5534777a7 100644 --- a/compiler/rustc_session/src/config/sigpipe.rs +++ b/compiler/rustc_session/src/config/sigpipe.rs @@ -1,3 +1,4 @@ +// tidy-keep-sync-with=tidy-ticket-sigpipe //! NOTE: Keep these constants in sync with `library/std/src/sys/pal/unix/mod.rs`! /// The default value if `-Zon-broken-pipe=...` is not specified. This resolves @@ -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 diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 3af6df6301774..42edbc1c0bf36 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2095,12 +2095,14 @@ 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> = (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 = (None, parse_opt_bool, [TRACKED], "make the current crate share its generic instantiations"), shell_argfiles: bool = (false, parse_bool, [UNTRACKED], diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 51cfbf594716c..94982ed9e7436 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -2210,6 +2210,7 @@ pub fn char_width(ch: char) -> usize { // Keep the following list in sync with `rustc_errors::emitter::OUTPUT_REPLACEMENTS`. These // are control points that we replace before printing with a visible codepoint for the sake // of being able to point at them with underlines. + // FIXME: sync me '\u{0000}' | '\u{0001}' | '\u{0002}' | '\u{0003}' | '\u{0004}' | '\u{0005}' | '\u{0006}' | '\u{0007}' | '\u{0008}' | '\u{000B}' | '\u{000C}' | '\u{000D}' | '\u{000E}' | '\u{000F}' | '\u{0010}' | '\u{0011}' | '\u{0012}' | '\u{0013}' diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index d2abd881c4591..87939f46e573a 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -439,6 +439,7 @@ fn virtual_call_violations_for_method<'tcx>( } else { // We confirm that the `receiver_is_dispatchable` is accurate later, // see `check_receiver_correct`. It should be kept in sync with this code. + // FIXME: sync me } } diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs index b32909efe0be7..204e8f717aecc 100644 --- a/compiler/rustc_trait_selection/src/traits/effects.rs +++ b/compiler/rustc_trait_selection/src/traits/effects.rs @@ -244,6 +244,7 @@ fn evaluate_host_effect_from_builtin_impls<'tcx>( } } +// tidy-keep-sync-with=tidy-ticket-evaluate_host_effect_for_destruct_goal // NOTE: Keep this in sync with `const_conditions_for_destruct` in the new solver. fn evaluate_host_effect_for_destruct_goal<'tcx>( selcx: &mut SelectionContext<'_, 'tcx>, @@ -331,6 +332,7 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>( }) .collect()) } +// tidy-keep-sync-with=tidy-ticket-evaluate_host_effect_for_destruct_goal fn evaluate_host_effect_from_selection_candiate<'tcx>( selcx: &mut SelectionContext<'_, 'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index aae0e34ddf393..ca4b1721f5d90 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -927,6 +927,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 @@ -991,6 +992,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( Err(ErrorGuaranteed { .. }) => true, } } + // 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 diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 968dc631e50e5..020bf94cfe9c8 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -502,6 +502,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } + // tidy-keep-sync-with=tidy-ticket-assemble_fn_pointer_candidates /// Implements one of the `Fn()` family for a fn pointer. fn assemble_fn_pointer_candidates( &mut self, @@ -541,6 +542,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { _ => {} } } + // tidy-keep-sync-with=tidy-ticket-assemble_fn_pointer_candidates /// Searches for impls that might apply to `obligation`. #[instrument(level = "debug", skip(self, candidates))] diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index fc76a86f79772..6db312bf8bac8 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -117,6 +117,7 @@ fn resolve_associated_item<'tcx>( // Now that we know which impl is being used, we can dispatch to // the actual function: Ok(match vtbl { + // tidy-keep-sync-with=tidy-ticket-resolve_associated_item-UserDefined traits::ImplSource::UserDefined(impl_data) => { debug!( "resolving ImplSource::UserDefined: {:?}, {:?}, {:?}, {:?}", @@ -230,6 +231,7 @@ fn resolve_associated_item<'tcx>( Some(ty::Instance::new(leaf_def.item.def_id, args)) } + // tidy-keep-sync-with=tidy-ticket-resolve_associated_item-UserDefined traits::ImplSource::Builtin(BuiltinImplSource::Object(_), _) => { let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_args); if trait_ref.has_non_region_infer() || trait_ref.has_non_region_param() { diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 1b5e44a913467..045d5cabc6b3d 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -226,6 +226,7 @@ pub use thin::ThinBox; #[stable(feature = "rust1", since = "1.0.0")] #[rustc_insignificant_dtor] #[doc(search_unbox)] +// FIXME: Sync with what? // The declaration of the `Box` struct must be kept in sync with the // compiler or ICEs will happen. pub struct Box< diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 53e2b238bae69..6aea0e8a083f2 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -303,8 +303,10 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! { #[lang = "panic_cannot_unwind"] // needed by codegen for panic in nounwind function #[rustc_nounwind] fn panic_cannot_unwind() -> ! { + // tidy-keep-sync-with=tidy-ticket-panic-message-nounwind // Keep the text in sync with `UnwindTerminateReason::as_str` in `rustc_middle`. panic_nounwind("panic in a function that cannot unwind") + // tidy-keep-sync-with=tidy-ticket-panic-message-nounwind } /// Panics because we are unwinding out of a destructor during cleanup. @@ -319,8 +321,10 @@ fn panic_cannot_unwind() -> ! { #[lang = "panic_in_cleanup"] // needed by codegen for panic in nounwind function #[rustc_nounwind] fn panic_in_cleanup() -> ! { + // tidy-keep-sync-with=tidy-ticket-panic-message-nobacktrace // Keep the text in sync with `UnwindTerminateReason::as_str` in `rustc_middle`. panic_nounwind_nobacktrace("panic in a destructor during cleanup") + // tidy-keep-sync-with=tidy-ticket-panic-message-nobacktrace } /// This function is used instead of panic_fmt in const eval. diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs index e93b5658e2436..869f699bbc382 100644 --- a/library/core/src/ptr/metadata.rs +++ b/library/core/src/ptr/metadata.rs @@ -58,10 +58,12 @@ use crate::ptr::NonNull; pub trait Pointee { /// The type for metadata in pointers and references to `Self`. #[lang = "metadata_type"] + // tidy-keep-sync-with=tidy-ticket-static_assert_expected_bounds_for_metadata // NOTE: Keep trait bounds in `static_assert_expected_bounds_for_metadata` - // in `library/core/src/ptr/metadata.rs` + // in `library/core/tests/ptr.rs` // in sync with those here: type Metadata: fmt::Debug + Copy + Send + Sync + Ord + Hash + Unpin + Freeze; + // tidy-keep-sync-with=tidy-ticket-static_assert_expected_bounds_for_metadata } /// Pointers to types implementing this trait alias are “thin”. diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index 7cefb615d0371..dec89c0f0c60e 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -586,12 +586,15 @@ fn ptr_metadata_bounds() { let _ = static_assert_expected_bounds_for_metadata::<::Metadata>; } + // tidy-keep-sync-with=tidy-ticket-static_assert_expected_bounds_for_metadata + // FIXME: should be core::hash::hash? fn static_assert_expected_bounds_for_metadata() where // Keep this in sync with the associated type in `library/core/src/ptr/metadata.rs` Meta: Debug + Copy + Send + Sync + Ord + std::hash::Hash + Unpin + Freeze, { } + // tidy-keep-sync-with=tidy-ticket-static_assert_expected_bounds_for_metadata } #[test] diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 3cc1cae8d000e..4ca6f3a9c56ac 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -170,6 +170,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_vendor = "unikraft", )))] { + // tidy-keep-sync-with=tidy-ticket-sigpipe // We don't want to add this as a public type to std, nor do we // want to `include!` a file from the compiler (which would break // Miri and xargo for example), so we choose to duplicate these @@ -182,6 +183,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { pub const SIG_IGN: u8 = 2; pub const SIG_DFL: u8 = 3; } + // tidy-keep-sync-with=tidy-ticket-sigpipe let (sigpipe_attr_specified, handler) = match sigpipe { sigpipe::DEFAULT => (false, Some(libc::SIG_IGN)), diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 4c4df922b3799..1d8b73f8983f9 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -291,6 +291,7 @@ fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: & libunwind_target } +// tidy-keep-sync-with=tidy-ticket-copy_third_party_objects /// Copies third party objects needed by various targets. fn copy_third_party_objects( builder: &Builder<'_>, @@ -320,6 +321,7 @@ fn copy_third_party_objects( target_deps } +// tidy-keep-sync-with=tidy-ticket-copy_third_party_objects /// Copies third party objects needed by various targets for self-contained linkage. fn copy_self_contained_objects( diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 026380a46c685..4df260a3c9d7c 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1462,6 +1462,7 @@ impl Config { // Allows creating alias for profile names, allowing // profiles to be renamed while maintaining back compatibility // Keep in sync with `profile_aliases` in bootstrap.py + // FIXME: sync me let profile_aliases = HashMap::from([("user", "dist")]); let include = match profile_aliases.get(include.as_str()) { Some(alias) => alias, diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index c477bdb829a91..5f7f75f7efa9e 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -231,6 +231,7 @@ impl Config { // options should be kept in sync with // src/bootstrap/src/core/download.rs // for consistency + // FIXME: sync with what? let mut curl = command("curl"); curl.args([ // follow redirect diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index ebe2c332258d7..a3da70a230516 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -644,6 +644,8 @@ impl Build { features.push("llvm"); } // keep in sync with `bootstrap/compile.rs:rustc_cargo_env` + // FIXME: this comment is leftover from https://github.com/rust-lang/rust/pull/93787, + // remove it? if self.config.rust_randomize_layout { features.push("rustc_randomized_layouts"); } diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index 42b444464e527..18ced1809b14a 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -167,6 +167,7 @@ impl<'a> Renderer<'a> { if let Outcome::Ignored { reason } = outcome { self.ignored_tests += 1; // Keep this in sync with the "up-to-date" ignore message inserted by compiletest. + // FIXME: sync me if reason == Some("up-to-date") { self.up_to_date_tests += 1; } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 0dda3466a7173..828228946c742 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -335,10 +335,12 @@ pub(crate) fn run_global_ctxt( // typeck function bodies or run the default rustc lints. // (see `override_queries` in the `config`) + // 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 tcx.dcx().abort_if_errors(); diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 009e9662933ae..a55cfda527bc1 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -439,6 +439,7 @@ impl DirState { } } +// tidy-keep-sync-with=tidy-ticket-UnusedExterns // NOTE: Keep this in sync with the equivalent structs in rustc // and cargo. // We could unify this struct the one in rustc but they have different @@ -450,6 +451,7 @@ pub(crate) struct UnusedExterns { /// List of unused externs by their names. unused_extern_names: Vec, } +// tidy-keep-sync-with=tidy-ticket-UnusedExterns fn add_exe_suffix(input: String, target: &TargetTuple) -> String { let exe_suffix = match target { diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index 2f424a482b5bb..973122621b781 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -16,6 +16,10 @@ termcolor = "1.1.3" rustc-hash = "2.0.0" fluent-syntax = "0.11.1" similar = "2.5.0" +md-5 = "0.10" +serde = "1" +serde_derive = "1" +serde_json = "1" [[bin]] name = "rust-tidy" diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 1e7eb82b83e98..243893fab1f47 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -93,4 +93,5 @@ pub mod unit_tests; pub mod unknown_revision; pub mod unstable_book; pub mod walk; +pub mod watcher; pub mod x_version; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 13a558fea48ea..04b04b986648f 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -146,6 +146,8 @@ fn main() { check!(x_version, &root_path, &cargo); + check!(watcher, &root_path, bless); + let collected = { drain_handles(&mut handles); diff --git a/src/tools/tidy/src/watcher.rs b/src/tools/tidy/src/watcher.rs new file mode 100644 index 0000000000000..9e5a255d9202d --- /dev/null +++ b/src/tools/tidy/src/watcher.rs @@ -0,0 +1,176 @@ +//! Checks that text between tags unchanged, emitting warning otherwise, +//! allowing asserting that code in different places over codebase is in sync. +//! +//! This works via hashing text between tags and saving hash in tidy. +//! +//! Usage: +//! +//! some.rs: +//! // tidy-ticket-foo +//! const FOO: usize = 42; +//! // tidy-ticket-foo +//! +//! some.sh: +//! # tidy-ticket-foo +//! export FOO=42 +//! # tidy-ticket-foo +use std::fs; +use std::fs::OpenOptions; +use std::path::{Path, PathBuf}; + +use md5::{Digest, Md5}; +use serde::{Deserialize, Serialize}; +use serde_json; + +#[cfg(test)] +mod tests; + +#[derive(Deserialize, Serialize, Debug)] +struct TagGroups { + tag_groups: Vec, +} + +#[derive(Deserialize, Serialize, Debug)] +struct TagGroup { + name: String, + #[serde(skip_serializing_if = "is_false")] + #[serde(default)] + /// if group sync in broken but you don't want to remove it + is_off: bool, + tags: Vec, +} + +#[derive(Deserialize, Serialize, Debug)] +struct Tag { + /// path to file + path: PathBuf, + /// md5 tag of tag content + hash: String, + /// tag string + tag: String, +} + +fn is_false(b: &bool) -> bool { + !b +} + +/// Return hash for source text between 2 tag occurrence, +/// ignoring lines where tag written +/// +/// Expecting: +/// tag is not multiline +/// source always have at least 2 occurrence of tag (>2 ignored) +fn span_hash(source: &str, tag: &str, bad: &mut bool, file_path: &Path) -> Result { + let start_idx = match source.find(tag) { + Some(idx) => idx, + None => { + return Err(tidy_error!( + bad, + "tag {} should exist in file {}", + tag, + file_path.display() + )); + } + }; + let end_idx = { + let end = match source[start_idx + tag.len()..].find(tag) { + // index from source start + Some(idx) => start_idx + tag.len() + idx, + None => return Err(tidy_error!(bad, "tag end {} should exist in provided text", tag)), + }; + // second line with tag can contain some other text before tag, ignore it + // by finding position of previous line ending + // + // FIXME: what if line ending is \r\n? In that case \r will be hashed too + let offset = source[start_idx..end].rfind('\n').unwrap(); + start_idx + offset + }; + + let mut hasher = Md5::new(); + + source[start_idx..end_idx] + .lines() + // skip first line with tag + .skip(1) + // hash next lines, ignoring end trailing whitespaces + .for_each(|line| { + let trimmed = line.trim_end(); + hasher.update(trimmed); + }); + Ok(format!("{:x}", hasher.finalize())) +} + +fn check_entry( + entry: &mut Tag, + tag_group_name: &str, + bad: &mut bool, + root_path: &Path, + bless: bool, +) { + let file_path = root_path.join(Path::new(&entry.path)); + let file = fs::read_to_string(&file_path) + .unwrap_or_else(|e| panic!("{:?}, path: {}", e, entry.path.display())); + let actual_hash = span_hash(&file, &entry.tag, bad, &file_path).unwrap(); + if actual_hash != entry.hash { + if !bless { + // Write tidy error description for watcher only once. + // Will not work if there was previous errors of other types. + if *bad == false { + tidy_error!( + bad, + "The code blocks tagged with tidy watcher has changed.\n\ + It's likely that code blocks with the following tags need to be changed too. Check src/tools/tidy/src/watcher.rs, find tag/hash in TIDY_WATCH_LIST list \ + and verify that sources for provided group of tags in sync. Once that done, run tidy again and update hashes in TIDY_WATCH_LIST with provided actual hashes." + ) + } + tidy_error!( + bad, + "hash for tag `{}` in path `{}` mismatch:\n actual: `{}`, expected: `{}`\n \ + Verify that tags from tag_group `{}` in sync.", + entry.tag, + entry.path.display(), + actual_hash, + entry.hash, + tag_group_name, + ); + } else { + entry.hash = actual_hash; + } + } +} + +/* + // sync self-profile-events help mesage with actual list of events + add_group!( + ("compiler/rustc_data_structures/src/profiling.rs", "881e7899c7d6904af1bc000594ee0418", "tidy-ticket-self-profile-events"), + ("compiler/rustc_session/src/options.rs", "012ee5a3b61ee1377744e5c6913fa00a", "tidy-ticket-self-profile-events") + ), + + // desynced, pieces in compiler/rustc_pattern_analysis/src/rustc.rs + // add_group!( + // ("compiler/rustc_pattern_analysis/src/constructor.rs", "c17706947fc814aa5648972a5b3dc143", "tidy-ticket-arity"), + // // ("compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs", "7ce77b84c142c22530b047703ef209f0", "tidy-ticket-wildcards") + // ), + + // desynced, pieces in compiler/rustc_hir_analysis/src/lib.rs missing? + //add_group!( // bad + // ("compiler/rustc_hir_analysis/src/lib.rs", "842e23fb65caf3a96681686131093316", "tidy-ticket-sess-time-item_types_checking"), + // ("src/librustdoc/core.rs", "85d9dd0cbb94fd521e2d15a8ed38a75f", "tidy-ticket-sess-time-item_types_checking") + // ), +*/ +pub fn check(root_path: &Path, bless: bool, bad: &mut bool) { + let config_path = root_path.join(Path::new("src/tools/tidy/src/watcher_list.json")); + let config_file = fs::read_to_string(&config_path).unwrap_or_else(|e| panic!("{:?}", e)); + let mut tag_groups: TagGroups = serde_json::from_str(&config_file).unwrap(); + for tag_group in tag_groups.tag_groups.iter_mut() { + if !tag_group.is_off { + for entry in tag_group.tags.iter_mut() { + check_entry(entry, &tag_group.name, bad, root_path, bless); + } + } + } + if bless { + let f = OpenOptions::new().write(true).truncate(true).open(config_path).unwrap(); + serde_json::to_writer_pretty(f, &tag_groups).unwrap(); + } +} diff --git a/src/tools/tidy/src/watcher/tests.rs b/src/tools/tidy/src/watcher/tests.rs new file mode 100644 index 0000000000000..a097bc3944048 --- /dev/null +++ b/src/tools/tidy/src/watcher/tests.rs @@ -0,0 +1,51 @@ +use super::*; + +#[test] +fn test_span_hash_one_line() { + let source = "some text\ntidy-tag\ncheckme=42\ntidy-tag\n"; + let tag = "tidy-tag"; + assert_eq!( + "42258eba764c3f94a24de379e5715dc8", + span_hash(source, tag, &mut true, Path::new("")).unwrap() + ); +} + +#[test] +fn test_span_hash_multiple_lines() { + let source = "some text\ntidy-tag\ncheckme=42\nother line\ntidy-tag\n"; + let tag = "tidy-tag"; + assert_eq!( + "49cb23dc2032ceea671ca48092750a1c", + span_hash(source, tag, &mut true, Path::new("")).unwrap() + ); +} + +#[test] +fn test_span_hash_has_some_text_in_line_with_tag() { + let source = "some text\ntidy-tag ignore me\ncheckme=42\nother line\ntidy-tag\n"; + let tag = "tidy-tag"; + assert_eq!( + "49cb23dc2032ceea671ca48092750a1c", + span_hash(source, tag, &mut true, Path::new("")).unwrap() + ); +} + +#[test] +fn test_span_hash_has_some_text_in_line_before_second_tag() { + let source = r#" +RUN ./build-clang.sh +ENV CC=clang CXX=clang++ +# tidy-ticket-perf-commit +# rustc-perf version from 2023-05-30 +ENV PERF_COMMIT 8b2ac3042e1ff2c0074455a0a3618adef97156b1 +# tidy-ticket-perf-commit +RUN curl -LS -o perf.zip https://github.com/rust-lang/rustc-perf/archive/$PERF_COMMIT.zip && \ + unzip perf.zip && \ + mv rustc-perf-$PERF_COMMIT rustc-perf && \ + rm perf.zip"#; + let tag = "tidy-ticket-perf-commit"; + assert_eq!( + "76c8d9783e38e25a461355f82fcd7955", + span_hash(source, tag, &mut true, Path::new("")).unwrap() + ); +} diff --git a/src/tools/tidy/src/watcher_list.json b/src/tools/tidy/src/watcher_list.json new file mode 100644 index 0000000000000..cc958245b5fb6 --- /dev/null +++ b/src/tools/tidy/src/watcher_list.json @@ -0,0 +1,256 @@ +{ + "tag_groups": [ + { + "name": "group_1", + "tags": [ + { + "path": "compiler/rustc_ast/src/token.rs", + "hash": "2df3e863dc4caffb31a7ddf001517232", + "tag": "tidy-ticket-ast-from_token" + }, + { + "path": "compiler/rustc_ast/src/token.rs", + "hash": "3279df5da05e0455f45630917fe2a797", + "tag": "tidy-ticket-ast-can_begin_literal_maybe_minus" + }, + { + "path": "compiler/rustc_parse/src/parser/expr.rs", + "hash": "479655a8587512fc26f7361d7bbd75a5", + "tag": "tidy-ticket-rustc_parse-can_begin_literal_maybe_minus" + } + ] + }, + { + "name": "group_2", + "tags": [ + { + "path": "compiler/rustc_builtin_macros/src/assert/context.rs", + "hash": "dbac73cc47a451d4822ccd3010c40a0f", + "tag": "tidy-ticket-all-expr-kinds" + }, + { + "path": "tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs", + "hash": "78ce54cc25baeac3ae07c876db25180c", + "tag": "tidy-ticket-all-expr-kinds" + } + ] + }, + { + "name": "group_3", + "tags": [ + { + "path": "compiler/rustc_const_eval/src/interpret/validity.rs", + "hash": "c4e96ecd3f81dcb54541b8ea41042e8f", + "tag": "tidy-ticket-try_visit_primitive" + }, + { + "path": "compiler/rustc_const_eval/src/interpret/validity.rs", + "hash": "cbe69005510c1a87ab07db601c0d36b8", + "tag": "tidy-ticket-visit_value" + } + ] + }, + { + "name": "group_4", + "tags": [ + { + "path": "compiler/rustc_data_structures/src/profiling.rs", + "hash": "881e7899c7d6904af1bc000594ee0418", + "tag": "tidy-ticket-self-profile-events" + }, + { + "path": "compiler/rustc_session/src/options.rs", + "hash": "012ee5a3b61ee1377744e5c6913fa00a", + "tag": "tidy-ticket-self-profile-events" + } + ] + }, + { + "name": "group_5", + "tags": [ + { + "path": "compiler/rustc_errors/src/json.rs", + "hash": "3963a8c4eee7f87eeb076622b8a92891", + "tag": "tidy-ticket-UnusedExterns" + }, + { + "path": "src/librustdoc/doctest.rs", + "hash": "14da85663568149c9b21686f4b7fa7b0", + "tag": "tidy-ticket-UnusedExterns" + } + ] + }, + { + "name": "group_6", + "tags": [ + { + "path": "compiler/rustc_middle/src/ty/util.rs", + "hash": "cae64b1bc854e7ee81894212facb5bfa", + "tag": "tidy-ticket-static_ptr_ty" + }, + { + "path": "compiler/rustc_middle/src/ty/util.rs", + "hash": "6f5ead08474b4d3e358db5d3c7aef970", + "tag": "tidy-ticket-thread_local_ptr_ty" + } + ] + }, + { + "name": "group_7", + "tags": [ + { + "path": "compiler/rustc_monomorphize/src/partitioning.rs", + "hash": "f4f33e9c14f4e0c3a20b5240ae36a7c8", + "tag": "tidy-ticket-short_description" + }, + { + "path": "compiler/rustc_codegen_ssa/src/back/write.rs", + "hash": "5286f7f76fcf564c98d7a8eaeec39b18", + "tag": "tidy-ticket-short_description" + } + ] + }, + { + "name": "group_8", + "tags": [ + { + "path": "compiler/rustc_session/src/config/sigpipe.rs", + "hash": "330e0776ba5a6c0a7439a5235297f08f", + "tag": "tidy-ticket-sigpipe" + }, + { + "path": "library/std/src/sys/pal/unix/mod.rs", + "hash": "2cdc37081831cdcf44f3331efbe440af", + "tag": "tidy-ticket-sigpipe" + } + ] + }, + { + "name": "group_9", + "tags": [ + { + "path": "compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs", + "hash": "8726918d084e0ac5bb07184008403f88", + "tag": "tidy-ticket-extract_tupled_inputs_and_output_from_callable" + }, + { + "path": "compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs", + "hash": "be2967d323633c7458533c6cec228273", + "tag": "tidy-ticket-assemble_fn_pointer_candidates" + } + ] + }, + { + "name": "group_10", + "tags": [ + { + "path": "compiler/rustc_trait_selection/src/traits/project.rs", + "hash": "262d10feb1b7ba8d3ffb4a95314bf404", + "tag": "tidy-ticket-assemble_candidates_from_impls-UserDefined" + }, + { + "path": "compiler/rustc_ty_utils/src/instance.rs", + "hash": "a51a6022efb405c5ee86acdf49ec222d", + "tag": "tidy-ticket-resolve_associated_item-UserDefined" + } + ] + }, + { + "name": "group_11", + "tags": [ + { + "path": "library/core/src/ptr/metadata.rs", + "hash": "357c958a096c33bed67cfc7212d940a2", + "tag": "tidy-ticket-static_assert_expected_bounds_for_metadata" + }, + { + "path": "library/core/tests/ptr.rs", + "hash": "d8c47e54b871d72dfdce56e6a89b5c31", + "tag": "tidy-ticket-static_assert_expected_bounds_for_metadata" + } + ] + }, + { + "name": "group_12", + "is_off": true, + "tags": [ + { + "path": "compiler/rustc_pattern_analysis/src/constructor.rs", + "hash": "c17706947fc814aa5648972a5b3dc143", + "tag": "tidy-ticket-arity" + }, + { + "path": "compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs", + "hash": "7ce77b84c142c22530b047703ef209f0", + "tag": "tidy-ticket-wildcards" + } + ] + }, + { + "name": "group_13", + "is_off": true, + "tags": [ + { + "path": "compiler/rustc_hir_analysis/src/lib.rs", + "hash": "842e23fb65caf3a96681686131093316", + "tag": "tidy-ticket-sess-time-item_types_checking" + }, + { + "path": "src/librustdoc/core.rs", + "hash": "85d9dd0cbb94fd521e2d15a8ed38a75f", + "tag": "tidy-ticket-sess-time-item_types_checking" + } + ] + }, + { + "name": "group_14", + "tags": [ + { + "path": "library/core/src/panicking.rs", + "hash": "b5387987dd6c927acf5ddfa33fdf3090", + "tag": "tidy-ticket-panic-message-nounwind" + }, + { + "path": "library/core/src/panicking.rs", + "hash": "f07f9a5af83a08e7287cd81226be8834", + "tag": "tidy-ticket-panic-message-nobacktrace" + }, + { + "path": "compiler/rustc_middle/src/mir/terminator.rs", + "hash": "110baa63da1da4d6ae54938b4bbd070f", + "tag": "tidy-ticket-panic-message" + } + ] + }, + { + "name": "group_15", + "tags": [ + { + "path": "compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs", + "hash": "50a549340456169ab3119d1dfecb6f96", + "tag": "tidy-ticket-evaluate_host_effect_for_destruct_goal" + }, + { + "path": "compiler/rustc_trait_selection/src/traits/effects.rs", + "hash": "a280510e2a7424dd874f14ad2180a938", + "tag": "tidy-ticket-evaluate_host_effect_for_destruct_goal" + } + ] + }, + { + "name": "group_16", + "tags": [ + { + "path": "compiler/rustc_metadata/src/native_libs.rs", + "hash": "332941877827af57790ac82c2a40177f", + "tag": "tidy-ticket-copy_third_party_objects" + }, + { + "path": "src/bootstrap/src/core/build_steps/compile.rs", + "hash": "ea843d88787238a509fdc5cb4ad3915b", + "tag": "tidy-ticket-copy_third_party_objects" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs index de7dbb9052edb..268db0bfef906 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs @@ -7,6 +7,7 @@ #![allow(path_statements, unused_allocation)] #![feature(core_intrinsics, generic_assert)] +// tidy-keep-sync-with=tidy-ticket-all-expr-kinds macro_rules! test { ( let mut $elem_ident:ident = $elem_expr:expr; @@ -118,3 +119,4 @@ fn main() { [ -elem == -3 ] => "Assertion failed: -elem == -3\nWith captures:\n elem = 1\n" ); } +// tidy-keep-sync-with=tidy-ticket-all-expr-kinds