view-types: store view types in the AST#156016
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
52c4eee to
2bafb0c
Compare
This comment has been minimized.
This comment has been minimized.
2bafb0c to
7f6749b
Compare
7f6749b to
77bdbc2
Compare
This comment has been minimized.
This comment has been minimized.
d9ef8d8 to
ec789ac
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
view-types: store borrows of view types in the AST
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (9d3dea7): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.1%, secondary -2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 503.61s -> 496.571s (-1.40%) |
This comment has been minimized.
This comment has been minimized.
ec789ac to
93208f2
Compare
|
^
r? nikomatsakis |
661a680 to
6035af1
Compare
| Ptr(MutTy), | ||
| /// A reference (`&'a T` or `&'a mut T`). | ||
| Ref(#[visitable(extra = LifetimeCtxt::Ref)] Option<Lifetime>, MutTy), | ||
| Ref(#[visitable(extra = LifetimeCtxt::Ref)] Option<Lifetime>, MutTy, ViewKind), |
There was a problem hiding this comment.
This is not the right model. The view is not attached to the reference but rather to the path type. You can have a view type without any reference at all (e.g., Foo.{F1, F2}).
There was a problem hiding this comment.
hi! Unless you have an objection, i would like to go with the following:
- Have a
TyKind::View(Box<Ty>, ThinVec<Ident>)variant (instead of the change you highlight) - Parse any
$ty.{ $( $ident ),* } - Check later in the compilation that
$tyis a kind of type we expect
Unless I have missed something, this is functionally identical to what you suggest, but leaves more room for nice error messages to be added.
I just pushed a commit that does what I just described, let me know what you think :)
There was a problem hiding this comment.
I don't have an objection to this in the AST, anyway.
|
Reminder, once the PR becomes ready for a review, use |
6035af1 to
9bdbdb2
Compare
9bdbdb2 to
7b29ee5
Compare
56b58a1 to
b103cec
Compare
This comment has been minimized.
This comment has been minimized.
b103cec to
f0d6895
Compare
|
@rustbot ready |
f0d6895 to
9a4f5ec
Compare
This comment has been minimized.
This comment has been minimized.
9a4f5ec to
827c78c
Compare
| let (kind, view, span) = match self.ty.kind { | ||
| ref kind if let Some(view) = kind.as_implicit_self_maybe_wrapped_in_view() => { | ||
| (SelfKind::Value(mutbl), view, self.pat.span) | ||
| } | ||
| TyKind::Ref(lt, MutTy { ref ty, mutbl }) | ||
| if let Some(view) = ty.kind.as_implicit_self_maybe_wrapped_in_view() => | ||
| { | ||
| (SelfKind::Region(lt, mutbl), view, self.pat.span) | ||
| } | ||
| TyKind::PinnedRef(lt, MutTy { ref ty, mutbl }) | ||
| if ty.kind.is_implicit_self() => | ||
| if let Some(view) = ty.kind.as_implicit_self_maybe_wrapped_in_view() => | ||
| { | ||
| Some(respan(self.pat.span, SelfKind::Pinned(lt, mutbl))) | ||
| (SelfKind::Pinned(lt, mutbl), view, self.pat.span) | ||
| } | ||
| _ => Some(respan( | ||
| self.pat.span.to(self.ty.span), | ||
| SelfKind::Explicit(self.ty.clone(), mutbl), | ||
| )), | ||
| _ => (SelfKind::Explicit(self.ty.clone(), mutbl), ViewKind::Full, self.ty.span), | ||
| }; | ||
| let param = respan(span, SelfParam { view, kind }); | ||
| return Some(param); |
There was a problem hiding this comment.
i am not happy at all with this code, but i cannot think of a better way to express things. opinions are welcome.
| matches!(self, TyKind::ImplicitSelf) | ||
| } | ||
|
|
||
| pub fn as_implicit_self_maybe_wrapped_in_view(&self) -> Option<ViewKind> { |
There was a problem hiding this comment.
similarly, this method name is very very very meh
This comment has been minimized.
This comment has been minimized.
827c78c to
1707ca0
Compare
View all comments
Tracking issue: #155938.
Instead of discarding view types, we store them in the AST now!