Closed arielb1 closed 7 years ago
The ICE here is caused by the assert in this function, opt_region_end_span
:
This function finds the Span
(location in the input source code) that a region ends. If you look at the error that the AST borrowck (i.e., older style borrowck) emits, we are basically computing the point where to write that "immutable borrow ends here" message:
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable (Ast)
--> x.rs:3:12
|
2 | let result = &*x;
| -- immutable borrow occurs here
3 | *(&mut *x) = 1;
| ^^ mutable borrow occurs here
4 | result
5 | }
| - immutable borrow ends here
Right now, there is a kind of complicated assertion. It is saying that one of two things should be:
None
. This causes us not to write "immutable borrow ends here".EndRegion
statement. These are special statements we insert into the MIR (only in lexical mode) that tell us where the various lexical lifetimes end.The problem is that in cases where the region never properly ends, we won't find an EndRegion
statement. I think what we want to do is rewrite the function a bit.
self.nonlexical_regionck.is_some()
), then we should always return None
.region_span_map
as we are doing and return Some(span.end_point())
if we find something in there, as we are doing now.self.mir.span.end_point()
:
self.mir
is the MIR for the function we are checkingself.mir.span
is the span in the source code where the function is definedSo, when we are done, if nonlexical_reionck
is None
, this function should always return Some(s)
for some span, but sometimes it will be the end of the function.
Hi, I want to work on this bug.
MIR borrowck ICEs when an error involving a region whose EndRegion is missing occurs (this occurs when a region can never end within the function). Instead it should emit a correct diagnostic.
This can occur for both free regions (e.g. issue-25579):
And for infinite loops:
Causing this ICE: