Skip to content

Commit 872e401

Browse files
committed
Fixed issue #144023 by changing error label and note
1 parent e5e79f8 commit 872e401

File tree

43 files changed

+660
-633
lines changed

Some content is hidden

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

43 files changed

+660
-633
lines changed

compiler/rustc_parse_format/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,11 @@ impl<'input> Parser<'input> {
859859
0,
860860
ParseError {
861861
description: "expected format parameter to occur after `:`".to_owned(),
862-
note: None,
863-
label: format!("expected `{}` to occur after `:`", alignment),
862+
note: Some(
863+
"See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details"
864+
.to_string(),
865+
),
866+
label: format!("expected `{}` to occur in its correct place", alignment),
864867
span: range,
865868
secondary_label: None,
866869
suggestion: Suggestion::None,

src/tools/clippy/clippy_lints/src/disallowed_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use clippy_config::Conf;
32
use clippy_config::types::{DisallowedPath, create_disallowed_map};
43
use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then};

src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
311311

312312
/// Functions marked with these attributes must have the exact signature.
313313
pub(crate) fn requires_exact_signature(attrs: &[Attribute]) -> bool {
314-
attrs.iter().any(|attr| {
315-
attr.is_proc_macro_attr()
316-
})
314+
attrs.iter().any(|attr| attr.is_proc_macro_attr())
317315
}
318316

319317
#[derive(Default)]

src/tools/miri/cargo-miri/src/arg.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
4545
}
4646
// These branches cannot be merged if we want to avoid the allocation in the `Borrowed` branch.
4747
match &arg {
48-
Cow::Borrowed(arg) =>
48+
Cow::Borrowed(arg) => {
4949
if let Some(suffix) = arg.strip_prefix(self.name) {
5050
// Strip leading `name`.
5151
if suffix.is_empty() {
@@ -55,8 +55,9 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
5555
// This argument is `name=value`; get the value.
5656
return Some(Ok(Cow::Borrowed(suffix)));
5757
}
58-
},
59-
Cow::Owned(arg) =>
58+
}
59+
}
60+
Cow::Owned(arg) => {
6061
if let Some(suffix) = arg.strip_prefix(self.name) {
6162
// Strip leading `name`.
6263
if suffix.is_empty() {
@@ -67,7 +68,8 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
6768
// here as a `String` cannot be subsliced (what would the lifetime be?).
6869
return Some(Ok(Cow::Owned(suffix.to_owned())));
6970
}
70-
},
71+
}
72+
}
7173
}
7274
Some(Err(arg))
7375
}
@@ -78,11 +80,9 @@ impl<'a, I: Iterator<Item = String> + 'a> ArgSplitFlagValue<'a, I> {
7880
args: I,
7981
name: &'a str,
8082
) -> impl Iterator<Item = Result<String, String>> + 'a {
81-
ArgSplitFlagValue::new(args.map(Cow::Owned), name).map(|x| {
82-
match x {
83-
Ok(s) => Ok(s.into_owned()),
84-
Err(s) => Err(s.into_owned()),
85-
}
83+
ArgSplitFlagValue::new(args.map(Cow::Owned), name).map(|x| match x {
84+
Ok(s) => Ok(s.into_owned()),
85+
Err(s) => Err(s.into_owned()),
8686
})
8787
}
8888
}
@@ -92,12 +92,10 @@ impl<'x: 'a, 'a, I: Iterator<Item = &'x str> + 'a> ArgSplitFlagValue<'a, I> {
9292
args: I,
9393
name: &'a str,
9494
) -> impl Iterator<Item = Result<&'x str, &'x str>> + 'a {
95-
ArgSplitFlagValue::new(args.map(Cow::Borrowed), name).map(|x| {
96-
match x {
97-
Ok(Cow::Borrowed(s)) => Ok(s),
98-
Err(Cow::Borrowed(s)) => Err(s),
99-
_ => panic!("iterator converted borrowed to owned"),
100-
}
95+
ArgSplitFlagValue::new(args.map(Cow::Borrowed), name).map(|x| match x {
96+
Ok(Cow::Borrowed(s)) => Ok(s),
97+
Err(Cow::Borrowed(s)) => Err(s),
98+
_ => panic!("iterator converted borrowed to owned"),
10199
})
102100
}
103101
}

src/tools/miri/cargo-miri/src/phases.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
8585
"setup" => MiriCommand::Setup,
8686
"test" | "t" | "run" | "r" | "nextest" => MiriCommand::Forward(subcommand),
8787
"clean" => MiriCommand::Clean,
88-
_ =>
89-
show_error!(
90-
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`."
91-
),
88+
_ => show_error!(
89+
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`."
90+
),
9291
};
9392
let verbose = num_arg_flag("-v") + num_arg_flag("--verbose");
9493
let quiet = has_arg_flag("-q") || has_arg_flag("--quiet");

src/tools/miri/cargo-miri/src/setup.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ pub fn setup(
7373
None =>
7474
// No-std heuristic taken from rust/src/bootstrap/config.rs
7575
// (https://github.com/rust-lang/rust/blob/25b5af1b3a0b9e2c0c57b223b2d0e3e203869b2c/src/bootstrap/config.rs#L549-L555).
76+
{
7677
target.contains("-none")
7778
|| target.contains("nvptx")
7879
|| target.contains("switch")
79-
|| target.contains("-uefi"),
80+
|| target.contains("-uefi")
81+
}
8082
Some(val) => val != "0",
8183
};
8284
let sysroot_config = if no_std {
@@ -168,13 +170,14 @@ pub fn setup(
168170
.when_build_required(notify)
169171
.build_from_source(&rust_src);
170172
match status {
171-
Ok(SysrootStatus::AlreadyCached) =>
173+
Ok(SysrootStatus::AlreadyCached) => {
172174
if !quiet && show_setup {
173175
eprintln!(
174176
"A sysroot for Miri is already available in `{}`.",
175177
sysroot_dir.display()
176178
);
177-
},
179+
}
180+
}
178181
Ok(SysrootStatus::SysrootBuilt) => {
179182
// Print what `notify` prepared.
180183
eprint!("{after_build_output}");

src/tools/miri/src/alloc/alloc_bytes.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ impl Drop for MiriAllocBytes {
5454
unsafe {
5555
match self.params.clone() {
5656
MiriAllocParams::Global => alloc::dealloc(self.ptr, alloc_layout),
57-
MiriAllocParams::Isolated(alloc) =>
58-
alloc.borrow_mut().dealloc(self.ptr, alloc_layout),
57+
MiriAllocParams::Isolated(alloc) => {
58+
alloc.borrow_mut().dealloc(self.ptr, alloc_layout)
59+
}
5960
}
6061
}
6162
}

src/tools/miri/src/bin/log/tracing_chrome.rs

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
// should not be included if the "tracing" feature is disabled.
2626
extern crate tracing_core;
2727

28-
use tracing_core::{field::Field, span, Event, Subscriber};
28+
use tracing_core::{Event, Subscriber, field::Field, span};
2929
use tracing_subscriber::{
30+
Layer,
3031
layer::Context,
3132
registry::{LookupSpan, SpanRef},
32-
Layer,
3333
};
3434

35-
use serde_json::{json, Value as JsonValue};
35+
use serde_json::{Value as JsonValue, json};
3636
use std::{
3737
marker::PhantomData,
3838
path::Path,
3939
sync::{
40-
atomic::{AtomicUsize, Ordering},
4140
Arc, Mutex,
41+
atomic::{AtomicUsize, Ordering},
4242
},
4343
};
4444

@@ -308,10 +308,7 @@ fn create_default_writer() -> Box<dyn Write + Send> {
308308
Box::new(
309309
std::fs::File::create(format!(
310310
"./trace-{}.json",
311-
std::time::SystemTime::UNIX_EPOCH
312-
.elapsed()
313-
.unwrap()
314-
.as_micros()
311+
std::time::SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros()
315312
))
316313
.expect("Failed to create trace file."),
317314
)
@@ -325,9 +322,7 @@ where
325322
let (tx, rx) = mpsc::channel();
326323
OUT.with(|val| val.replace(Some(tx.clone())));
327324

328-
let out_writer = builder
329-
.out_writer
330-
.unwrap_or_else(|| create_default_writer());
325+
let out_writer = builder.out_writer.unwrap_or_else(|| create_default_writer());
331326

332327
let handle = std::thread::spawn(move || {
333328
let mut write = BufWriter::new(out_writer);
@@ -437,10 +432,7 @@ where
437432
write.flush().unwrap();
438433
});
439434

440-
let guard = FlushGuard {
441-
sender: tx.clone(),
442-
handle: Cell::new(Some(handle)),
443-
};
435+
let guard = FlushGuard { sender: tx.clone(), handle: Cell::new(Some(handle)) };
444436
let layer = ChromeLayer {
445437
out: Arc::new(Mutex::new(tx)),
446438
start: std::time::Instant::now(),
@@ -488,19 +480,12 @@ where
488480
None
489481
}
490482
}
491-
EventOrSpan::Span(s) => s
492-
.extensions()
493-
.get::<ArgsWrapper>()
494-
.map(|e| &e.args)
495-
.cloned(),
483+
EventOrSpan::Span(s) => s.extensions().get::<ArgsWrapper>().map(|e| &e.args).cloned(),
496484
};
497485
let name = name.unwrap_or_else(|| meta.name().into());
498486
let target = target.unwrap_or_else(|| meta.target().into());
499-
let (file, line) = if self.include_locations {
500-
(meta.file(), meta.line())
501-
} else {
502-
(None, None)
503-
};
487+
let (file, line) =
488+
if self.include_locations { (meta.file(), meta.line()) } else { (None, None) };
504489

505490
if new_thread {
506491
let name = match std::thread::current().name() {
@@ -510,14 +495,7 @@ where
510495
self.send_message(Message::NewThread(tid, name));
511496
}
512497

513-
Callsite {
514-
tid,
515-
name,
516-
target,
517-
file,
518-
line,
519-
args,
520-
}
498+
Callsite { tid, name, target, file, line, args }
521499
}
522500

523501
fn get_root_id(&self, span: SpanRef<S>) -> Option<i64> {
@@ -534,7 +512,7 @@ where
534512
} else {
535513
None
536514
}
537-
},
515+
}
538516
TraceStyle::Async => Some(
539517
span.scope()
540518
.from_root()
@@ -543,7 +521,7 @@ where
543521
.unwrap_or(span)
544522
.id()
545523
.into_u64()
546-
.cast_signed() // the comment above explains the cast
524+
.cast_signed(), // the comment above explains the cast
547525
),
548526
}
549527
}
@@ -622,9 +600,7 @@ where
622600
if self.include_args {
623601
let mut args = Object::new();
624602
attrs.record(&mut JsonVisitor { object: &mut args });
625-
ctx.span(id).unwrap().extensions_mut().insert(ArgsWrapper {
626-
args: Arc::new(args),
627-
});
603+
ctx.span(id).unwrap().extensions_mut().insert(ArgsWrapper { args: Arc::new(args) });
628604
}
629605
if let TraceStyle::Threaded = self.trace_style {
630606
return;
@@ -650,8 +626,7 @@ struct JsonVisitor<'a> {
650626

651627
impl<'a> tracing_subscriber::field::Visit for JsonVisitor<'a> {
652628
fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
653-
self.object
654-
.insert(field.name().to_owned(), format!("{value:?}").into());
629+
self.object.insert(field.name().to_owned(), format!("{value:?}").into());
655630
}
656631
}
657632

src/tools/miri/src/bin/miri.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,9 @@ fn main() {
516516
Some(BorrowTrackerMethod::TreeBorrows(params)) => {
517517
params.precise_interior_mut = false;
518518
}
519-
_ =>
520-
fatal_error!(
521-
"`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
522-
),
519+
_ => fatal_error!(
520+
"`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
521+
),
523522
};
524523
} else if arg == "-Zmiri-disable-data-race-detector" {
525524
miri_config.data_race_detector = false;
@@ -541,12 +540,12 @@ fn main() {
541540
"abort" => miri::IsolatedOp::Reject(miri::RejectOpWith::Abort),
542541
"hide" => miri::IsolatedOp::Reject(miri::RejectOpWith::NoWarning),
543542
"warn" => miri::IsolatedOp::Reject(miri::RejectOpWith::Warning),
544-
"warn-nobacktrace" =>
545-
miri::IsolatedOp::Reject(miri::RejectOpWith::WarningWithoutBacktrace),
546-
_ =>
547-
fatal_error!(
548-
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
549-
),
543+
"warn-nobacktrace" => {
544+
miri::IsolatedOp::Reject(miri::RejectOpWith::WarningWithoutBacktrace)
545+
}
546+
_ => fatal_error!(
547+
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
548+
),
550549
};
551550
} else if arg == "-Zmiri-ignore-leaks" {
552551
miri_config.ignore_leaks = true;

0 commit comments

Comments
 (0)