-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve instances of TypePath
more accurately
#3220
base: master
Are you sure you want to change the base?
Conversation
TypePath
more accurately
#define unwrap_type_segment(x) \ | ||
(unwrap_type_segment_inner<typename std::remove_const< \ | ||
typename std::remove_reference<decltype (x)>::type>::type>::unwrap (x)) | ||
|
||
template <class T> class unwrap_type_segment_inner; | ||
|
||
template <> class unwrap_type_segment_inner<AST::SimplePathSegment> | ||
{ | ||
public: | ||
using ret = AST::SimplePathSegment; | ||
|
||
static AST::SimplePathSegment &unwrap (AST::SimplePathSegment &x) | ||
{ | ||
return x; | ||
} | ||
|
||
static const AST::SimplePathSegment &unwrap (const AST::SimplePathSegment &x) | ||
{ | ||
return x; | ||
} | ||
}; | ||
|
||
template <class T> class unwrap_type_segment_inner<std::unique_ptr<T>> | ||
{ | ||
public: | ||
using ret = typename unwrap_type_segment_inner<T>::ret; | ||
|
||
static ret &unwrap (std::unique_ptr<T> &x) | ||
{ | ||
return unwrap_type_segment (*x); | ||
} | ||
static const ret &unwrap (const std::unique_ptr<T> &x) | ||
{ | ||
return unwrap_type_segment (*x); | ||
} | ||
}; | ||
|
||
template <class T> class unwrap_type_segment_inner | ||
{ | ||
public: | ||
using ret = AST::PathIdentSegment; | ||
|
||
static ret &unwrap (T &x) { return x.get_ident_segment (); } | ||
static const ret &unwrap (const T &x) { return x.get_ident_segment (); } | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really needed? I can't really wrap my head around that code or what code it "replaces" if that makes sense. it seems a bit hard to maintain, but if there's a lot to gain from using it I'm happy with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to help handle different segment types being passed to resolve_path
, by converting segment references down into PathIdentSegment
or SimplePathSegment
references. I suppose I could try to reduce it down to a couple of templated function overloads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to reduce it down to function overloads I keep getting linker errors, since some of the functions aren't templates, and everything's defined in an .hxx
file (included in multiple places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some commits to try to make things more clear
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (unwrap_type_segment): Add. (unwrap_type_segment_inner): Add. (ForeverStack::find_starting_point): Use unwrap_type_segment. (ForeverStack::resolve_segments): Likewise. (ForeverStack::resolve_path): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Resolve TypePath using ForeverStack::resolve_path. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove complex-path1.rs. Signed-off-by: Owen Avery <[email protected]>
Should I try to edit this, or keep it as-is? |
Depends on #3219