Skip to content

Commit 9052ca9

Browse files
committed
Auto merge of rust-lang#111710 - Dylan-DPC:rollup-eutrx54, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#110884 (Support RISC-V unaligned-scalar-mem target feature) - rust-lang#111160 (Update serde in workspace and non-synced dependencies) - rust-lang#111168 (Specialize ToString implementation for fmt::Arguments) - rust-lang#111527 (add examples of port 0 binding behavior) - rust-lang#111561 (Include better context for "already exists" error in compiletest) - rust-lang#111633 (Avoid `&format("...")` calls in error message code.) - rust-lang#111679 (Remove libs message about ACPs from triagebot) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 77c836e + 7909088 commit 9052ca9

File tree

46 files changed

+189
-187
lines changed

Some content is hidden

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

46 files changed

+189
-187
lines changed

Cargo.lock

+7-6
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ dependencies = [
723723
name = "compiletest"
724724
version = "0.0.0"
725725
dependencies = [
726+
"anyhow",
726727
"build_helper",
727728
"colored",
728729
"diff",
@@ -2695,9 +2696,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
26952696

26962697
[[package]]
26972698
name = "proc-macro2"
2698-
version = "1.0.53"
2699+
version = "1.0.56"
26992700
source = "registry+https://github.com/rust-lang/crates.io-index"
2700-
checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73"
2701+
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
27012702
dependencies = [
27022703
"unicode-ident",
27032704
]
@@ -4477,18 +4478,18 @@ dependencies = [
44774478

44784479
[[package]]
44794480
name = "serde"
4480-
version = "1.0.159"
4481+
version = "1.0.160"
44814482
source = "registry+https://github.com/rust-lang/crates.io-index"
4482-
checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065"
4483+
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
44834484
dependencies = [
44844485
"serde_derive",
44854486
]
44864487

44874488
[[package]]
44884489
name = "serde_derive"
4489-
version = "1.0.159"
4490+
version = "1.0.160"
44904491
source = "registry+https://github.com/rust-lang/crates.io-index"
4491-
checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585"
4492+
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
44924493
dependencies = [
44934494
"proc-macro2",
44944495
"quote",

compiler/rustc_abi/src/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tracing::debug;
1212
pub trait LayoutCalculator {
1313
type TargetDataLayoutRef: Borrow<TargetDataLayout>;
1414

15-
fn delay_bug(&self, txt: &str);
15+
fn delay_bug(&self, txt: String);
1616
fn current_data_layout(&self) -> Self::TargetDataLayoutRef;
1717

1818
fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutS {
@@ -969,7 +969,7 @@ fn univariant(
969969
for &i in &inverse_memory_index {
970970
let field = &fields[i];
971971
if !sized {
972-
this.delay_bug(&format!(
972+
this.delay_bug(format!(
973973
"univariant: field #{} comes after unsized field",
974974
offsets.len(),
975975
));

compiler/rustc_borrowck/src/nll.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ pub(super) fn dump_annotation<'tcx>(
430430
fn for_each_region_constraint<'tcx>(
431431
tcx: TyCtxt<'tcx>,
432432
closure_region_requirements: &ClosureRegionRequirements<'tcx>,
433-
with_msg: &mut dyn FnMut(&str) -> io::Result<()>,
433+
with_msg: &mut dyn FnMut(String) -> io::Result<()>,
434434
) -> io::Result<()> {
435435
for req in &closure_region_requirements.outlives_requirements {
436436
let subject = match req.subject {
@@ -439,7 +439,7 @@ fn for_each_region_constraint<'tcx>(
439439
format!("{:?}", ty.instantiate(tcx, |vid| tcx.mk_re_var(vid)))
440440
}
441441
};
442-
with_msg(&format!("where {}: {:?}", subject, req.outlived_free_region,))?;
442+
with_msg(format!("where {}: {:?}", subject, req.outlived_free_region,))?;
443443
}
444444
Ok(())
445445
}

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ macro_rules! span_mirbug {
7171
$crate::type_check::mirbug(
7272
$context.tcx(),
7373
$context.last_span,
74-
&format!(
74+
format!(
7575
"broken MIR in {:?} ({:?}): {}",
7676
$context.body().source.def_id(),
7777
$elem,
@@ -274,7 +274,7 @@ fn translate_outlives_facts(typeck: &mut TypeChecker<'_, '_>) {
274274
}
275275

276276
#[track_caller]
277-
fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: &str) {
277+
fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: String) {
278278
// We sometimes see MIR failures (notably predicate failures) due to
279279
// the fact that we check rvalue sized predicates here. So use `delay_span_bug`
280280
// to avoid reporting bugs in those cases.

compiler/rustc_builtin_macros/src/asm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
550550
if !parser.errors.is_empty() {
551551
let err = parser.errors.remove(0);
552552
let err_sp = template_span.from_inner(InnerSpan::new(err.span.start, err.span.end));
553-
let msg = &format!("invalid asm template string: {}", err.description);
553+
let msg = format!("invalid asm template string: {}", err.description);
554554
let mut e = ecx.struct_span_err(err_sp, msg);
555555
e.span_label(err_sp, err.label + " in asm template string");
556556
if let Some(note) = err.note {
@@ -585,7 +585,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
585585
|| args.reg_args.contains(idx)
586586
{
587587
let msg = format!("invalid reference to argument at index {}", idx);
588-
let mut err = ecx.struct_span_err(span, &msg);
588+
let mut err = ecx.struct_span_err(span, msg);
589589
err.span_label(span, "from here");
590590

591591
let positional_args = args.operands.len()
@@ -638,7 +638,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
638638
ecx.struct_span_err(
639639
template_span
640640
.from_inner(InnerSpan::new(span.start, span.end)),
641-
&msg,
641+
msg,
642642
)
643643
.emit();
644644
None

compiler/rustc_builtin_macros/src/deriving/clone.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn cs_clone_simple(
145145
}
146146
_ => cx.span_bug(
147147
trait_span,
148-
&format!("unexpected substructure in simple `derive({})`", name),
148+
format!("unexpected substructure in simple `derive({})`", name),
149149
),
150150
}
151151
}
@@ -179,10 +179,10 @@ fn cs_clone(
179179
vdata = &variant.data;
180180
}
181181
EnumTag(..) | AllFieldlessEnum(..) => {
182-
cx.span_bug(trait_span, &format!("enum tags in `derive({})`", name,))
182+
cx.span_bug(trait_span, format!("enum tags in `derive({})`", name,))
183183
}
184184
StaticEnum(..) | StaticStruct(..) => {
185-
cx.span_bug(trait_span, &format!("associated function in `derive({})`", name))
185+
cx.span_bug(trait_span, format!("associated function in `derive({})`", name))
186186
}
187187
}
188188

@@ -194,7 +194,7 @@ fn cs_clone(
194194
let Some(ident) = field.name else {
195195
cx.span_bug(
196196
trait_span,
197-
&format!("unnamed field in normal struct in `derive({})`", name,),
197+
format!("unnamed field in normal struct in `derive({})`", name,),
198198
);
199199
};
200200
let call = subcall(cx, field);

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ impl<'a> TraitDef<'a> {
15911591
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
15921592
sp,
15931593
ast::CRATE_NODE_ID,
1594-
&format!(
1594+
format!(
15951595
"{} slice in a packed struct that derives a built-in trait",
15961596
ty
15971597
),

compiler/rustc_builtin_macros/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ fn report_invalid_references(
814814
};
815815
e = ecx.struct_span_err(
816816
span,
817-
&format!("invalid reference to positional {} ({})", arg_list, num_args_desc),
817+
format!("invalid reference to positional {} ({})", arg_list, num_args_desc),
818818
);
819819
e.note("positional arguments are zero-based");
820820
}

compiler/rustc_builtin_macros/src/source_util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ pub fn expand_include_str(
188188
base::MacEager::expr(cx.expr_str(sp, interned_src))
189189
}
190190
Err(_) => {
191-
cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display()));
191+
cx.span_err(sp, format!("{} wasn't a utf-8 file", file.display()));
192192
DummyResult::any(sp)
193193
}
194194
},
195195
Err(e) => {
196-
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
196+
cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e));
197197
DummyResult::any(sp)
198198
}
199199
}
@@ -221,7 +221,7 @@ pub fn expand_include_bytes(
221221
base::MacEager::expr(expr)
222222
}
223223
Err(e) => {
224-
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
224+
cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e));
225225
DummyResult::any(sp)
226226
}
227227
}

compiler/rustc_codegen_cranelift/src/pretty_clif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub(crate) fn write_ir_file(
227227
// Using early_warn as no Session is available here
228228
rustc_session::early_warn(
229229
rustc_session::config::ErrorOutputType::default(),
230-
&format!("error writing ir file: {}", err),
230+
format!("error writing ir file: {}", err),
231231
);
232232
}
233233
}

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
250250
("f", Some(sym::riscv_target_feature)),
251251
("m", Some(sym::riscv_target_feature)),
252252
("relax", Some(sym::riscv_target_feature)),
253+
("unaligned-scalar-mem", Some(sym::riscv_target_feature)),
253254
("v", Some(sym::riscv_target_feature)),
254255
("zba", Some(sym::riscv_target_feature)),
255256
("zbb", Some(sym::riscv_target_feature)),

compiler/rustc_driver_impl/src/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn arg_expand_all(at_args: &[String]) -> Vec<String> {
2525
Ok(arg) => args.extend(arg),
2626
Err(err) => rustc_session::early_error(
2727
rustc_session::config::ErrorOutputType::default(),
28-
&format!("Failed to load argument file: {err}"),
28+
format!("Failed to load argument file: {err}"),
2929
),
3030
}
3131
}

compiler/rustc_driver_impl/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn run_compiler(
322322
1 => panic!("make_input should have provided valid inputs"),
323323
_ => early_error(
324324
config.opts.error_format,
325-
&format!(
325+
format!(
326326
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
327327
matches.free[0], matches.free[1],
328328
),
@@ -527,7 +527,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
527527
}
528528
}
529529
Err(InvalidErrorCode) => {
530-
early_error(output, &format!("{code} is not a valid error code"));
530+
early_error(output, format!("{code} is not a valid error code"));
531531
}
532532
}
533533
}
@@ -1102,7 +1102,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
11021102
.map(|(flag, _)| format!("{e}. Did you mean `-{flag} {opt}`?")),
11031103
_ => None,
11041104
};
1105-
early_error(ErrorOutputType::default(), &msg.unwrap_or_else(|| e.to_string()));
1105+
early_error(ErrorOutputType::default(), msg.unwrap_or_else(|| e.to_string()));
11061106
});
11071107

