Skip to content

Commit 5ad7454

Browse files
committed
Auto merge of rust-lang#120491 - GuillaumeGomez:rollup-94wj681, r=GuillaumeGomez
Rollup of 18 pull requests Successful merges: - rust-lang#119123 (Add triagebot mentions entry for simd intrinsics) - rust-lang#119991 (Reject infinitely-sized reads from io::Repeat) - rust-lang#120172 (bootstrap: add more unit tests) - rust-lang#120250 (rustdoc: Prevent JS injection from localStorage) - rust-lang#120376 (Update codegen test for LLVM 18) - rust-lang#120387 (interpret/memory: fix safety comment for large array memset optimization) - rust-lang#120400 (Bound errors span label cleanup) - rust-lang#120402 (Make the coroutine def id of an async closure the child of the closure def id) - rust-lang#120403 (Add instructions of how to use pre-vendored 'rustc-src') - rust-lang#120424 (raw pointer metadata API: data address -> data pointer) - rust-lang#120425 (Remove unnecessary unit returns in query declarations) - rust-lang#120439 (Move UI issue tests to subdirectories) - rust-lang#120443 (Fixes footnote handling in rustdoc) - rust-lang#120452 (std: Update documentation of seek_write on Windows) - rust-lang#120460 (Be more careful about interpreting a label/lifetime as a mistyped char literal.) - rust-lang#120464 (Add matthewjasper to some review groups) - rust-lang#120467 (Update books) - rust-lang#120488 (Diagnostic lifetimes cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c401f09 + f99b510 commit 5ad7454

File tree

158 files changed

+578
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+578
-427
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -3003,11 +3003,11 @@ dependencies = [
30033003

30043004
[[package]]
30053005
name = "pulldown-cmark"
3006-
version = "0.9.3"
3006+
version = "0.9.6"
30073007
source = "registry+https://github.com/rust-lang/crates.io-index"
3008-
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
3008+
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
30093009
dependencies = [
3010-
"bitflags 1.3.2",
3010+
"bitflags 2.4.1",
30113011
"memchr",
30123012
"unicase",
30133013
]

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Display for RegionName {
188188
}
189189

190190
impl rustc_errors::IntoDiagnosticArg for RegionName {
191-
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
191+
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
192192
self.to_string().into_diagnostic_arg()
193193
}
194194
}

compiler/rustc_codegen_gcc/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) enum PossibleFeature<'a> {
3535
struct ExitCode(Option<i32>);
3636

3737
impl IntoDiagnosticArg for ExitCode {
38-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
38+
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
3939
let ExitCode(exit_code) = self;
4040
match exit_code {
4141
Some(t) => t.into_diagnostic_arg(),

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl fmt::Display for CguReuse {
206206
}
207207

208208
impl IntoDiagnosticArg for CguReuse {
209-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
209+
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
210210
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
211211
}
212212
}

compiler/rustc_codegen_ssa/src/back/write.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ use rustc_data_structures::memmap::Mmap;
1414
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
1515
use rustc_data_structures::sync::Lrc;
1616
use rustc_errors::emitter::Emitter;
17-
use rustc_errors::{translation::Translate, DiagCtxt, FatalError, Level};
18-
use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, ErrCode, Style};
17+
use rustc_errors::translation::Translate;
18+
use rustc_errors::{
19+
DiagCtxt, DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, ErrCode,
20+
FatalError, FluentBundle, Level, Style,
21+
};
1922
use rustc_fs_util::link_or_copy;
2023
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2124
use rustc_incremental::{
@@ -995,11 +998,9 @@ pub(crate) enum Message<B: WriteBackendMethods> {
995998
/// process another codegen unit.
996999
pub struct CguMessage;
9971000

998-
type DiagnosticArgName<'source> = Cow<'source, str>;
999-
10001001
struct Diagnostic {
10011002
msgs: Vec<(DiagnosticMessage, Style)>,
1002-
args: FxHashMap<DiagnosticArgName<'static>, rustc_errors::DiagnosticArgValue<'static>>,
1003+
args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>,
10031004
code: Option<ErrCode>,
10041005
lvl: Level,
10051006
}
@@ -1800,18 +1801,18 @@ impl SharedEmitter {
18001801
}
18011802

18021803
impl Translate for SharedEmitter {
1803-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
1804+
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
18041805
None
18051806
}
18061807

1807-
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
1808+
fn fallback_fluent_bundle(&self) -> &FluentBundle {
18081809
panic!("shared emitter attempted to translate a diagnostic");
18091810
}
18101811
}
18111812

18121813
impl Emitter for SharedEmitter {
18131814
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
1814-
let args: FxHashMap<Cow<'_, str>, rustc_errors::DiagnosticArgValue<'_>> =
1815+
let args: FxHashMap<Cow<'_, str>, DiagnosticArgValue> =
18151816
diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect();
18161817
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
18171818
msgs: diag.messages.clone(),

compiler/rustc_codegen_ssa/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a> CopyPath<'a> {
147147
struct DebugArgPath<'a>(pub &'a Path);
148148

149149
impl IntoDiagnosticArg for DebugArgPath<'_> {
150-
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
150+
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
151151
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
152152
}
153153
}
@@ -974,7 +974,7 @@ pub enum ExpectedPointerMutability {
974974
}
975975

