]> git.lizzy.rs Git - rust.git/commitdiff
Add comments explaining why some operations are not constant inside normal functions
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 12 Oct 2018 07:30:28 +0000 (09:30 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 12 Oct 2018 07:30:28 +0000 (09:30 +0200)
src/librustc_mir/transform/qualify_consts.rs

index 32b570b32d5b90ac6639951889bb39718fdb838b..1281fc96c0da7a13770e03f079ab3820413b498d 100644 (file)
@@ -735,8 +735,11 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
                     (CastTy::Ptr(_), CastTy::Int(_)) |
                     (CastTy::FnPtr, CastTy::Int(_)) => {
                         if let Mode::Fn = self.mode {
+                            // in normal functions, mark such casts as not promotable
                             self.add(Qualif::NOT_CONST);
                         } else if !self.tcx.sess.features_untracked().const_raw_ptr_to_usize_cast {
+                            // in const fn and constants require the feature gate
+                            // FIXME: make it unsafe inside const fn and constants
                             emit_feature_err(
                                 &self.tcx.sess.parse_sess, "const_raw_ptr_to_usize_cast",
                                 self.span, GateIssue::Language,
@@ -759,8 +762,11 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
                             op == BinOp::Offset);
 
                     if let Mode::Fn = self.mode {
+                        // raw pointer operations are not allowed inside promoteds
                         self.add(Qualif::NOT_CONST);
                     } else if !self.tcx.sess.features_untracked().const_compare_raw_pointers {
+                        // require the feature gate inside constants and const fn
+                        // FIXME: make it unsafe to use these operations
                         emit_feature_err(
                             &self.tcx.sess.parse_sess,
                             "const_compare_raw_pointers",