Skip to content

Let pattern matching on tuple structs broken for double generic functions. #11508

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

Closed
nightpool opened this issue Jan 13, 2014 · 1 comment · Fixed by #12738
Closed

Let pattern matching on tuple structs broken for double generic functions. #11508

nightpool opened this issue Jan 13, 2014 · 1 comment · Fixed by #12738
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@nightpool
Copy link

The demo code from Closed01 doesn't compile.

use std::rand::{Closed01, random};

fn main() {
    let Closed01(val) = random::<Closed01<f32>>();
    println!("{} is a random number between 0 and 1!", val);
}

The compiler gives an error message of

error: mismatched types: expected `std::rand::Closed01<f32>` but found 
`std::rand::Closed01<BUG[0u]>` (expected f32 but found type parameter)

@huonw found a workaround by wrapping it in a function:
rust fn extract<T>(Closed01(x): Closed01<T>) -> T { x }

I'm not sure what exactly is going on here, but I'm guessing it has something to do with the double generic function <Closed01> and let pattern matching for tuple structs.

@jfager
Copy link
Contributor

jfager commented Mar 5, 2014

This looks like its no longer an issue, just needs a test.

bors added a commit that referenced this issue Mar 6, 2014
Closes #6738
Closes #7061
Closes #7899
Closes #9719
Closes #10028
Closes #10228
Closes #10401
Closes #11192
Closes #11508
Closes #11529
Closes #11873
Closes #11925
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 16, 2023
Lint `needless_borrow` and `explicit_auto_deref` on most union field accesses

Changes both lints to follow rustc's rules around auto-deref through `ManuallyDrop` union fields rather than just bailing on union fields.

changelog: [`needless_borrow`] & [`explicit_auto_deref`]: Lint on most union field accesses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants