| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
Mark variables captured by reference as mutable correctly
Closes #59620
r? @pnkfelix
|
|
More restrictive 2 phase borrows - take 2
Signal lint diagnostic `mutable_borrow_reservation_conflict` when borrow-check finds a 2-phase borrow's reservation overlapping with a shared borrow.
(pnkfelix updated description)
cc #56254 , #59159
blocks PR #59114
r? @pnkfelix
cc @RalfJung @nikomatsakis
|
|
This commit changes the behavior of Formatter::debug_struct,
debug_tuple, debug_list, debug_set, and debug_map to render trailing
commas in {:#?} mode, which is the dominant style in modern Rust code.
Before:
Language {
name: "Rust",
trailing_commas: false
}
After:
Language {
name: "Rust",
trailing_commas: true,
}
|
|
|
|
|
|
Fallback to `static_impl_trait` for nice error message by peeking at the
return type and the lifetime type. Point at the return type instead of
the return expr/stmt in NLL mode.
|
|
pnkfelix:issue-55748-pat-types-are-constraints-on-bindings-too, r=nikomatsakis
extra testing of how NLL handles wildcard type `_`
test that wildcard type `_` is not duplicated by `type Foo<X> = (X, X);` and potentially instantiated at different types when used in type ascriptions in let bindings.
(NLL's handling of this for the type ascription *expression form* is currently broken, or at least differs from what AST-borrowck does. I'll file a separate bug about that. Its not something critical to address since that expression is guarded by `#![feature(type_ascription)]`.)
cc #55748
|
|
|
|
|
|
potentially instantiated at different types.
(Updated to reflect changes in diagnostic output and compiletest infrastructure.)
|
|
Fix #54822 and associated faulty tests
Type checking associated constants can require trait bounds, but an empty
parameter environment was provided to the trait solver. Providing an
appropriate parameter environment seems to fix #54822 and also make one of the
cases in src/test/ui/nll/trait-associated-constant.rs that should compile
successfully do so. It also (slightly) improves the error message in
src/test/ui/associated-const/associated-const-generic-obligations.rs
|
|
|
|
|
|
|
|
Type checking associated constants can require trait bounds, but an empty
parameter environment was provided to the trait solver. Providing an
appropriate parameter environment seems to fix #54822 and also make one of the
cases in src/test/ui/nll/trait-associated-constant.rs that should compile
successfully do so. It also (slightly) improves the error message in
src/test/ui/associated-const/associated-const-generic-obligations.rs
|
|
[NLL] Type check operations with pointer types
It seems these were forgotten about. Moving to `Rvalue::AddressOf` simplifies the coercions from references, but I want this to be fixed as soon as possible.
r? @pnkfelix
|
|
Type annotations are shared between the MIR of a function and the
promoted constants for that function, so keep them in the type checker
when we check the promoted MIR.
|
|
Previously, a promoted that contains a function item wouldn't have the
function items bounds propagated to
the main function body.
|
|
Use normal mutable borrows in matches
`ref mut` borrows are currently two-phase with NLL enabled. This changes them to be proper mutable borrows. To accommodate this, first the position of fake borrows is changed:
```text
[ 1. Pre-match ]
|
[ (old create fake borrows) ]
[ 2. Discriminant testing -- check discriminants ] <-+
| |
| (once a specific arm is chosen) |
| |
[ (old read fake borrows) ] |
[ 3. Create "guard bindings" for arm ] |
[ (create fake borrows) ] |
| |
[ 4. Execute guard code ] |
[ (read fake borrows) ] --(guard is false)-----------+
|
| (guard results in true)
|
[ 5. Create real bindings and execute arm ]
|
[ Exit match ]
```
The following additional changes are made to accommodate `ref mut` bindings:
* We no longer create fake `Shared` borrows. These borrows are no longer needed for soundness, just to avoid some arguably strange cases.
* `Shallow` borrows no longer conflict with existing borrows, avoiding conflicting access between the guard borrow access and the `ref mut` borrow.
There is some further clean up done in this PR:
* Avoid the "later used here" note for Shallow borrows (since it's not relevant with the message provided)
* Make any use of a two-phase borrow activate it.
* Simplify the cleanup_post_borrowck passes into a single pass.
cc #56254
r? @nikomatsakis
|
|
|
|
|
|
Check the Self-type of inherent associated constants
r? @arielb1
|
|
Add better error message for partial move
closes #56657
r? @davidtwco
|
|
|
|
|
|
This commit fixes the logic of detecting when a use happen in a later
iteration of where a borrow was defined
Fixes #53773
|
|
|
|
Check user type annotations for range patterns.
Fixes #58299.
This PR builds on the fix from #58161 (which fixed miscompilation
caused by the introduction of `AscribeUserType` patterns for associated
constants) to start checking these patterns are well-formed for ranges
(previous fix just ignored them so that miscompilation wouldn't occur).
r? @arielb1
|
|
|
|
|
|
Cosmetic improvements to doc comments
This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).
r? @steveklabnik
Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
|
|
This commit builds on the fix from #58161 (which fixed miscompilation
caused by the introduction of `AscribeUserType` patterns for associated
constants) to start checking these patterns are well-formed for ranges
(previous fix just ignored them so that miscompilation wouldn't occur).
|
|
Fix span for closure return type when annotated.
Fixes #58053.
This PR adjusts the span used to label closure return types so that
if the user specifies the return type, i.e. `|_| -> X {}` instead of
`|_| {}`, we correctly highlight all of it and not just the last
character.
r? @pnkfelix
|
|
|
|
This commit fixes a bug introduced by #55937 which started checking user
type annotations for associated type patterns. Where lowering a
associated constant expression would previously return a
`PatternKind::Constant`, it now returns a `PatternKind::AscribeUserType`
with a `PatternKind::Constant` inside, this commit unwraps that to
access the constant pattern inside and behaves as before.
|
|
|
|
This commit adjusts the span used to label closure return types so that
if the user specifies the return type, i.e. `|_| -> X {}` instead of
`|_| {}`, we correctly highlight all of it and not just the last
character.
|
|
The borrow place *must* be a place that we track borrows for, otherwise
we will likely ICE.
|
|
|
|
[NLL] Clean up handling of type annotations
* Renames (Canonical)?UserTypeAnnotation -> (Canonical)?UserType so that the name CanonicalUserTypeAnnotation is free.
* Keep the inferred type associated to user type annotations in the MIR, so that it can be compared against the annotated type, even when the annotated expression gets removed from the MIR. (#54943)
* Use the inferred type to allow infallible handling of user type projections (#57531)
* Uses revisions for the tests in #56993
* Check the types of `Unevaluated` constants with no annotations (#46702)
* Some drive-by cleanup
Closes #46702
Closes #54943
Closes #57531
Closes #57731
cc #56993 leaving this open to track the underlying issue: we are not running tests with full NLL enabled on CI at the moment
r? @nikomatsakis
|
|
When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement `Copy`
trait.
|
|
|
|
|
|
We equate the type in the annotation with the inferred type first so
that we have a fully inferred type to perform the well-formedness check
on.
|
|
|
|
|
|
Implement basic input validation for built-in attributes
Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax").
For some subset of attributes (found by crater run), errors are lowered to deprecation warnings.
NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
|