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

& ref ident patterns are buggy with DSTs #30277

Closed
Stebalien opened this issue Dec 9, 2015 · 1 comment
Closed

& ref ident patterns are buggy with DSTs #30277

Stebalien opened this issue Dec 9, 2015 · 1 comment

Comments

@Stebalien
Copy link
Contributor

Aborts (no backtrace):

struct Test([i32]);
let t: &'static Test = unsafe { std::mem::transmute(&[0i32] as &[i32]) };
let & ref a = t;

With:

rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Forked from: #30240.

@Stebalien
Copy link
Contributor Author

According to @Aatch,

For the third error, the issue is due to an inconsistency between how the & pattern handles DSTs and how ref ident expects DST values to be given to it, so & ref ident has the outer pattern passing along a different value to the one the inner inner pattern expects, yay! I fixed one case in #30245, but not the one you're hitting here.

Aatch added a commit to Aatch/rust that referenced this issue Dec 9, 2015
We shouldn't load DSTs when recursing into the sub-pattern of `& ref ident`.

Fixes rust-lang#30277
bors added a commit that referenced this issue Dec 12, 2015
We shouldn't load DSTs when recursing into the sub-pattern of `& ref ident`.

Fixes #30277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant