]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/transform/qualify_consts.rs
Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikic
[rust.git] / src / librustc_mir / transform / qualify_consts.rs
index 3702dd9ad493fb3df20685c10d22e8addca7b8bb..5463b9444731f8c40657f0b156c6ef5609dd3d16 100644 (file)
@@ -564,6 +564,7 @@ fn in_call(
                             | "transmute"
                             | "simd_insert"
                             | "simd_extract"
+                            | "ptr_offset_from"
                             => return true,
 
                             _ => {}
@@ -1606,20 +1607,12 @@ fn visit_terminator_kind(&mut self,
                     // This is not a problem, because the argument explicitly
                     // requests constness, in contrast to regular promotion
                     // which happens even without the user requesting it.
-                    // We can error out with a hard error if the argument is not
-                    // constant here.
+                    //
+                    // `promote_consts` is responsible for emitting the error if
+                    // the argument is not promotable.
                     if !IsNotPromotable::in_operand(self, arg) {
                         debug!("visit_terminator_kind: candidate={:?}", candidate);
                         self.promotion_candidates.push(candidate);
-                    } else {
-                        if is_shuffle {
-                            span_err!(self.tcx.sess, self.span, E0526,
-                                      "shuffle indices are not constant");
-                        } else {
-                            self.tcx.sess.span_err(self.span,
-                                &format!("argument {} is required to be a constant",
-                                         i + 1));
-                        }
                     }
                 }
             }