Skip to content
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

add test for 62220 #70539

Merged
merged 1 commit into from
Mar 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/test/ui/const-generics/issues/issue-62220.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// build-pass
#![allow(incomplete_features)]

#![feature(const_generics)]
pub struct Vector<T, const N: usize>([T; N]);

pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddyb @varkor Shouldn't error: constant expression depends on a generic parameter happen here or is this cause we're not applying WF for type aliases... but then why won't it happen for the usage below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not doing const WF at all except for array types, today.
#70107 aims to fix that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah; forgot that hadn't landed yet. Let's merge this PR like this then once the other comment has been addressed and we can make adjustments later in the other.


impl<T, const N: usize> Vector<T, { N }> {
/// Drop the last component and return the vector with one fewer dimension.
pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
unimplemented!()
}
}

fn vec4<T>(a: T, b: T, c: T, d: T) -> Vector<T, 4> {
Vector([a, b, c, d])
}

fn main() {
let (_xyz, _w): (TruncatedVector<u32, 4>, u32) = vec4(0u32, 1, 2, 3).trunc();
}