Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for const generics (RFC 2000) #44580
Comments
This comment has been minimized.
This comment has been minimized.
|
#44275 added a @EpicatSupercell has expressed interest in working on this, I'll mentor them through the initial implementation. However, we can't go too far because of the limitations described in #44275. That is, we need @nikomatsakis' lazy normalization to allow constant expressions embedded in types to observe the bounds in scope (from the function / type definition / impl / etc. item they're in), without producing cyclic dependencies half the time. |
This comment has been minimized.
This comment has been minimized.
|
Implementation waypoints (for more direct mentoring, seek
Note that all of this should allow |
eddyb
added
the
E-mentor
label
Sep 18, 2017
eddyb
self-assigned this
Sep 18, 2017
This comment has been minimized.
This comment has been minimized.
|
I'd like to take a stab at this :) |
carols10cents
added
the
hacktoberfest
label
Sep 29, 2017
fitzgen
referenced this issue
Oct 3, 2017
Open
Tracking rustc bugs/features/RFCs that affect bindgen #849
This comment has been minimized.
This comment has been minimized.
samsartor
commented
Oct 26, 2017
This comment has been minimized.
This comment has been minimized.
|
@samsartor there was a refactoring that had to be done before the main implementation work. That is now almost done (I'm waiting for feedback currently). I don't actually know how much work there is after that. Parsing const params was what I started with initially, before the refactoring. It's not done but I should be able to get that done relatively soon. |
This comment has been minimized.
This comment has been minimized.
|
@jplatte It would be nice, if you could link the pull request. I was not able to find it. |
This comment has been minimized.
This comment has been minimized.
|
There is no PR yet. All my work can be found here. |
This comment has been minimized.
This comment has been minimized.
RobertWHurst
commented
Nov 6, 2017
|
Nice work so far @jplatte |
This comment has been minimized.
This comment has been minimized.
|
There is now a PR for the groundwork ( |
This comment has been minimized.
This comment has been minimized.
huhlig
commented
Nov 17, 2017
|
I think this is already included but it would be good to handle the C++ style folding for handling linear algebra style n dimensional arrays with varying lengths, I.E. a 4x4 [[f64;4];4]or a 4x3x5x6 dimensional array [[[[f64;6];5];3];4] and be able to properly wrap and generate specialized methods for both it AND proper trait implementations for scalars properly dimensioned vectors, etc. See https://gist.github.com/huhlig/8b21850b54a75254be4b093551f8c2cb for a rudamentary example. |
This comment has been minimized.
This comment has been minimized.
|
I don't recall anyone proposing fold expressions for Rust before, much less as part of this RFC. But since this is Rust, is there any reason we couldn't implement fold expressions as an ordinary macro, rather than new dedicated syntax? |
kennytm
referenced this issue
Nov 19, 2017
Closed
The trait `std::convert::AsRef<[u8]>` is not implemented for string.len() > 32 #17
This comment has been minimized.
This comment has been minimized.
|
This is correct. To give a quick update for those not following the PR #53645, const generics have compile and work in at least one simple usecase. What remains is finishing up codegen for other usecases, including const generics in arrys, and some error output cleanup. After that, the PR should be ready merge and people can start playing with it. |
This comment has been minimized.
This comment has been minimized.
jeffvandyke
commented
Jan 16, 2019
|
Might be off-topic, but will this allow a variant or fork of Chunks and related methods to have |
This comment has been minimized.
This comment has been minimized.
|
@jeffvandyke You might be thinking of ChunksExact specifically. Such a change would be API-breaking, so it can't be done. We could add new APIs that give array references in the future, but we can't break existing ones. |
This comment has been minimized.
This comment has been minimized.
I'm only waiting for this to be implemented and stabilized before proposing a PR that adds such API in addition to The runtime and compile-time variants both have their use-cases, you don't always know your chunk size ahead of time. Optimization-wise, if you use |
This comment has been minimized.
This comment has been minimized.
I'd suggest not waiting for stabilization as such an API would be one more good use to help exercise this feature for stabilization. |
This was referenced Feb 4, 2019
jonas-schievink
referenced this issue
Feb 9, 2019
Open
Const generic parameters have incorrect hygiene #58307
This comment has been minimized.
This comment has been minimized.
nhynes
commented
Mar 12, 2019
•
|
I'm guessing that this doesn't yet work for #![feature(const_generics)]
struct The<const Val: u64>();
impl<const Val: u64> The<Val> {
fn the() {
println!("{}", Val);
}
}but, as was indeed warned, the compiler crashed with
The error is related to the but props to Rust for even considering this feature. I had no idea if it'd work but the syntax seemed natural, I went for it, and lo rustc said it existed :) |
This comment has been minimized.
This comment has been minimized.
HadrienG2
commented
Mar 12, 2019
|
I'm not surprised that it is not working, as this hotly anticipated feature is still being plumbed through the compiler as we speak (see e.g. #59008 and #58581 and the earlier work on #53645 which was abandoned because the PR was too big, but still kept open as a tracker to announce progress). However, I'm not sure if out-of-bounds slice accesses should be expected of the current implementation stubs. @varkor @yodaldevoid, can you have a look? |
This comment has been minimized.
This comment has been minimized.
|
Yes, the warning is correct: const generics are not yet functional in any form. There are still a few more pull requests before they're ready to start getting played around with. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Coder-256
commented
Mar 12, 2019
|
Sorry if this is not the right place to ask questions but I couldn't find anywhere better. Just 2 questions:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
|
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@Coder-256 Both of these questions are not related to const generics, but rather const functions. Const generics are for being generic over consts (e.g. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Coder-256
commented
Mar 12, 2019
|
@rpjohnst Thank you, but I think I might have been unclear. I have already seen both rust-lang/rfcs#2632 and rust-lang/rfcs#2000, but I'm pretty sure that this is not mentioned in either. (but I could be wrong?) What I am asking about is conditionally const functions. See the examples I wrote since it is hard to describe. @yodaldevoid Whoops you're right, where should I ask this? As for the macro question, I agree that there isn't really much use for it now that I think about it |
This comment was marked as off-topic.
This comment was marked as off-topic.
Your |
This comment was marked as off-topic.
This comment was marked as off-topic.
Coder-256
commented
Mar 12, 2019
|
@varkor I'm not convinced that that's the case (since the trait bounds change), but I'll ask in rust-lang/rfcs#2632. |
Coder-256
referenced this issue
Mar 12, 2019
Open
Calling methods on generic parameters of const fns #2632
This comment has been minimized.
This comment has been minimized.
Jezza
commented
Mar 14, 2019
|
Crash Report: Code: #![feature(const_generics)]
use std::marker::PhantomData;
struct BoundedU32<const LOWER: u32, const UPPER: u32> {
value: u32,
_marker: PhantomData<(LOWER, UPPER)>,
}Compiler:
|
This comment has been minimized.
This comment has been minimized.
|
@Jezza: const generics isn't fully implemented yet and is not expected to work. We'll make an announcement when it's time to start experimenting with |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Good point: I'll investigate this. Note that this is only a problem with |
This comment has been minimized.
This comment has been minimized.
varkor
added
the
A-const-generics
label
Mar 21, 2019
This comment has been minimized.
This comment has been minimized.
|
Minimized: #![feature(const_generics)]
struct S<const C: u8>(C);Resolve ICEs before producing the "expected type, found value" error. The index is out-of-bounds here: |
withoutboats commentedSep 14, 2017
•
edited by varkor
Tracking issue for rust-lang/rfcs#2000
cc @eddyb
Blocking stabilization: