Commit Graph

950 Commits

Author SHA1 Message Date
Mara Bos cadf901b1d Remove assert_matches feature attributes. 2021-05-03 09:30:11 -04:00
Mark Rousskov aa3e8d3e78 Remove assert_matches users 2021-05-03 09:30:11 -04:00
bors eb9ec31168 Auto merge of #82919 - bstrie:stabchar, r=dtolnay
Stabilize `assoc_char_funcs` and `assoc_char_consts`

Stabilizes the following associated items on `char`:

* [`char::MAX`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.MAX)
* [`char::REPLACEMENT_CHARACTER`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.REPLACEMENT_CHARACTER)
* [`char::UNICODE_VERSION`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.UNICODE_VERSION)
* [`char::decode_utf16`](https://doc.rust-lang.org/std/primitive.char.html#method.decode_utf16)
* [`char::from_u32`](https://doc.rust-lang.org/std/primitive.char.html#method.from_u32)
* [`char::from_u32_unchecked`](https://doc.rust-lang.org/std/primitive.char.html#method.from_u32_unchecked)
* [`char::from_digit`](https://doc.rust-lang.org/std/primitive.char.html#method.from_digit)

Closes #71763.
2021-03-20 06:36:42 +00:00
bstrie 567f0e1a39
Stabilize `assoc_char_funcs` and `assoc_char_consts` 2021-03-19 20:35:08 -07:00
Dylan DPC 51a29cbb23
Rollup merge of #83297 - oli-obk:why_bug_today_if_you_can_delay_to_tomorrow, r=petrochenkov
Do not ICE on ty::Error as an error must already have been reported

fixes #83253
2021-03-19 23:01:42 +01:00
bors cebc8fef5f Auto merge of #82951 - sexxi-goose:wr-mir-replace-methods2, r=nikomatsakis
Replace closures_captures and upvar_capture with closure_min_captures

Removed all uses of closures_captures and upvar_capture and refactored code to work with closure_min_captures. This also involved removing functions that were no longer needed like the bridge.

Closes https://github.com/rust-lang/project-rfc-2229/issues/18
r? `@nikomatsakis`
2021-03-19 18:23:44 +00:00
Oli Scherer 430c0d1d95 Do not ICE on ty::Error as an error must already have been reported 2021-03-19 11:46:27 +00:00
Aman Arora 88db752e57 Hash hir_owner in typeck results 2021-03-19 00:39:39 -04:00
Jennifer Wills 52dba13e41 Replace closures_captures and upvar_capture with closure_min_captures
make changes to liveness to use closure_min_captures

use different span

borrow check uses new structures

rename to CapturedPlace

stop using upvar_capture in regionck

remove the bridge

cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs

remove line from livenes test

make our unused var checking more consistent

update tests

adding more warnings to the tests

move is_ancestor_or_same_capture to rustc_middle/ty

update names to reflect the closures

add FIXME

check that all captures are immutable borrows before returning

add surrounding if statement like the original

move var out of the loop and rename

Co-authored-by: Logan Mosier <logmosier@gmail.com>
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2021-03-18 20:45:49 -04:00
Mara Bos cfb4ad4f2a Remove unwrap_none/expect_none from compiler/. 2021-03-18 14:25:54 +01:00
bors 2aafe452b8 Auto merge of #82868 - petrochenkov:bto, r=estebank
Report missing cases of `bare_trait_objects`

Fixes https://github.com/rust-lang/rust/issues/65371
2021-03-18 05:27:26 +00:00
Vadim Petrochenkov 38ed36bba4 hir: Preserve used syntax in `TyKind::TraitObject` 2021-03-18 03:02:32 +03:00
Dylan DPC b688b694d0
Rollup merge of #83080 - tmiasko:inline-coverage, r=wesleywiser
Make source-based code coverage compatible with MIR inlining

When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.

Fixes #83061
2021-03-18 00:28:09 +01:00
bors b4adc21c4f Auto merge of #83188 - petrochenkov:field, r=lcnr
ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17 16:49:46 +00:00
bors 04ae50179a Auto merge of #83090 - jackh726:bound_var_replacer_option, r=varkor
Make functions passed to BoundVarReplacer be optional

This means we can reuse the bound vars when we don't care to change them
2021-03-17 14:01:48 +00:00
Yuki Okushi 9c7aca58fc
Rollup merge of #83124 - cjgillot:iiib, r=petrochenkov
Do not insert impl_trait_in_bindings opaque definitions twice.

The reference to the item already appears inside the `OpaqueDef`. It does not need to be repeated as a statement.
2021-03-17 15:20:55 +09:00
bors e655fb6221 Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper
Implement (but don't use) valtree and refactor in preparation of use

This PR does not cause any functional change. It refactors various things that are needed to make valtrees possible. This refactoring got big enough that I decided I'd want it reviewed as a PR instead of trying to make one huge PR with all the changes.

cc `@rust-lang/wg-const-eval` on the following commits:

* 2027184 implement valtree
* eeecea9 fallible Scalar -> ScalarInt
* 042f663 ScalarInt convenience methods

cc `@eddyb` on ef04a6d

cc `@rust-lang/wg-mir-opt` for cf1700c (`mir::Constant` can now represent either a `ConstValue` or a `ty::Const`, and it is totally possible to have two different representations for the same value)
2021-03-16 22:42:56 +00:00
bors f5d8117c33 Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`
2021-03-16 19:19:06 +00:00
Oli Scherer c4d564c780
Update compiler/rustc_middle/src/ty/consts/valtree.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16 18:31:33 +01:00
Oli Scherer 5b9bd903c0
Update compiler/rustc_middle/src/ty/consts/valtree.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16 18:31:25 +01:00
Vadim Petrochenkov b25d3ba781 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
bors 4c10c84c63 Auto merge of #83153 - Aaron1011:eval-always-extern_mod_stmt_cnum, r=michaelwoerister
Mark `extern_mod_stmt_cnum` as `eval_always`

This query reads from global untracked state, so it always needs to be
evaluated.
2021-03-16 01:33:06 +00:00
Tomasz Miąsko 335427a3db Use delay_span_bug instead of panic in layout_scalar_valid_range
83054 introduced validation of scalar range attributes, but panicking
code that uses the attribute remained reachable. Use `delay_span_bug`
instead to avoid the ICE.
2021-03-16 00:00:00 +00:00
Jack Huey ba27cae728 Make functions passed to BoundVarReplacer be optional 2021-03-15 19:00:37 -04:00
Tomasz Miąsko 5a9538acb5 Functions inlined into reachable functions are reachable
Consider functions to be reachable for code coverage purposes, either
when they reach the code generation directly, or indirectly as inlined
part of another function.
2021-03-15 23:26:03 +01:00
Roxane 22eaffe71a Add comments with examples and tests 2021-03-15 13:16:04 -04:00
Aaron Hill e70d47b3b5
Mark `extern_mod_stmt_cnum` as `eval_always`
This query reads from global untracked state, so it always needs to be
evaluated.
2021-03-15 12:26:49 -04:00
Dylan DPC 9b16c7a712
Rollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank
Don't encode file information for span with a dummy location

Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-15 16:22:58 +01:00
Dylan DPC f1061d1dff
Rollup merge of #83108 - jyn514:remove-unused, r=estebank
Remove unused `opt_local_def_id_to_hir_id` function

Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.
2021-03-15 16:22:53 +01:00
Oli Scherer 1ffd21a15c Pacify tidy 2021-03-15 12:19:29 +00:00
Oli Scherer 9f407ae5ee Do not expose fallible `to_int` operation on `Scalar`.
Any use of it has been shown to be a bug in the past.
2021-03-15 12:06:52 +00:00
Oli Scherer bc8641a487 Document valtree 2021-03-15 12:06:52 +00:00
Oli Scherer c30c1be1e6 s/ConstantSource/ConstantKind/ 2021-03-15 12:06:52 +00:00
bors 2a55274e0c Auto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum
Update to rustc-rayon 0.3.1

This pulls in rust-lang/rustc-rayon#8 to fix #81425. (h/t `@ammaraskar)`

That revealed weak constraints on `rustc_arena::DropArena`, because its
`DropType` was holding type-erased raw pointers to generic `T`. We can
implement `Send` for `DropType` (under `cfg(parallel_compiler)`) by
requiring all `T: Send` before they're type-erased.
2021-03-15 08:49:25 +00:00
Aaron Hill 7429c688a5
Don't encode file information for span with a dummy location
Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-14 20:22:13 -04:00
Roxane 685a4c6b6b Use the correct FakeReadCause 2021-03-14 19:28:57 -04:00
Camille GILLOT e8b2e7b01c Assert there is no duplicate node. 2021-03-14 21:47:42 +01:00
Roxane ec10b71d42 Introduce new fake reads 2021-03-14 16:31:26 -04:00
Joshua Nelson e161a2fd73 Remove unused `opt_local_def_id_to_hir_id` function
Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.
2021-03-14 01:37:13 -05:00
bors acca818928 Auto merge of #83064 - cjgillot:fhash, r=jackh726
Tweaks to stable hashing
2021-03-13 20:21:40 +00:00
bors 32dce353de Auto merge of #82891 - cjgillot:monoparent, r=petrochenkov
Make def_key and HIR parenting consistent.

r? `@petrochenkov`
2021-03-13 12:28:04 +00:00
Camille GILLOT 445b4e379c Make def_key and HIR parenting consistent. 2021-03-12 22:48:32 +01:00
Oli Scherer 6ca1d87194 Visit `mir::Constant::user_ty` for completeness.
It's not necessary yet, but it may become necessary with things like lazy normalization.
2021-03-12 12:59:37 +00:00
Oli Scherer 20f737966e Replace a custom lift method with a Lift impl 2021-03-12 12:44:12 +00:00
Oli Scherer 3127a9c60f Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
Oli Scherer 3ecde6f5db Directly intern allocations so that we can write a `Lift` impl for them 2021-03-12 12:34:29 +00:00
Oli Scherer 914df2a493 Add `ty` helper function for mir constants
This is in preparation of the `literal` field becoming an enum that distinguishes between type level constants and runtime constants
2021-03-12 12:33:46 +00:00
Oli Scherer 0bb367e070 Split pretty printer logic for scalar int and scalar ptr
Value trees won't have scalar ptr at all, so we need a scalar int printing method anyway. This way we'll be able to share that method between all const representations.
2021-03-12 12:24:29 +00:00
Oli Scherer b729cc9d61 Pull out ConstValue relating into its own function 2021-03-12 12:23:50 +00:00
Oli Scherer 5e8a89b2e5 Reduce the duplication in the relation logic for constants 2021-03-12 12:23:11 +00:00