| Age | Commit message (Collapse) | Author | Lines |
|
NLL: Add union justifications to conflicting borrows.
Fixes #57100.
This PR adds justifications to error messages for conflicting borrows of union fields.
Where previously an error message would say ``cannot borrow `u.b` as mutable..``, it now says ``cannot borrow `u` (via `u.b`) as mutable..``.
r? @pnkfelix
|
|
|
|
NLL: Fix bug in associated constant type annotations.
Fixes #57280.
This PR reverses the variance used when relating types from the type
annotation of an associated constant - this matches the behaviour of the
lexical borrow checker and fixes a bug whereby matching a `&'a str`
against a `&'static str` would produce an error.
r? @nikomatsakis
|
|
Fix broken links to second edition TRPL.
Fixes https://github.com/rust-lang/rust/issues/57104.
Remove `second-edition/` from TRPL hyperlinks.
|
|
This commit improves diagnostic labels to mention which field a borrow
overlaps with and adds a note explaining that the fields overlap.
|
|
This commit improves the logic for place descriptions in conflicting
borrow errors so that borrows of union fields have better messages even
when the unions are embedded in other unions or structs.
|
|
This commit reverses the variance used when relating types from the type
annotation of an associated constant - this matches the behaviour of the
lexical borrow checker and fixes a bug whereby matching a `&'a str`
against a `&'static str` would produce an error.
|
|
|
|
Fixes https://github.com/rust-lang/rust/issues/57104.
|
|
This commit buffers the errors output by the `rustc_dump_user_substs`
attribute so that they can be output in order of span and would
therefore be consistent.
|
|
This commit adds support for user type annotations in variables declared
using `ref` bindings. When a variable declared using a `ref` binding,
then the `LocalDecl` has the type `&T` where the `&` was introduced by
the `ref` binding but the canonicalized type annotation has only a
`T` since the reference is implicit with the `ref` binding.
Therefore, to support type annotations, the canonicalized type
annotation either needs wrapped in a reference, or the `LocalDecl` type
must have a wrapped reference removed for comparison. It is easier to
remove the outer reference from the `LocalDecl` for the purpose of
comparison, so that is the approach this commit takes.
|
|
This commit refactors the `UserTypeAnnotation` type to be referred to by
an index within `UserTypeProjection`. `UserTypeAnnotation` is instead
kept in an `IndexVec` within the `Mir` struct.
Further, instead of `UserTypeAnnotation` containing canonicalized types,
it now contains normal types and the entire `UserTypeAnnotation` is
canonicalized. To support this, the type was moved from the `rustc::mir`
module to `rustc::ty` module.
|
|
|
|
describe index with _
|
|
|
|
make non_camel_case_types an early lint
This allows us to catch these kinds of style violations much earlier, as evidenced by the large number of tests that had to be updated for this change.
|
|
address some FIXME whose associated issues were marked as closed
part of #44366
|
|
|
|
This commit modifies the wording of the warning for
backwards-incompatible changes in migrate mode. The warning messages are
changed to be lowercase and not include line-breaks in order to be
consistent with other compiler diagnostics.
|
|
MIR borrowck doesn't accept the example of iterating and updating a mutable reference
Fixes #46589.
r? @pnkfelix or @nikomatsakis
|
|
|
|
This commit extends previous work to kill borrows from a local after
assignment into that local to kill borrows from a projection after
assignment into a prefix of that place.
|
|
Enum layout optimizations mean that the discriminant of an enum may not
be stored in a tag disjoint from the rest of the fields of the enum.
Stop borrow checking as though they are.
|
|
|
|
This commit puts a fix in place for the ICE in region naming code so
that it doesn't break the compiler. However, this results in the
diagnostic being poorer as the borrow explanation that was causing the
ICE is not being added - this should be fixed as a follow-up.
|
|
This commit adds the test for writing into a projection of a local to
confirm there are no remaining borrows.
|
|
Refer to the second borrow as the "second borrow" in E0501.rs
Fixes #55314.
r? @davidtwco
|
|
Propagate all closure requirements to the caller
Closes #56477
This should be backported to 1.32 if it doesn't make the cut.
r? @pnkfelix
cc @nikomatsakis
|
|
|
|
|
|
|
|
|
|
Add placeholder types
Fixes #48696 (handle universes in canonicalization of type inference vars), and fixes #55098.
|
|
Cleanup from lexical MIR borrowck removal
Lexical MIR borrowck was removed months ago now, and `EndRegion`s are no longer used for MIRI verification.
* Remove `rustc::mir::StatementKind::EndRegion` and the `-Zemit_end_regions` flag
* Use `RegionVid` instead of `Region` in BorrowSet
* Rewrite drop generation to create fewer goto terminators.
r? @nikomatsakis
|
|
|
|
remove "approx env bounds" if we already know from trait
Alternative to https://github.com/rust-lang/rust/pull/55988 that fixes #55756 -- smaller fix that I cannot see having (correctness) repercussions beyond the test at hand, and hence better for backporting. (Famous last words, I know.)
r? @eddyb
|
|
|
|
Since lexical MIR borrow check is gone, and validation no longer uses
these, they can be removed.
|
|
pnkfelix:issue-54382-more-precise-spans-for-temps-and-their-drops, r=davidtwco
More precise spans for temps and their drops
This PR has two main enhancements:
1. when possible during code generation for a statement (like `expr();`), pass along the span of a statement, and then attribute the drops of temporaries from that statement to the statement's end-point (which will be the semicolon if it is a statement that is terminating by a semicolon).
2. when evaluating a block expression into a MIR temp, use the span of the block's tail expression (rather than the span of whole block including its statements and curly-braces) for the span of the temp.
Each of these individually increases the precision of our diagnostic output; together they combine to make a much clearer picture about the control flow through the spans.
Fix #54382
|
|
|
|
NLL Diagnostic Review 3: Unions not reinitialized after assignment into field
Fixes #55651, #55652.
This PR makes two changes:
First, it updates the dataflow builder to add an init for the place
containing a union if there is an assignment into the field of
that union.
Second, it stops a "use of uninitialized" error occuring when there is an
assignment into the field of an uninitialized union that was previously
initialized. Making this assignment would re-initialize the union, as
tested in `src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr`.
The check for previous initialization ensures that we do not start
supporting partial initialization yet (cc #21232, #54499, #54986).
This PR also fixes #55652 which was marked as requiring investigation
as the changes in this PR add an error that was previously missing
(and mentioned in the review comments) and confirms that the error
that was present is correct and a result of earlier partial
initialization changes in NLL.
r? @pnkfelix (due to earlier work with partial initialization)
cc @nikomatsakis
|
|
ICE with #![feature(nll)] and elided lifetimes
Fixes #55394.
This commit fixes an ICE and determines the correct return span in cases
with a method implemented on a struct with an an elided lifetime.
r? @pnkfelix
|
|
This commit fixes an ICE and determines the correct return span in cases
with a method implemented on a struct with an an elided lifetime.
|
|
|
|
(I opted to rely on compare-mode=nll rather than opt into
`#![feature(nll)]`, mostly to make it easy to observe the interesting
differences between the AST-borrwock diagnostic and the NLL one.)
|
|
This commit filters out locals that have never been initialized for
consideration in the `unused_mut` lint.
This is intended to detect when the statement that would have
initialized the local was removed as unreachable code. In these cases,
we would not want to lint. This is the same behaviour as the AST borrow
checker.
This is achieved by taking advantage of an existing pass over the MIR
for the `unused_mut` lint and creating a set of those locals that were
never initialized.
|
|
This commit adds a run-pass test for the subset of
`src/test/ui/borrowck/borrowck-union-move-assign.rs` that is intended to
pass as the union is reinitialized.
|
|
universes refactor 3
Some more refactorings from my universe branch. These are getting a bit more "invasive" -- they start to plumb the universe information through the canonicalization process. As of yet though I don't **believe** this branch changes our behavior in any notable way, though I'm marking the branch as `WIP` to give myself a chance to verify this.
r? @scalexm
|
|
|
|
But.. we don't really use it for anything right now.
|