Skip to content

Commit

Permalink
Auto merge of rust-lang#94966 - matthiaskrgr:rollup-iqzswh3, r=matthi…
Browse files Browse the repository at this point in the history
…askrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#94810 (debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments.)
 - rust-lang#94947 (fix typos)
 - rust-lang#94956 (Fix small typo in FIXME)
 - rust-lang#94958 (Support other types of pluralization in pluralize macro)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 15, 2022
2 parents be52b4a + 183262d commit 83460d5
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 52 deletions.
13 changes: 10 additions & 3 deletions compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,18 @@ fn push_debuginfo_type_name<'tcx>(
if projection_bounds.len() != 0 {
if principal_has_generic_params {
// push_generic_params_internal() above added a `>` but we actually
// want to add more items to that list, so remove that again.
// want to add more items to that list, so remove that again...
pop_close_angle_bracket(output);
// .. and add a comma to separate the regular generic args from the
// associated types.
push_arg_separator(cpp_like_debuginfo, output);
} else {
// push_generic_params_internal() did not add `<...>`, so we open
// angle brackets here.
output.push('<');
}

for (item_def_id, ty) in projection_bounds {
push_arg_separator(cpp_like_debuginfo, output);

if cpp_like_debuginfo {
output.push_str("assoc$<");
push_item_name(tcx, item_def_id, false, output);
Expand All @@ -244,8 +249,10 @@ fn push_debuginfo_type_name<'tcx>(
output.push('=');
push_debuginfo_type_name(tcx, ty, true, output, visited);
}
push_arg_separator(cpp_like_debuginfo, output);
}

pop_arg_separator(output);
push_close_angle_bracket(cpp_like_debuginfo, output);
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<T> {
fn union(&mut self, other: &HybridBitSet<T>) -> bool {
// FIXME: This is slow if `other` is dense, but it hasn't been a problem
// in practice so far.
// If a a faster implementation of this operation is required, consider
// If a faster implementation of this operation is required, consider
// reopening https://github.com/rust-lang/rust/pull/94625
assert_eq!(self.domain_size, other.domain_size());
sequential_update(|elem| self.insert(elem), other.iter())
Expand All @@ -665,7 +665,7 @@ impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<T> {
fn subtract(&mut self, other: &HybridBitSet<T>) -> bool {
// FIXME: This is slow if `other` is dense, but it hasn't been a problem
// in practice so far.
// If a a faster implementation of this operation is required, consider
// If a faster implementation of this operation is required, consider
// reopening https://github.com/rust-lang/rust/pull/94625
assert_eq!(self.domain_size, other.domain_size());
sequential_update(|elem| self.remove(elem), other.iter())
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl UnsafeCode {
cx.struct_span_lint(UNSAFE_CODE, span, decorate);
}

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

ast::ItemKind::Fn(..) => {
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a `no_mangle` function",
);
}
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a function with `export_name`",
Expand All @@ -397,14 +397,14 @@ impl EarlyLintPass for UnsafeCode {

ast::ItemKind::Static(..) => {
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a `no_mangle` static",
);
}
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a static with `export_name`",
Expand All @@ -419,14 +419,14 @@ impl EarlyLintPass for UnsafeCode {
fn check_impl_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
if let ast::AssocItemKind::Fn(..) = it.kind {
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a `no_mangle` method",
);
}
if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) {
self.report_overriden_symbol_name(
self.report_overridden_symbol_name(
cx,
attr.span,
"declaration of a method with `export_name`",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'s> LintLevelsBuilder<'s> {
continue
};
for id in ids {
// ForceWarn and Forbid cannot be overriden
// ForceWarn and Forbid cannot be overridden
if let Some((Level::ForceWarn | Level::Forbid, _)) = self.current_specs().get(&id) {
continue;
}
Expand All @@ -137,7 +137,7 @@ impl<'s> LintLevelsBuilder<'s> {
self.sets.get_lint_level(id.lint, self.cur, Some(self.current_specs()), &self.sess);
// Setting to a non-forbid level is an error if the lint previously had
// a forbid level. Note that this is not necessarily true even with a
// `#[forbid(..)]` attribute present, as that is overriden by `--cap-lints`.
// `#[forbid(..)]` attribute present, as that is overridden by `--cap-lints`.
//
// This means that this only errors if we're truly lowering the lint
// level from forbid.
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ macro_rules! pluralize {
($x:expr) => {
if $x != 1 { "s" } else { "" }
};
("is", $x:expr) => {
if $x == 1 { "is" } else { "are" }
};
("this", $x:expr) => {
if $x == 1 { "this" } else { "these" }
};
}

/// Indicates the confidence in the correctness of a suggestion.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/generic_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn bb_to_graph_node(block: BasicBlock, body: &Body<'_>, dark_mode: bool) -> Node
let style = NodeStyle { title_bg: Some(bgcolor.to_owned()), ..Default::default() };
let mut stmts: Vec<String> = data.statements.iter().map(|x| format!("{:?}", x)).collect();

// add the terminator to the stmts, gsgdt can print it out seperately
// add the terminator to the stmts, gsgdt can print it out separately
let mut terminator_head = String::new();
data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
stmts.push(terminator_head);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
Pointer::new(*alloc, access.access_offset),
access.uninit_size.bytes(),
pluralize!(access.uninit_size.bytes()),
if access.uninit_size.bytes() != 1 { "are" } else { "is" },
pluralize!("is", access.uninit_size.bytes()),
Pointer::new(*alloc, access.uninit_offset),
),
InvalidUninitBytes(None) => write!(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct BorrowCheckResult<'tcx> {

/// The result of the `mir_const_qualif` query.
///
/// Each field (except `error_occured`) corresponds to an implementer of the `Qualif` trait in
/// Each field (except `error_occurred`) corresponds to an implementer of the `Qualif` trait in
/// `rustc_const_eval/src/transform/check_consts/qualifs.rs`. See that file for more information on each
/// `Qualif`.
#[derive(Clone, Copy, Debug, Default, TyEncodable, TyDecodable, HashStable)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ fn foo(&self) -> Self::T { String::new() }
"{some} method{s} {are} available that return{r} `{ty}`",
some = if methods.len() == 1 { "a" } else { "some" },
s = pluralize!(methods.len()),
are = if methods.len() == 1 { "is" } else { "are" },
are = pluralize!("is", methods.len()),
r = if methods.len() == 1 { "s" } else { "" },
ty = expected
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD

let (thir, expr) = tcx.thir_body(def);
let thir = &thir.borrow();
// If `thir` is empty, a type error occured, skip this body.
// If `thir` is empty, a type error occurred, skip this body.
if thir.exprs.is_empty() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ impl CheckAttrVisitor<'_> {
span,
format!(
"there {} only {} argument{}",
if arg_count != 1 { "are" } else { "is" },
pluralize!("is", arg_count),
arg_count,
pluralize!(arg_count)
),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
for sp in spans {
let msg = if sp == last_bound_span {
format!(
"...because of {} bound{}",
if bounds.len() <= 2 { "this" } else { "these" },
if bounds.len() <= 2 { "" } else { "s" },
"...because of {these} bound{s}",
these = pluralize!("this", bounds.len() - 1),
s = pluralize!(bounds.len() - 1),
)
} else {
String::new()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod desc {
pub const parse_linker_plugin_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
pub const parse_location_detail: &str =
"comma seperated list of location details to track: `file`, `line`, or `column`";
"comma separated list of location details to track: `file`, `line`, or `column`";
pub const parse_switch_with_opt_path: &str =
"an optional path to the profiling data output directory";
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
Expand Down Expand Up @@ -1283,7 +1283,7 @@ options! {
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
"generate JSON tracing data file from LLVM data (default: no)"),
location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
"comma seperated list of location details to be tracked when using caller_location \
"comma separated list of location details to be tracked when using caller_location \
valid options are `file`, `line`, and `column` (default: all)"),
ls: bool = (false, parse_bool, [UNTRACKED],
"list the symbols defined by a library crate (default: no)"),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct SymbolGallery {

impl SymbolGallery {
/// Insert a symbol and its span into symbol gallery.
/// If the symbol has occurred before, ignore the new occurance.
/// If the symbol has occurred before, ignore the new occurrance.
pub fn insert(&self, symbol: Symbol, span: Span) {
self.symbols.lock().entry(symbol).or_insert(span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
(true, Some(None)) => {
Some(format!("{cannot_do_this} in const contexts"))
}
// overriden post message
// overridden post message
(true, Some(Some(post_message))) => {
Some(format!("{cannot_do_this}{post_message}"))
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sp,
&format!(
"include the missing field{} in the pattern{}",
if len == 1 { "" } else { "s" },
pluralize!(len),
if have_inaccessible_fields { " and ignore the inaccessible fields" } else { "" }
),
format!(
Expand All @@ -1780,10 +1780,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_suggestion(
sp,
&format!(
"if you don't care about {} missing field{}, you can explicitly ignore {}",
if len == 1 { "this" } else { "these" },
if len == 1 { "" } else { "s" },
if len == 1 { "it" } else { "them" },
"if you don't care about {these} missing field{s}, you can explicitly ignore {them}",
these = pluralize!("this", len),
s = pluralize!(len),
them = if len == 1 { "it" } else { "them" },
),
format!("{}..{}", prefix, postfix),
Applicability::MachineApplicable,
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_typeck/src/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! `tcx.inherent_impls(def_id)`). That value, however,
//! is computed by selecting an idea from this table.

use rustc_errors::struct_span_err;
use rustc_errors::{pluralize, struct_span_err};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
Expand Down Expand Up @@ -410,7 +410,6 @@ impl<'tcx> InherentCollect<'tcx> {
let to_implement = if assoc_items.is_empty() {
String::new()
} else {
let plural = assoc_items.len() > 1;
let assoc_items_kind = {
let item_types = assoc_items.iter().map(|x| x.kind);
if item_types.clone().all(|x| x == hir::AssocItemKind::Const) {
Expand All @@ -427,9 +426,9 @@ impl<'tcx> InherentCollect<'tcx> {

format!(
" to implement {} {}{}",
if plural { "these" } else { "this" },
pluralize!("this", assoc_items.len()),
assoc_items_kind,
if plural { "s" } else { "" }
pluralize!(assoc_items.len()),
)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {

let num_redundant_lt_args = lt_arg_spans.len() - self.num_expected_lifetime_args();
let msg_lifetimes = format!(
"remove {} {} argument{}",
if num_redundant_lt_args == 1 { "this" } else { "these" },
"lifetime",
pluralize!(num_redundant_lt_args),
"remove {these} lifetime argument{s}",
these = pluralize!("this", num_redundant_lt_args),
s = pluralize!(num_redundant_lt_args),
);

err.span_suggestion(
Expand Down Expand Up @@ -700,10 +699,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
let num_redundant_gen_args =
gen_arg_spans.len() - self.num_expected_type_or_const_args();
let msg_types_or_consts = format!(
"remove {} {} argument{}",
if num_redundant_gen_args == 1 { "this" } else { "these" },
"generic",
pluralize!(num_redundant_type_or_const_args),
"remove {these} generic argument{s}",
these = pluralize!("this", num_redundant_gen_args),
s = pluralize!(num_redundant_gen_args),
);

err.span_suggestion(
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ fn assert_send() {

#[allow(dead_code)]
// Check that the member-like functions conditionally provided by #[derive()]
// are not overriden by genuine member functions with a different signature.
// are not overridden by genuine member functions with a different signature.
fn assert_derives() {
fn hash<T: Hash, H: Hasher>(v: BTreeSet<T>, state: &mut H) {
v.hash(state);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ impl Rustflags {
}

/// By default, cargo will pick up on various variables in the environment. However, bootstrap
/// reuses those variables to pass additional flags to rustdoc, so by default they get overriden.
/// reuses those variables to pass additional flags to rustdoc, so by default they get overridden.
/// Explicitly add back any previous value in the environment.
///
/// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ fn resolve_associated_trait_item<'a>(
///
/// This function returns `None` if no associated item was found in the impl.
/// This can occur when the trait associated item has a default value that is
/// not overriden in the impl.
/// not overridden in the impl.
///
/// This is just a wrapper around [`TyCtxt::impl_item_implementor_ids()`] and
/// [`TyCtxt::associated_item()`] (with some helpful logging added).
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
om.items.push((item, renamed))
}
hir::ItemKind::Macro(ref macro_def, _) => {
// `#[macro_export] macro_rules!` items are handled seperately in `visit()`,
// `#[macro_export] macro_rules!` items are handled separately in `visit()`,
// above, since they need to be documented at the module top level. Accordingly,
// we only want to handle macros if one of three conditions holds:
//
Expand Down
Loading

0 comments on commit 83460d5

Please sign in to comment.