{
resolved = type.handle_substitions (mappings);
}
-
-// nothing to do for these
void
-SubstMapperInternal::visit (TyTy::InferType &type)
+SubstMapperInternal::visit (TyTy::FnPtr &type)
{
- resolved = type.clone ();
+ resolved = type.handle_substitions (mappings);
}
+
+// nothing to do for these
void
-SubstMapperInternal::visit (TyTy::FnPtr &type)
+SubstMapperInternal::visit (TyTy::InferType &type)
{
resolved = type.clone ();
}
get_unsafety (), get_combined_refs ());
}
+FnPtr *
+FnPtr::handle_substitions (SubstitutionArgumentMappings &mappings)
+{
+ auto &mappings_table = Analysis::Mappings::get ();
+
+ auto fn = clone ()->as<FnPtr> ();
+ fn->set_ref (mappings_table.get_next_hir_id ());
+ fn->set_ty_ref (mappings_table.get_next_hir_id ());
+
+ if (!fn->result_type.get_tyty ()->is_concrete ())
+ {
+ BaseType *concrete
+ = Resolver::SubstMapperInternal::Resolve (fn->result_type.get_tyty (),
+ mappings);
+ fn->result_type
+ = TyVar::subst_covariant_var (fn->result_type.get_tyty (), concrete);
+ }
+
+ for (size_t i = 0; i < fn->params.size (); i++)
+ {
+ TyVar &field = fn->params.at (i);
+ if (!field.get_tyty ()->is_concrete ())
+ {
+ BaseType *concrete
+ = Resolver::SubstMapperInternal::Resolve (field.get_tyty (),
+ mappings);
+ fn->params[i]
+ = TyVar::subst_covariant_var (field.get_tyty (), concrete);
+ }
+ }
+
+ return fn;
+}
+
void
ClosureType::accept_vis (TyVisitor &vis)
{
Unsafety get_unsafety () const { return unsafety; }
+ FnPtr *handle_substitions (SubstitutionArgumentMappings &mappings);
+
private:
std::vector<TyVar> params;
TyVar result_type;
--- /dev/null
+mod core {
+ mod marker {
+ #[lang = "sized"]
+ pub trait Sized {}
+
+ #[lang = "phantom_data"]
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub struct PhantomData<T: ?Sized>;
+
+ #[unstable(feature = "structural_match", issue = "31434")]
+ #[lang = "structural_teq"]
+ pub trait StructuralEq {
+ // Empty.
+ }
+
+ #[unstable(feature = "structural_match", issue = "31434")]
+ #[lang = "structural_peq"]
+ pub trait StructuralPartialEq {
+ // Empty.
+ }
+ }
+
+ pub mod cmp {
+ use super::marker::Sized;
+
+ #[lang = "eq"]
+ pub trait PartialEq<Rhs: ?Sized = Self> {
+ fn eq(&self, other: &Rhs) -> bool;
+
+ fn ne(&self, other: &Rhs) -> bool {
+ !self.eq(other)
+ }
+ }
+
+ pub trait Eq: PartialEq<Self> {
+ fn assert_receiver_is_total_eq(&self) {}
+ }
+ }
+
+ pub mod ptr {
+
+ use super::cmp::{Eq, PartialEq};
+
+ macro_rules! fnptr_impls_safety_abi {
+ ($FnTy: ty, $($Arg: ident),*) => {
+ #[stable(feature = "fnptr_impls", since = "1.4.0")]
+ impl<Ret, $($Arg),*> PartialEq for $FnTy {
+ #[inline]
+ fn eq(&self, other: &Self) -> bool {
+ *self as usize == *other as usize
+ }
+ }
+
+ #[stable(feature = "fnptr_impls", since = "1.4.0")]
+ impl<Ret, $($Arg),*> Eq for $FnTy {}
+
+ }
+ }
+
+ fnptr_impls_safety_abi! { extern "Rust" fn() -> Ret, }
+ }
+}
+
+#[derive(PartialEq, Eq)]
+struct AllowedBelow {
+ // { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
+ f: fn(),
+}
--- /dev/null
+mod core {
+ mod marker {
+ #[lang = "sized"]
+ pub trait Sized {}
+
+ #[lang = "phantom_data"]
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub struct PhantomData<T: ?Sized>;
+
+ #[unstable(feature = "structural_match", issue = "31434")]
+ #[lang = "structural_teq"]
+ pub trait StructuralEq {
+ // Empty.
+ }
+
+ #[unstable(feature = "structural_match", issue = "31434")]
+ #[lang = "structural_peq"]
+ pub trait StructuralPartialEq {
+ // Empty.
+ }
+ }
+
+ pub mod cmp {
+ use super::marker::Sized;
+
+ #[lang = "eq"]
+ pub trait PartialEq<Rhs: ?Sized = Self> {
+ fn eq(&self, other: &Rhs) -> bool;
+
+ fn ne(&self, other: &Rhs) -> bool {
+ !self.eq(other)
+ }
+ }
+
+ pub trait Eq: PartialEq<Self> {
+ fn assert_receiver_is_total_eq(&self) {}
+ }
+ }
+
+ pub mod ptr {
+
+ use super::cmp::{Eq, PartialEq};
+
+ macro_rules! fnptr_impls_safety_abi {
+ ($FnTy: ty, $($Arg: ident),*) => {
+ #[stable(feature = "fnptr_impls", since = "1.4.0")]
+ impl<Ret, $($Arg),*> PartialEq for $FnTy {
+ #[inline]
+ fn eq(&self, other: &Self) -> bool {
+ *self as usize == *other as usize
+ }
+ }
+
+ #[stable(feature = "fnptr_impls", since = "1.4.0")]
+ impl<Ret, $($Arg),*> Eq for $FnTy {}
+
+ }
+ }
+
+ fnptr_impls_safety_abi! { extern "Rust" fn() -> Ret, }
+ fnptr_impls_safety_abi! { extern "C" fn() -> Ret, }
+ fnptr_impls_safety_abi! { unsafe extern "Rust" fn() -> Ret, }
+ fnptr_impls_safety_abi! { unsafe extern "C" fn() -> Ret, }
+ }
+}
+
+#[derive(PartialEq, Eq)]
+struct AllowedBelow {
+ // { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
+ f: fn(),
+}