Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakis
Use a slice where a vector is not necessary
This commit is contained in:
commit
59f8422a17
@ -746,7 +746,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
// This is used to track which lifetimes have already been defined, and
|
// This is used to track which lifetimes have already been defined, and
|
||||||
// which are new in-band lifetimes that need to have a definition created
|
// which are new in-band lifetimes that need to have a definition created
|
||||||
// for them.
|
// for them.
|
||||||
fn with_in_scope_lifetime_defs<T, F>(&mut self, params: &Vec<GenericParam>, f: F) -> T
|
fn with_in_scope_lifetime_defs<T, F>(&mut self, params: &[GenericParam], f: F) -> T
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut LoweringContext) -> T,
|
F: FnOnce(&mut LoweringContext) -> T,
|
||||||
{
|
{
|
||||||
@ -2237,7 +2237,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
|
|
||||||
fn lower_generic_params(
|
fn lower_generic_params(
|
||||||
&mut self,
|
&mut self,
|
||||||
params: &Vec<GenericParam>,
|
params: &[GenericParam],
|
||||||
add_bounds: &NodeMap<Vec<GenericBound>>,
|
add_bounds: &NodeMap<Vec<GenericBound>>,
|
||||||
mut itctx: ImplTraitContext,
|
mut itctx: ImplTraitContext,
|
||||||
) -> hir::HirVec<hir::GenericParam> {
|
) -> hir::HirVec<hir::GenericParam> {
|
||||||
|
@ -396,7 +396,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
|
|||||||
pub fn hash_stable_trait_impls<'a, 'gcx, W, R>(
|
pub fn hash_stable_trait_impls<'a, 'gcx, W, R>(
|
||||||
hcx: &mut StableHashingContext<'a>,
|
hcx: &mut StableHashingContext<'a>,
|
||||||
hasher: &mut StableHasher<W>,
|
hasher: &mut StableHasher<W>,
|
||||||
blanket_impls: &Vec<DefId>,
|
blanket_impls: &[DefId],
|
||||||
non_blanket_impls: &HashMap<fast_reject::SimplifiedType, Vec<DefId>, R>)
|
non_blanket_impls: &HashMap<fast_reject::SimplifiedType, Vec<DefId>, R>)
|
||||||
where W: StableHasherResult,
|
where W: StableHasherResult,
|
||||||
R: std_hash::BuildHasher,
|
R: std_hash::BuildHasher,
|
||||||
|
@ -48,7 +48,7 @@ use syntax_pos::{DUMMY_SP, Span};
|
|||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub fn report_fulfillment_errors(&self,
|
pub fn report_fulfillment_errors(&self,
|
||||||
errors: &Vec<FulfillmentError<'tcx>>,
|
errors: &[FulfillmentError<'tcx>],
|
||||||
body_id: Option<hir::BodyId>,
|
body_id: Option<hir::BodyId>,
|
||||||
fallback_has_occurred: bool) {
|
fallback_has_occurred: bool) {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -1015,7 +1015,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let kind = if is_closure { "closure" } else { "function" };
|
let kind = if is_closure { "closure" } else { "function" };
|
||||||
|
|
||||||
let args_str = |arguments: &Vec<ArgKind>, other: &Vec<ArgKind>| {
|
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {
|
||||||
let arg_length = arguments.len();
|
let arg_length = arguments.len();
|
||||||
let distinct = match &other[..] {
|
let distinct = match &other[..] {
|
||||||
&[ArgKind::Tuple(..)] => true,
|
&[ArgKind::Tuple(..)] => true,
|
||||||
|
@ -68,7 +68,7 @@ pub struct GroupedMoveErrors<'tcx> {
|
|||||||
move_to_places: Vec<MovePlace<'tcx>>
|
move_to_places: Vec<MovePlace<'tcx>>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<MoveError<'tcx>>) {
|
fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveError<'tcx>]) {
|
||||||
let grouped_errors = group_errors_with_same_origin(errors);
|
let grouped_errors = group_errors_with_same_origin(errors);
|
||||||
for error in &grouped_errors {
|
for error in &grouped_errors {
|
||||||
let mut err = report_cannot_move_out_of(bccx, error.move_from.clone());
|
let mut err = report_cannot_move_out_of(bccx, error.move_from.clone());
|
||||||
@ -103,7 +103,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<Move
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn group_errors_with_same_origin<'tcx>(errors: &Vec<MoveError<'tcx>>)
|
fn group_errors_with_same_origin<'tcx>(errors: &[MoveError<'tcx>])
|
||||||
-> Vec<GroupedMoveErrors<'tcx>> {
|
-> Vec<GroupedMoveErrors<'tcx>> {
|
||||||
let mut grouped_errors = Vec::new();
|
let mut grouped_errors = Vec::new();
|
||||||
for error in errors {
|
for error in errors {
|
||||||
|
@ -1395,7 +1395,7 @@ fn generated_output_paths(
|
|||||||
|
|
||||||
// Runs `f` on every output file path and returns the first non-None result, or None if `f`
|
// Runs `f` on every output file path and returns the first non-None result, or None if `f`
|
||||||
// returns None for every file path.
|
// returns None for every file path.
|
||||||
fn check_output<F, T>(output_paths: &Vec<PathBuf>, f: F) -> Option<T>
|
fn check_output<F, T>(output_paths: &[PathBuf], f: F) -> Option<T>
|
||||||
where
|
where
|
||||||
F: Fn(&PathBuf) -> Option<T>,
|
F: Fn(&PathBuf) -> Option<T>,
|
||||||
{
|
{
|
||||||
@ -1407,7 +1407,7 @@ where
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn output_contains_path(output_paths: &Vec<PathBuf>, input_path: &PathBuf) -> bool {
|
pub fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool {
|
||||||
let input_path = input_path.canonicalize().ok();
|
let input_path = input_path.canonicalize().ok();
|
||||||
if input_path.is_none() {
|
if input_path.is_none() {
|
||||||
return false;
|
return false;
|
||||||
@ -1422,7 +1422,7 @@ pub fn output_contains_path(output_paths: &Vec<PathBuf>, input_path: &PathBuf) -
|
|||||||
check_output(output_paths, check).is_some()
|
check_output(output_paths, check).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn output_conflicts_with_dir(output_paths: &Vec<PathBuf>) -> Option<PathBuf> {
|
pub fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
|
||||||
let check = |output_path: &PathBuf| {
|
let check = |output_path: &PathBuf| {
|
||||||
if output_path.is_dir() {
|
if output_path.is_dir() {
|
||||||
Some(output_path.clone())
|
Some(output_path.clone())
|
||||||
@ -1433,7 +1433,7 @@ pub fn output_conflicts_with_dir(output_paths: &Vec<PathBuf>) -> Option<PathBuf>
|
|||||||
check_output(output_paths, check)
|
check_output(output_paths, check)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &Vec<PathBuf>) {
|
fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[PathBuf]) {
|
||||||
// Write out dependency rules to the dep-info file if requested
|
// Write out dependency rules to the dep-info file if requested
|
||||||
if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
|
if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
|
||||||
return;
|
return;
|
||||||
|
@ -62,7 +62,7 @@ struct StackFrame {
|
|||||||
pub traces: Vec<trace::Rec>,
|
pub traces: Vec<trace::Rec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn total_duration(traces: &Vec<trace::Rec>) -> Duration {
|
fn total_duration(traces: &[trace::Rec]) -> Duration {
|
||||||
let mut sum : Duration = Duration::new(0,0);
|
let mut sum : Duration = Duration::new(0,0);
|
||||||
for t in traces.iter() { sum += t.dur_total; }
|
for t in traces.iter() { sum += t.dur_total; }
|
||||||
return sum
|
return sum
|
||||||
|
@ -107,7 +107,7 @@ fn html_of_fraction(frac: f64) -> (String, String) {
|
|||||||
else { (format!("< 0.1%", ), css) }
|
else { (format!("< 0.1%", ), css) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn total_duration(traces: &Vec<Rec>) -> Duration {
|
fn total_duration(traces: &[Rec]) -> Duration {
|
||||||
let mut sum : Duration = Duration::new(0,0);
|
let mut sum : Duration = Duration::new(0,0);
|
||||||
for t in traces.iter() {
|
for t in traces.iter() {
|
||||||
sum += t.dur_total;
|
sum += t.dur_total;
|
||||||
@ -123,7 +123,7 @@ fn duration_div(nom: Duration, den: Duration) -> f64 {
|
|||||||
to_nanos(nom) as f64 / to_nanos(den) as f64
|
to_nanos(nom) as f64 / to_nanos(den) as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_traces_rec(file: &mut File, traces: &Vec<Rec>, total: Duration, depth: usize) {
|
fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usize) {
|
||||||
for t in traces {
|
for t in traces {
|
||||||
let (eff_text, eff_css_classes) = html_of_effect(&t.effect);
|
let (eff_text, eff_css_classes) = html_of_effect(&t.effect);
|
||||||
let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.dur_total);
|
let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.dur_total);
|
||||||
@ -149,7 +149,7 @@ fn write_traces_rec(file: &mut File, traces: &Vec<Rec>, total: Duration, depth:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &Vec<Rec>) {
|
fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &[Rec]) {
|
||||||
for t in traces.iter() {
|
for t in traces.iter() {
|
||||||
match t.effect {
|
match t.effect {
|
||||||
Effect::TimeBegin(ref msg) => {
|
Effect::TimeBegin(ref msg) => {
|
||||||
@ -218,7 +218,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &Vec<Rec>) {
|
pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) {
|
||||||
let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
|
let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
|
||||||
let mut counts : HashMap<String, QueryMetric> = HashMap::with_capacity(capacity);
|
let mut counts : HashMap<String, QueryMetric> = HashMap::with_capacity(capacity);
|
||||||
compute_counts_rec(&mut counts, traces);
|
compute_counts_rec(&mut counts, traces);
|
||||||
|
@ -749,7 +749,7 @@ impl EmitterWriter {
|
|||||||
max
|
max
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_max_line_num(&mut self, span: &MultiSpan, children: &Vec<SubDiagnostic>) -> usize {
|
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
|
||||||
let mut max = 0;
|
let mut max = 0;
|
||||||
|
|
||||||
let primary = self.get_multispan_max_line_num(span);
|
let primary = self.get_multispan_max_line_num(span);
|
||||||
@ -954,7 +954,7 @@ impl EmitterWriter {
|
|||||||
|
|
||||||
fn emit_message_default(&mut self,
|
fn emit_message_default(&mut self,
|
||||||
msp: &MultiSpan,
|
msp: &MultiSpan,
|
||||||
msg: &Vec<(String, Style)>,
|
msg: &[(String, Style)],
|
||||||
code: &Option<DiagnosticId>,
|
code: &Option<DiagnosticId>,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
max_line_num_len: usize,
|
max_line_num_len: usize,
|
||||||
@ -1317,10 +1317,10 @@ impl EmitterWriter {
|
|||||||
|
|
||||||
fn emit_messages_default(&mut self,
|
fn emit_messages_default(&mut self,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
message: &Vec<(String, Style)>,
|
message: &[(String, Style)],
|
||||||
code: &Option<DiagnosticId>,
|
code: &Option<DiagnosticId>,
|
||||||
span: &MultiSpan,
|
span: &MultiSpan,
|
||||||
children: &Vec<SubDiagnostic>,
|
children: &[SubDiagnostic],
|
||||||
suggestions: &[CodeSuggestion]) {
|
suggestions: &[CodeSuggestion]) {
|
||||||
let max_line_num_len = if self.ui_testing {
|
let max_line_num_len = if self.ui_testing {
|
||||||
ANONYMIZED_LINE_NUM.len()
|
ANONYMIZED_LINE_NUM.len()
|
||||||
@ -1433,7 +1433,7 @@ fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
|
|||||||
num_overlap(a1.start_col, a1.end_col + padding, a2.start_col, a2.end_col, false)
|
num_overlap(a1.start_col, a1.end_col + padding, a2.start_col, a2.end_col, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
|
fn emit_to_destination(rendered_buffer: &[Vec<StyledString>],
|
||||||
lvl: &Level,
|
lvl: &Level,
|
||||||
dst: &mut Destination,
|
dst: &mut Destination,
|
||||||
short_message: bool)
|
short_message: bool)
|
||||||
|
@ -120,7 +120,7 @@ struct FactWriter<'w> {
|
|||||||
impl<'w> FactWriter<'w> {
|
impl<'w> FactWriter<'w> {
|
||||||
fn write_facts_to_path<T>(
|
fn write_facts_to_path<T>(
|
||||||
&self,
|
&self,
|
||||||
rows: &Vec<T>,
|
rows: &[T],
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
) -> Result<(), Box<dyn Error>>
|
) -> Result<(), Box<dyn Error>>
|
||||||
where
|
where
|
||||||
|
@ -78,7 +78,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
|||||||
self.eval_fn_call(
|
self.eval_fn_call(
|
||||||
instance,
|
instance,
|
||||||
Some((Place::undef(), target)),
|
Some((Place::undef(), target)),
|
||||||
&vec![valty],
|
&[valty],
|
||||||
span,
|
span,
|
||||||
fn_sig,
|
fn_sig,
|
||||||
)
|
)
|
||||||
|
@ -222,7 +222,7 @@ impl RestoreSubsliceArrayMoveOut {
|
|||||||
// indices is an integer interval. If all checks pass do the replacent.
|
// indices is an integer interval. If all checks pass do the replacent.
|
||||||
// items are Vec<Option<LocalUse, index in source array, source place for init local>>
|
// items are Vec<Option<LocalUse, index in source array, source place for init local>>
|
||||||
fn check_and_patch<'tcx>(candidate: Location,
|
fn check_and_patch<'tcx>(candidate: Location,
|
||||||
items: &Vec<Option<(&LocalUse, u32, &Place<'tcx>)>>,
|
items: &[Option<(&LocalUse, u32, &Place<'tcx>)>],
|
||||||
opt_size: Option<u64>,
|
opt_size: Option<u64>,
|
||||||
patch: &mut MirPatch<'tcx>,
|
patch: &mut MirPatch<'tcx>,
|
||||||
dst_place: &Place<'tcx>) {
|
dst_place: &Place<'tcx>) {
|
||||||
|
@ -147,7 +147,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_late_bound_lifetime_defs(&self, params: &Vec<GenericParam>) {
|
fn check_late_bound_lifetime_defs(&self, params: &[GenericParam]) {
|
||||||
// Check only lifetime parameters are present and that the lifetime
|
// Check only lifetime parameters are present and that the lifetime
|
||||||
// parameters that are present have no bounds.
|
// parameters that are present have no bounds.
|
||||||
let non_lt_param_spans: Vec<_> = params.iter().filter_map(|param| match param.kind {
|
let non_lt_param_spans: Vec<_> = params.iter().filter_map(|param| match param.kind {
|
||||||
|
@ -783,7 +783,7 @@ impl<'a> Resolver<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let ident = Ident::new(Symbol::intern(name), span);
|
let ident = Ident::new(Symbol::intern(name), span);
|
||||||
self.lookup_typo_candidate(&vec![ident], MacroNS, is_macro, span)
|
self.lookup_typo_candidate(&[ident], MacroNS, is_macro, span)
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(suggestion) = suggestion {
|
if let Some(suggestion) = suggestion {
|
||||||
|
@ -2690,7 +2690,7 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
|||||||
for it in &implementor.inner_impl().items {
|
for it in &implementor.inner_impl().items {
|
||||||
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
||||||
write!(w, "<span class=\"where fmt-newline\"> ")?;
|
write!(w, "<span class=\"where fmt-newline\"> ")?;
|
||||||
assoc_type(w, it, &vec![], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
|
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
|
||||||
write!(w, ";</span>")?;
|
write!(w, ";</span>")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3040,7 +3040,7 @@ fn assoc_const(w: &mut fmt::Formatter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
|
fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
|
||||||
bounds: &Vec<clean::GenericBound>,
|
bounds: &[clean::GenericBound],
|
||||||
default: Option<&clean::Type>,
|
default: Option<&clean::Type>,
|
||||||
link: AssocItemLink) -> fmt::Result {
|
link: AssocItemLink) -> fmt::Result {
|
||||||
write!(w, "type <a href='{}' class=\"type\">{}</a>",
|
write!(w, "type <a href='{}' class=\"type\">{}</a>",
|
||||||
@ -3749,7 +3749,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
|||||||
for it in &impl_.items {
|
for it in &impl_.items {
|
||||||
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
||||||
out.push_str("<span class=\"where fmt-newline\"> ");
|
out.push_str("<span class=\"where fmt-newline\"> ");
|
||||||
assoc_type(&mut out, it, &vec![],
|
assoc_type(&mut out, it, &[],
|
||||||
Some(&tydef.type_),
|
Some(&tydef.type_),
|
||||||
AssocItemLink::GotoSource(t_did, &FxHashSet()))?;
|
AssocItemLink::GotoSource(t_did, &FxHashSet()))?;
|
||||||
out.push_str(";</span>");
|
out.push_str(";</span>");
|
||||||
|
@ -3065,7 +3065,7 @@ impl<'a> State<'a> {
|
|||||||
unsafety: ast::Unsafety,
|
unsafety: ast::Unsafety,
|
||||||
decl: &ast::FnDecl,
|
decl: &ast::FnDecl,
|
||||||
name: Option<ast::Ident>,
|
name: Option<ast::Ident>,
|
||||||
generic_params: &Vec<ast::GenericParam>)
|
generic_params: &[ast::GenericParam])
|
||||||
-> io::Result<()> {
|
-> io::Result<()> {
|
||||||
self.ibox(INDENT_UNIT)?;
|
self.ibox(INDENT_UNIT)?;
|
||||||
if !generic_params.is_empty() {
|
if !generic_params.is_empty() {
|
||||||
|
Loading…
Reference in New Issue
Block a user