-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Liveness, borrowck and last use interact badly #2633
Copy link
Copy link
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-type-systemArea: Type systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-type-systemArea: Type systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This arose from #2584. This code snippet from
trans::base::trans_assign_opillustrates the problem:bcxhas typeblock, which is now a newtype-like enum whose LHS is an @ of a class. The bug is exposed by the fact thatblockdoesn't get treated as immediate even though its representation is a box, but that's not the main bug. The main problem is that there's an implicit move because of the second use ofbcxas a field in the record literal: it's a last use, implying thatbcxgets zeroed at that point. Normally, borrowck would flag a move of something that has a reference to it (the reference gets brought about by the first instance ofbcx, as the first argument tomove_val). But since the implicit moves due to last-use information aren't visible to borrowck, the code happily compiles, runs, and then segfaults whenmove_valdereferences its first argument.@nikomatsakis and I discussed this a bit on IRC and there's not a clear solution (though there is an obvious workaround for #2584). Perhaps the answer is to just remove last-use analysis.