1
Fork 0

Remove code that was removed in master, and the corresponding diagnostic

This commit is contained in:
Nathan Stocks 2022-10-05 15:46:14 -06:00
parent 965dbf6c28
commit 8e07a85ad7
2 changed files with 1 additions and 30 deletions

View file

@ -17,7 +17,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::parse::feature_err;
use rustc_span::{sym, Span, Symbol};
use crate::errors::{ConstImplConstTrait, ExprNotAllowedInContext};
use crate::errors::ExprNotAllowedInContext;
/// An expression that is not *always* legal in a const context.
#[derive(Clone, Copy)]
@ -196,26 +196,6 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
self.tcx.hir()
}
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
let tcx = self.tcx;
if let hir::ItemKind::Impl(hir::Impl {
constness: hir::Constness::Const,
of_trait: Some(trait_ref),
..
}) = item.kind
&& let Some(def_id) = trait_ref.trait_def_id()
{
let source_map = tcx.sess.source_map();
if !tcx.has_attr(def_id, sym::const_trait) {
tcx.sess.emit_err(ConstImplConstTrait {
span: source_map.guess_head_span(item.span),
def_span: source_map.guess_head_span(tcx.def_span(def_id)),
});
}
}
intravisit::walk_item(self, item);
}
fn visit_anon_const(&mut self, anon: &'tcx hir::AnonConst) {
let kind = Some(hir::ConstContext::Const);
self.recurse_into(kind, None, |this| intravisit::walk_anon_const(this, anon));