Skip to content

Commit f7629ef

Browse files
authored
Explain a comment in more detail
1 parent 8b097c4 commit f7629ef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
979979
if !constant_arguments.contains(&i) {
980980
return
981981
}
982-
// if the argument requires a constant, we care about constness, not
983-
// promotability
982+
// Since the argument is required to be constant,
983+
// we care about constness, not promotability.
984+
// If we checked for promotability, we'd miss out on
985+
// the results of function calls (which are never promoted)
986+
// This is not a problem, because the argument explicitly
987+
// requests constness, in contrast to regular promotion
988+
// which happens even without the user requesting it.
989+
// We can error out with a hard error if the argument is not
990+
// constant here.
984991
if (this.qualif - Qualif::NOT_PROMOTABLE).is_empty() {
985992
this.promotion_candidates.push(candidate);
986993
} else {

0 commit comments

Comments
 (0)