11081108
// For all options we just parsed, we check a few aspects:
@@ -1250,7 +1250,7 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
12501250
#[cfg(windows)]
12511251
if let Some(msg) = info.payload().downcast_ref::<String>() {
12521252
if msg.starts_with("failed printing to stdout: ") && msg.ends_with("(os error 232)") {
1253-
early_error_no_abort(ErrorOutputType::default(), &msg);
1253+
early_error_no_abort(ErrorOutputType::default(), msg.as_str());
12541254
return;
12551255
}
12561256
};
@@ -1342,7 +1342,7 @@ pub fn init_rustc_env_logger() {
13421342
/// other than `RUSTC_LOG`.
13431343
pub fn init_env_logger(env: &str) {
13441344
if let Err(error) = rustc_log::init_env_logger(env) {
1345-
early_error(ErrorOutputType::default(), &error.to_string());
1345+
early_error(ErrorOutputType::default(), error.to_string());
13461346
}
13471347
}
13481348

@@ -1409,7 +1409,7 @@ pub fn main() -> ! {
14091409
arg.into_string().unwrap_or_else(|arg| {
14101410
early_error(
14111411
ErrorOutputType::default(),
1412-
&format!("argument {i} is not valid Unicode: {arg:?}"),
1412+
format!("argument {i} is not valid Unicode: {arg:?}"),
14131413
)
14141414
})
14151415
})

