diff options
Diffstat (limited to 'compiler')
17 files changed, 34 insertions, 39 deletions
diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 07d49b6e729..1e795efa2e1 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -791,7 +791,7 @@ fn get_rust_try_fn<'ll, 'tcx>( ))); // `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32` let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig( - vec![try_fn_ty, i8p, catch_fn_ty].into_iter(), + [try_fn_ty, i8p, catch_fn_ty].into_iter(), tcx.types.i32, false, hir::Unsafety::Unsafe, diff --git a/compiler/rustc_data_structures/src/thin_vec/tests.rs b/compiler/rustc_data_structures/src/thin_vec/tests.rs index 5abfd939373..0221b9912bb 100644 --- a/compiler/rustc_data_structures/src/thin_vec/tests.rs +++ b/compiler/rustc_data_structures/src/thin_vec/tests.rs @@ -10,8 +10,8 @@ impl<T> ThinVec<T> { fn test_from_iterator() { assert_eq!(std::iter::empty().collect::<ThinVec<String>>().into_vec(), Vec::<String>::new()); assert_eq!(std::iter::once(42).collect::<ThinVec<_>>().into_vec(), vec![42]); - assert_eq!(vec![1, 2].into_iter().collect::<ThinVec<_>>().into_vec(), vec![1, 2]); - assert_eq!(vec![1, 2, 3].into_iter().collect::<ThinVec<_>>().into_vec(), vec![1, 2, 3]); + assert_eq!([1, 2].into_iter().collect::<ThinVec<_>>().into_vec(), vec![1, 2]); + assert_eq!([1, 2, 3].into_iter().collect::<ThinVec<_>>().into_vec(), vec![1, 2, 3]); } #[test] diff --git a/compiler/rustc_data_structures/src/vec_map/tests.rs b/compiler/rustc_data_structures/src/vec_map/tests.rs index 9083de85982..458b60077dc 100644 --- a/compiler/rustc_data_structures/src/vec_map/tests.rs +++ b/compiler/rustc_data_structures/src/vec_map/tests.rs @@ -14,7 +14,7 @@ fn test_from_iterator() { ); assert_eq!(std::iter::once((42, true)).collect::<VecMap<_, _>>().into_vec(), vec![(42, true)]); assert_eq!( - vec![(1, true), (2, false)].into_iter().collect::<VecMap<_, _>>().into_vec(), + [(1, true), (2, false)].into_iter().collect::<VecMap<_, _>>().into_vec(), vec![(1, true), (2, false)] ); } @@ -41,7 +41,7 @@ fn test_insert() { #[test] fn test_get() { - let v = vec![(1, true), (2, false)].into_iter().collect::<VecMap<_, _>>(); + let v = [(1, true), (2, false)].into_iter().collect::<VecMap<_, _>>(); assert_eq!(v.get(&1), Some(&true)); assert_eq!(v.get(&2), Some(&false)); assert_eq!(v.get(&3), None); diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index dde978cd8c6..c2af2b2a86d 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -455,7 +455,7 @@ impl DiagnosticSpan { let backtrace_step = backtrace.next().map(|bt| { let call_site = Self::from_span_full(bt.call_site, false, None, None, backtrace, je); let def_site_span = - Self::from_span_full(bt.def_site, false, None, None, vec![].into_iter(), je); + Self::from_span_full(bt.def_site, false, None, None, [].into_iter(), je); Box::new(DiagnosticSpanMacroExpansion { span: call_site, macro_decl_name: bt.kind.descr(), diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 56564656556..efbe0b65715 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -158,7 +158,7 @@ impl FromInternal<(TreeAndSpacing, &'_ mut Vec<Self>, &mut Rustc<'_, '_>)> for ch in data.as_str().chars() { escaped.extend(ch.escape_debug()); } - let stream = vec![ + let stream = [ Ident(sym::doc, false), Eq, TokenKind::lit(token::Str, Symbol::intern(&escaped), None), @@ -221,7 +221,7 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> { let integer = TokenKind::lit(token::Integer, symbol, suffix); let a = tokenstream::TokenTree::token(minus, span); let b = tokenstream::TokenTree::token(integer, span); - return vec![a, b].into_iter().collect(); + return [a, b].into_iter().collect(); } TokenTree::Literal(self::Literal { lit: token::Lit { kind: token::Float, symbol, suffix }, @@ -232,7 +232,7 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> { let float = TokenKind::lit(token::Float, symbol, suffix); let a = tokenstream::TokenTree::token(minus, span); let b = tokenstream::TokenTree::token(float, span); - return vec![a, b].into_iter().collect(); + return [a, b].into_iter().collect(); } TokenTree::Literal(self::Literal { lit, span }) => { return tokenstream::TokenTree::token(Literal(lit), span).into(); diff --git a/compiler/rustc_graphviz/src/tests.rs b/compiler/rustc_graphviz/src/tests.rs index a297bac86c4..154bae4cb05 100644 --- a/compiler/rustc_graphviz/src/tests.rs +++ b/compiler/rustc_graphviz/src/tests.rs @@ -56,7 +56,7 @@ impl NodeLabels<&'static str> { match self { UnlabelledNodes(len) => vec![None; len], AllNodesLabelled(lbls) => lbls.into_iter().map(Some).collect(), - SomeNodesLabelled(lbls) => lbls.into_iter().collect(), + SomeNodesLabelled(lbls) => lbls, } } diff --git a/compiler/rustc_incremental/src/persist/fs/tests.rs b/compiler/rustc_incremental/src/persist/fs/tests.rs index 652ef6bcdce..184796948b6 100644 --- a/compiler/rustc_incremental/src/persist/fs/tests.rs +++ b/compiler/rustc_incremental/src/persist/fs/tests.rs @@ -13,7 +13,7 @@ fn test_all_except_most_recent() { .keys() .cloned() .collect::<FxHashSet<PathBuf>>(), - vec![PathBuf::from("1"), PathBuf::from("2"), PathBuf::from("3"), PathBuf::from("4"),] + [PathBuf::from("1"), PathBuf::from("2"), PathBuf::from("3"), PathBuf::from("4"),] .into_iter() .collect::<FxHashSet<PathBuf>>() ); @@ -40,7 +40,7 @@ fn test_find_source_directory_in_iter() { // Find newest assert_eq!( find_source_directory_in_iter( - vec![ + [ PathBuf::from("crate-dir/s-3234-0000-svh"), PathBuf::from("crate-dir/s-2234-0000-svh"), PathBuf::from("crate-dir/s-1234-0000-svh") @@ -54,7 +54,7 @@ fn test_find_source_directory_in_iter() { // Filter out "-working" assert_eq!( find_source_directory_in_iter( - vec![ + [ PathBuf::from("crate-dir/s-3234-0000-working"), PathBuf::from("crate-dir/s-2234-0000-svh"), PathBuf::from("crate-dir/s-1234-0000-svh") @@ -66,12 +66,12 @@ fn test_find_source_directory_in_iter() { ); // Handle empty - assert_eq!(find_source_directory_in_iter(vec![].into_iter(), &already_visited), None); + assert_eq!(find_source_directory_in_iter([].into_iter(), &already_visited), None); // Handle only working assert_eq!( find_source_directory_in_iter( - vec![ + [ PathBuf::from("crate-dir/s-3234-0000-working"), PathBuf::from("crate-dir/s-2234-0000-working"), PathBuf::from("crate-dir/s-1234-0000-working") diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index f0c73d0c2f3..1bf01676cb8 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -771,7 +771,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.suggest_boxing_for_return_impl_trait( err, ret_sp, - vec![then, else_sp].into_iter(), + [then, else_sp].into_iter(), ); } } @@ -807,11 +807,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ); let sugg = arm_spans .flat_map(|sp| { - vec![ - (sp.shrink_to_lo(), "Box::new(".to_string()), - (sp.shrink_to_hi(), ")".to_string()), - ] - .into_iter() + [(sp.shrink_to_lo(), "Box::new(".to_string()), (sp.shrink_to_hi(), ")".to_string())] + .into_iter() }) .collect::<Vec<_>>(); err.multipart_suggestion( diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 9cf6cde2591..8bb0e8b960c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -540,8 +540,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // error[E0284]: type annotations needed // --> file.rs:2:5 // | - // 2 | vec![Ok(2)].into_iter().collect()?; - // | ^^^^^^^ cannot infer type + // 2 | [Ok(2)].into_iter().collect()?; + // | ^^^^^^^ cannot infer type // | // = note: cannot resolve `<_ as std::ops::Try>::Ok == _` if span.contains(*call_span) { *call_span } else { span } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 9677e7642b8..4121a759c37 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -550,8 +550,8 @@ impl<'a> Parser<'a> { /// a diagnostic to suggest removing them. /// /// ```ignore (diagnostic) - /// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>(); - /// ^^ help: remove extra angle brackets + /// let _ = [1, 2, 3].into_iter().collect::<Vec<usize>>>>(); + /// ^^ help: remove extra angle brackets /// ``` /// /// If `true` is returned, then trailing brackets were recovered, tokens were consumed diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs index 2cb2661a526..a6c1b344d70 100644 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs @@ -17,12 +17,10 @@ pub fn target(target_cpu: String) -> Target { linker: Some("avr-gcc".to_owned()), executables: true, eh_frame_header: false, - pre_link_args: vec![(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] - .into_iter() - .collect(), - late_link_args: vec![(LinkerFlavor::Gcc, vec!["-lgcc".to_owned()])] + pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] .into_iter() .collect(), + late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".to_owned()])].into_iter().collect(), max_atomic_width: Some(0), atomic_cas: false, ..TargetOptions::default() diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index ca1949b9f75..2c149318730 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -574,15 +574,15 @@ impl ToJson for StackProbeType { fn to_json(&self) -> Json { Json::Object(match self { StackProbeType::None => { - vec![(String::from("kind"), "none".to_json())].into_iter().collect() + [(String::from("kind"), "none".to_json())].into_iter().collect() } StackProbeType::Inline => { - vec![(String::from("kind"), "inline".to_json())].into_iter().collect() + [(String::from("kind"), "inline".to_json())].into_iter().collect() } StackProbeType::Call => { - vec![(String::from("kind"), "call".to_json())].into_iter().collect() + [(String::from("kind"), "call".to_json())].into_iter().collect() } - StackProbeType::InlineOrCall { min_llvm_version_for_inline } => vec![ + StackProbeType::InlineOrCall { min_llvm_version_for_inline } => [ (String::from("kind"), "inline-or-call".to_json()), ( String::from("min-llvm-version-for-inline"), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index a9ae0ec53c7..72878b6cb38 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2247,7 +2247,7 @@ pub fn recursive_type_with_infinite_size_error( spans .iter() .flat_map(|&span| { - vec![ + [ (span.shrink_to_lo(), "Box<".to_string()), (span.shrink_to_hi(), ">".to_string()), ] diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 0f276718c16..8704c4c7469 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1226,7 +1226,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { .returns .iter() .flat_map(|expr| { - vec![ + [ (expr.span.shrink_to_lo(), "Box::new(".to_string()), (expr.span.shrink_to_hi(), ")".to_string()), ] diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index fa88c8ee370..bb3b3203a7c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1953,7 +1953,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::Generator(_, ref substs, _) => { let ty = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty()); let witness = substs.as_generator().witness(); - t.rebind(vec![ty].into_iter().chain(iter::once(witness)).collect()) + t.rebind([ty].into_iter().chain(iter::once(witness)).collect()) } ty::GeneratorWitness(types) => { diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index 6192c77d6c6..01221e5dfa9 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -1667,10 +1667,10 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { ], Applicability::MachineApplicable, ); - let sugg = vec![sp, cause.span] + let sugg = [sp, cause.span] .into_iter() .flat_map(|sp| { - vec![ + [ (sp.shrink_to_lo(), "Box::new(".to_string()), (sp.shrink_to_hi(), ")".to_string()), ] diff --git a/compiler/rustc_typeck/src/variance/terms.rs b/compiler/rustc_typeck/src/variance/terms.rs index d7f9df668bf..36fbfc21ff5 100644 --- a/compiler/rustc_typeck/src/variance/terms.rs +++ b/compiler/rustc_typeck/src/variance/terms.rs @@ -86,7 +86,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>( fn lang_items(tcx: TyCtxt<'_>) -> Vec<(hir::HirId, Vec<ty::Variance>)> { let lang_items = tcx.lang_items(); - let all = vec![ + let all = [ (lang_items.phantom_data(), vec![ty::Covariant]), (lang_items.unsafe_cell_type(), vec![ty::Invariant]), ]; |