976976
impl IntoDiagnosticArg for ExpectedPointerMutability {
977-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
977+
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
978978
match self {
979979
ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")),
980980
ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")),

compiler/rustc_const_eval/src/const_eval/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl MachineStopType for ConstEvalErrKind {
3434
}
3535
fn add_args(
3636
self: Box<Self>,
37-
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue<'static>),
37+
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue),
3838
) {
3939
use ConstEvalErrKind::*;
4040
match *self {

compiler/rustc_const_eval/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl ReportErrorExt for ResourceExhaustionInfo {
906906
}
907907

908908
impl rustc_errors::IntoDiagnosticArg for InternKind {
909-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
909+
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
910910
DiagnosticArgValue::Str(Cow::Borrowed(match self {
911911
InternKind::Static(Mutability::Not) => "static",
912912
InternKind::Static(Mutability::Mut) => "static_mut",

compiler/rustc_const_eval/src/interpret/memory.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
396396
/// to the allocation it points to. Supports both shared and mutable references, as the actual
397397
/// checking is offloaded to a helper closure.
398398
///
399-
/// If this returns `None`, the size is 0; it can however return `Some` even for size 0.
399+
/// Returns `None` if and only if the size is 0.
400400
fn check_and_deref_ptr<T>(
401401
&self,
402402
ptr: Pointer<Option<M::Provenance>>,
@@ -1214,10 +1214,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
12141214
let size_in_bytes = size.bytes_usize();
12151215
// For particularly large arrays (where this is perf-sensitive) it's common that
12161216
// we're writing a single byte repeatedly. So, optimize that case to a memset.
1217-
if size_in_bytes == 1 && num_copies >= 1 {
1218-
// SAFETY: `src_bytes` would be read from anyway by copies below (num_copies >= 1).
1219-
// Since size_in_bytes = 1, then the `init.no_bytes_init()` check above guarantees
1220-
// that this read at type `u8` is OK -- it must be an initialized byte.
1217+
if size_in_bytes == 1 {
1218+
debug_assert!(num_copies >= 1); // we already handled the zero-sized cases above.
1219+
// SAFETY: `src_bytes` would be read from anyway by `copy` below (num_copies >= 1).
12211220
let value = *src_bytes;
12221221
dest_bytes.write_bytes(value, (size * num_copies).bytes_usize());
12231222
} else if src_alloc_id == dest_alloc_id {

compiler/rustc_errors/src/diagnostic.rs

+15-25
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,36 @@ pub struct SuggestionsDisabled;
2323
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
2424
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
2525
/// diagnostic emission.
26-
pub type DiagnosticArg<'iter, 'source> =
27-
(&'iter DiagnosticArgName<'source>, &'iter DiagnosticArgValue<'source>);
26+
pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);
2827

2928
/// Name of a diagnostic argument.
30-
pub type DiagnosticArgName<'source> = Cow<'source, str>;
29+
pub type DiagnosticArgName = Cow<'static, str>;
3130

3231
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
3332
/// to a `FluentValue` by the emitter to be used in diagnostic translation.
3433
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
35-
pub enum DiagnosticArgValue<'source> {
36-
Str(Cow<'source, str>),
34+
pub enum DiagnosticArgValue {
35+
Str(Cow<'static, str>),
3736
Number(i128),
38-
StrListSepByAnd(Vec<Cow<'source, str>>),
37+
StrListSepByAnd(Vec<Cow<'static, str>>),
3938
}
4039

4140
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
4241
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
4342
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
4443
/// crates to implement this.
4544
pub trait IntoDiagnosticArg {
46-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static>;
45+
fn into_diagnostic_arg(self) -> DiagnosticArgValue;
4746
}
4847

49-
impl<'source> IntoDiagnosticArg for DiagnosticArgValue<'source> {
50-
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
51-
match self {
52-
DiagnosticArgValue::Str(s) => DiagnosticArgValue::Str(Cow::Owned(s.into_owned())),
53-
DiagnosticArgValue::Number(n) => DiagnosticArgValue::Number(n),
54-
DiagnosticArgValue::StrListSepByAnd(l) => DiagnosticArgValue::StrListSepByAnd(
55-
l.into_iter().map(|s| Cow::Owned(s.into_owned())).collect(),
56-
),
57-
}
48+
impl IntoDiagnosticArg for DiagnosticArgValue {
49+
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
50+
self
5851
}
5952
}
6053

61-
impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> {
62-
fn into(self) -> FluentValue<'source> {
54+
impl Into<FluentValue<'static>> for DiagnosticArgValue {
55+
fn into(self) -> FluentValue<'static> {
6356
match self {
6457
DiagnosticArgValue::Str(s) => From::from(s),
6558
DiagnosticArgValue::Number(n) => From::from(n),
@@ -109,7 +102,7 @@ pub struct Diagnostic {
109102
pub span: MultiSpan,
110103
pub children: Vec<SubDiagnostic>,
111104
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
112-
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>,
105+
args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>,
113106

114107
/// This is not used for highlighting or rendering any error message. Rather, it can be used
115108
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@@ -916,7 +909,7 @@ impl Diagnostic {
916909
// Exact iteration order of diagnostic arguments shouldn't make a difference to output because
917910
// they're only used in interpolation.
918911
#[allow(rustc::potential_query_instability)]
919-
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_, 'static>> {
912+
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_>> {
920913
self.args.iter()
921914
}
922915

@@ -929,10 +922,7 @@ impl Diagnostic {
929922
self
930923
}
931924

932-
pub fn replace_args(
933-
&mut self,
934-
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>,
935-
) {
925+
pub fn replace_args(&mut self, args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>) {
936926
self.args = args;
937927
}
938928

@@ -990,7 +980,7 @@ impl Diagnostic {
990980
) -> (
991981
&Level,
992982
&[(DiagnosticMessage, Style)],
993-
Vec<(&Cow<'static, str>, &DiagnosticArgValue<'static>)>,
983+
Vec<(&Cow<'static, str>, &DiagnosticArgValue)>,
994984
&Option<ErrCode>,
995985
&Option<IsLint>,
996986
&MultiSpan,

0 commit comments

Comments
 (0)