-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[nll] compilation error from mozjs-0.1.10 #47722
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
Labels
A-NLL
Area: Non-lexical lifetimes (NLL)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
Comments
4 tasks
I'd like to take a look at this. |
Explicitly casting #![feature(nll)]
struct AutoGCRooter {
stackTop: *mut *mut AutoGCRooter,
}
impl AutoGCRooter {
unsafe fn add_to_root_stack(&mut self) {
*self.stackTop = self as *mut AutoGCRooter;
}
}
fn main() {} My guess is that there's an issue with the automatic coercion from |
It turns out you can remove one layer of indirection and still get the same error: #![feature(nll)]
struct AutoGCRooter {
stackTop: *mut AutoGCRooter,
}
impl AutoGCRooter {
unsafe fn add_to_root_stack(&mut self) {
self.stackTop = self;
}
}
fn main() {} |
Aaron1011
added a commit
to Aaron1011/rust
that referenced
this issue
Jan 30, 2018
Implicit coercions from references to pointers were lowered to slightly different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted in certain uses of self-referential structs compiling correctly when an explicit cast was used, but not when the implicit coercion was used. To fix this, this commit adds an outer 'Use' expr when applying a raw-ptr-borrow adjustment. This makes the lowered Mir for coercions identical to that of explicit coercions, allowing the original code to compile regardless of how the raw ptr cast occurs. Fixes rust-lang#47722
Aaron1011
added a commit
to Aaron1011/rust
that referenced
this issue
Jan 30, 2018
Implicit coercions from references to pointers were lowered to slightly different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted in certain uses of self-referential structs compiling correctly when an explicit cast was used, but not when the implicit coercion was used. To fix this, this commit adds an outer 'Use' expr when applying a raw-ptr-borrow adjustment. This makes the lowered Mir for coercions identical to that of explicit coercions, allowing the original code to compile regardless of how the raw ptr cast occurs. Fixes rust-lang#47722
bors
added a commit
that referenced
this issue
Feb 5, 2018
Fix ref-to-ptr coercions not working with NLL in certain cases Implicit coercions from references to pointers were lowered to slightly different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted in certain uses of self-referential structs compiling correctly when an explicit cast was used, but not when the implicit coercion was used. To fix this, this commit adds an outer 'Use' expr when applying a raw-ptr-borrow adjustment. This makes the lowered Mir for coercions identical to that of explicit coercions, allowing the original code to compile regardless of how the raw ptr cast occurs. Fixes #47722
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-NLL
Area: Non-lexical lifetimes (NLL)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In #47596, @SimonSapin reported several NLL errors in dependencies of the servo crate. @lqd later minimized one of those errors into this example:
which yields:
Removing feature(nll) makes the code work, so probably this is an NLL bug.
The text was updated successfully, but these errors were encountered: