Skip to content

Commit 83460d5

Browse files
committed
Auto merge of #94966 - matthiaskrgr:rollup-iqzswh3, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #94810 (debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments.) - #94947 (fix typos) - #94956 (Fix small typo in FIXME) - #94958 (Support other types of pluralization in pluralize macro) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents be52b4a + 183262d commit 83460d5

File tree

27 files changed

+78
-52
lines changed

27 files changed

+78
-52
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,18 @@ fn push_debuginfo_type_name<'tcx>(
226226
if projection_bounds.len() != 0 {
227227
if principal_has_generic_params {
228228
// push_generic_params_internal() above added a `>` but we actually
229-
// want to add more items to that list, so remove that again.
229+
// want to add more items to that list, so remove that again...
230230
pop_close_angle_bracket(output);
231+
// .. and add a comma to separate the regular generic args from the
232+
// associated types.
233+
push_arg_separator(cpp_like_debuginfo, output);
234+
} else {
235+
// push_generic_params_internal() did not add `<...>`, so we open
236+
// angle brackets here.
237+
output.push('<');
231238
}
232239

233240
for (item_def_id, ty) in projection_bounds {
234-
push_arg_separator(cpp_like_debuginfo, output);
235-
236241
if cpp_like_debuginfo {
237242
output.push_str("assoc$<");
238243
push_item_name(tcx, item_def_id, false, output);
@@ -244,8 +249,10 @@ fn push_debuginfo_type_name<'tcx>(
244249
output.push('=');
245250
push_debuginfo_type_name(tcx, ty, true, output, visited);
246251
}
252+
push_arg_separator(cpp_like_debuginfo, output);
247253
}
248254

255+
pop_arg_separator(output);
249256
push_close_angle_bracket(cpp_like_debuginfo, output);
250257
}
251258

compiler/rustc_index/src/bit_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<T> {
656656
fn union(&mut self, other: &HybridBitSet<T>) -> bool {
657657
// FIXME: This is slow if `other` is dense, but it hasn't been a problem
658658
// in practice so far.
659-
// If a a faster implementation of this operation is required, consider
659+
// If a faster implementation of this operation is required, consider
660660
// reopening https://github.com/rust-lang/rust/pull/94625
661661
assert_eq!(self.domain_size, other.domain_size());
662662
sequential_update(|elem| self.insert(elem), other.iter())
@@ -665,7 +665,7 @@ impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<T> {
665665
fn subtract(&mut self, other: &HybridBitSet<T>) -> bool {
666666
// FIXME: This is slow if `other` is dense, but it hasn't been a problem
667667
// in practice so far.
668-
// If a a faster implementation of this operation is required, consider
668+
// If a faster implementation of this operation is required, consider
669669
// reopening https://github.com/rust-lang/rust/pull/94625
670670
assert_eq!(self.domain_size, other.domain_size());
671671
sequential_update(|elem| self.remove(elem), other.iter())

compiler/rustc_lint/src/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl UnsafeCode {
328328
cx.struct_span_lint(UNSAFE_CODE, span, decorate);
329329
}
330330

331-
fn report_overriden_symbol_name(&self, cx: &EarlyContext<'_>, span: Span, msg: &str) {
331+
fn report_overridden_symbol_name(&self, cx: &EarlyContext<'_>, span: Span, msg: &str) {
332332
self.report_unsafe(cx, span, |lint| {
333333
lint.build(msg)
334334
.note(
@@ -380,14 +380,14 @@ impl EarlyLintPass for UnsafeCode {
380380

381381
ast::ItemKind::Fn(..) => {
382382
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
383-
self.report_overriden_symbol_name(
383+
self.report_overridden_symbol_name(
384384
cx,
385385
attr.span,
386386
"declaration of a `no_mangle` function",
387387
);
388388
}
389389
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
390-
self.report_overriden_symbol_name(
390+
self.report_overridden_symbol_name(
391391
cx,
392392
attr.span,
393393
"declaration of a function with `export_name`",
@@ -397,14 +397,14 @@ impl EarlyLintPass for UnsafeCode {
397397

398398
ast::ItemKind::Static(..) => {
399399
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
400-
self.report_overriden_symbol_name(
400+
self.report_overridden_symbol_name(
401401
cx,
402402
attr.span,
403403
"declaration of a `no_mangle` static",
404404
);
405405
}
406406
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
407-
self.report_overriden_symbol_name(
407+
self.report_overridden_symbol_name(
408408
cx,
409409
attr.span,
410410
"declaration of a static with `export_name`",
@@ -419,14 +419,14 @@ impl EarlyLintPass for UnsafeCode {
419419
fn check_impl_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
420420
if let ast::AssocItemKind::Fn(..) = it.kind {
421421
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
422-
self.report_overriden_symbol_name(
422+
self.report_overridden_symbol_name(
423423
cx,
424424
attr.span,
425425
"declaration of a `no_mangle` method",
426426
);
427427
}
428428
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
429-
self.report_overriden_symbol_name(
429+
self.report_overridden_symbol_name(
430430
cx,
431431
attr.span,
432432
"declaration of a method with `export_name`",

compiler/rustc_lint/src/levels.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'s> LintLevelsBuilder<'s> {
116116
continue
117117
};
118118
for id in ids {
119-
// ForceWarn and Forbid cannot be overriden
119+
// ForceWarn and Forbid cannot be overridden
120120
if let Some((Level::ForceWarn | Level::Forbid, _)) = self.current_specs().get(&id) {
121121
continue;
122122
}
@@ -137,7 +137,7 @@ impl<'s> LintLevelsBuilder<'s> {
137137
self.sets.get_lint_level(id.lint, self.cur, Some(self.current_specs()), &self.sess);
138138
// Setting to a non-forbid level is an error if the lint previously had
139139
// a forbid level. Note that this is not necessarily true even with a
140-
// `#[forbid(..)]` attribute present, as that is overriden by `--cap-lints`.
140+
// `#[forbid(..)]` attribute present, as that is overridden by `--cap-lints`.
141141
//
142142
// This means that this only errors if we're truly lowering the lint
143143
// level from forbid.

compiler/rustc_lint_defs/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ macro_rules! pluralize {
2020
($x:expr) => {
2121
if $x != 1 { "s" } else { "" }
2222
};
23+
("is", $x:expr) => {
24+
if $x == 1 { "is" } else { "are" }
25+
};
26+
("this", $x:expr) => {
27+
if $x == 1 { "this" } else { "these" }
28+
};
2329
}
2430

2531
/// Indicates the confidence in the correctness of a suggestion.

compiler/rustc_middle/src/mir/generic_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn bb_to_graph_node(block: BasicBlock, body: &Body<'_>, dark_mode: bool) -> Node
5050
let style = NodeStyle { title_bg: Some(bgcolor.to_owned()), ..Default::default() };
5151
let mut stmts: Vec<String> = data.statements.iter().map(|x| format!("{:?}", x)).collect();
5252

53-
// add the terminator to the stmts, gsgdt can print it out seperately
53+
// add the terminator to the stmts, gsgdt can print it out separately
5454
let mut terminator_head = String::new();
5555
data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
5656
stmts.push(terminator_head);

compiler/rustc_middle/src/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
400400
Pointer::new(*alloc, access.access_offset),
401401
access.uninit_size.bytes(),
402402
pluralize!(access.uninit_size.bytes()),
403-
if access.uninit_size.bytes() != 1 { "are" } else { "is" },
403+
pluralize!("is", access.uninit_size.bytes()),
404404
Pointer::new(*alloc, access.uninit_offset),
405405
),
406406
InvalidUninitBytes(None) => write!(

compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub struct BorrowCheckResult<'tcx> {
250250

251251
/// The result of the `mir_const_qualif` query.
252252
///
253-
/// Each field (except `error_occured`) corresponds to an implementer of the `Qualif` trait in
253+
/// Each field (except `error_occurred`) corresponds to an implementer of the `Qualif` trait in
254254
/// `rustc_const_eval/src/transform/check_consts/qualifs.rs`. See that file for more information on each
255255
/// `Qualif`.
256256
#[derive(Clone, Copy, Debug, Default, TyEncodable, TyDecodable, HashStable)]

compiler/rustc_middle/src/ty/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ fn foo(&self) -> Self::T { String::new() }
847847
"{some} method{s} {are} available that return{r} `{ty}`",
848848
some = if methods.len() == 1 { "a" } else { "some" },
849849
s = pluralize!(methods.len()),
850-
are = if methods.len() == 1 { "is" } else { "are" },
850+
are = pluralize!("is", methods.len()),
851851
r = if methods.len() == 1 { "s" } else { "" },
852852
ty = expected
853853
);

compiler/rustc_mir_build/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD
608608

609609
let (thir, expr) = tcx.thir_body(def);
610610
let thir = &thir.borrow();
611-
// If `thir` is empty, a type error occured, skip this body.
611+
// If `thir` is empty, a type error occurred, skip this body.
612612
if thir.exprs.is_empty() {
613613
return;
614614
}

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ impl CheckAttrVisitor<'_> {
14101410
span,
14111411
format!(
14121412
"there {} only {} argument{}",
1413-
if arg_count != 1 { "are" } else { "is" },
1413+
pluralize!("is", arg_count),
14141414
arg_count,
14151415
pluralize!(arg_count)
14161416
),

compiler/rustc_resolve/src/late/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
504504
for sp in spans {
505505
let msg = if sp == last_bound_span {
506506
format!(
507-
"...because of {} bound{}",
508-
if bounds.len() <= 2 { "this" } else { "these" },
509-
if bounds.len() <= 2 { "" } else { "s" },
507+
"...because of {these} bound{s}",
508+
these = pluralize!("this", bounds.len() - 1),
509+
s = pluralize!(bounds.len() - 1),
510510
)
511511
} else {
512512
String::new()

compiler/rustc_session/src/options.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ mod desc {
394394
pub const parse_linker_plugin_lto: &str =
395395
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
396396
pub const parse_location_detail: &str =
397-
"comma seperated list of location details to track: `file`, `line`, or `column`";
397+
"comma separated list of location details to track: `file`, `line`, or `column`";
398398
pub const parse_switch_with_opt_path: &str =
399399
"an optional path to the profiling data output directory";
400400
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
@@ -1283,7 +1283,7 @@ options! {
12831283
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
12841284
"generate JSON tracing data file from LLVM data (default: no)"),
12851285
location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
1286-
"comma seperated list of location details to be tracked when using caller_location \
1286+
"comma separated list of location details to be tracked when using caller_location \
12871287
valid options are `file`, `line`, and `column` (default: all)"),
12881288
ls: bool = (false, parse_bool, [UNTRACKED],
12891289
"list the symbols defined by a library crate (default: no)"),

compiler/rustc_session/src/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct SymbolGallery {
6969

7070
impl SymbolGallery {
7171
/// Insert a symbol and its span into symbol gallery.
72-
/// If the symbol has occurred before, ignore the new occurance.
72+
/// If the symbol has occurred before, ignore the new occurrance.
7373
pub fn insert(&self, symbol: Symbol, span: Span) {
7474
self.symbols.lock().entry(symbol).or_insert(span);
7575
}

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
369369
(true, Some(None)) => {
370370
Some(format!("{cannot_do_this} in const contexts"))
371371
}
372-
// overriden post message
372+
// overridden post message
373373
(true, Some(Some(post_message))) => {
374374
Some(format!("{cannot_do_this}{post_message}"))
375375
}

compiler/rustc_typeck/src/check/pat.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17611761
sp,
17621762
&format!(
17631763
"include the missing field{} in the pattern{}",
1764-
if len == 1 { "" } else { "s" },
1764+
pluralize!(len),
17651765
if have_inaccessible_fields { " and ignore the inaccessible fields" } else { "" }
17661766
),
17671767
format!(
@@ -1780,10 +1780,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17801780
err.span_suggestion(
17811781
sp,
17821782
&format!(
1783-
"if you don't care about {} missing field{}, you can explicitly ignore {}",
1784-
if len == 1 { "this" } else { "these" },
1785-
if len == 1 { "" } else { "s" },
1786-
if len == 1 { "it" } else { "them" },
1783+
"if you don't care about {these} missing field{s}, you can explicitly ignore {them}",
1784+
these = pluralize!("this", len),
1785+
s = pluralize!(len),
1786+
them = if len == 1 { "it" } else { "them" },
17871787
),
17881788
format!("{}..{}", prefix, postfix),
17891789
Applicability::MachineApplicable,

compiler/rustc_typeck/src/coherence/inherent_impls.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! `tcx.inherent_impls(def_id)`). That value, however,
88
//! is computed by selecting an idea from this table.
99
10-
use rustc_errors::struct_span_err;
10+
use rustc_errors::{pluralize, struct_span_err};
1111
use rustc_hir as hir;
1212
use rustc_hir::def_id::{DefId, LocalDefId};
1313
use rustc_hir::itemlikevisit::ItemLikeVisitor;
@@ -410,7 +410,6 @@ impl<'tcx> InherentCollect<'tcx> {
410410
let to_implement = if assoc_items.is_empty() {
411411
String::new()
412412
} else {
413-
let plural = assoc_items.len() > 1;
414413
let assoc_items_kind = {
415414
let item_types = assoc_items.iter().map(|x| x.kind);
416415
if item_types.clone().all(|x| x == hir::AssocItemKind::Const) {
@@ -427,9 +426,9 @@ impl<'tcx> InherentCollect<'tcx> {
427426

428427
format!(
429428
" to implement {} {}{}",
430-
if plural { "these" } else { "this" },
429+
pluralize!("this", assoc_items.len()),
431430
assoc_items_kind,
432-
if plural { "s" } else { "" }
431+
pluralize!(assoc_items.len()),
433432
)
434433
};
435434

compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
657657

658658
let num_redundant_lt_args = lt_arg_spans.len() - self.num_expected_lifetime_args();
659659
let msg_lifetimes = format!(
660-
"remove {} {} argument{}",
661-
if num_redundant_lt_args == 1 { "this" } else { "these" },
662-
"lifetime",
663-
pluralize!(num_redundant_lt_args),
660+
"remove {these} lifetime argument{s}",
661+
these = pluralize!("this", num_redundant_lt_args),
662+
s = pluralize!(num_redundant_lt_args),
664663
);
665664

666665
err.span_suggestion(
@@ -700,10 +699,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
700699
let num_redundant_gen_args =
701700
gen_arg_spans.len() - self.num_expected_type_or_const_args();
702701
let msg_types_or_consts = format!(
703-
"remove {} {} argument{}",
704-
if num_redundant_gen_args == 1 { "this" } else { "these" },
705-
"generic",
706-
pluralize!(num_redundant_type_or_const_args),
702+
"remove {these} generic argument{s}",
703+
these = pluralize!("this", num_redundant_gen_args),
704+
s = pluralize!(num_redundant_gen_args),
707705
);
708706

709707
err.span_suggestion(

library/alloc/src/collections/btree/set/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ fn assert_send() {
609609

610610
#[allow(dead_code)]
611611
// Check that the member-like functions conditionally provided by #[derive()]
612-
// are not overriden by genuine member functions with a different signature.
612+
// are not overridden by genuine member functions with a different signature.
613613
fn assert_derives() {
614614
fn hash<T: Hash, H: Hasher>(v: BTreeSet<T>, state: &mut H) {
615615
v.hash(state);

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ impl Rustflags {
17951795
}
17961796

17971797
/// By default, cargo will pick up on various variables in the environment. However, bootstrap
1798-
/// reuses those variables to pass additional flags to rustdoc, so by default they get overriden.
1798+
/// reuses those variables to pass additional flags to rustdoc, so by default they get overridden.
17991799
/// Explicitly add back any previous value in the environment.
18001800
///
18011801
/// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`.

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ fn resolve_associated_trait_item<'a>(
948948
///
949949
/// This function returns `None` if no associated item was found in the impl.
950950
/// This can occur when the trait associated item has a default value that is
951-
/// not overriden in the impl.
951+
/// not overridden in the impl.
952952
///
953953
/// This is just a wrapper around [`TyCtxt::impl_item_implementor_ids()`] and
954954
/// [`TyCtxt::associated_item()`] (with some helpful logging added).

src/librustdoc/visit_ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
326326
om.items.push((item, renamed))
327327
}
328328
hir::ItemKind::Macro(ref macro_def, _) => {
329-
// `#[macro_export] macro_rules!` items are handled seperately in `visit()`,
329+
// `#[macro_export] macro_rules!` items are handled separately in `visit()`,
330330
// above, since they need to be documented at the module top level. Accordingly,
331331
// we only want to handle macros if one of three conditions holds:
332332
//

0 commit comments

Comments
 (0)