Don't make a def id for impl_trait_in_bindings
This commit is contained in:
parent
f1ec5d64b3
commit
ca055ee7db
3 changed files with 20 additions and 0 deletions
|
@ -356,6 +356,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
|
||||||
let kind = match self.impl_trait_context {
|
let kind = match self.impl_trait_context {
|
||||||
ImplTraitContext::Universal => DefKind::TyParam,
|
ImplTraitContext::Universal => DefKind::TyParam,
|
||||||
ImplTraitContext::Existential => DefKind::OpaqueTy,
|
ImplTraitContext::Existential => DefKind::OpaqueTy,
|
||||||
|
ImplTraitContext::InBinding => return visit::walk_ty(self, ty),
|
||||||
};
|
};
|
||||||
let id = self.create_def(*id, name, kind, ty.span);
|
let id = self.create_def(*id, name, kind, ty.span);
|
||||||
match self.impl_trait_context {
|
match self.impl_trait_context {
|
||||||
|
@ -365,6 +366,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
|
||||||
ImplTraitContext::Existential => {
|
ImplTraitContext::Existential => {
|
||||||
self.with_parent(id, |this| visit::walk_ty(this, ty))
|
self.with_parent(id, |this| visit::walk_ty(this, ty))
|
||||||
}
|
}
|
||||||
|
ImplTraitContext::InBinding => unreachable!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_ => visit::walk_ty(self, ty),
|
_ => visit::walk_ty(self, ty),
|
||||||
|
@ -374,6 +376,13 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
|
||||||
fn visit_stmt(&mut self, stmt: &'a Stmt) {
|
fn visit_stmt(&mut self, stmt: &'a Stmt) {
|
||||||
match stmt.kind {
|
match stmt.kind {
|
||||||
StmtKind::MacCall(..) => self.visit_macro_invoc(stmt.id),
|
StmtKind::MacCall(..) => self.visit_macro_invoc(stmt.id),
|
||||||
|
// FIXME(impl_trait_in_bindings): We don't really have a good way of
|
||||||
|
// introducing the right `ImplTraitContext` here for all the cases we
|
||||||
|
// care about, in case we want to introduce ITIB to other positions
|
||||||
|
// such as turbofishes (e.g. `foo::<impl Fn()>(|| {})`).
|
||||||
|
StmtKind::Let(ref local) => self.with_impl_trait(ImplTraitContext::InBinding, |this| {
|
||||||
|
visit::walk_local(this, local)
|
||||||
|
}),
|
||||||
_ => visit::walk_stmt(self, stmt),
|
_ => visit::walk_stmt(self, stmt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ impl InvocationParent {
|
||||||
enum ImplTraitContext {
|
enum ImplTraitContext {
|
||||||
Existential,
|
Existential,
|
||||||
Universal,
|
Universal,
|
||||||
|
InBinding,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used for tracking import use types which will be used for redundant import checking.
|
/// Used for tracking import use types which will be used for redundant import checking.
|
||||||
|
|
10
tests/ui/impl-trait/in-bindings/dont-make-def-id.rs
Normal file
10
tests/ui/impl-trait/in-bindings/dont-make-def-id.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
// Make sure we don't create an opaque def id for ITIB.
|
||||||
|
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
#![feature(impl_trait_in_bindings)]
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let _: impl Sized = 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue