mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)
This commit is contained in:
parent
b9c403be11
commit
bdc9291ed9
@ -522,7 +522,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
mut bx: Bx,
|
mut bx: Bx,
|
||||||
terminator: &mir::Terminator<'tcx>,
|
terminator: &mir::Terminator<'tcx>,
|
||||||
func: &mir::Operand<'tcx>,
|
func: &mir::Operand<'tcx>,
|
||||||
args: &Vec<mir::Operand<'tcx>>,
|
args: &[mir::Operand<'tcx>],
|
||||||
destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>,
|
destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>,
|
||||||
cleanup: Option<mir::BasicBlock>,
|
cleanup: Option<mir::BasicBlock>,
|
||||||
fn_span: Span,
|
fn_span: Span,
|
||||||
|
@ -603,7 +603,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_content_with_pager(content: &String) {
|
fn show_content_with_pager(content: &str) {
|
||||||
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
|
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
|
||||||
if cfg!(windows) { OsString::from("more.com") } else { OsString::from("less") }
|
if cfg!(windows) { OsString::from("more.com") } else { OsString::from("less") }
|
||||||
});
|
});
|
||||||
|
@ -417,7 +417,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
// obviously it never weeds out ALL errors.
|
// obviously it never weeds out ALL errors.
|
||||||
fn process_errors(
|
fn process_errors(
|
||||||
&self,
|
&self,
|
||||||
errors: &Vec<RegionResolutionError<'tcx>>,
|
errors: &[RegionResolutionError<'tcx>],
|
||||||
) -> Vec<RegionResolutionError<'tcx>> {
|
) -> Vec<RegionResolutionError<'tcx>> {
|
||||||
debug!("process_errors()");
|
debug!("process_errors()");
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
|
let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
|
||||||
errors.clone()
|
errors.to_owned()
|
||||||
} else {
|
} else {
|
||||||
errors.iter().filter(|&e| !is_bound_failure(e)).cloned().collect()
|
errors.iter().filter(|&e| !is_bound_failure(e)).cloned().collect()
|
||||||
};
|
};
|
||||||
|
@ -574,7 +574,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
|||||||
/// format!("Expected a point greater than ({x}, {y})", x = self.x, y = self.y)
|
/// format!("Expected a point greater than ({x}, {y})", x = self.x, y = self.y)
|
||||||
/// ```
|
/// ```
|
||||||
/// This function builds the entire call to format!.
|
/// This function builds the entire call to format!.
|
||||||
fn build_format(&self, input: &String, span: proc_macro2::Span) -> proc_macro2::TokenStream {
|
fn build_format(&self, input: &str, span: proc_macro2::Span) -> proc_macro2::TokenStream {
|
||||||
// This set is used later to generate the final format string. To keep builds reproducible,
|
// This set is used later to generate the final format string. To keep builds reproducible,
|
||||||
// the iteration order needs to be deterministic, hence why we use a BTreeSet here instead
|
// the iteration order needs to be deterministic, hence why we use a BTreeSet here instead
|
||||||
// of a HashSet.
|
// of a HashSet.
|
||||||
|
@ -954,7 +954,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
target_place: PlaceRef<'tcx>,
|
target_place: PlaceRef<'tcx>,
|
||||||
places: &Vec<Operand<'tcx>>,
|
places: &[Operand<'tcx>],
|
||||||
) -> Option<(Span, Option<GeneratorKind>, Span)> {
|
) -> Option<(Span, Option<GeneratorKind>, Span)> {
|
||||||
debug!(
|
debug!(
|
||||||
"closure_span: def_id={:?} target_place={:?} places={:?}",
|
"closure_span: def_id={:?} target_place={:?} places={:?}",
|
||||||
|
@ -58,11 +58,7 @@ impl vll::LinkElem for Appearance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LocalUseMap {
|
impl LocalUseMap {
|
||||||
crate fn build(
|
crate fn build(live_locals: &[Local], elements: &RegionValueElements, body: &Body<'_>) -> Self {
|
||||||
live_locals: &Vec<Local>,
|
|
||||||
elements: &RegionValueElements,
|
|
||||||
body: &Body<'_>,
|
|
||||||
) -> Self {
|
|
||||||
let nones = IndexVec::from_elem_n(None, body.local_decls.len());
|
let nones = IndexVec::from_elem_n(None, body.local_decls.len());
|
||||||
let mut local_use_map = LocalUseMap {
|
let mut local_use_map = LocalUseMap {
|
||||||
first_def_at: nones.clone(),
|
first_def_at: nones.clone(),
|
||||||
|
@ -153,7 +153,7 @@ impl<T: Copy + Eq + Hash + std::fmt::Debug, PATH: Default> RefTracking<T, PATH>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Format a path
|
/// Format a path
|
||||||
fn write_path(out: &mut String, path: &Vec<PathElem>) {
|
fn write_path(out: &mut String, path: &[PathElem]) {
|
||||||
use self::PathElem::*;
|
use self::PathElem::*;
|
||||||
|
|
||||||
for elem in path.iter() {
|
for elem in path.iter() {
|
||||||
|
@ -140,7 +140,7 @@ impl<'a> BcbCounters<'a> {
|
|||||||
/// message for subsequent debugging.
|
/// message for subsequent debugging.
|
||||||
fn make_bcb_counters(
|
fn make_bcb_counters(
|
||||||
&mut self,
|
&mut self,
|
||||||
coverage_spans: &Vec<CoverageSpan>,
|
coverage_spans: &[CoverageSpan],
|
||||||
) -> Result<Vec<CoverageKind>, Error> {
|
) -> Result<Vec<CoverageKind>, Error> {
|
||||||
debug!("make_bcb_counters(): adding a counter or expression to each BasicCoverageBlock");
|
debug!("make_bcb_counters(): adding a counter or expression to each BasicCoverageBlock");
|
||||||
let num_bcbs = self.basic_coverage_blocks.num_nodes();
|
let num_bcbs = self.basic_coverage_blocks.num_nodes();
|
||||||
@ -465,7 +465,7 @@ impl<'a> BcbCounters<'a> {
|
|||||||
fn choose_preferred_expression_branch(
|
fn choose_preferred_expression_branch(
|
||||||
&self,
|
&self,
|
||||||
traversal: &TraverseCoverageGraphWithLoops,
|
traversal: &TraverseCoverageGraphWithLoops,
|
||||||
branches: &Vec<BcbBranch>,
|
branches: &[BcbBranch],
|
||||||
) -> BcbBranch {
|
) -> BcbBranch {
|
||||||
let branch_needs_a_counter =
|
let branch_needs_a_counter =
|
||||||
|branch: &BcbBranch| branch.counter(&self.basic_coverage_blocks).is_none();
|
|branch: &BcbBranch| branch.counter(&self.basic_coverage_blocks).is_none();
|
||||||
@ -509,7 +509,7 @@ impl<'a> BcbCounters<'a> {
|
|||||||
fn find_some_reloop_branch(
|
fn find_some_reloop_branch(
|
||||||
&self,
|
&self,
|
||||||
traversal: &TraverseCoverageGraphWithLoops,
|
traversal: &TraverseCoverageGraphWithLoops,
|
||||||
branches: &Vec<BcbBranch>,
|
branches: &[BcbBranch],
|
||||||
) -> Option<BcbBranch> {
|
) -> Option<BcbBranch> {
|
||||||
let branch_needs_a_counter =
|
let branch_needs_a_counter =
|
||||||
|branch: &BcbBranch| branch.counter(&self.basic_coverage_blocks).is_none();
|
|branch: &BcbBranch| branch.counter(&self.basic_coverage_blocks).is_none();
|
||||||
|
@ -99,7 +99,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
substs_ref: SubstsRef<'tcx>,
|
substs_ref: SubstsRef<'tcx>,
|
||||||
args: &Vec<Operand<'tcx>>,
|
args: &[Operand<'tcx>],
|
||||||
source_info: SourceInfo,
|
source_info: SourceInfo,
|
||||||
) {
|
) {
|
||||||
let param_env = self.tcx.param_env(def_id);
|
let param_env = self.tcx.param_env(def_id);
|
||||||
@ -162,7 +162,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
|||||||
.unwrap_or(None)
|
.unwrap_or(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nth_arg_span(&self, args: &Vec<Operand<'tcx>>, n: usize) -> Span {
|
fn nth_arg_span(&self, args: &[Operand<'tcx>], n: usize) -> Span {
|
||||||
match &args[n] {
|
match &args[n] {
|
||||||
Operand::Copy(place) | Operand::Move(place) => {
|
Operand::Copy(place) | Operand::Move(place) => {
|
||||||
self.body.local_decls[place.local].source_info.span
|
self.body.local_decls[place.local].source_info.span
|
||||||
|
@ -79,7 +79,7 @@ crate struct PlaceBuilder<'tcx> {
|
|||||||
/// part of a path that is captued by a closure. We stop applying projections once we see the first
|
/// part of a path that is captued by a closure. We stop applying projections once we see the first
|
||||||
/// projection that isn't captured by a closure.
|
/// projection that isn't captured by a closure.
|
||||||
fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
|
fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
|
||||||
mir_projections: &Vec<PlaceElem<'tcx>>,
|
mir_projections: &[PlaceElem<'tcx>],
|
||||||
) -> Vec<HirProjectionKind> {
|
) -> Vec<HirProjectionKind> {
|
||||||
|
|
||||||
let mut hir_projections = Vec::new();
|
let mut hir_projections = Vec::new();
|
||||||
@ -128,7 +128,7 @@ fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
|
|||||||
/// list are being applied to the same root variable.
|
/// list are being applied to the same root variable.
|
||||||
fn is_ancestor_or_same_capture(
|
fn is_ancestor_or_same_capture(
|
||||||
proj_possible_ancestor: &Vec<HirProjectionKind>,
|
proj_possible_ancestor: &Vec<HirProjectionKind>,
|
||||||
proj_capture: &Vec<HirProjectionKind>,
|
proj_capture: &[HirProjectionKind],
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// We want to make sure `is_ancestor_or_same_capture("x.0.0", "x.0")` to return false.
|
// We want to make sure `is_ancestor_or_same_capture("x.0.0", "x.0")` to return false.
|
||||||
// Therefore we can't just check if all projections are same in the zipped iterator below.
|
// Therefore we can't just check if all projections are same in the zipped iterator below.
|
||||||
@ -171,7 +171,7 @@ fn find_capture_matching_projections<'a, 'tcx>(
|
|||||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||||
var_hir_id: HirId,
|
var_hir_id: HirId,
|
||||||
closure_def_id: DefId,
|
closure_def_id: DefId,
|
||||||
projections: &Vec<PlaceElem<'tcx>>,
|
projections: &[PlaceElem<'tcx>],
|
||||||
) -> Option<(usize, &'a ty::CapturedPlace<'tcx>)> {
|
) -> Option<(usize, &'a ty::CapturedPlace<'tcx>)> {
|
||||||
let closure_min_captures = typeck_results.closure_min_captures.get(&closure_def_id)?;
|
let closure_min_captures = typeck_results.closure_min_captures.get(&closure_def_id)?;
|
||||||
let root_variable_min_captures = closure_min_captures.get(&var_hir_id)?;
|
let root_variable_min_captures = closure_min_captures.get(&var_hir_id)?;
|
||||||
|
@ -1151,13 +1151,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||||||
/// When evaluating a `trait` use its associated types' idents for suggestions in E0412.
|
/// When evaluating a `trait` use its associated types' idents for suggestions in E0412.
|
||||||
fn with_trait_items<T>(
|
fn with_trait_items<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
trait_items: &'ast Vec<P<AssocItem>>,
|
trait_items: &'ast [P<AssocItem>],
|
||||||
f: impl FnOnce(&mut Self) -> T,
|
f: impl FnOnce(&mut Self) -> T,
|
||||||
) -> T {
|
) -> T {
|
||||||
let trait_assoc_items = replace(
|
let trait_assoc_items =
|
||||||
&mut self.diagnostic_metadata.current_trait_assoc_items,
|
replace(&mut self.diagnostic_metadata.current_trait_assoc_items, Some(&trait_items));
|
||||||
Some(&trait_items[..]),
|
|
||||||
);
|
|
||||||
let result = f(self);
|
let result = f(self);
|
||||||
self.diagnostic_metadata.current_trait_assoc_items = trait_assoc_items;
|
self.diagnostic_metadata.current_trait_assoc_items = trait_assoc_items;
|
||||||
result
|
result
|
||||||
|
@ -76,7 +76,7 @@ impl<'a> FileSearch<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
sysroot: &'a Path,
|
sysroot: &'a Path,
|
||||||
triple: &'a str,
|
triple: &'a str,
|
||||||
search_paths: &'a Vec<SearchPath>,
|
search_paths: &'a [SearchPath],
|
||||||
tlib_path: &'a SearchPath,
|
tlib_path: &'a SearchPath,
|
||||||
kind: PathKind,
|
kind: PathKind,
|
||||||
) -> FileSearch<'a> {
|
) -> FileSearch<'a> {
|
||||||
|
@ -3483,7 +3483,7 @@ enum AssocItemLink<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AssocItemLink<'a> {
|
impl<'a> AssocItemLink<'a> {
|
||||||
fn anchor(&self, id: &'a String) -> Self {
|
fn anchor(&self, id: &'a str) -> Self {
|
||||||
match *self {
|
match *self {
|
||||||
AssocItemLink::Anchor(_) => AssocItemLink::Anchor(Some(&id)),
|
AssocItemLink::Anchor(_) => AssocItemLink::Anchor(Some(&id)),
|
||||||
ref other => *other,
|
ref other => *other,
|
||||||
|
Loading…
Reference in New Issue
Block a user