about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer <github35764891676564198441@oli-obk.de>2018-10-25 18:28:14 +0200
committerGitHub <noreply@github.com>2018-10-25 18:28:14 +0200
commitf7629eff32cf23680074ae72144ed748139100fe (patch)
tree6778386ecb173cd55fe9cba417673a5351ce66f4
parent8b097c4ce92869b012c36ba0c7c0a2a096a17849 (diff)
downloadrust-f7629eff32cf23680074ae72144ed748139100fe.tar.gz
rust-f7629eff32cf23680074ae72144ed748139100fe.zip
Explain a comment in more detail
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 4808f02c1df..99ccf4f3cf5 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -979,8 +979,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
                     if !constant_arguments.contains(&i) {
                         return
                     }
-                    // if the argument requires a constant, we care about constness, not
-                    // promotability
+                    // Since the argument is required to be constant,
+                    // we care about constness, not promotability.
+                    // If we checked for promotability, we'd miss out on
+                    // the results of function calls (which are never promoted)
+                    // 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.
                     if (this.qualif - Qualif::NOT_PROMOTABLE).is_empty() {
                         this.promotion_candidates.push(candidate);
                     } else {