tidy + move logic to fn
This commit is contained in:
parent
ca5a6e43dd
commit
b3425587a6
3 changed files with 30 additions and 31 deletions
|
@ -319,36 +319,11 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
|||
}
|
||||
}
|
||||
ItemKind::TyAlias(self_ty, _) => icx.to_ty(self_ty),
|
||||
ItemKind::Impl(
|
||||
hir::Impl { self_ty, .. }
|
||||
) => {
|
||||
struct MyVisitor(Vec<Span>);
|
||||
impl<'v> hir::intravisit::Visitor<'v> for MyVisitor {
|
||||
fn visit_ty(&mut self, t: &'v Ty<'v>) {
|
||||
if matches!(
|
||||
&t.kind,
|
||||
TyKind::Path(hir::QPath::Resolved(
|
||||
_,
|
||||
Path {
|
||||
res: hir::def::Res::SelfTyAlias { .. },
|
||||
..
|
||||
},
|
||||
))
|
||||
) {
|
||||
self.0.push(t.span);
|
||||
return;
|
||||
}
|
||||
hir::intravisit::walk_ty(self, t);
|
||||
}
|
||||
}
|
||||
|
||||
let mut my_visitor = MyVisitor(vec![]);
|
||||
my_visitor.visit_ty(self_ty);
|
||||
|
||||
match my_visitor.0 {
|
||||
spans if spans.len() > 0 => {
|
||||
ItemKind::Impl(hir::Impl { self_ty, .. }) => {
|
||||
match self_ty.find_self_aliases() {
|
||||
spans if spans.len() > 0 => {
|
||||
tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: (), });
|
||||
tcx.ty_error()
|
||||
tcx.ty_error()
|
||||
},
|
||||
_ => icx.to_ty(*self_ty),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue