Skip to content

Commit 6da17d2

Browse files
committed
is_const_context -> is_inside_const_context
1 parent ecb5933 commit 6da17d2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/librustc_middle/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'hir> Map<'hir> {
586586

587587
/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
588588
/// Used exclusively for diagnostics, to avoid suggestion function calls.
589-
pub fn is_const_context(&self, hir_id: HirId) -> bool {
589+
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool {
590590
self.body_const_context(self.local_def_id(self.enclosing_body_owner(hir_id))).is_some()
591591
}
592592

src/librustc_typeck/check/demand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
800800
if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false }
801801
};
802802

803-
let is_const_context = self.tcx.hir().is_const_context(expr.hir_id);
803+
let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id);
804804
let suggest_to_change_suffix_or_into =
805805
|err: &mut DiagnosticBuilder<'_>, is_fallible: bool| {
806806
let msg = if literal_is_ty_suffixed(expr) {
807807
&lit_msg
808-
} else if is_const_context {
808+
} else if in_const_context {
809809
// Do not recommend `into` or `try_into` in const contexts.
810810
return;
811811
} else if is_fallible {

src/librustc_typeck/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5097,7 +5097,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
50975097
expected: Ty<'tcx>,
50985098
found: Ty<'tcx>,
50995099
) {
5100-
if self.tcx.hir().is_const_context(expr.hir_id) {
5100+
if self.tcx.hir().is_inside_const_context(expr.hir_id) {
51015101
// Do not suggest `Box::new` in const context.
51025102
return;
51035103
}
@@ -5134,7 +5134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
51345134
) -> bool {
51355135
// Handle #68197.
51365136

5137-
if self.tcx.hir().is_const_context(expr.hir_id) {
5137+
if self.tcx.hir().is_inside_const_context(expr.hir_id) {
51385138
// Do not suggest `Box::new` in const context.
51395139
return false;
51405140
}

0 commit comments

Comments
 (0)