50 Commits

Author SHA1 Message Date
Matthew Jasper
aa6fb6caf9 Enable migrate mode by default on the 2015 edition
This also fully stabilizes two-phase borrows on all editions
2019-04-21 20:50:02 +01:00
Taiki Endo
725af30809 librustc_mir => 2018 2019-02-08 06:28:15 +09:00
David Wood
c2b477c19a
Improve diagnostic labels and add note.
This commit improves diagnostic labels to mention which field a borrow
overlaps with and adds a note explaining that the fields overlap.
2019-01-04 22:43:51 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Daan de Graaf
1560a75f6a Refer to the second borrow as the "second borrow". 2018-11-30 14:55:51 +01:00
Matthias Krüger
f6b8876d45 use String::from() instead of format!() macro to construct Strings. 2018-10-31 00:10:10 +01:00
Matthew Jasper
2a3969a3f7 Use new region infer errors for explaining borrows
This gives at least some explanation for why a borrow is expected to
last for a certain free region. Also:

* Reports E0373: "closure may outlive the current function" with NLL.
* Special cases the case of returning a reference to (or value
  referencing) a local variable or temporary (E0515).
* Special case assigning a reference to a local variable in a closure
  to a captured variable.
2018-10-21 12:35:00 +01:00
Matthew Jasper
275432c115 Give an error number for "borrowed data escapes outside of closure" 2018-10-20 23:11:30 +01:00
ljedrz
d28aed6dc4 Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
David Wood
aa701154f0
Extend closure special-casing for generators.
This commit extends existing special-casing of closures to highlight the
use of variables within generators that are causing the generator to
borrow them.
2018-10-18 17:48:18 +02:00
Felix S. Klock II
ea4d934c32 Change the diagnostic number from 714 to 716. 2018-09-25 15:23:57 +01:00
Mikhail Modin
5fc0b743d7 add "temporary value dropped while borrowed" error
Issue #54131
2018-09-25 15:23:56 +01:00
Matthew Jasper
b55bb2e918 Better messages for errors from Shallow borrows 2018-09-24 23:33:13 +01:00
Felix S. Klock II
1f0fbddfff Fine tune dianostics for when a borrow conflicts with a destructor that needs exclusive access.
In particular:

 1. Extend `WriteKind::StorageDeadOrDrop` with state to track whether
    we are running a destructor or just freeing backing storage.  (As
    part of this, when we drop a Box<..<Box<T>..> where `T` does not
    need drop, we now signal that the drop of `T` is a kind of storage
    dead rather than a drop.)

 2. When reporting that a value does not live long enough, check if
    we're doing an "interesting" drop, i.e. we aren't just trivally
    freeing the borrowed state, but rather a user-defined dtor will
    run and potentially require exclusive aces to the borrowed state.

 3. Added a new diagnosic to describe the scenario here.
2018-09-18 02:06:45 +02:00
Matthias Krüger
ede1f7d2a5 use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() 2018-08-23 10:14:52 +02:00
varkor
6f637da50c Remove Ty prefix from Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error} 2018-08-22 16:07:44 +01:00
David Wood
43850e0bee
Special case error message for thread-local statics. 2018-08-07 12:08:52 +02:00
Matthew Jasper
903851f785 Highlight closure spans for borrow and initialization errors 2018-08-03 23:00:27 +01:00
Matthew Jasper
13b5f69848 Improve NLL mutability errors
* Better explain why the place is immutable
* Distinguish &T and *const T
* Use better spans when a mutable borrow is for a closure capture
2018-07-20 20:01:11 +01:00
Santiago Pastorino
1dae309ca1
Run rustfmt 2018-06-22 18:24:02 -03:00
Santiago Pastorino
ad612d660c
Fix erroneous error note when using field after move 2018-06-22 18:23:33 -03:00
Felix S. Klock II
fbe7d5bce8 When NLL has illegal move due to borrowed content, provide feedback about why the move wasn't a copy.
This should address #51190.
2018-06-06 22:42:27 +02:00
gaurikholkar
e5a96a4b95 modify the error message- CR Comments 2018-04-07 13:17:16 +05:30
gaurikholkar
1fb25fbbe3 reduce nested loops in the code 2018-04-06 20:00:21 +05:30
Gauri Kholkar
c1192065ea
Update borrowck_errors.rs 2018-04-05 22:04:20 +05:30
gaurikholkar
1b06fe1ef5 Merge branch 'master' of https://github.com/rust-lang/rust into e0389 2018-04-05 21:52:40 +05:30
csmoe
55116243e7 remove unneeded where clause 2018-03-18 20:18:21 +08:00
csmoe
c62d9eb729 fix formatting 2018-03-16 14:52:16 +08:00
csmoe
0b111e677c change &self to self and fix lifetime annotations 2018-03-16 14:52:15 +08:00
gaurikholkar
0c7fc046d3 code refactor, modify compile-fail tests 2018-03-10 20:55:02 +05:30
Michael Woerister
542bc75dea Turn features() into a query. 2018-03-05 11:05:01 +01:00
Esteban Küber
90bc98c5d1 Modify message to match label 2018-01-10 11:41:12 -08:00
Santiago Pastorino
e980fb8bef feature nll implies borrowck=mir 2017-12-20 14:38:13 -05:00
Niko Matsakis
0e64a756f8 integrate -Znll-dump-cause into borrowck 2017-12-20 14:04:51 -05:00
est31
c9af68e90c Replace -Zborrowck-mir with -Zborrowck=mode
where mode is one of {ast,mir,compare}.

