Commit Graph

70 Commits

Author SHA1 Message Date
lcnr 11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01:00
jyn eb53721a34 recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
Michael Goulet b97ff8eb16 Add print_trait_sugared 2023-12-05 17:15:46 +00:00
Rémy Rakic b442120a30 add tests from crater for liveness causing scope differences 2023-12-01 14:04:54 +00:00
Nilstrieb 9b80d85722 Manual find replace updates 2023-11-24 21:04:51 +01:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
lcnr 8fcbd1991f review + fix CI 2023-11-14 13:41:28 +00:00
lcnr 15f21562e6 finish RegionKind rename
- `ReFree` -> `ReLateParam`
- `ReEarlyBound` -> `ReEarlyParam`
2023-11-14 13:13:27 +00:00
lcnr 86fa1317a3 rename ReLateBound to ReBound
other changes:
- `Region::new_late_bound` -> `Region::new_bound`
- `Region::is_late_bound` -> `Region::is_bound`
2023-11-13 14:13:54 +00:00
Rémy Rakic 2dff90dc23 add test for issue 117146 2023-11-04 01:04:12 +00:00
bors cd674d6179 Auto merge of #116300 - cjgillot:split-move, r=petrochenkov
Separate move path tracking between borrowck and drop elaboration.

The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration.

The 2 first commits are cleanups.

The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more.

The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-24 00:25:32 +00:00
Matthias Krüger 726709bca4 Rollup merge of #116960 - lqd:applied-member-constraints-scope, r=matthewjasper
Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only

The location-insensitive analysis considered loans to escape if there were member constraints, which makes *some* sense for scopes and matches the scopes that NLL computes on all the tests.

However, polonius and NLLs differ on the fuzzed case #116657, where an SCC has member constraints but no applied ones (and is kinda surprising). The existing UI tests with member constraints impacting scopes all have some constraint applied.

This PR changes the location-insensitive analysis to consider a loan to escape if there are applied member constraints, and for extra paranoia/insurance via fuzzing and crater: actually checks the constraint's min choice is indeed a universal region as we expect. (This could be turned into a `debug_assert` and early return as a slight optimization after these periods of verification)

The 4 UI tests where member constraints are meaningful for computing scopes still pass obviously, and this also fixes #116657.

r? `@matthewjasper`
2023-10-23 16:23:52 +02:00
Camille GILLOT 8d535070a2 Do not report errors from move path builder. 2023-10-21 10:29:40 +00:00
Oli Scherer af93c20c06 Rename lots of files that had generator in their name 2023-10-20 21:14:02 +00:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer 60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Rémy Rakic 8b76518a28 add non-regression test for issue 116657 2023-10-19 21:11:21 +00:00
Ali MJ Al-Nasrawy a8830631b9 remove trailing dots 2023-10-08 10:06:17 +00:00
Ali MJ Al-Nasrawy 996ffcb718 always show and explain sub region 2023-10-08 09:59:51 +00:00
Ali MJ Al-Nasrawy 5be0b2283a improve the suggestion of generic_bound_failure 2023-10-08 09:56:57 +00:00
Alex Macleod 5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
Camille GILLOT 26cb34cd18 Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
Ralf Jung c4ec12f4b7 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
Rémy Rakic f3a1bae88c add test for issue 114907 2023-08-30 14:10:52 +00:00
Martin Nordholts 8a7520995c Remove FIXME about NLL diagnostic that is already improved
The FIXME was added in 46984 when the diagnostic message looked like
this:

    // FIXME(#46983): error message should be better
    &s.0 //~ ERROR free region `` does not outlive free region `'static`

The message was improved in 90667 and now looks like this:

    &s.0 //~ ERROR lifetime may not live long enough

but the FIXME was not removed. The issue 46983 about that diagnostics
should be improved has been closed. We can remove the FIXME now.
2023-08-06 21:20:15 +02:00
Mara Bos 0e729404da Change default panic handler message format. 2023-07-29 11:42:50 +02:00
Mahdi Dibaiee e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Michael Goulet fe870424a7 Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
Eric Mark Martin 76a7772759 resolve typerelative ctors to adt 2023-06-30 08:26:56 -04:00
Santiago Pastorino 3ef510ca80 Print def_id on EarlyBoundRegion debug 2023-06-21 19:34:21 -03:00
Guillaume Gomez 6b9b55ac98 Rollup merge of #112654 - aliemjay:closure-output-normalize, r=compiler-errors
normalize closure output in equate_inputs_and_outputs

Fixes #112604
2023-06-15 22:04:57 +02:00
Ali MJ Al-Nasrawy c75e6e0f6c normalize closure output before relation 2023-06-15 12:49:49 +00:00
许杰友 Jieyou Xu (Joe) edafbaffb2 Adjust UI tests for unit_bindings
- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
2023-06-12 20:24:48 +08:00
Michael Goulet 979379aff7 Resolve vars in result from scrape_region_constraints 2023-06-05 19:40:30 +00:00
Urgau c93d9c1794 Rename drop_ref lint to dropping_references 2023-05-21 14:16:41 +02:00
Urgau 1c7ab18c08 Rename drop_copy lint to dropping_copy_types 2023-05-21 13:37:32 +02:00
bors 077fc26f0a Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwco
Uplift `clippy::{drop,forget}_{ref,copy}` lints

This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints.

Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted.

## `drop_ref` and `forget_ref`

The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value.

### Example

```rust
let mut lock_guard = mutex.lock();
std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
// still locked
operation_that_requires_mutex_to_be_unlocked();
```

### Explanation

Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended.

## `drop_copy` and `forget_copy`

The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait.

### Example

```rust
let x: i32 = 42; // i32 implements Copy
std::mem::forget(x) // A copy of x is passed to the function, leaving the
                    // original unaffected
```

### Explanation

Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation.

-----

Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12 12:04:32 +00:00
Urgau 61ff2718f7 Adjust tests for new drop and forget lints 2023-05-10 19:36:02 +02:00
Matthias Krüger 985ea22489 Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkov
Move some tests

r? ``@petrochenkov``
2023-05-09 20:49:31 +02:00
Caio 0285611096 Move tests 2023-05-08 17:58:01 -03:00
Ezra Shaw 87a1b3840e tweak spans for ref mut suggestion 2023-05-05 22:40:05 +12:00
Ezra Shaw 57c6a3183c tweak "make mut" spans (No. 3) 2023-05-05 22:40:05 +12:00
Ezra Shaw fd8aa5ec7d tweak "make mut" spans when assigning to locals 2023-05-05 22:40:04 +12:00
Michael Goulet bb99cdc7cd vars are ? 2023-04-25 19:53:09 +00:00
Maybe Waffle cac143f0e3 Extend and use hir::Node::body_id 2023-04-19 19:13:45 +00:00
Oli Scherer f263f88bea Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
Jack Huey f0edcc8a6f Remove index from BrAnon 2023-04-06 23:01:40 -04:00
Thom Chiovoloni 46fad955c0 Fix a debuginfo test with a hard-coded hash 2023-04-05 15:59:29 +00:00
Thom Chiovoloni 0db1f54f89 Bless tests 2023-04-05 15:59:29 +00:00
Ali MJ Al-Nasrawy a42cbdb165 allow ReError in CanonicalUserTypeAnnotation 2023-03-31 14:53:42 +00:00