Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/rustc_parse_format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,11 @@ impl<'input> Parser<'input> {
0,
ParseError {
description: "expected format parameter to occur after `:`".to_owned(),
note: None,
label: format!("expected `{}` to occur after `:`", alignment),
note: Some(
"See https://doc.rust-lang.org/std/fmt/index.html#syntax for more details"
.to_string(),
),
label: format!("expected `{}` to occur in its correct place", alignment),
span: range,
secondary_label: None,
suggestion: Suggestion::None,
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/clippy_lints/src/disallowed_macros.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like formatting only changes in Clippy. Please revert those. It's a minor inconvenience during the sync (This extra newline removal isn't but the other file is).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use clippy_config::Conf;
use clippy_config::types::{DisallowedPath, create_disallowed_map};
use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then};
Expand Down
4 changes: 1 addition & 3 deletions src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {

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

#[derive(Default)]
Expand Down
28 changes: 13 additions & 15 deletions src/tools/miri/cargo-miri/src/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
}
// These branches cannot be merged if we want to avoid the allocation in the `Borrowed` branch.
match &arg {
Cow::Borrowed(arg) =>
Cow::Borrowed(arg) => {
if let Some(suffix) = arg.strip_prefix(self.name) {
// Strip leading `name`.
if suffix.is_empty() {
Expand All @@ -55,8 +55,9 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
// This argument is `name=value`; get the value.
return Some(Ok(Cow::Borrowed(suffix)));
}
},
Cow::Owned(arg) =>
}
}
Cow::Owned(arg) => {
if let Some(suffix) = arg.strip_prefix(self.name) {
// Strip leading `name`.
if suffix.is_empty() {
Expand All @@ -67,7 +68,8 @@ impl<'s, I: Iterator<Item = Cow<'s, str>>> Iterator for ArgSplitFlagValue<'_, I>
// here as a `String` cannot be subsliced (what would the lifetime be?).
return Some(Ok(Cow::Owned(suffix.to_owned())));
}
},
}
}
}
Some(Err(arg))
}
Expand All @@ -78,11 +80,9 @@ impl<'a, I: Iterator<Item = String> + 'a> ArgSplitFlagValue<'a, I> {
args: I,
name: &'a str,
) -> impl Iterator<Item = Result<String, String>> + 'a {
ArgSplitFlagValue::new(args.map(Cow::Owned), name).map(|x| {
match x {
Ok(s) => Ok(s.into_owned()),
Err(s) => Err(s.into_owned()),
}
ArgSplitFlagValue::new(args.map(Cow::Owned), name).map(|x| match x {
Ok(s) => Ok(s.into_owned()),
Err(s) => Err(s.into_owned()),
})
}
}
Expand All @@ -92,12 +92,10 @@ impl<'x: 'a, 'a, I: Iterator<Item = &'x str> + 'a> ArgSplitFlagValue<'a, I> {
args: I,
name: &'a str,
) -> impl Iterator<Item = Result<&'x str, &'x str>> + 'a {
ArgSplitFlagValue::new(args.map(Cow::Borrowed), name).map(|x| {
match x {
Ok(Cow::Borrowed(s)) => Ok(s),
Err(Cow::Borrowed(s)) => Err(s),
_ => panic!("iterator converted borrowed to owned"),
}
ArgSplitFlagValue::new(args.map(Cow::Borrowed), name).map(|x| match x {
Ok(Cow::Borrowed(s)) => Ok(s),
Err(Cow::Borrowed(s)) => Err(s),
_ => panic!("iterator converted borrowed to owned"),
})
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/tools/miri/cargo-miri/src/phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
"setup" => MiriCommand::Setup,
"test" | "t" | "run" | "r" | "nextest" => MiriCommand::Forward(subcommand),
"clean" => MiriCommand::Clean,
_ =>
show_error!(
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`."
),
_ => show_error!(
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`."
),
};
let verbose = num_arg_flag("-v") + num_arg_flag("--verbose");
let quiet = has_arg_flag("-q") || has_arg_flag("--quiet");
Expand Down
9 changes: 6 additions & 3 deletions src/tools/miri/cargo-miri/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ pub fn setup(
None =>
// No-std heuristic taken from rust/src/bootstrap/config.rs
// (https://github.com/rust-lang/rust/blob/25b5af1b3a0b9e2c0c57b223b2d0e3e203869b2c/src/bootstrap/config.rs#L549-L555).
{
target.contains("-none")
|| target.contains("nvptx")
|| target.contains("switch")
|| target.contains("-uefi"),
|| target.contains("-uefi")
}
Some(val) => val != "0",
};
let sysroot_config = if no_std {
Expand Down Expand Up @@ -168,13 +170,14 @@ pub fn setup(
.when_build_required(notify)
.build_from_source(&rust_src);
match status {
Ok(SysrootStatus::AlreadyCached) =>
Ok(SysrootStatus::AlreadyCached) => {
if !quiet && show_setup {
eprintln!(
"A sysroot for Miri is already available in `{}`.",
sysroot_dir.display()
);
},
}
}
Ok(SysrootStatus::SysrootBuilt) => {
// Print what `notify` prepared.
eprint!("{after_build_output}");
Expand Down
5 changes: 3 additions & 2 deletions src/tools/miri/src/alloc/alloc_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ impl Drop for MiriAllocBytes {
unsafe {
match self.params.clone() {
MiriAllocParams::Global => alloc::dealloc(self.ptr, alloc_layout),
MiriAllocParams::Isolated(alloc) =>
alloc.borrow_mut().dealloc(self.ptr, alloc_layout),
MiriAllocParams::Isolated(alloc) => {
alloc.borrow_mut().dealloc(self.ptr, alloc_layout)
}
}
}
}
Expand Down
55 changes: 15 additions & 40 deletions src/tools/miri/src/bin/log/tracing_chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
// should not be included if the "tracing" feature is disabled.
extern crate tracing_core;

use tracing_core::{field::Field, span, Event, Subscriber};
use tracing_core::{Event, Subscriber, field::Field, span};
use tracing_subscriber::{
Layer,
layer::Context,
registry::{LookupSpan, SpanRef},
Layer,
};

use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
use std::{
marker::PhantomData,
path::Path,
sync::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,
atomic::{AtomicUsize, Ordering},
},
};

Expand Down Expand Up @@ -308,10 +308,7 @@ fn create_default_writer() -> Box<dyn Write + Send> {
Box::new(
std::fs::File::create(format!(
"./trace-{}.json",
std::time::SystemTime::UNIX_EPOCH
.elapsed()
.unwrap()
.as_micros()
std::time::SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros()
))
.expect("Failed to create trace file."),
)
Expand All @@ -325,9 +322,7 @@ where
let (tx, rx) = mpsc::channel();
OUT.with(|val| val.replace(Some(tx.clone())));

let out_writer = builder
.out_writer
.unwrap_or_else(|| create_default_writer());
let out_writer = builder.out_writer.unwrap_or_else(|| create_default_writer());

let handle = std::thread::spawn(move || {
let mut write = BufWriter::new(out_writer);
Expand Down Expand Up @@ -437,10 +432,7 @@ where
write.flush().unwrap();
});

let guard = FlushGuard {
sender: tx.clone(),
handle: Cell::new(Some(handle)),
};
let guard = FlushGuard { sender: tx.clone(), handle: Cell::new(Some(handle)) };
let layer = ChromeLayer {
out: Arc::new(Mutex::new(tx)),
start: std::time::Instant::now(),
Expand Down Expand Up @@ -488,19 +480,12 @@ where
None
}
}
EventOrSpan::Span(s) => s
.extensions()
.get::<ArgsWrapper>()
.map(|e| &e.args)
.cloned(),
EventOrSpan::Span(s) => s.extensions().get::<ArgsWrapper>().map(|e| &e.args).cloned(),
};
let name = name.unwrap_or_else(|| meta.name().into());
let target = target.unwrap_or_else(|| meta.target().into());
let (file, line) = if self.include_locations {
(meta.file(), meta.line())
} else {
(None, None)
};
let (file, line) =
if self.include_locations { (meta.file(), meta.line()) } else { (None, None) };

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

Callsite {
tid,
name,
target,
file,
line,
args,
}
Callsite { tid, name, target, file, line, args }
}

fn get_root_id(&self, span: SpanRef<S>) -> Option<i64> {
Expand All @@ -534,7 +512,7 @@ where
} else {
None
}
},
}
TraceStyle::Async => Some(
span.scope()
.from_root()
Expand All @@ -543,7 +521,7 @@ where
.unwrap_or(span)
.id()
.into_u64()
.cast_signed() // the comment above explains the cast
.cast_signed(), // the comment above explains the cast
),
}
}
Expand Down Expand Up @@ -622,9 +600,7 @@ where
if self.include_args {
let mut args = Object::new();
attrs.record(&mut JsonVisitor { object: &mut args });
ctx.span(id).unwrap().extensions_mut().insert(ArgsWrapper {
args: Arc::new(args),
});
ctx.span(id).unwrap().extensions_mut().insert(ArgsWrapper { args: Arc::new(args) });
}
if let TraceStyle::Threaded = self.trace_style {
return;
Expand All @@ -650,8 +626,7 @@ struct JsonVisitor<'a> {

impl<'a> tracing_subscriber::field::Visit for JsonVisitor<'a> {
fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
self.object
.insert(field.name().to_owned(), format!("{value:?}").into());
self.object.insert(field.name().to_owned(), format!("{value:?}").into());
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,9 @@ fn main() {
Some(BorrowTrackerMethod::TreeBorrows(params)) => {
params.precise_interior_mut = false;
}
_ =>
fatal_error!(
"`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
),
_ => fatal_error!(
"`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
),
};
} else if arg == "-Zmiri-disable-data-race-detector" {
miri_config.data_race_detector = false;
Expand All @@ -541,12 +540,12 @@ fn main() {
"abort" => miri::IsolatedOp::Reject(miri::RejectOpWith::Abort),
"hide" => miri::IsolatedOp::Reject(miri::RejectOpWith::NoWarning),
"warn" => miri::IsolatedOp::Reject(miri::RejectOpWith::Warning),
"warn-nobacktrace" =>
miri::IsolatedOp::Reject(miri::RejectOpWith::WarningWithoutBacktrace),
_ =>
fatal_error!(
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
),
"warn-nobacktrace" => {
miri::IsolatedOp::Reject(miri::RejectOpWith::WarningWithoutBacktrace)
}
_ => fatal_error!(
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
),
};
} else if arg == "-Zmiri-ignore-leaks" {
miri_config.ignore_leaks = true;
Expand Down
Loading
Loading