From ef658907a5e88563e4b67a07ba1639c7bf58756f Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 3 Mar 2023 08:38:07 +0100 Subject: [PATCH 1/3] Match end user facing unmatched backticks in compiler/ --- compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 2 +- compiler/rustc_const_eval/src/interpret/intrinsics.rs | 2 +- .../rustc_const_eval/src/transform/check_consts/check.rs | 2 +- compiler/rustc_data_structures/src/stable_hasher/tests.rs | 2 +- compiler/rustc_expand/src/mbe/transcribe.rs | 2 +- compiler/rustc_infer/locales/en-US.ftl | 8 ++++---- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_interface/locales/en-US.ftl | 2 +- compiler/rustc_middle/src/ty/layout.rs | 2 +- compiler/rustc_mir_build/src/build/expr/as_constant.rs | 2 +- compiler/rustc_session/locales/en-US.ftl | 2 +- compiler/rustc_session/src/config.rs | 2 +- .../impl-on-dyn-trait-with-implicit-static-bound.stderr | 8 ++++---- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 4baf1b6aa8701..37bc8533dc8db 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -949,7 +949,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { .push_span_label(*span, "this has an implicit `'static` lifetime requirement"); multi_span.push_span_label( ident.span, - "calling this method introduces the `impl`'s 'static` requirement", + "calling this method introduces the `impl`'s `'static` requirement", ); err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span }); err.span_suggestion_verbose( diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index c65d677e8ea75..a2b8647a965c8 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -457,7 +457,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { assert_eq!(input_len, dest_len, "Return vector length must match input length"); assert!( index < dest_len, - "Index `{}` must be in bounds of vector with length {}`", + "Index `{}` must be in bounds of vector with length `{}`", index, dest_len ); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index e4366f655e471..aa24d9053b98a 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -332,7 +332,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { fn check_static(&mut self, def_id: DefId, span: Span) { if self.tcx.is_thread_local_static(def_id) { - self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef"); + self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`"); } self.check_op_spanned(ops::StaticAccess, span) } diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index b0d66c32a07ad..724be5888ddb4 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -150,7 +150,7 @@ fn test_isize_compression() { let hash_b = hash(&(b as isize, a as isize)); assert_ne!( hash_a, hash_b, - "The hash stayed the same when permuting values `{a}` and `{b}!", + "The hash stayed the same when permuting values `{a}` and `{b}`!", ); } diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index b79835be73a7e..47a8b4bc48885 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -282,7 +282,7 @@ pub(super) fn transcribe<'a>( } // There should be no meta-var declarations in the invocation of a macro. - mbe::TokenTree::MetaVarDecl(..) => panic!("unexpected `TokenTree::MetaVarDecl"), + mbe::TokenTree::MetaVarDecl(..) => panic!("unexpected `TokenTree::MetaVarDecl`"), } } } diff --git a/compiler/rustc_infer/locales/en-US.ftl b/compiler/rustc_infer/locales/en-US.ftl index c5b2b6c2d7357..e3db44477de4e 100644 --- a/compiler/rustc_infer/locales/en-US.ftl +++ b/compiler/rustc_infer/locales/en-US.ftl @@ -79,7 +79,7 @@ infer_subtype = ...so that the {$requirement -> [if_else_different] `if` and `else` have incompatible types [no_else] `if` missing an `else` returns `()` [fn_main_correct_type] `main` function has the correct type - [fn_start_correct_type] #[start]` function has the correct type + [fn_start_correct_type] `#[start]` function has the correct type [intristic_correct_type] intrinsic has the correct type [method_correct_type] method receiver has the correct type *[other] types are compatible @@ -92,7 +92,7 @@ infer_subtype_2 = ...so that {$requirement -> [if_else_different] `if` and `else` have incompatible types [no_else] `if` missing an `else` returns `()` [fn_main_correct_type] `main` function has the correct type - [fn_start_correct_type] #[start]` function has the correct type + [fn_start_correct_type] `#[start]` function has the correct type [intristic_correct_type] intrinsic has the correct type [method_correct_type] method receiver has the correct type *[other] types are compatible @@ -277,7 +277,7 @@ infer_tid_consider_borrowing = consider borrowing this type parameter in the tra infer_tid_param_help = the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` infer_dtcs_has_lifetime_req_label = this has an implicit `'static` lifetime requirement -infer_dtcs_introduces_requirement = calling this method introduces the `impl`'s 'static` requirement +infer_dtcs_introduces_requirement = calling this method introduces the `impl`'s `'static` requirement infer_dtcs_has_req_note = the used `impl` has a `'static` requirement infer_dtcs_suggestion = consider relaxing the implicit `'static` requirement @@ -313,7 +313,7 @@ infer_but_needs_to_satisfy = {$has_param_name -> [false] ...and is required to live as long as `'static` here } .used_here = ...is used here... - .introduced_by_bound = 'static` lifetime requirement introduced by this bound + .introduced_by_bound = `'static` lifetime requirement introduced by this bound infer_more_targeted = {$has_param_name -> [true] `{$param_name}` diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 79efc1ce7bfc0..bf6af57c66a40 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1690,7 +1690,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { format!("{name} is defined in the current crate") } else { let crate_name = self.tcx.crate_name(defid.krate); - format!("{name} is defined in crate `{crate_name}") + format!("{name} is defined in crate `{crate_name}`") }; diagnostic.span_note(def_span, msg); }; diff --git a/compiler/rustc_interface/locales/en-US.ftl b/compiler/rustc_interface/locales/en-US.ftl index da58492ccf27c..37994899a2038 100644 --- a/compiler/rustc_interface/locales/en-US.ftl +++ b/compiler/rustc_interface/locales/en-US.ftl @@ -33,7 +33,7 @@ interface_rustc_error_fatal = fatal error triggered by #[rustc_error] interface_rustc_error_unexpected_annotation = - unexpected annotation used with `#[rustc_error(...)]! + unexpected annotation used with `#[rustc_error(...)]`! interface_failed_writing_file = failed to write file {$path}: {$error}" diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 090272a6fa6d9..9a517d2d2b425 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -93,7 +93,7 @@ impl IntegerExt for Integer { if discr < fit { bug!( "Integer::repr_discr: `#[repr]` hint too small for \ - discriminant range of enum `{}", + discriminant range of enum `{}`", ty ) } diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index 2f63333d46b1d..cfacb5ea32777 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -55,7 +55,7 @@ pub fn as_constant_inner<'tcx>( ConstantKind::Ty(tcx.const_error_with_guaranteed(ty, guar)) } Err(LitToConstError::TypeError) => { - bug!("encountered type error in `lit_to_mir_constant") + bug!("encountered type error in `lit_to_mir_constant`") } }; diff --git a/compiler/rustc_session/locales/en-US.ftl b/compiler/rustc_session/locales/en-US.ftl index fe553edab4276..ff53f22d43f93 100644 --- a/compiler/rustc_session/locales/en-US.ftl +++ b/compiler/rustc_session/locales/en-US.ftl @@ -5,7 +5,7 @@ session_incorrect_cgu_reuse_type = }`{$expected_reuse}` session_cgu_not_recorded = - CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded` + CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded session_feature_gate_error = {$explain} diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 295e93f610339..52fd9fc6afbd0 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2245,7 +2245,7 @@ pub fn parse_externs( early_error( error_format, "the `-Z unstable-options` flag must also be passed to \ - enable `--extern options", + enable `--extern` options", ); } for opt in opts.split(',') { diff --git a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index 679ebd61ead1a..da72c8ebf19b6 100644 --- a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -17,7 +17,7 @@ note: the used `impl` has a `'static` requirement LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement LL | fn use_self(&self) -> &() { panic!() } - | -------- calling this method introduces the `impl`'s 'static` requirement + | -------- calling this method introduces the `impl`'s `'static` requirement help: consider relaxing the implicit `'static` requirement | LL | impl MyTrait for dyn ObjectTrait + '_ { @@ -42,7 +42,7 @@ note: the used `impl` has a `'static` requirement LL | impl dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement LL | fn use_self(&self) -> &() { panic!() } - | -------- calling this method introduces the `impl`'s 'static` requirement + | -------- calling this method introduces the `impl`'s `'static` requirement help: consider relaxing the implicit `'static` requirement | LL | impl dyn ObjectTrait + '_ { @@ -65,7 +65,7 @@ note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:26 | LL | fn use_self(&self) -> &() { panic!() } - | -------- calling this method introduces the `impl`'s 'static` requirement + | -------- calling this method introduces the `impl`'s `'static` requirement ... LL | impl MyTrait for dyn ObjectTrait {} | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -91,7 +91,7 @@ note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:106:26 | LL | fn use_self(&self) -> &() { panic!() } - | -------- calling this method introduces the `impl`'s 'static` requirement + | -------- calling this method introduces the `impl`'s `'static` requirement ... LL | impl MyTrait for dyn ObjectTrait {} | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement From 5a02105fffb96a60878ab6c4eb4f4d209b2aa8a2 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 3 Mar 2023 04:16:52 +0100 Subject: [PATCH 2/3] Rustdoc-ify LiteralKind note --- compiler/rustc_lexer/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index e6f04fe0aaa63..322ec31fb2cff 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -166,15 +166,17 @@ pub enum DocStyle { Inner, } -// Note that the suffix is *not* considered when deciding the `LiteralKind` in -// this type. This means that float literals like `1f32` are classified by this -// type as `Int`. (Compare against `rustc_ast::token::LitKind` and -// `rustc_ast::ast::LitKind.) +/// Enum representing the literal types supported by the lexer. +/// +/// Note that the suffix is *not* considered when deciding the `LiteralKind` in +/// this type. This means that float literals like `1f32` are classified by this +/// type as `Int`. (Compare against `rustc_ast::token::LitKind` and +/// `rustc_ast::ast::LitKind`). #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum LiteralKind { /// "12_u8", "0o100", "0b120i99", "1f32". Int { base: Base, empty_int: bool }, - /// "12.34f32", "1e3", but not "1f32`. + /// "12.34f32", "1e3", but not "1f32". Float { base: Base, empty_exponent: bool }, /// "'a'", "'\\'", "'''", "';" Char { terminated: bool }, From c54f061228b239cb80df2dafd622c5b55513d4f2 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 3 Mar 2023 02:26:24 +0100 Subject: [PATCH 3/3] Don't put integers into backticks during formatting --- compiler/rustc_const_eval/src/interpret/intrinsics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index a2b8647a965c8..9ad945359b6b3 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -457,7 +457,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { assert_eq!(input_len, dest_len, "Return vector length must match input length"); assert!( index < dest_len, - "Index `{}` must be in bounds of vector with length `{}`", + "Index `{}` must be in bounds of vector with length {}", index, dest_len ); @@ -477,7 +477,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (input, input_len) = self.operand_to_simd(&args[0])?; assert!( index < input_len, - "index `{}` must be in bounds of vector with length `{}`", + "index `{}` must be in bounds of vector with length {}", index, input_len );