Commit Graph

5965 Commits

Author SHA1 Message Date
Michael Goulet
079a2e865f is_{some,ok}_and 2023-11-25 18:47:16 +00:00
León Orell Valerian Liehr
a663bb946f
Rollup merge of #118271 - compiler-errors:float, r=RalfJung
Separate `NaN`/`Inf` floats with `_`

r? RalfJung

Fixes #118221

No test 🤷 unless you know a good way to print an `ImmTy` in a unit test?
2023-11-25 10:21:08 +01:00
bors
34c5ab9aac Auto merge of #118227 - Mark-Simulacrum:worker-local-outline, r=cjgillot
Optimize QueryArena allocation

This shifts the WorkerLocal wrapper to be outside the QueryArena, meaning that instead of having each query allocate distinct arenas per-worker we allocate the full set of arenas per-worker. This is primarily a code size optimization (locally, ~85 kilobytes, [perf is reporting >100 kilobytes](https://perf.rust-lang.org/compare.html?start=1fd418f92ed13db88a21865ba5d909abcf16b6cc&end=884c95a3f1fe8d28630ec3cdb0c8f95b2e539fde&stat=instructions%3Au&tab=artifact-size)), saving a bunch of code in the initialization of the arenas which was previously duplicated lots of times (per arena type).

Additionally this tells LLVM that the thread count can't be zero in this code (I believe this is true?) which shaves some small amount of bytes off as well since we eliminate checks for zero in the vec allocations.
2023-11-25 02:01:39 +00:00
Michael Goulet
b601b40b40 Separate Nan/Inf floats with _ 2023-11-24 23:35:18 +00:00
bors
41fe75ec6b Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercote
Cache flags for `ty::Const`

Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost.

r? `@ghost`
2023-11-24 04:54:35 +00:00
Mark Rousskov
107ea5d3bc Move WorkerLocal out of QueryArenas
This cuts librustc_driver.so code size by ~85 kilobytes.
2023-11-23 20:15:29 -05:00
Michael Goulet
4ec68576d3 Cache flags for ty::Const 2023-11-22 23:28:28 +00:00
bors
1e9dda77b5 Auto merge of #118120 - compiler-errors:closure-kind, r=lcnr
Remove `PredicateKind::ClosureKind`

We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes.

This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate.

Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22 21:09:01 +00:00
bors
06d1afe518 Auto merge of #118178 - compiler-errors:rollup-0i11w85, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #118012 (Add support for global allocation in smir)
 - #118013 (Enable Rust to use the EHCont security feature of Windows)
 - #118100 (Enable profiler in dist-powerpc64-linux)
 - #118142 (Tighten up link attributes for llvm-wrapper bindings)
 - #118147 (Fix some unnecessary casts)
 - #118161 (Allow defining opaques in `check_coroutine_obligations`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-22 18:49:51 +00:00
Michael Goulet
4ec548afbe
Rollup merge of #118161 - compiler-errors:coroutine-obligation-opaques, r=lcnr
Allow defining opaques in `check_coroutine_obligations`

In the new trait solver, when an obligation stalls on an unresolved coroutine witness, we will stash away the *root* obligation, even if the stalled obligation is only a distant descendent of the root obligation, since the new solver is purely recursive.

This means that we may need to reprocess alias-relate obligations (and others) which may define opaque types in the new solver. Currently, we use the coroutine's def id as the defining anchor in `check_coroutine_obligations`, which will allow defining no opaque types, resulting in errors like:

```
error[E0271]: type mismatch resolving `{coroutine@<source>:6:5: 6:17} <: impl Clone`
 --> <source>:6:5
  |
6 | /     move |_: ()| {
7 | |         let () = yield ();
8 | |     }
  | |_____^ types differ
```

So this PR fixes the defining anchor and does the same trick as `check_opaque_well_formed`, where we manually compare opaques that were defined against their hidden types to make sure they weren't defined differently when processing these stalled coroutine obligations.

r? `@lcnr` cc `@cjgillot`
2023-11-22 09:28:52 -08:00
Michael Goulet
040151a4be
Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkin
Fix some unnecessary casts

`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-22 09:28:51 -08:00
bors
6d2b84b3ed Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin
Stabilize RFC3324 dyn upcasting coercion

This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324.

The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398.

~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~

Heavily inspired by https://github.com/rust-lang/rust/pull/101718
Fixes https://github.com/rust-lang/rust/issues/65991
2023-11-22 16:15:34 +00:00
Urgau
4c2d6de70e Stabilize RFC3324 dyn upcasting coercion
Aka trait_upcasting feature.

And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-22 13:56:36 +01:00
Nicholas Nethercote
7060fc8327 Replace no_ord_impl with orderable.
Similar to the previous commit, this replaces `newtype_index`'s opt-out
`no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22 18:38:17 +11:00
Nicholas Nethercote
3ef9d4d0ed Replace custom_encodable with encodable.
By default, `newtype_index!` types get a default `Encodable`/`Decodable`
impl. You can opt out of this with `custom_encodable`. Opting out is the
opposite to how Rust normally works with autogenerated (derived) impls.

This commit inverts the behaviour, replacing `custom_encodable` with
`encodable` which opts into the default `Encodable`/`Decodable` impl.
Only 23 of the 59 `newtype_index!` occurrences need `encodable`.

Even better, there were eight crates with a dependency on
`rustc_serialize` just from unused default `Encodable`/`Decodable`
impls. This commit removes that dependency from those eight crates.
2023-11-22 18:37:14 +11:00
Michael Goulet
4f958a4802 Allow defining opaques in check_coroutine_obligations 2023-11-22 03:44:13 +00:00
bors
739d556826 Auto merge of #117582 - compiler-errors:uplift-canonical-var, r=jackh726
Uplift `CanonicalVarInfo` and friends into `rustc_type_ir`

Depends on #117580 and #117578

Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` so they can be consumed by an interner-agnostic `Canonicalizer` implementation for the new trait solver ❤️

r? `@ghost`
2023-11-22 02:43:23 +00:00
bors
ed10a53025 Auto merge of #118152 - matthiaskrgr:rollup-bqcck4w, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #117972 (Add VarDebugInfo to Stable MIR)
 - #118109 (rustdoc-search: simplify `checkPath` and `sortResults`)
 - #118110 (Document `DefiningAnchor` a bit more)
 - #118112 (Don't ICE when ambiguity is found when selecting `Index` implementation in typeck)
 - #118135 (Remove quotation from filename in stable_mir)

Failed merges:

 - #118012 (Add support for global allocation in smir)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-22 00:30:56 +00:00
Matthias Krüger
a11be28e13
Rollup merge of #118110 - compiler-errors:defining-anchor, r=aliemjay
Document `DefiningAnchor` a bit more

r? types
2023-11-21 23:46:19 +01:00
Nilstrieb
c089a162d8 Fix some unnecessary casts
`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix`
with some manual review to ensure every fix is correct.
2023-11-21 22:11:08 +01:00
Nilstrieb
21a870515b Fix clippy::needless_borrow in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01:00
Michael Goulet
93298ee0dd Remove ClosureKind predicate kind 2023-11-21 18:35:45 +00:00
Michael Goulet
d1daf0e841 Uplift CanonicalVarInfo and friends 2023-11-21 17:49:57 +00:00
Michael Goulet
f26e8ff3ac Uplift BoundVar 2023-11-21 17:49:56 +00:00
Nilstrieb
cbadb2e1c0
Rollup merge of #118029 - saethlin:allocid-gc, r=RalfJung
Expand Miri's BorTag GC to a Provenance GC

As suggested in https://github.com/rust-lang/miri/issues/3080#issuecomment-1732505573

We previously solved memory growth issues associated with the Stacked Borrows and Tree Borrows runtimes with a GC. But of course we also have state accumulation associated with whole allocations elsewhere in the interpreter, and this PR starts tackling those.

To do this, we expand the visitor for the GC so that it can visit a BorTag or an AllocId. Instead of collecting all live AllocIds into a single HashSet, we just collect from the Machine itself then go through an accessor `InterpCx::is_alloc_live` which checks a number of allocation data structures in the core interpreter. This avoids the overhead of all the inserts that collecting their keys would require.

r? ``@RalfJung``
2023-11-21 14:36:13 +01:00
Nilstrieb
f13f980900
Rollup merge of #118121 - nnethercote:rustc_hir, r=compiler-errors
`rustc_hir` cleanups

Just some improvements I found while looking at this code.

r? `@WaffleLapkin`
2023-11-21 09:06:30 +01:00
bors
baf4abff31 Auto merge of #118107 - matthiaskrgr:rollup-k5bfkfr, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #117327 (Add documentation for some queries)
 - #117835 (Note about object lifetime defaults in does not live long enough error)
 - #117851 (Uplift `InferConst` to `rustc_type_ir`)
 - #117973 (test: Add test for async-move in 2015 Rust proc macro)
 - #117992 (Don't require intercrate mode for negative coherence)
 - #118010 (Typeck break expr even if break is illegal)
 - #118026 (Don't consider regions in `deref_into_dyn_supertrait` lint)
 - #118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-21 02:02:30 +00:00
Michael Goulet
0000b35288 Document DefiningAnchor a bit more 2023-11-20 21:47:49 +00:00
Matthias Krüger
6258697445
Rollup merge of #117851 - compiler-errors:uplift-infer-const, r=spastorino
Uplift `InferConst` to `rustc_type_ir`

We need this in `rustc_type_ir` because the canonicalizer must understand the difference between a const vid and an effect vid. In that way, it's not an implementation detail of the representation of an infer const, but just part of the type ir.

If we find out later on that it's better to leave the representation up to the consumer of `rustc_type_ir`, we could abstract `InferConst` (and probably `InferTy` as well) with some traits, but I don't see the benefit of that indirection currently.
2023-11-20 20:56:41 +01:00
Matthias Krüger
87540879f4
Rollup merge of #117835 - Nilstrieb:note-object-lifetime-defaults, r=compiler-errors
Note about object lifetime defaults in does not live long enough error

This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose.

The implementation feels a bit questionable, I'm not sure whether there are better ways to do this. There probably are.

fixes #117835

r? types
2023-11-20 20:56:40 +01:00
Matthias Krüger
da5eebf942
Rollup merge of #117327 - Nilstrieb:more-query-docs, r=compiler-errors
Add documentation for some queries
2023-11-20 20:56:40 +01:00
Michael Goulet
2d187d54fd Store feature stability un-split 2023-11-20 19:11:26 +00:00
Michael Goulet
86299a1247 Unify defined_lib_features and lib_features queries 2023-11-20 19:08:16 +00:00
Michael Goulet
b4c3d7f3fd Uplift InferConst to rustc_type_ir 2023-11-20 17:29:31 +00:00
Michael Goulet
c3ba158d30 Use InferTy from rustc_type_ir unconditionally 2023-11-20 17:27:41 +00:00
Nicholas Nethercote
6ba4c2f017 Remove unused arena kinds in rustc_hir and rustc_middle. 2023-11-20 15:05:26 +11:00
Michael Goulet
94d9b7e708
Rollup merge of #117832 - RalfJung:interpret-shift, r=cjgillot
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch

While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
2023-11-19 19:14:33 -08:00
Ben Kimock
0d0a41789f Expand Miri's BorTag GC to a Provenance GC 2023-11-19 13:29:02 -05:00
Nilstrieb
5e32da567e Add documentation for some queries 2023-11-19 17:26:24 +01:00
Matthias Krüger
aa2289d3bc
Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber
Use `copied` instead of manual `map`
2023-11-17 23:04:22 +01:00
bors
069a4af48b Auto merge of #117944 - lcnr:region-refactor-uwu, r=BoxyUwU
some additional region refactorings

the commits are selfcontained 

r? `@BoxyUwU`
2023-11-17 14:27:20 +00:00
bors
78efca8845 Auto merge of #117278 - lcnr:try-normalize-ty, r=compiler-errors
new solver normalization improvements

cool beans

At the core of this PR is a `try_normalize_ty` which stops for rigid aliases by using `commit_if_ok`.

Reworks alias-relate to fully normalize both the lhs and rhs and then equate the resulting rigid (or inference) types. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/68 by avoiding the exponential blowup. Also supersedes #116369 by only defining opaque types if the hidden type is rigid.

I removed the stability check in `EvalCtxt::evaluate_goal` due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/75. While I personally have opinions on how to fix it, that still requires further t-types/`@nikomatsakis` buy-in, so I removed that for now. Once we've decided on our approach there, we can revert this commit.

r? `@compiler-errors`
2023-11-17 10:16:41 +00:00
lcnr
40b154e53c rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`
- `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17 09:29:48 +00:00
Takayuki Maeda
68f5762ff0
Rollup merge of #117963 - nnethercote:rustc_query_system, r=compiler-errors
`rustc_query_system` cleanups

Minor cleanups.

r? `@compiler-errors`
2023-11-17 12:56:32 +09:00
Nicholas Nethercote
a3b4961d5f Move lint_store from GlobalCtxt to Session.
This was made possible by the removal of plugin support, which
simplified lint store creation.

This simplifies the places in rustc and rustdoc that call
`describe_lints`, which are early on. The lint store is now built before
those places, so they don't have to create their own lint store for
temporary use, they can just use the main one.
2023-11-17 10:39:18 +11:00
bors
0ea7ddcc35 Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung
Let Miri see the AllocId for all TyCtxt allocations

Per https://github.com/rust-lang/miri/pull/3103#discussion_r1391589896

r? `@RalfJung`
2023-11-16 15:15:54 +00:00
Ben Kimock
d7cecd3db2 Let Miri see the AllocId for all TyCtxt allocations 2023-11-16 08:30:49 -05:00
Nicholas Nethercote
8f669f558a Reduce exposure of things. 2023-11-16 16:49:22 +11:00
Mark Rousskov
917f6540ed Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00