diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-22 13:07:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 13:07:05 +0000 |
commit | 2cce6b8919ce16acd37a7a203049a52925a7e295 (patch) | |
tree | 0ac934a218d9f65af25065aa4abe94976533cb4a /gcc/rust/backend/rust-compile-resolve-path.cc | |
parent | 6c9e57efa5474cfe5d0440e1022ee3c4a8400199 (diff) | |
parent | ee794effe3b55d2aa8acc108fb36bd8d05672dfa (diff) | |
download | gcc-2cce6b8919ce16acd37a7a203049a52925a7e295.zip gcc-2cce6b8919ce16acd37a7a203049a52925a7e295.tar.gz gcc-2cce6b8919ce16acd37a7a203049a52925a7e295.tar.bz2 |
Merge #873
873: Method resolution should respect deref lang-items r=philberty a=philberty
Method resolution in rust must respect the autoderef cycle by calling into the deref lang items as required. This
allows for method resolution behind boxing for example. See below for an example gimple dump of two levels
of deref operator overloads. The commit message ee794effe3b55d2aa8acc108fb36bd8d05672dfa holds much
more detail on the changes in this patch.
```
void main ()
{
const struct bar;
const struct foo;
const i32 foobar;
try
{
bar.0 = 123;
foo.0 = &bar;
RUSTTMP.3 = <Foo as Deref>::deref<&Bar> (&foo);
RUSTTMP.5 = <&T as Deref>::deref<Bar> (RUSTTMP.3);
foobar = Bar::foobar (*RUSTTMP.5);
}
finally
{
bar = {CLOBBER};
foo = {CLOBBER};
}
}
```
Fixes #884
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-resolve-path.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index c1d0778..5c727d6 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -152,10 +152,10 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, // let the query system figure it out return query_compile (ref, lookup, final_segment, mappings, expr_locus, is_qualified_path); -} // namespace Compile +} tree -ResolvePathRef::query_compile (HirId ref, TyTy::BaseType *lookup, +HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, const HIR::PathIdentSegment &final_segment, const Analysis::NodeMapping &mappings, Location expr_locus, bool is_qualified_path) @@ -194,13 +194,11 @@ ResolvePathRef::query_compile (HirId ref, TyTy::BaseType *lookup, rust_assert (ok); if (!lookup->has_subsititions_defined ()) - return CompileInherentImplItem::Compile (self, resolved_item, ctx, - true, nullptr, true, - expr_locus); + return CompileInherentImplItem::Compile (resolved_item, ctx, true, + nullptr, true, expr_locus); else - return CompileInherentImplItem::Compile (self, resolved_item, ctx, - true, lookup, true, - expr_locus); + return CompileInherentImplItem::Compile (resolved_item, ctx, true, + lookup, true, expr_locus); } else { @@ -278,12 +276,12 @@ ResolvePathRef::query_compile (HirId ref, TyTy::BaseType *lookup, rust_assert (ok); if (!lookup->has_subsititions_defined ()) - return CompileInherentImplItem::Compile (self, impl_item, ctx, - true, nullptr, true, + return CompileInherentImplItem::Compile (impl_item, ctx, true, + nullptr, true, expr_locus); else - return CompileInherentImplItem::Compile (self, impl_item, ctx, - true, lookup, true, + return CompileInherentImplItem::Compile (impl_item, ctx, true, + lookup, true, expr_locus); lookup->set_ty_ref (impl_item->get_impl_mappings ().get_hirid ()); |