compiler/rustc_expand/src/base.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use rustc_attr::{self as attr, Deprecation, Stability};
1515
use rustc_data_structures::fx::FxIndexMap;
1616
use rustc_data_structures::sync::{self, Lrc};
1717
use rustc_errors::{
18-
Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, MultiSpan, PResult,
18+
Applicability, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, IntoDiagnostic,
19+
MultiSpan, PResult,
1920
};
2021
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
2122
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, RegisteredTools};
@@ -1110,7 +1111,7 @@ impl<'a> ExtCtxt<'a> {
11101111
pub fn struct_span_err<S: Into<MultiSpan>>(
11111112
&self,
11121113
sp: S,
1113-
msg: &str,
1114+
msg: impl Into<DiagnosticMessage>,
11141115
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
11151116
self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg)
11161117
}
@@ -1132,14 +1133,14 @@ impl<'a> ExtCtxt<'a> {
11321133
/// Compilation will be stopped in the near future (at the end of
11331134
/// the macro expansion phase).
11341135
#[rustc_lint_diagnostics]
1135-
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
1136+
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
11361137
self.sess.parse_sess.span_diagnostic.span_err(sp, msg);
11371138
}
11381139
#[rustc_lint_diagnostics]
1139-
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
1140+
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
11401141
self.sess.parse_sess.span_diagnostic.span_warn(sp, msg);
11411142
}
1142-
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
1143+
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
11431144
self.sess.parse_sess.span_diagnostic.span_bug(sp, msg);
11441145
}
11451146
pub fn trace_macros_diag(&mut self) {

compiler/rustc_expand/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
16641664
&UNUSED_ATTRIBUTES,
16651665
attr.span,
16661666
self.cx.current_expansion.lint_node_id,
1667-
&format!("unused attribute `{}`", attr_name),
1667+
format!("unused attribute `{}`", attr_name),
16681668
BuiltinLintDiagnostics::UnusedBuiltinAttribute {
16691669
attr_name,
16701670
macro_name: pprust::path_to_string(&call.path),

compiler/rustc_expand/src/mbe/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(super) fn failed_to_match_macro<'cx>(
4848

4949
let span = token.span.substitute_dummy(sp);
5050

51-
let mut err = cx.struct_span_err(span, &parse_failure_msg(&token));
51+
let mut err = cx.struct_span_err(span, parse_failure_msg(&token));
5252
err.span_label(span, label);
5353
if !def_span.is_dummy() && !cx.source_map().is_imported(def_span) {
5454
err.span_label(cx.source_map().guess_head_span(def_span), "when calling this macro");
@@ -170,7 +170,7 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx,
170170
}
171171
Error(err_sp, msg) => {
172172
let span = err_sp.substitute_dummy(self.root_span);
173-
self.cx.struct_span_err(span, msg).emit();
173+
self.cx.struct_span_err(span, msg.as_str()).emit();
174174
self.result = Some(DummyResult::any(span));
175175
}
176176
ErrorReported(_) => self.result = Some(DummyResult::any(self.root_span)),

compiler/rustc_expand/src/mbe/macro_check.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use crate::mbe::{KleeneToken, TokenTree};
110110
use rustc_ast::token::{Delimiter, Token, TokenKind};
111111
use rustc_ast::{NodeId, DUMMY_NODE_ID};
112112
use rustc_data_structures::fx::FxHashMap;
113-
use rustc_errors::MultiSpan;
113+
use rustc_errors::{DiagnosticMessage, MultiSpan};
114114
use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
115115
use rustc_session::parse::ParseSess;
116116
use rustc_span::symbol::kw;
@@ -593,7 +593,7 @@ fn check_ops_is_prefix(
593593
return;
594594
}
595595
}
596-
buffer_lint(sess, span.into(), node_id, &format!("unknown macro variable `{}`", name));
596+
buffer_lint(sess, span.into(), node_id, format!("unknown macro variable `{}`", name));
597597
}
598598

599599
/// Returns whether `binder_ops` is a prefix of `occurrence_ops`.
@@ -626,7 +626,7 @@ fn ops_is_prefix(
626626
if i >= occurrence_ops.len() {
627627
let mut span = MultiSpan::from_span(span);
628628
span.push_span_label(binder.span, "expected repetition");
629-
let message = &format!("variable '{}' is still repeating at this depth", name);
629+
let message = format!("variable '{}' is still repeating at this depth", name);
630630
buffer_lint(sess, span, node_id, message);
631631
return;
632632
}
@@ -642,7 +642,12 @@ fn ops_is_prefix(
642642
}
643643
}
644644

645-
fn buffer_lint(sess: &ParseSess, span: MultiSpan, node_id: NodeId, message: &str) {
645+
fn buffer_lint(
646+
sess: &ParseSess,
647+
span: MultiSpan,
648+
node_id: NodeId,
649+
message: impl Into<DiagnosticMessage>,
650+
) {
646651
// Macros loaded from other crates have dummy node ids.
647652
if node_id != DUMMY_NODE_ID {
648653
sess.buffer_lint(&META_VARIABLE_MISUSE, span, node_id, message);

compiler/rustc_expand/src/mbe/transcribe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ fn out_of_bounds_err<'a>(
510510
must be less than {max}"
511511
)
512512
};
513-
cx.struct_span_err(span, &msg)
513+
cx.struct_span_err(span, msg)
514514
}
515515

516516
fn transcribe_metavar_expr<'a>(

0 commit comments

Comments
 (0)