summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_errors/src/diagnostic.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /compiler/rustc_errors/src/diagnostic.rs
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_errors/src/diagnostic.rs')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 29c692128..ed0d06ed0 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -10,7 +10,7 @@ use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
use std::borrow::Cow;
-use std::fmt;
+use std::fmt::{self, Debug};
use std::hash::{Hash, Hasher};
use std::panic::Location;
@@ -33,7 +33,7 @@ pub type DiagnosticArgName<'source> = Cow<'source, str>;
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
pub enum DiagnosticArgValue<'source> {
Str(Cow<'source, str>),
- Number(usize),
+ Number(i128),
StrListSepByAnd(Vec<Cow<'source, str>>),
}
@@ -352,14 +352,9 @@ impl Diagnostic {
/// Labels all the given spans with the provided label.
/// See [`Self::span_label()`] for more information.
- pub fn span_labels(
- &mut self,
- spans: impl IntoIterator<Item = Span>,
- label: impl AsRef<str>,
- ) -> &mut Self {
- let label = label.as_ref();
+ pub fn span_labels(&mut self, spans: impl IntoIterator<Item = Span>, label: &str) -> &mut Self {
for span in spans {
- self.span_label(span, label);
+ self.span_label(span, label.to_string());
}
self
}
@@ -394,17 +389,18 @@ impl Diagnostic {
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
) -> &mut Self {
- let mut msg: Vec<_> = vec![("required when trying to coerce from type `", Style::NoStyle)];
+ let mut msg: Vec<_> =
+ vec![(Cow::from("required when trying to coerce from type `"), Style::NoStyle)];
msg.extend(expected.0.iter().map(|x| match *x {
- StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
- StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight),
+ StringPart::Normal(ref s) => (Cow::from(s.clone()), Style::NoStyle),
+ StringPart::Highlighted(ref s) => (Cow::from(s.clone()), Style::Highlight),
}));
- msg.push(("` to type '", Style::NoStyle));
+ msg.push((Cow::from("` to type '"), Style::NoStyle));
msg.extend(found.0.iter().map(|x| match *x {
- StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
- StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight),
+ StringPart::Normal(ref s) => (Cow::from(s.clone()), Style::NoStyle),
+ StringPart::Highlighted(ref s) => (Cow::from(s.clone()), Style::Highlight),
}));
- msg.push(("`", Style::NoStyle));
+ msg.push((Cow::from("`"), Style::NoStyle));
// For now, just attach these as notes
self.highlighted_note(msg);