]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/infer/error_reporting.rs
Merge pull request #20674 from jbcrail/fix-misspelled-comments
[rust.git] / src / librustc / middle / infer / error_reporting.rs
index 9f5c8de8811f07ed2a30a3ce86a6de285c558ca7..762617fb49b88c1dca21d29cdf9c8a187dfe9aaf 100644 (file)
@@ -200,9 +200,9 @@ fn report_region_errors(&self,
                                 ref trace_origins,
                                 ref same_regions) => {
                     if !same_regions.is_empty() {
-                        self.report_processed_errors(var_origins[],
-                                                     trace_origins[],
-                                                     same_regions[]);
+                        self.report_processed_errors(var_origins.index(&FullRange),
+                                                     trace_origins.index(&FullRange),
+                                                     same_regions.index(&FullRange));
                     }
                 }
             }
@@ -268,7 +268,7 @@ fn process_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>)
                 }
             }
             let pe = ProcessedErrors(var_origins, trace_origins, same_regions);
-            debug!("errors processed: {}", pe);
+            debug!("errors processed: {:?}", pe);
             processed_errors.push(pe);
         }
         return processed_errors;
@@ -297,7 +297,7 @@ fn free_regions_from_same_fn(tcx: &ty::ctxt,
                                      sub: Region,
                                      sup: Region)
                                      -> Option<FreeRegionsFromSameFn> {
-            debug!("free_regions_from_same_fn(sub={}, sup={})", sub, sup);
+            debug!("free_regions_from_same_fn(sub={:?}, sup={:?})", sub, sup);
             let (scope_id, fr1, fr2) = match (sub, sup) {
                 (ReFree(fr1), ReFree(fr2)) => {
                     if fr1.scope != fr2.scope {
@@ -376,7 +376,7 @@ fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>) {
             format!("{}: {} ({})",
                  message_root_str,
                  expected_found_str,
-                 ty::type_err_to_str(self.tcx, terr))[]);
+                 ty::type_err_to_str(self.tcx, terr)).index(&FullRange));
 
         match trace.origin {
             infer::MatchExpressionArm(_, arm_span) =>
@@ -445,25 +445,25 @@ fn report_generic_bound_failure(&self,
                 // Does the required lifetime have a nice name we can print?
                 self.tcx.sess.span_err(
                     origin.span(),
-                    format!("{} may not live long enough", labeled_user_string)[]);
+                    format!("{} may not live long enough", labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound `{}: {}`...",
                         bound_kind.user_string(self.tcx),
-                        sub.user_string(self.tcx))[]);
+                        sub.user_string(self.tcx)).index(&FullRange));
             }
 
             ty::ReStatic => {
                 // Does the required lifetime have a nice name we can print?
                 self.tcx.sess.span_err(
                     origin.span(),
-                    format!("{} may not live long enough", labeled_user_string)[]);
+                    format!("{} may not live long enough", labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound `{}: 'static`...",
-                        bound_kind.user_string(self.tcx))[]);
+                        bound_kind.user_string(self.tcx)).index(&FullRange));
             }
 
             _ => {
@@ -472,15 +472,15 @@ fn report_generic_bound_failure(&self,
                     origin.span(),
                     format!(
                         "{} may not live long enough",
-                        labeled_user_string)[]);
+                        labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound for `{}`",
-                        bound_kind.user_string(self.tcx))[]);
+                        bound_kind.user_string(self.tcx)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
-                    format!("{} must be valid for ", labeled_user_string)[],
+                    format!("{} must be valid for ", labeled_user_string).index(&FullRange),
                     sub,
                     "...");
             }
@@ -522,7 +522,7 @@ fn report_concrete_failure(&self,
                             ty::local_var_name_str(self.tcx,
                                                    upvar_id.var_id)
                                 .get()
-                                .to_string())[]);
+                                .to_string()).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "...the borrowed pointer is valid for ",
@@ -534,7 +534,7 @@ fn report_concrete_failure(&self,
                             ty::local_var_name_str(self.tcx,
                                                    upvar_id.var_id)
                                 .get()
-                                .to_string())[],
+                                .to_string()).index(&FullRange),
                     sup,
                     "");
             }
@@ -580,7 +580,7 @@ fn report_concrete_failure(&self,
                             outlive the enclosing closure",
                             ty::local_var_name_str(self.tcx,
                                                    id).get()
-                                                      .to_string())[]);
+                                                      .to_string()).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "captured variable is valid for ",
@@ -622,7 +622,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("the type `{}` does not fulfill the \
                              required lifetime",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(self.tcx,
                                         "type must outlive ",
                                         sub,
@@ -648,7 +648,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("the type `{}` (provided as the value of \
                              a type parameter) is not valid at this point",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(self.tcx,
                                         "type must outlive ",
                                         sub,
@@ -714,7 +714,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("type of expression contains references \
                              that are not valid during the expression: `{}`",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "type is only valid for ",
@@ -736,7 +736,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("in type `{}`, reference has a longer lifetime \
                              than the data it references",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "the pointer is valid for ",
@@ -861,7 +861,7 @@ fn give_suggestion(&self, same_regions: &[SameRegions]) {
         let (fn_decl, generics, unsafety, ident, expl_self, span)
                                     = node_inner.expect("expect item fn");
         let taken = lifetimes_in_scope(self.tcx, scope_id);
-        let life_giver = LifeGiver::with_taken(taken[]);
+        let life_giver = LifeGiver::with_taken(taken.index(&FullRange));
         let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
                                        generics, same_regions, &life_giver);
         let (fn_decl, expl_self, generics) = rebuilder.rebuild();
@@ -937,7 +937,7 @@ fn rebuild(&self)
             }
             expl_self_opt = self.rebuild_expl_self(expl_self_opt, lifetime,
                                                    &anon_nums, &region_names);
-            inputs = self.rebuild_args_ty(inputs[], lifetime,
+            inputs = self.rebuild_args_ty(inputs.index(&FullRange), lifetime,
                                           &anon_nums, &region_names);
             output = self.rebuild_output(&output, lifetime, &anon_nums, &region_names);
             ty_params = self.rebuild_ty_params(ty_params, lifetime,
@@ -972,7 +972,7 @@ fn pick_lifetime(&self,
                 names.push(lt_name);
             }
             names.sort();
-            let name = token::str_to_ident(names[0][]).name;
+            let name = token::str_to_ident(names[0].index(&FullRange)).name;
             return (name_to_dummy_lifetime(name), Kept);
         }
         return (self.life_giver.give_lifetime(), Fresh);
@@ -1222,7 +1222,7 @@ fn rebuild_arg_ty_or_output(&self,
                                 .sess
                                 .fatal(format!(
                                         "unbound path {}",
-                                        pprust::path_to_string(path))[])
+                                        pprust::path_to_string(path)).index(&FullRange))
                         }
                         Some(&d) => d
                     };
@@ -1420,7 +1420,7 @@ fn give_expl_lifetime_param(&self,
                                               opt_explicit_self, generics);
         let msg = format!("consider using an explicit lifetime \
                            parameter as shown: {}", suggested_fn);
-        self.tcx.sess.span_help(span, msg[]);
+        self.tcx.sess.span_help(span, msg.index(&FullRange));
     }
 
     fn report_inference_failure(&self,
@@ -1463,7 +1463,7 @@ fn report_inference_failure(&self,
             var_origin.span(),
             format!("cannot infer an appropriate lifetime{} \
                     due to conflicting requirements",
-                    var_description)[]);
+                    var_description).index(&FullRange));
     }
 
     fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
@@ -1511,7 +1511,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         self.tcx.sess.span_note(
                             trace.origin.span(),
                             format!("...so that {} ({})",
-                                    desc, values_str)[]);
+                                    desc, values_str).index(&FullRange));
                     }
                     None => {
                         // Really should avoid printing this error at
@@ -1520,7 +1520,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         // doing right now. - nmatsakis
                         self.tcx.sess.span_note(
                             trace.origin.span(),
-                            format!("...so that {}", desc)[]);
+                            format!("...so that {}", desc).index(&FullRange));
                     }
                 }
             }
@@ -1537,7 +1537,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         "...so that closure can access `{}`",
                         ty::local_var_name_str(self.tcx, upvar_id.var_id)
                             .get()
-                            .to_string())[])
+                            .to_string()).index(&FullRange))
             }
             infer::InfStackClosure(span) => {
                 self.tcx.sess.span_note(
@@ -1562,7 +1562,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                             does not outlive the enclosing closure",
                             ty::local_var_name_str(
                                 self.tcx,
-                                id).get().to_string())[]);
+                                id).get().to_string()).index(&FullRange));
             }
             infer::IndexSlice(span) => {
                 self.tcx.sess.span_note(
@@ -1606,7 +1606,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     span,
                     format!("...so type `{}` of expression is valid during the \
                              expression",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::BindingTypeIsNotValidAtDecl(span) => {
                 self.tcx.sess.span_note(
@@ -1618,14 +1618,14 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     span,
                     format!("...so that the reference type `{}` \
                              does not outlive the data it points at",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
             }
             infer::RelateParamBound(span, t) => {
                 self.tcx.sess.span_note(
                     span,
                     format!("...so that the type `{}` \
                              will meet the declared lifetime bounds",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::RelateDefaultParamBound(span, t) => {
                 self.tcx.sess.span_note(
@@ -1633,13 +1633,13 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     format!("...so that type parameter \
                              instantiated with `{}`, \
                              will meet its declared lifetime bounds",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::RelateRegionParamBound(span) => {
                 self.tcx.sess.span_note(
                     span,
                     format!("...so that the declared lifetime parameter bounds \
-                                are satisfied")[]);
+                                are satisfied").index(&FullRange));
             }
         }
     }
@@ -1691,7 +1691,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
         Some(node) => match node {
             ast_map::NodeItem(item) => match item.node {
                 ast::ItemFn(_, _, _, ref gen, _) => {
-                    taken.push_all(gen.lifetimes[]);
+                    taken.push_all(gen.lifetimes.index(&FullRange));
                     None
                 },
                 _ => None
@@ -1699,7 +1699,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
             ast_map::NodeImplItem(ii) => {
                 match *ii {
                     ast::MethodImplItem(ref m) => {
-                        taken.push_all(m.pe_generics().lifetimes[]);
+                        taken.push_all(m.pe_generics().lifetimes.index(&FullRange));
                         Some(m.id)
                     }
                     ast::TypeImplItem(_) => None,
@@ -1758,10 +1758,10 @@ fn give_lifetime(&self) -> ast::Lifetime {
         let mut lifetime;
         loop {
             let mut s = String::from_str("'");
-            s.push_str(num_to_string(self.counter.get())[]);
+            s.push_str(num_to_string(self.counter.get()).index(&FullRange));
             if !self.taken.contains(&s) {
                 lifetime = name_to_dummy_lifetime(
-                                    token::str_to_ident(s[]).name);
+                                    token::str_to_ident(s.index(&FullRange)).name);
                 self.generated.borrow_mut().push(lifetime);
                 break;
             }