]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/check/op.rs
Rollup merge of #74872 - JohnTitor:ping-risc-v, r=Mark-Simulacrum
[rust.git] / src / librustc_typeck / check / op.rs
index b61aa73bb0184cca73211de38d8849eff8cbccd4..fd516c88ec61aac2896f340e66d4baee1236c065 100644 (file)
@@ -240,7 +240,7 @@ fn check_overloaded_binop(
                         // some cases applied on the RHS, on top of which we need
                         // to autoref, which is not allowed by apply_adjustments.
                         // self.apply_adjustments(rhs_expr, vec![autoref]);
-                        self.tables
+                        self.typeck_results
                             .borrow_mut()
                             .adjustments_mut()
                             .entry(rhs_expr.hir_id)
@@ -496,14 +496,14 @@ fn add_type_neq_err_label(
         err.span_label(span, ty.to_string());
         if let FnDef(def_id, _) = ty.kind {
             let source_map = self.tcx.sess.source_map();
-            if !self.tcx.has_typeck_tables(def_id) {
+            if !self.tcx.has_typeck_results(def_id) {
                 return false;
             }
             // We're emitting a suggestion, so we can just ignore regions
             let fn_sig = self.tcx.fn_sig(def_id).skip_binder();
 
             let other_ty = if let FnDef(def_id, _) = other_ty.kind {
-                if !self.tcx.has_typeck_tables(def_id) {
+                if !self.tcx.has_typeck_results(def_id) {
                     return false;
                 }
                 // We're emitting a suggestion, so we can just ignore regions
@@ -562,7 +562,11 @@ fn check_str_addition(
                    on the left and may require reallocation. This \
                    requires ownership of the string on the left";
 
-        let is_std_string = |ty| &format!("{:?}", ty) == "std::string::String";
+        let string_type = self.tcx.get_diagnostic_item(sym::string_type);
+        let is_std_string = |ty: Ty<'tcx>| match ty.ty_adt_def() {
+            Some(ty_def) => Some(ty_def.did) == string_type,
+            None => false,
+        };
 
         match (&lhs_ty.kind, &rhs_ty.kind) {
             (&Ref(_, l_ty, _), &Ref(_, r_ty, _)) // &str or &String + &str, &String or &&str