mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Handle ForeignItem as TAIT scope.
This commit is contained in:
parent
b8c207435c
commit
7366bdaea2
@ -69,6 +69,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
|
||||
Node::Item(it) => locator.visit_item(it),
|
||||
Node::ImplItem(it) => locator.visit_impl_item(it),
|
||||
Node::TraitItem(it) => locator.visit_trait_item(it),
|
||||
Node::ForeignItem(it) => locator.visit_foreign_item(it),
|
||||
other => bug!("{:?} is not a valid scope for an opaque type item", other),
|
||||
}
|
||||
}
|
||||
@ -240,6 +241,12 @@ impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
|
||||
trace!(?it.owner_id);
|
||||
assert_ne!(it.owner_id.def_id, self.def_id);
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_foreign_item(self, it);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
||||
|
21
tests/ui/type-alias-impl-trait/nested-in-anon-const.rs
Normal file
21
tests/ui/type-alias-impl-trait/nested-in-anon-const.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Regression test for issue #119295.
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type Bar<T> = T;
|
||||
type S<const A: usize> = [i32; A];
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me(
|
||||
x: Bar<
|
||||
S<
|
||||
{ //~ ERROR mismatched types
|
||||
type B<Z> = impl Sized;
|
||||
//~^ ERROR unconstrained opaque type
|
||||
},
|
||||
>,
|
||||
>,
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {}
|
20
tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr
Normal file
20
tests/ui/type-alias-impl-trait/nested-in-anon-const.stderr
Normal file
@ -0,0 +1,20 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/nested-in-anon-const.rs:12:17
|
||||
|
|
||||
LL | / {
|
||||
LL | | type B<Z> = impl Sized;
|
||||
LL | |
|
||||
LL | | },
|
||||
| |_________________^ expected `usize`, found `()`
|
||||
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/nested-in-anon-const.rs:13:33
|
||||
|
|
||||
LL | type B<Z> = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: `B` must be used in combination with a concrete type within the same item
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user