Commit Graph

97 Commits

Author SHA1 Message Date
Jakob Degen
5952d7159a Restrict query recursion in needs_significant_drop
Overly aggressive use of the query system to improve caching lead to query cycles and consequently
ICEs. This patch fixes this by restricting the use of the query system as a cache to those cases
where it is definitely correct.
2022-02-24 12:23:35 -05:00
lcnr
1245131a11 use List<Ty<'tcx>> for tuples 2022-02-21 07:09:11 +01:00
est31
2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00
Nicholas Nethercote
7024dc523a Overhaul RegionKind and Region.
Specifically, change `Region` from this:
```
pub type Region<'tcx> = &'tcx RegionKind;
```
to this:
```
pub struct Region<'tcx>(&'tcx Interned<RegionKind>);
```

This now matches `Ty` and `Predicate` more closely.

Things to note
- Regions have always been interned, but we haven't been using pointer-based
  `Eq` and `Hash`. This is now happening.
- I chose to impl `Deref` for `Region` because it makes pattern matching a lot
  nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`.
- Various methods are moved from `RegionKind` to `Region`.
- There is a lot of tedious sigil changes.
- A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a
  `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`.
- A couple of test outputs change slightly, I'm not sure why, but the new
  outputs are a little better.
2022-02-15 16:08:52 +11:00
Nicholas Nethercote
e9a0c429c5 Overhaul TyS and Ty.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.
2022-02-15 16:03:24 +11:00
lcnr
7ebd48d006 remove TyS::same_type
it ignored regions and constants in adts,
but didn't do so for references or any other types.
This seemed quite weird
2022-02-01 11:21:26 +01:00
Matthias Krüger
6749f32c33
Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726
Improve terminology around "after typeck"

Closes #70258.
2022-01-31 06:58:26 +01:00
Aaron Hill
c8941d3e48
Store a Symbol instead of an Ident in AssocItem
This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-19 17:13:21 -05:00
bors
7be8693984 Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
partially revertish `lazily "compute" anon const default substs`

reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted
why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049>

r? `@lcnr`
2022-01-16 11:19:21 +00:00
Camille GILLOT
67727aa7c3 Reduce use of local_def_id_to_hir_id. 2022-01-15 21:26:25 +01:00
Camille GILLOT
60064726ae Return a LocalDefId in get_parent_item. 2022-01-15 21:26:20 +01:00
Ellen
71bbb603f4 initial revert 2022-01-15 01:16:55 +00:00
Camille GILLOT
1be6e2d6e9 Link impl items to corresponding trait items in late resolver. 2022-01-08 20:45:59 +01:00
Matthew Jasper
3b7d496f72 Add query to avoid name comparison in leaf_def 2022-01-07 13:31:36 -08:00
Matthew Jasper
1b057a33bd Move associated_item* providers to their own module 2022-01-07 13:23:35 -08:00
Matthew Jasper
d7595853a2 Add trait_item_def_id to AssocItem
This allows avoiding some lookups by name
2022-01-07 12:28:12 -08:00
Deadbeef
a1f91aa410
Use a const ParamEnv when in default_method_body_is_const 2021-12-17 20:42:48 +08:00
Deadbeef
84b1d859c8
Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
This reverts commit ff2439b7b9, reversing
changes made to 2a9e0831d6.
2021-12-12 12:34:46 +08:00
Camille GILLOT
8576ab45e4 Store impl_trait_fn inside OpaqueTyOrigin. 2021-12-07 21:30:45 +01:00
Santiago Pastorino
85b723c4e6
Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"
This reverts commit 18bb8c61a9, reversing
changes made to d9baa36190.
2021-12-03 10:11:21 -03:00
Matthias Krüger
f056f0d1b4
Rollup merge of #91462 - b-naber:use-try-normalize-erasing-regions, r=jackh726
Use try_normalize_erasing_regions in needs_drop

Fixes https://github.com/rust-lang/rust/issues/81199

r? ``@jackh726``
2021-12-03 06:24:17 +01:00
b-naber
a11994e423 use try_normalize_erasing_regions in needs_drop 2021-12-02 23:27:08 +01:00
bors
18bb8c61a9 Auto merge of #91354 - fee1-dead:const_env, r=spastorino
Cleanup: Eliminate ConstnessAnd

This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.

We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.

This is a continuation of https://github.com/rust-lang/rust/pull/90274.

r? `@oli-obk`

cc `@spastorino` `@ecstatic-morse`
2021-12-02 11:48:58 +00:00
Deadbeef
5ebc99e5b2
Format 2021-12-01 23:33:37 +08:00
Deadbeef
87cd1ce6c1
ParamEnv should be const when ImplItem is within a const impl. 2021-11-29 22:21:38 +08:00
Oli Scherer
a9a79f657c
Completely remove ConstnessAnd 2021-11-29 21:19:49 +08:00
Oli Scherer
e37947f097
Re-use constness_for_typeck instead of rolling it ourselves 2021-11-29 21:19:46 +08:00
Oli Scherer
721ffd14c3
Add constness to ParamEnv
This now causes a lot of queries to be executed twice, as reveal_all forces NotConst
2021-11-29 21:19:46 +08:00
Camille GILLOT
5fb4648757 Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
Jakob Degen
746091c610 Recurse through query system when checking ADT drop types, hopefully improving perf 2021-11-13 14:47:17 -05:00
bstrie
ce1143e94d impl Copy/Clone for arrays in std, not in compiler 2021-11-08 13:11:58 -05:00
pierwill
521b1ee974 Improve terminology around "after typeck" 2021-11-06 20:59:38 -05:00
bors
85c0558d03 Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis
Fixes incorrect handling of ADT's drop requirements

Fixes #90024 and a bunch of duplicates.

The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params.

First contribution of more than a few lines, so feedback definitely appreciated.
2021-10-28 16:03:13 +00:00
Jakob Degen
aff37f8f7b Clean up debug statements in needs_drop 2021-10-25 20:45:46 -04:00
b-naber
c6b69017e2 expose default substs in param_env 2021-10-25 16:04:57 +02:00
Jakob Degen
9158fc2071 Fixes incorrect handling of ADT's drop requirements
See https://github.com/rust-lang/rust/issues/90024#issuecomment-950105433
2021-10-23 06:47:17 -04:00
Camille GILLOT
6e98688e68 Replace FnLikeNode by FnKind. 2021-10-19 23:31:51 +02:00
bjorn3
83ddedf170 Remove various unused feature gates 2021-10-02 19:09:18 +02:00
bors
05044c2e6c Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakis
2229: Mark insignificant dtor in stdlib

I looked at all public [stdlib Drop implementations](https://doc.rust-lang.org/stable/std/ops/trait.Drop.html#implementors) and categorized them into Insigificant/Maybe/Significant Drop.

Reasons are noted here: https://docs.google.com/spreadsheets/d/19edb9r5lo2UqMrCOVjV0fwcSdS-R7qvKNL76q7tO8VA/edit#gid=1838773501

One thing missing from this PR is tagging HashMap as insigificant destructor as that needs some discussion.

r? `@Mark-Simulacrum`

cc `@nikomatsakis`
2021-09-26 19:36:00 +00:00
Aman Arora
994793faab PR fixup 2021-09-22 05:17:30 -04:00
bors
ac2d9fc509 Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c87 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21 19:25:49 +00:00
Aman Arora
d2cbe21756 Handle type params in insig dtors 2021-09-21 05:06:19 -04:00
Aman Arora
95cfbe43d2 2229: Early exit when we see an insigificant drop 2021-09-21 04:06:00 -04:00
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
Camille GILLOT
d7795d302a Do not store visibility in *ItemRef. 2021-09-20 00:29:53 +02:00
Deadbeef
82117289f2
Remove the queries 2021-09-09 05:21:32 +00:00
Deadbeef
a13b13ff46
Const drop selection candidates 2021-09-09 05:21:31 +00:00
Deadbeef
104e40fb74
Const dropping 2021-09-09 05:21:29 +00:00
bors
d5cd3205fd Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth
Rollup of 11 pull requests

Successful merges:

 - #87832 (Fix debugger stepping behavior with `match` expressions)
 - #88123 (Make spans for tuple patterns in E0023 more precise)
 - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally")
 - #88216 (Don't stabilize creation of TryReserveError instances)
 - #88270 (Handle type ascription type ops in NLL HRTB diagnostics)
 - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7)
 - #88320 (type_implements_trait consider obligation failure on overflow)
 - #88332 (Add argument types tait tests)
 - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.)
 - #88346 (Revert "Add type of a let tait test impl trait straight in let")
 - #88348 (Add field types tait tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-27 01:07:17 +00:00
Manish Goregaokar
8aa46e51df
Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank
Make spans for tuple patterns in E0023 more precise

As suggested in #86307. Closes #86307.

r? ````@estebank````
2021-08-26 12:38:06 -07:00