is_const_context -> is_inside_const_context
This commit is contained in:
parent
ecb593379c
commit
6da17d244b
3 changed files with 5 additions and 5 deletions
|
|
@ -586,7 +586,7 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
|
||||
/// Used exclusively for diagnostics, to avoid suggestion function calls.
|
||||
pub fn is_const_context(&self, hir_id: HirId) -> bool {
|
||||
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool {
|
||||
self.body_const_context(self.local_def_id(self.enclosing_body_owner(hir_id))).is_some()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -800,12 +800,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false }
|
||||
};
|
||||
|
||||
let is_const_context = self.tcx.hir().is_const_context(expr.hir_id);
|
||||
let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id);
|
||||
let suggest_to_change_suffix_or_into =
|
||||
|err: &mut DiagnosticBuilder<'_>, is_fallible: bool| {
|
||||
let msg = if literal_is_ty_suffixed(expr) {
|
||||
&lit_msg
|
||||
} else if is_const_context {
|
||||
} else if in_const_context {
|
||||
// Do not recommend `into` or `try_into` in const contexts.
|
||||
return;
|
||||
} else if is_fallible {
|
||||
|
|
|
|||
|
|
@ -5097,7 +5097,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
) {
|
||||
if self.tcx.hir().is_const_context(expr.hir_id) {
|
||||
if self.tcx.hir().is_inside_const_context(expr.hir_id) {
|
||||
// Do not suggest `Box::new` in const context.
|
||||
return;
|
||||
}
|
||||
|
|
@ -5134,7 +5134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> bool {
|
||||
// Handle #68197.
|
||||
|
||||
if self.tcx.hir().is_const_context(expr.hir_id) {
|
||||
if self.tcx.hir().is_inside_const_context(expr.hir_id) {
|
||||
// Do not suggest `Box::new` in const context.
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue