-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
NLL / MIR-borrowck regression in serde #48179
Comments
@SimonSapin: While I can reproduce the second error ( |
No, I can still reproduce both on rustc 1.25.0-nightly (3ec5a99 2018-02-14). |
@SimonSapin: Oops, I misread your first comment. I didn't see that it took two sets of flags to produce the errors. My understanding is that the combination of
|
Doesn’t NLL imply MIR borrow-checking? Isn’t I’m not sure what you mean by "two sets of flags". The two full, independent commands I run in the serde repo are:
|
@SimonSapin: For more details, see the code that handles it: rust/src/librustc/session/mod.rs Lines 448 to 488 in 29c8276
as well as this comment: #48070 (comment) |
I'd like to work on this. |
@Aaron1011 Good to know, thanks. If I only test one set of flags, which one should that be? |
I suspect that it should be all of them: @nikomatsakis: Can you confirm this? |
Here's an initial minimization (can probably be improved on): pub struct Container<T: Iterator> {
value: Option<T::Item>,
}
impl<T: Iterator> Container<T> {
pub fn new(iter: T) -> Self {
panic!()
}
}
pub struct Wrapper<'a> {
content: &'a Content,
}
impl<'a, 'de> Wrapper<'a> {
pub fn new(content: &'a Content) -> Self {
Wrapper {
content: content,
}
}
}
pub struct Content;
fn crash_it(content: Content) {
let items = vec![content];
let map = items.iter().map(|ref o| Wrapper::new(o));
let mut map_visitor = Container::new(map);
}
fn main() {} The dtorck error occurs as a result of calling |
Looking at this further, this issue seems to be similar to the problem in #47920. With NLL, TypeChecker#fully_perform_op is used to wrap many inference-related operations, including projection normalization. However, Here's how I believe this causes the current issue: Both With NLL, the projection cache is unable to work properly, since inference variables will never be properly re-used. Every time a particular projection is resolved, a new inference variable will be generated, which will never be equated with the proper type. This means that I'm not sure how best to resolve this - from what I understand, clearing out the constraints from the infcx (at some point in time) is important to the correctness of the implementation of NLL. One idea I have is to apply the 'type freshener' used for the selection cache to the projection cache - but only when using NLL. However, I'm not certain if this would be sound. |
@Aaron1011 I'll take a look. I've got a PR that is making some progress towards refactoring how the |
This might be the same as #48132? |
@SimonSapin: I think it is - @FraGag's explanation of their repro is almost identical to mine. |
This works with #48411 |
@nikomatsakis That seems to contradict what you wrote there:
|
@SimonSapin true. That was realy meant to apply to code that does not have NLL enabled. With NLL, it fixes (obviously) some bugs. |
On
nightly-2018-02-13
16362c7,RUSTFLAGS=-Zborrowck=mir cargo build
causes the first error below andRUSTFLAGS=-Znll cargo build --all-features
causes the second one. I don’t know if they’re related.CC @nikomatsakis
The text was updated successfully, but these errors were encountered: