| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Now we can do the well formedness checks in the parser, yay!
|
|
DefaultImpl is a highly confusing name for what we now call auto impls,
as in `impl Send for ..`. The name auto impl is not formally decided
but for sanity anything is better than `DefaultImpl` which refers
neither to `default impl` nor to `impl Default`.
|
|
This prevents regressions on some annoying cases.
|
|
Also, fix numbering in mir-opt tests. We are now anonymizing more
consistently, I think, and hence some of the `TyAnon` indices shifted.
|
|
typeck: suggest use of match_default_bindings feature
Fixes #45383.
Updates #42640.
r? @nikomatsakis
cc @tschottdorf
This needs a UI test, but thought I'd get some early feedback.
|
|
|
|
|
|
enable non-lexical lifetimes in the MIR borrow checker
This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. **Don't get too excited:** it includes still a number of hacks (the subtyping code is particularly hacky). However, it *does* kinda' work. =)
The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass `-Znll`, you only get an error from the AST borrowck, demonstrating that the integration succeeds:
```
struct MyStruct {
field: String
}
fn main() {
let mut my_struct = MyStruct { field: format!("Hello") };
let value = &my_struct.field;
if value.is_empty() {
my_struct.field.push_str("Hello, world!");
//~^ ERROR cannot borrow (Ast)
}
}
```
|
|
|
|
|
|
|
|
Fixes #45383.
Updates #42640.
|
|
Remove a couple of obsolete lints
|
|
Fix a quadradic duplication in json for multi-suggestions
r? @petrochenkov
|
|
Implement RFC 1861: Extern types
A few notes :
- Type parameters are not supported. This was an unresolved question from the RFC. It is not clear how useful this feature is, and how variance should be treated. This can be added in a future PR.
- `size_of_val` / `align_of_val` can be called with extern types, and respectively return 0 and 1. This differs from the RFC, which specified that they should panic, but after discussion with @eddyb on IRC this seems like a better solution.
If/when a `DynSized` trait is added, this will be disallowed statically.
- Auto traits are not implemented by default, since the contents of extern types is unknown. This means extern types are `!Sync`, `!Send` and `!Freeze`. This seems like the correct behaviour to me.
Manual `unsafe impl Sync for Foo` is still possible.
- This PR allows extern type to be used as the tail of a struct, as described by the RFC :
```rust
extern {
type OpaqueTail;
}
#[repr(C)]
struct FfiStruct {
data: u8,
more_data: u32,
tail: OpaqueTail,
}
```
However this is undesirable, as the alignment of `tail` is unknown (the current PR assumes an alignment of 1). Unfortunately we can't prevent it in the general case as the tail could be a type parameter :
```rust
#[repr(C)]
struct FfiStruct<T: ?Sized> {
data: u8,
more_data: u32,
tail: T,
}
```
Adding a `DynSized` trait would solve this as well, by requiring tail fields to be bound by it.
- Despite being unsized, pointers to extern types are thin and can be casted from/to integers. However it is not possible to write a `null<T>() -> *const T` function which works with extern types, as I've explained here : https://github.com/rust-lang/rust/issues/43467#issuecomment-321678621
- Trait objects cannot be built from extern types. I intend to support it eventually, although how this interacts with `DynSized`/`size_of_val` is still unclear.
- The definition of `c_void` is unmodified
|
|
Improve diagnostics when list of tokens has incorrect separators
Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations:
```
struct S(pub () ()); // omitted separator
use std::{foo. bar}; // used a similar but wrong separator
```
Fixes #44339
r? @petrochenkov
|
|
|
|
Don't emit the same compiler diagnostic twice.
This PR makes the compiler filter out diagnostic messages that have already been emitted during the same compilation session.
|
|
|
|
|
|
|
|
|
|
With regrets, this breaks rustfmt and rls.
This is in the matter of #45388.
|
|
Cleanly error for non-const variable in associated const
Not sure if wrapping the whole `visit::walk_impl_item` call is correct.
Closes #44239
|
|
Fix a few bugs in drop generation
This fixes a few bugs in drop generation, one of which causes spurious MIR borrowck errors.
Fixes #44832.
r? @eddyb
|
|
|
|
test: Update Emscripten failures/passing
All tests should now have annotation for *why* they're ignored on emscripten. A
few tests no longer need such an annotation as well!
Closes #41299
|
|
code suggestions for non-shorthand field pattern, no-mangle lints
continuing in the spirit of #44942

r? @estebank
|
|
Improves #44832
borrowck-overloaded-index-move-index.rs - fixed
borrowck-multiple-captures.rs - still ICE
borrowck-issue-2657-1.rs - fixed
borrowck-loan-blocks-move.rs - fixed
borrowck-move-from-subpath-of-borrowed-path.rs - fixed
borrowck-mut-borrow-linear-errors.rs - still ICE
borrowck-no-cycle-in-exchange-heap.rs - fixed
borrowck-unary-move.rs - fixed
borrowck-loan-blocks-move-cc.rs - fixed
borrowck-vec-pattern-element-loan.rs - still broken
|
|
All tests should now have annotation for *why* they're ignored on emscripten. A
few tests no longer need such an annotation as well!
Closes #41299
|
|
|
|
dont duplicate error codes
choose unlikely error code
specify error pattern in test
|
|
At reviewer's suggestion, we remove the function/static name from the
main lint message. While we're correspondingly adjusting the
expectations of a compile-fail test, we remove an obsolete FIXME
comment, another quantum of progress towards resolving the fabulous
metabug #44366.
|
|
Provide the full span of method calls to `check_argument_types`
... so that it includes the span of the passed arguments, not just the name of the called method.
Fixes #44760.
|
|
MIR-borrowck: add false edges to match arms
basic fix for https://github.com/rust-lang/rust/issues/45043, should be modified with #45184
|
|
|
|
|
|
usize index message for vec
|
|
pnkfelix:mir-borrowck-moves-of-supporting-prefixes-invalidate-uses-too, r=arielb1
MIR-borrowck: moves of prefixes invalidate uses too
I overlooked the fact that when we check if a path is moved, we need to check for interference between the (shallow) prefixes and the use in question.
~~Long term, we may want to revise how this computation is done. For example, it might be better to represent the set of invalidated prefixes in the dataflow computation (the `maybe_uninitialized` dataflow), and thus avoid one of the loops in the code here.~~
* Update: I was wrong in my original recollection of the dataflow code, which actually does the right thing, in terms of precisely tracking substructure initialization and movement.
Fix #44833
----
Update: The initial version of this PR's description (and the code as well) erroneously focused on supporting prefixes. ~~But the two main cases of interest are: 1. the *shallow* prefixes, and 2. the deref-free prefix built off a local (if the lvalue is indeed built off a local)~~
Update 2: The main cases of interest are in fact: 1. the nearest prefix with a MovePath, and 2. the suffixes.
|
|
MIR borrowck: print lvalues in error messages in the same way that the AST borrowck
Fix #44974
- Print fields with `.name` rather than `.<num>`
- Autoderef values if followed by a field or an index
- Output `[..]` when borrowing inside a slice
|
|
borrowcks.
(There are other tests that this PR also improves, but were not
completely synchronized. I chose to wait until later to pull those
into the `revisions: ast mir` testing pattern; later being either when
they *are* synchronized, or in some PR where we migrate all borrowck
tests, regardless of whether MIR-borrowck is "finished" for them or
not.)
|
|
Expanded to cover partial-initialization ideas.
|
|
|
|
Refactor fmt::Display and fmt::Debug impls in ppaux
Also fixes #44887.
There was a problem that unnamed late-bound regions are *always* named `'r` while they are displayed using `std::fmt::Display`.
---
```rust
fn main() {
f(|_: (), _: ()| {});
}
fn f<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
```
Before (incorrectly shadows lifetime, `for<'r>` omitted for the second argument):
```
error[E0631]: type mismatch in closure arguments
--> test.rs:2:5
|
2 | f(|_: (), _: ()| {});
| ^ ----------------- found signature of `fn((), ()) -> _`
| |
| expected signature of `for<'r> fn(&'r (), fn(&'r ())) -> _`
|
= note: required by `f`
```
After:
```
error[E0631]: type mismatch in closure arguments
--> test.rs:2:5
|
2 | f(|_: (), _: ()| {});
| ^ ----------------- found signature of `fn((), ()) -> _`
| |
| expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _`
|
= note: required by `f`
```
r? @nikomatsakis
|
|
|
|
|
|
|
|
r=nikomatsakis
MIR-borrowck: gather and signal any move errors
When building up the `MoveData` structure for a given MIR, also accumulate any erroneous actions, and then report all of those errors when the construction is complete.
This PR adds a host of move-related error constructor methods to `trait BorrowckErrors`. I think I got the notes right; but we should plan to audit all of the notes before turning MIR-borrowck on by default.
Fix #44830
|
|
|