mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #140232 - nnethercote:rm-unnecessary-clones, r=SparrowLii
Remove unnecessary clones r? `@SparrowLii`
This commit is contained in:
@@ -799,7 +799,7 @@ fn print_mac_def(
|
||||
has_bang,
|
||||
Some(*ident),
|
||||
macro_def.body.delim,
|
||||
¯o_def.body.tokens.clone(),
|
||||
¯o_def.body.tokens,
|
||||
true,
|
||||
sp,
|
||||
);
|
||||
@@ -1468,7 +1468,7 @@ fn print_mac(&mut self, m: &ast::MacCall) {
|
||||
true,
|
||||
None,
|
||||
m.args.delim,
|
||||
&m.args.tokens.clone(),
|
||||
&m.args.tokens,
|
||||
true,
|
||||
m.span(),
|
||||
);
|
||||
|
||||
@@ -262,7 +262,7 @@ pub fn run<F, T>(tcx: TyCtxt<'_>, f: F) -> Result<T, Error>
|
||||
/// // Your code goes in here.
|
||||
/// # ControlFlow::Continue(())
|
||||
/// }
|
||||
/// # let args = vec!["--verbose".to_string()];
|
||||
/// # let args = &["--verbose".to_string()];
|
||||
/// let result = run!(args, analyze_code);
|
||||
/// # assert_eq!(result, Err(CompilerError::Skipped))
|
||||
/// # }
|
||||
@@ -284,7 +284,7 @@ pub fn run<F, T>(tcx: TyCtxt<'_>, f: F) -> Result<T, Error>
|
||||
/// // Your code goes in here.
|
||||
/// # ControlFlow::Continue(())
|
||||
/// }
|
||||
/// # let args = vec!["--verbose".to_string()];
|
||||
/// # let args = &["--verbose".to_string()];
|
||||
/// # let extra_args = vec![];
|
||||
/// let result = run!(args, || analyze_code(extra_args));
|
||||
/// # assert_eq!(result, Err(CompilerError::Skipped))
|
||||
@@ -346,7 +346,6 @@ pub struct StableMir<B = (), C = (), F = fn($(optional!($with_tcx TyCtxt))?) ->
|
||||
C: Send,
|
||||
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
|
||||
{
|
||||
args: Vec<String>,
|
||||
callback: Option<F>,
|
||||
result: Option<ControlFlow<B, C>>,
|
||||
}
|
||||
@@ -358,14 +357,14 @@ impl<B, C, F> StableMir<B, C, F>
|
||||
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
|
||||
{
|
||||
/// Creates a new `StableMir` instance, with given test_function and arguments.
|
||||
pub fn new(args: Vec<String>, callback: F) -> Self {
|
||||
StableMir { args, callback: Some(callback), result: None }
|
||||
pub fn new(callback: F) -> Self {
|
||||
StableMir { callback: Some(callback), result: None }
|
||||
}
|
||||
|
||||
/// Runs the compiler against given target and tests it with `test_function`
|
||||
pub fn run(&mut self) -> Result<C, CompilerError<B>> {
|
||||
pub fn run(&mut self, args: &[String]) -> Result<C, CompilerError<B>> {
|
||||
let compiler_result = rustc_driver::catch_fatal_errors(|| -> interface::Result::<()> {
|
||||
run_compiler(&self.args.clone(), self);
|
||||
run_compiler(&args, self);
|
||||
Ok(())
|
||||
});
|
||||
match (compiler_result, self.result.take()) {
|
||||
@@ -415,7 +414,7 @@ fn after_analysis<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
StableMir::new($args, $callback).run()
|
||||
StableMir::new($callback).run($args)
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +117,7 @@ fn relate_mir_and_user_args<'tcx>(
|
||||
CRATE_DEF_ID,
|
||||
ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span),
|
||||
);
|
||||
let instantiated_predicate =
|
||||
ocx.normalize(&cause.clone(), param_env, instantiated_predicate);
|
||||
let instantiated_predicate = ocx.normalize(&cause, param_env, instantiated_predicate);
|
||||
|
||||
ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_predicate));
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ pub struct Iter<'a, T: 'a> {
|
||||
#[stable(feature = "collection_debug", since = "1.17.0")]
|
||||
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_tuple("Iter").field(&self.iter.clone()).finish()
|
||||
f.debug_tuple("Iter").field(&self.iter).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -683,7 +683,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
|
||||
match EditorKind::prompt_user() {
|
||||
Ok(editor_kind) => {
|
||||
if let Some(editor_kind) = editor_kind {
|
||||
while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {}
|
||||
while !t!(create_editor_settings_maybe(config, &editor_kind)) {}
|
||||
} else {
|
||||
println!("Ok, skipping editor setup!");
|
||||
}
|
||||
@@ -695,7 +695,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
|
||||
|
||||
/// Create the recommended editor LSP config file for rustc development, or just print it
|
||||
/// If this method should be re-called, it returns `false`.
|
||||
fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Result<bool> {
|
||||
fn create_editor_settings_maybe(config: &Config, editor: &EditorKind) -> io::Result<bool> {
|
||||
let hashes = editor.hashes();
|
||||
let (current_hash, historical_hashes) = hashes.split_last().unwrap();
|
||||
let settings_path = editor.settings_path(config);
|
||||
@@ -752,7 +752,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
|
||||
// exists but user modified, back it up
|
||||
Some(false) => {
|
||||
// exists and is not current version or outdated, so back it up
|
||||
let backup = settings_path.clone().with_extension(editor.backup_extension());
|
||||
let backup = settings_path.with_extension(editor.backup_extension());
|
||||
eprintln!(
|
||||
"WARNING: copying `{}` to `{}`",
|
||||
settings_path.file_name().unwrap().to_str().unwrap(),
|
||||
|
||||
@@ -145,7 +145,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "alloc_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -219,7 +219,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "alloc_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--edition=2021".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -85,7 +85,7 @@ fn check_items<T: CrateDef>(items: &[T], expected: &[&str]) {
|
||||
fn main() {
|
||||
let path = "assoc_items.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -57,7 +57,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "attribute_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -81,7 +81,7 @@ fn visit_terminator(&mut self, term: &Terminator, _loc: Location) {
|
||||
fn main() {
|
||||
let path = "binop_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
|
||||
let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
|
||||
run!(args, test_binops).unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ fn contains<T: CrateDef + std::fmt::Debug>(items: &[T], expected: &[&str]) {
|
||||
fn main() {
|
||||
let path = "crate_definitions.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -76,7 +76,7 @@ fn check_fn_def(ty: Ty) {
|
||||
fn main() {
|
||||
let path = "defs_ty_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -112,7 +112,7 @@ fn get_instances(body: mir::Body) -> Vec<Instance> {
|
||||
fn main() {
|
||||
let path = "defs_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -58,7 +58,7 @@ fn test_foreign() -> ControlFlow<()> {
|
||||
fn main() {
|
||||
let path = "foreign_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
|
||||
@@ -87,7 +87,7 @@ fn test_body(body: mir::Body) {
|
||||
fn main() {
|
||||
let path = "instance_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
|
||||
@@ -115,7 +115,7 @@ fn visit_terminator(&mut self, term: &Terminator, _loc: Location) {
|
||||
fn main() {
|
||||
let path = "binop_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
|
||||
let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
|
||||
run!(args, test_intrinsics).unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ fn test_item_kind() -> ControlFlow<()> {
|
||||
fn main() {
|
||||
let path = "item_kind_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
|
||||
@@ -61,7 +61,7 @@ fn check_ty(ty: Ty) {
|
||||
fn main() {
|
||||
let path = "normalization_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
|
||||
@@ -72,7 +72,7 @@ fn assert_impl(impl_names: &HashSet<String>, target: &str) {
|
||||
fn main() {
|
||||
let path = "trait_queries.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -120,7 +120,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "transform_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -78,7 +78,7 @@ fn visit_place(&mut self, place: &Place, _ptx: PlaceContext, _loc: Location) {
|
||||
fn main() {
|
||||
let path = "ty_fold_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -25,40 +25,42 @@
|
||||
fn main() {
|
||||
let path = "input_compilation_result_test.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec!["rustc".to_string(), path.to_string()];
|
||||
test_continue(args.clone());
|
||||
test_break(args.clone());
|
||||
test_failed(args.clone());
|
||||
test_skipped(args.clone());
|
||||
let args = &["rustc".to_string(), path.to_string()];
|
||||
test_continue(args);
|
||||
test_break(args);
|
||||
test_failed(args);
|
||||
test_skipped(args);
|
||||
test_captured(args)
|
||||
}
|
||||
|
||||
fn test_continue(args: Vec<String>) {
|
||||
fn test_continue(args: &[String]) {
|
||||
let result = run!(args, || ControlFlow::Continue::<(), bool>(true));
|
||||
assert_eq!(result, Ok(true));
|
||||
}
|
||||
|
||||
fn test_break(args: Vec<String>) {
|
||||
fn test_break(args: &[String]) {
|
||||
let result = run!(args, || ControlFlow::Break::<bool, i32>(false));
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false)));
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
fn test_skipped(mut args: Vec<String>) {
|
||||
fn test_skipped(args: &[String]) {
|
||||
let mut args = args.to_vec();
|
||||
args.push("--version".to_string());
|
||||
let result = run!(args, || unreachable!() as ControlFlow<()>);
|
||||
let result = run!(&args, || unreachable!() as ControlFlow<()>);
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Skipped));
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
fn test_failed(mut args: Vec<String>) {
|
||||
fn test_failed(args: &[String]) {
|
||||
let mut args = args.to_vec();
|
||||
args.push("--cfg=broken".to_string());
|
||||
let result = run!(args, || unreachable!() as ControlFlow<()>);
|
||||
let result = run!(&args, || unreachable!() as ControlFlow<()>);
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Failed));
|
||||
}
|
||||
|
||||
/// Test that we are able to pass a closure and set the return according to the captured value.
|
||||
fn test_captured(args: Vec<String>) {
|
||||
fn test_captured(args: &[String]) {
|
||||
let captured = "10".to_string();
|
||||
let result = run!(args, || ControlFlow::Continue::<(), usize>(captured.len()));
|
||||
assert_eq!(result, Ok(captured.len()));
|
||||
|
||||
@@ -186,7 +186,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -146,7 +146,7 @@ fn get_item<'a>(
|
||||
fn main() {
|
||||
let path = "input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
|
||||
@@ -40,7 +40,7 @@ fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||
fn main() {
|
||||
let path = "internal_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
CRATE_NAME.to_string(),
|
||||
|
||||
@@ -46,7 +46,7 @@ fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||
fn main() {
|
||||
let path = "internal_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
CRATE_NAME.to_string(),
|
||||
|
||||
@@ -183,14 +183,14 @@ fn visit_terminator(&mut self, term: &mut mir::Terminator, location: mir::visit:
|
||||
fn main() {
|
||||
let path = "sim_visitor_input.rs";
|
||||
generate_input(&path).unwrap();
|
||||
let args = vec![
|
||||
let args = &[
|
||||
"rustc".to_string(),
|
||||
"-Cpanic=abort".to_string(),
|
||||
"--crate-name".to_string(),
|
||||
CRATE_NAME.to_string(),
|
||||
path.to_string(),
|
||||
];
|
||||
run!(args.clone(), test_visitor).unwrap();
|
||||
run!(args, test_visitor).unwrap();
|
||||
run!(args, test_mut_visitor).unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user