Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 272000c

Browse files
committedApr 28, 2019
Auto merge of #60317 - flip1995:internal_lints, r=oli-obk
Internal lints: usage_of_qualified_ty & ty_pass_by_reference Closes #59952 Implements internal lints: - `USAGE_OF_QUALIFIED_TY` - `TY_PASS_BY_REFERENCE` r? @oli-obk
2 parents bdfdbcd + 2e5f0b3 commit 272000c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+480
-170
lines changed
 

‎src/librustc/infer/error_reporting/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
690690
name: String,
691691
sub: ty::subst::SubstsRef<'tcx>,
692692
pos: usize,
693-
other_ty: &Ty<'tcx>,
693+
other_ty: Ty<'tcx>,
694694
) {
695695
// `value` and `other_value` hold two incomplete type representation for display.
696696
// `name` is the path of both types being compared. `sub`
@@ -768,10 +768,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
768768
path: String,
769769
sub: ty::subst::SubstsRef<'tcx>,
770770
other_path: String,
771-
other_ty: &Ty<'tcx>,
771+
other_ty: Ty<'tcx>,
772772
) -> Option<()> {
773773
for (i, ta) in sub.types().enumerate() {
774-
if &ta == other_ty {
774+
if ta == other_ty {
775775
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
776776
return Some(());
777777
}
@@ -839,7 +839,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
839839
/// Compares two given types, eliding parts that are the same between them and highlighting
840840
/// relevant differences, and return two representation of those types for highlighted printing.
841841
fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> (DiagnosticStyledString, DiagnosticStyledString) {
842-
fn equals<'tcx>(a: &Ty<'tcx>, b: &Ty<'tcx>) -> bool {
842+
fn equals<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
843843
match (&a.sty, &b.sty) {
844844
(a, b) if *a == *b => true,
845845
(&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_)))
@@ -1099,7 +1099,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10991099
}
11001100
};
11011101

1102-
let span = cause.span(&self.tcx);
1102+
let span = cause.span(self.tcx);
11031103

11041104
diag.span_label(span, terr.to_string());
11051105
if let Some((sp, msg)) = secondary_span {
@@ -1233,7 +1233,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12331233
trace, terr
12341234
);
12351235

1236-
let span = trace.cause.span(&self.tcx);
1236+
let span = trace.cause.span(self.tcx);
12371237
let failure_code = trace.cause.as_failure_code(terr);
12381238
let mut diag = match failure_code {
12391239
FailureCode::Error0317(failure_str) => {

‎src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use errors::DiagnosticBuilder;
1111

1212
struct FindLocalByTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
1313
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
14-
target_ty: &'a Ty<'tcx>,
14+
target_ty: Ty<'tcx>,
1515
hir_map: &'a hir::map::Map<'gcx>,
1616
found_local_pattern: Option<&'gcx Pat>,
1717
found_arg_pattern: Option<&'gcx Pat>,
@@ -26,7 +26,7 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
2626
Some(ty) => {
2727
let ty = self.infcx.resolve_type_vars_if_possible(&ty);
2828
ty.walk().any(|inner_ty| {
29-
inner_ty == *self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
29+
inner_ty == self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
3030
(&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => {
3131
self.infcx
3232
.type_variables
@@ -68,10 +68,10 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
6868
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
6969
pub fn extract_type_name(
7070
&self,
71-
ty: &'a Ty<'tcx>,
71+
ty: Ty<'tcx>,
7272
highlight: Option<ty::print::RegionHighlightMode>,
7373
) -> String {
74-
if let ty::Infer(ty::TyVar(ty_vid)) = (*ty).sty {
74+
if let ty::Infer(ty::TyVar(ty_vid)) = ty.sty {
7575
let ty_vars = self.type_variables.borrow();
7676
if let TypeVariableOrigin::TypeParameterDefinition(_, name) =
7777
*ty_vars.var_origin(ty_vid) {
@@ -102,7 +102,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
102102

103103
let mut local_visitor = FindLocalByTypeVisitor {
104104
infcx: &self,
105-
target_ty: &ty,
105+
target_ty: ty,
106106
hir_map: &self.tcx.hir(),
107107
found_local_pattern: None,
108108
found_arg_pattern: None,

0 commit comments

Comments
 (0)
Please sign in to comment.