This commit only implements the functionality.
The tests will be updated in a follow up commit.
2017-11-26 16:36:52 +01:00
Oliver Schneider
6ae440e048
Make the difference between lint codes and error codes explicit 2017-11-02 10:19:41 +01:00
Niko Matsakis
b2c248efea reorder 'gcx and 'tcx in BorrowckErrors impl 2017-10-31 12:41:40 -04:00
Niko Matsakis
f700728a3b make end-point optional in the borrow check 2017-10-31 12:41:39 -04:00
Carol (Nichols || Goulding)
0e46cf4db4 Reword to avoid using either re-assignment or reassignment in errors 2017-10-25 11:29:52 -04:00
Felix S. Klock II
5b68e1f8da Add Origin::Ast arguments to all of the migrated AST-borrowck diagnostics. 2017-10-10 13:12:00 +02:00
Felix S. Klock II
cf11ef436b Fixed client code for diagnostics migration, adding new methods to trait BorrowckErrors as necessary. 2017-10-10 13:12:00 +02:00
bors
650b1b1f3a Auto merge of #45016 - pnkfelix:mir-borrowck-gather-and-signal-move-errors, 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
2017-10-08 18:12:26 +00:00
Felix S. Klock II
fdd7d13c24 Move E0509 diagnostic into mod borrowck_errors shared between ast- and mir-borrowck. 2017-10-04 12:47:53 +02:00
Felix S. Klock II
a995b56a5e Move E0508 diagnostic into mod borrowck_errors shared between ast- and mir-borrowck. 2017-10-04 12:47:46 +02:00
Felix S. Klock II
a12cefb497 Move E0507 diagnostic into mod borrowck_errors shared between ast- and mir-borrowck.
(Had to modify signature of `report_cannot_move_out_of` slightly to
satisfy requirements of newly added `fn cannot_move_out_of` method.)
2017-10-04 12:47:40 +02:00
Mikhail Modin
c68b10f5ee add notes to report_conflicting_borrow MIR borrowck 2017-10-04 10:35:42 +03:00
Basile Desloges
d328d264aa mir-borrowck: Factorize error message for cannot_assign_static() between AST and MIR borrowck 2017-09-29 15:41:26 +02:00
Basile Desloges
5c8066b4a7 mir-borrowck: Move span_label calls for cannot_use_when_mutably_borrowed() inside borrowck_errors.rs 2017-09-29 15:41:26 +02:00
Basile Desloges
bcda695720 mir-borrowck: Move span_label calls for cannot_assign_to_borrowed() inside borrowck_errors.rs 2017-09-29 15:41:26 +02:00
Felix S. Klock II
8e79fc72cb Move borrowck error msg construction to module in rustc_mir (for later reuse by mir borrowck).
post-rebase: Do not put "(Ast)" suffix in error msg unless passed `-Z borrowck-mir`.
(But unconditionally include "(Mir)" suffix for mir-borrowck errors.)
2017-08-16 15:52:45 +02:00