Auto merge of #104591 - Manishearth:rollup-b3ser4e, r=Manishearth
Rollup of 8 pull requests Successful merges: - #102977 (remove HRTB from `[T]::is_sorted_by{,_key}`) - #103378 (Fix mod_inv termination for the last iteration) - #103456 (`unchecked_{shl|shr}` should use `u32` as the RHS) - #103701 (Simplify some pointer method implementations) - #104047 (Diagnostics `icu4x` based list formatting.) - #104338 (Enforce that `dyn*` coercions are actually pointer-sized) - #104498 (Edit docs for `rustc_errors::Handler::stash_diagnostic`) - #104556 (rustdoc: use `code-header` class to format enum variants) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ff0ffda6b3
48 changed files with 3030 additions and 150 deletions
|
@ -27,3 +27,6 @@ serde_json = "1.0.59"
|
|||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = [ "handleapi", "synchapi", "winbase" ] }
|
||||
|
||||
[features]
|
||||
rustc_use_parallel_compiler = ['rustc_error_messages/rustc_use_parallel_compiler']
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
|
||||
};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
|
||||
use rustc_error_messages::FluentValue;
|
||||
use rustc_lint_defs::{Applicability, LintExpectationId};
|
||||
use rustc_span::edition::LATEST_STABLE_EDITION;
|
||||
|
@ -34,6 +35,7 @@ pub type DiagnosticArgName<'source> = Cow<'source, str>;
|
|||
pub enum DiagnosticArgValue<'source> {
|
||||
Str(Cow<'source, str>),
|
||||
Number(usize),
|
||||
StrListSepByAnd(Vec<Cow<'source, str>>),
|
||||
}
|
||||
|
||||
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
|
||||
|
@ -49,6 +51,9 @@ impl<'source> IntoDiagnosticArg for DiagnosticArgValue<'source> {
|
|||
match self {
|
||||
DiagnosticArgValue::Str(s) => DiagnosticArgValue::Str(Cow::Owned(s.into_owned())),
|
||||
DiagnosticArgValue::Number(n) => DiagnosticArgValue::Number(n),
|
||||
DiagnosticArgValue::StrListSepByAnd(l) => DiagnosticArgValue::StrListSepByAnd(
|
||||
l.into_iter().map(|s| Cow::Owned(s.into_owned())).collect(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +63,7 @@ impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> {
|
|||
match self {
|
||||
DiagnosticArgValue::Str(s) => From::from(s),
|
||||
DiagnosticArgValue::Number(n) => From::from(n),
|
||||
DiagnosticArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ use rustc_target::abi::TargetDataLayoutErrors;
|
|||
use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::fmt::Write;
|
||||
use std::num::ParseIntError;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitStatus;
|
||||
|
@ -191,23 +190,9 @@ impl From<Vec<Symbol>> for DiagnosticSymbolList {
|
|||
|
||||
impl IntoDiagnosticArg for DiagnosticSymbolList {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
// FIXME: replace the logic here with a real list formatter
|
||||
let symbols = match &self.0[..] {
|
||||
[symbol] => format!("`{symbol}`"),
|
||||
[symbol, last] => {
|
||||
format!("`{symbol}` and `{last}`",)
|
||||
}
|
||||
[symbols @ .., last] => {
|
||||
let mut result = String::new();
|
||||
for symbol in symbols {
|
||||
write!(result, "`{symbol}`, ").unwrap();
|
||||
}
|
||||
write!(result, "and `{last}`").unwrap();
|
||||
result
|
||||
}
|
||||
[] => unreachable!(),
|
||||
};
|
||||
DiagnosticArgValue::Str(Cow::Owned(symbols))
|
||||
DiagnosticArgValue::StrListSepByAnd(
|
||||
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -644,13 +644,14 @@ impl Handler {
|
|||
inner.stashed_diagnostics = Default::default();
|
||||
}
|
||||
|
||||
/// Stash a given diagnostic with the given `Span` and `StashKey` as the key for later stealing.
|
||||
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||
/// Retrieve a stashed diagnostic with `steal_diagnostic`.
|
||||
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
inner.stash((span, key), diag);
|
||||
}
|
||||
|
||||
/// Steal a previously stashed diagnostic with the given `Span` and `StashKey` as the key.
|
||||
/// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||
pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
inner.steal((span, key)).map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue