diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-10-12 09:30:28 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-10-12 09:30:28 +0200 |
| commit | 76f8a90d53a3f212820e95260257105dd1da9910 (patch) | |
| tree | f339f935d4286663d975dc0a307658332cf3e4a9 | |
| parent | 670d07efbb3fc3d5c7b38fefec39db9cfc6a1294 (diff) | |
| download | rust-76f8a90d53a3f212820e95260257105dd1da9910.tar.gz rust-76f8a90d53a3f212820e95260257105dd1da9910.zip | |
Add comments explaining why some operations are not constant inside normal functions
| -rw-r--r-- | src/librustc_mir/transform/qualify_consts.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 32b570b32d5..1281fc96c0d 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -735,8 +735,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { (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 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { 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", |
