Commit Graph

23418 Commits

Author SHA1 Message Date
bors
e216300876 Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
Vadim Petrochenkov
1cec923fbb rustc_metadata: Freeze cstore after the full crate list is queried 2023-03-23 20:44:48 +04:00
Vadim Petrochenkov
71927ad083 resolve: Rename some cstore methods to match queries and add comments
about costs associated with replacing them with query calls.
2023-03-23 20:44:02 +04:00
bors
df7fd9995f Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoerister
rustc_interface: Add a new query `pre_configure`

It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early.

Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes.
This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working.

Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23 15:17:59 +00:00
bors
99c49d95cd Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs)
 - #109137 (resolve: Querify most cstore access methods (subset 2))
 - #109380 (add `known-bug` test for unsoundness issue)
 - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate))
 - #109475 (Simpler checked shifts in MIR building)
 - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.)
 - #109506 (make param bound vars visibly bound vars with -Zverbose)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 12:35:05 +00:00
Vadim Petrochenkov
bec4eab3f9 rustdoc: Skip doc link resolution for non-exported items 2023-03-23 16:19:59 +04:00
Vadim Petrochenkov
aca1b1e0b3 rustc_interface: Add a new query pre_configure
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early.

Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-23 14:22:48 +04:00
Vadim Petrochenkov
6cc33b7691 expand: Pass ast::Crate by reference to AST transforming passes
Also some more attributes are passed by reference.
2023-03-23 14:20:55 +04:00
bors
9a6b0c3326 Auto merge of #108355 - dpaoliello:dlltoolm, r=michaelwoerister
Fix cross-compiling with dlltool for raw-dylib

Fix for #103939

Issue Details:
When attempting to cross-compile using the `raw-dylib` feature and the GNU toolchain, rustc would attempt to find a cross-compiling version of dlltool (e.g., `i686-w64-mingw32-dlltool`). The has two issues 1) on Windows dlltool is always `dlltool` (no cross-compiling named versions exist) and 2) it only supported compiling to i686 and x86_64 resulting in ARM 32 and 64 compiling as x86_64.

Fix Details:
* On Windows always use the normal `dlltool` binary.
* Add the ARM64 cross-compiling dlltool name (support for this is coming: https://sourceware.org/bugzilla/show_bug.cgi?id=29964)
* Provide the `-m` argument to dlltool to indicate the target machine type.

(This is the first of two PRs to fix the remaining issues for the `raw-dylib` feature (#58713) that is blocking stabilization (#104218))
2023-03-23 09:51:32 +00:00
Kai Luo
6e8a8282b8 Implement current_dll_path for AIX 2023-03-23 16:50:49 +08:00
Kai Luo
3a7977e3ca Link against libc++ on AIX 2023-03-23 16:33:54 +08:00
Matthias Krüger
477ce585d4
Rollup merge of #109506 - BoxyUwU:debugable_bound_var_printing, r=compiler-errors
make param bound vars visibly bound vars with -Zverbose

I was trying to debug some type/const bound var stuff and it was shockingly tricky due to the fact that even with `-Zverbose` enabled the `T` in `for<T> T: Trait` prints as `T` making it seem like its `TyKind::Param` when it is infact `TyKind::Bound`. This PR "fixes" this when `-Zverbose` is set to allow rendering it as `^T` or `^1_T` depending on binder depth.

r? ```@compiler-errors```
2023-03-23 08:35:36 +01:00
Matthias Krüger
7afed92749
Rollup merge of #109475 - scottmcm:simpler-shifts, r=WaffleLapkin
Simpler checked shifts in MIR building

Doing masking to check unsigned shift amounts is overcomplicated; just comparing the shift directly saves a statement and a temporary, as well as is much easier to read as a human.  And shifting by unsigned is the canonical case -- notably, all the library shifting methods (that don't support every type) take shift RHSs as `u32` -- so we might as well make that simpler since it's easy to do so.

This PR also changes *signed* shift amounts to `IntToInt` casts and then uses the same check as for unsigned.  The bit-masking is a nice trick, but for example LLVM actually canonicalizes it to an unsigned comparison anyway <https://rust.godbolt.org/z/8h59fMGT4> so I don't think it's worth the effort and the extra `Constant`.  (If MIR's `assert` was `assert_nz` then the masking might make sense, but when the `!=` uses another statement I think the comparison is better.)

To review, I suggest looking at 2ee0468c49 first -- that's the interesting code change and has a MIR diff.

My favourite part of the diff:
```diff
-        _20 = BitAnd(_19, const 340282366920938463463374607431768211448_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        _21 = Ne(move _20, const 0_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        assert(!move _21, "attempt to shift right by `{}`, which would overflow", _19) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        _18 = Lt(_17, const 8_u128);     // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        assert(move _18, "attempt to shift right by `{}`, which would overflow", _17) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
```
2023-03-23 08:35:35 +01:00
Matthias Krüger
5d28853efe
Rollup merge of #109462 - compiler-errors:alias-relate, r=BoxyUwU,lcnr
Make alias-eq have a relation direction (and rename it to alias-relate)

Emitting an "alias-eq" is too strict in some situations, since we don't always want strict equality between a projection and rigid ty. Adds a relation direction.

* I could probably just reuse this [`RelationDir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/combine/enum.RelationDir.html) -- happy to uplift that struct into middle and use that instead, but I didn't feel compelled to... 🤷
* Some of the matching in `compute_alias_relate_goal` is a bit verbose -- I guess I could simplify it by using [`At::relate`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/at/struct.At.html#method.relate) and mapping the relation-dir to a variance.
* Alternatively, I coulld simplify things by making more helper functions on `EvalCtxt` (e.g. `EvalCtxt::relate_with_direction(T, T)` that also does the nested goal registration). No preference.

r? ```@lcnr``` cc ```@BoxyUwU``` though boxy can claim it if she wants
NOTE: first commit is all the changes, the second is just renaming stuff
2023-03-23 08:35:35 +01:00
Matthias Krüger
3e33fb9f12
Rollup merge of #109137 - petrochenkov:qcstore2, r=cjgillot
resolve: Querify most cstore access methods (subset 2)

These changes are less likely to cause perf regressions than the rest of https://github.com/rust-lang/rust/pull/108346.
2023-03-23 08:35:34 +01:00
Kai Luo
3957d3a08a Adjust debug info stripping 2023-03-23 15:14:27 +08:00
Kai Luo
f11611018f Fix copy-paste error 2023-03-23 15:05:45 +08:00
bors
84dd6dfd9d Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108954 (rustdoc: handle generics better when matching notable traits)
 - #109203 (refactor/feat: refactor identifier parsing a bit)
 - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions)
 - #109358 (rustc: Remove unused `Session` argument from some attribute functions)
 - #109359 (Update stdarch)
 - #109378 (Remove Ty::is_region_ptr)
 - #109423 (Use region-erased self type during IAT selection)
 - #109447 (new solver cleanup + implement coherence)
 - #109501 (make link clickable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 07:01:03 +00:00
Kai Luo
485aec41af Add AixLinker to support linking on AIX 2023-03-23 15:00:46 +08:00
Michael Goulet
e5189cc7e4 Nested impl traits trigger opaque_hidden_inferred_bound too much 2023-03-23 06:19:52 +00:00
Michael Goulet
244cdaa457 Remove AliasRelationDirection::Supertype 2023-03-23 05:57:09 +00:00
Michael Goulet
f6fd754680 Printing alias-relate goals correctly 2023-03-23 05:56:40 +00:00
Michael Goulet
3a36a093dd Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
Michael Goulet
5dc3fd7c05 Include relation direction in AliasEq predicate 2023-03-23 05:56:27 +00:00
Mu42
2580348ca3 Use span_look_ahead instead of next_point 2023-03-23 09:41:49 +08:00
bors
1c771fec33 Auto merge of #108861 - b-naber:eager-nll-type-relating, r=lcnr
Make NLL Type Relating Eager

We previously instantiated bound regions in nll type relating lazily. Making this eager is more consistent with how we handle type relating in [`higher_ranked_sub`](0a3b557d52/compiler/rustc_infer/src/infer/higher_ranked/mod.rs (L28)) and should allow us to short circuit in case there's structural equality.
2023-03-23 01:26:59 +00:00
Boxy
3f7aeb30ae make param bound vars visibly bound vars 2023-03-23 00:07:55 +00:00
Scott McMurray
64cce5fc7d Add CastKind::Transmute to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.

Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
Matthias Krüger
783f3a1965
Rollup merge of #109501 - lukas-code:link, r=WaffleLapkin
make link clickable
2023-03-22 22:44:43 +01:00
Matthias Krüger
28b9354bf6
Rollup merge of #109447 - lcnr:coherence, r=compiler-errors
new solver cleanup + implement coherence

the cleanup:
- change `Certainty::unify_and` to consider ambig + overflow to be ambig
- rename `trait_candidate_should_be_dropped_in_favor_of` to `candidate_should_be_dropped_in_favor_of`
- remove outdated fixme

For coherence I mostly just add an ambiguous candidate if the current trait ref is unknowable. I am doing the same for reservation impl where I also just add an ambiguous candidate.
2023-03-22 22:44:43 +01:00
Matthias Krüger
b22db3fca4
Rollup merge of #109423 - fmease:iat-selection-erase-regions-in-self-ty, r=compiler-errors
Use region-erased self type during IAT selection

Split off from #109410 as discussed.
Fixes #109299.

Re UI test: I use a reproducer of #109299 that contains a name resolution error instead of reproducer [`regionck-2.rs`](fc7ed4af16/tests/ui/associated-inherent-types/regionck-2.rs) (as found in the `AliasKind::Inherent` PR) since it would (incorrectly) pass typeck in this PR due to the lack of regionck and I'd rather not make *that* a regression test (with or without `known-bug`).

``@rustbot`` label F-inherent_associated_types

r? ``@compiler-errors``
2023-03-22 22:44:42 +01:00
Matthias Krüger
2ee07a19b7
Rollup merge of #109378 - MU001999:master, r=scottmcm
Remove Ty::is_region_ptr

Fixes #109372
2023-03-22 22:44:42 +01:00
Matthias Krüger
577d85f92f
Rollup merge of #109358 - petrochenkov:nosess, r=cjgillot
rustc: Remove unused `Session` argument from some attribute functions

(One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
2023-03-22 22:44:41 +01:00
Matthias Krüger
950aa3ef86
Rollup merge of #109213 - oli-obk:cstore, r=cjgillot
Eagerly intern and check CrateNum/StableCrateId collisions

r? ``@cjgillot``

It seems better to check things ahead of time than checking them afterwards.
The [previous version](https://github.com/rust-lang/rust/pull/108390) was a bit nonsensical, so this addresses the feedback
2023-03-22 22:44:40 +01:00
Matthias Krüger
34fa6daa5c
Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=Nilstrieb
refactor/feat: refactor identifier parsing a bit

\+ error recovery for `expected_ident_found`

Prior art: #108854
2023-03-22 22:44:39 +01:00
bors
8859fde21f Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`)
 - #109392 (Custom MIR: Allow optional RET type annotation)
 - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17)
 - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting)
 - #109452 (Ignore the vendor directory for tidy tests.)
 - #109457 (Remove comment about reusing rib allocations)
 - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors)
 - #109477 (`HirId` to `LocalDefId` cleanup)
 - #109489 (More general captures)
 - #109494 (Do not feed param_env for RPITITs impl side)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-22 21:35:02 +00:00
Daniel Paoliello
a90f342b03 Use -m option instead of looking for a cross-compiling version of dlltool 2023-03-22 14:30:28 -07:00
Lukas Markeffsky
1581b97acb make link clickable 2023-03-22 22:01:19 +01:00
Scott McMurray
b537e6bc53 Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00
Matthias Krüger
6244b94377
Rollup merge of #109494 - spastorino:new-rpitit-18, r=compiler-errors
Do not feed param_env for RPITITs impl side

r? `@compiler-errors`

I don't think this needs more comments or things that we already have but please let me know if you want some comments or something else in this PR.
2023-03-22 20:08:05 +01:00
Matthias Krüger
9629156fc7
Rollup merge of #109489 - est31:generalize_captures, r=WaffleLapkin
More general captures

This avoids repetition of the binding.
2023-03-22 20:08:04 +01:00
Matthias Krüger
040001e7c1
Rollup merge of #109477 - lcnr:cleanup, r=cjgillot
`HirId` to `LocalDefId` cleanup

revival of the still relevant parts of #109125
2023-03-22 20:08:04 +01:00
Matthias Krüger
3712bfff1b
Rollup merge of #109457 - Veykril:ribstack, r=petrochenkov
Remove comment about reusing rib allocations

Perf indicates this to not be worth the complexity

cc #4948
2023-03-22 20:08:03 +01:00
Dylan DPC
eda88a30c7
Rollup merge of #109435 - oli-obk:🇨🇭🥚_copy_op, r=RalfJung
Detect uninhabited types early in const eval

r? `@RalfJung`

implements https://github.com/rust-lang/rust/pull/108442#discussion_r1143003840

this is a breaking change, as some UB during const eval is now detected instead of silently being ignored. Users can see this and other UB that may cause future breakage with `-Zextra-const-ub-checks` or just by running miri on their code, which sets that flag by default.
2023-03-23 00:00:35 +05:30
Dylan DPC
031640ccd2
Rollup merge of #109414 - spastorino:new-rpitit-16, r=compiler-errors
Do not consider synthesized RPITITs on missing items checks

Without this patch for `tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs` we get ...

```
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs:4:12
  |
4 | #![feature(return_position_impl_trait_in_trait)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0046]: not all trait items implemented, missing: `foo`, ``
  --> tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs:12:1
   |
8  |     fn foo(&self) -> impl Sized;
   |     ----------------------------
   |     |                |
   |     |                `` from trait
   |     `foo` from trait
...
12 | impl MyTrait for i32 {
   | ^^^^^^^^^^^^^^^^^^^^ missing `foo`, `` in implementation

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.
```

instead of ...

```
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12
   |
LL | #![feature(return_position_impl_trait_in_trait)]
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = note: `#[warn(incomplete_features)]` on by default

error[E0046]: not all trait items implemented, missing: `foo`
  --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1
   |
LL |     fn foo(&self) -> impl Sized;
   |     ---------------------------- `foo` from trait
...
LL | impl MyTrait for i32 {
   | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.
```

r? `@compiler-errors`
2023-03-23 00:00:35 +05:30
Dylan DPC
b9151b2d70
Rollup merge of #109405 - compiler-errors:rpitit-as-opaques, r=spastorino
RPITITs are `DefKind::Opaque` with new lowering strategy

r? `@spastorino`

Kinda cherry-picked #109400
2023-03-23 00:00:34 +05:30
Dylan DPC
8ce52b7b65
Rollup merge of #109317 - ehuss:discriminant-link-fix, r=Nilstrieb
Update links for custom discriminants.

The discriminant documentation was updated in https://github.com/rust-lang/reference/pull/1055 which changed the layout a bit. This updates the links to the updated locations.
2023-03-23 00:00:34 +05:30
Dylan DPC
af3bd22783
Rollup merge of #109312 - petrochenkov:docice5, r=GuillaumeGomez
rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes https://github.com/rust-lang/rust/issues/108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since https://github.com/rust-lang/rust/pull/93805 anyway.
2023-03-23 00:00:33 +05:30
Dylan DPC
70918ecf06
Rollup merge of #109280 - compiler-errors:no-vec-map, r=Mark-Simulacrum
Remove `VecMap`

Not sure what the use of this data structure is over just using `FxIndexMap` or a `Vec`.

r? ```@ghost```
2023-03-23 00:00:32 +05:30
Dylan DPC
14d06467f0
Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholk
move Option::as_slice to intrinsic

````@scottmcm```` suggested on #109095 I use a direct approach of unpacking the operation in MIR lowering, so here's the implementation.

cc ````@nikic```` as this should hopefully unblock #107224 (though perhaps other changes to the prior implementation, which I left for bootstrapping, are needed).
2023-03-23 00:00:31 +05:30
Michael Goulet
a34c92760c Implement non-const Destruct trait in new solver 2023-03-22 18:22:27 +00:00
Michael Goulet
5456eecab0 Clean up substs building 2023-03-22 18:16:01 +00:00
Michael Goulet
08284449a2 Subst gat normalize pred correctly 2023-03-22 18:16:01 +00:00
b-naber
8f4cf2e000 print sccs_info strings correctly 2023-03-22 18:13:18 +00:00
Santiago Pastorino
1c9ad28dd2
Do not feed param_env for RPITITs impl side 2023-03-22 14:06:22 -03:00
b-naber
35bc8ae86f eager nll type relating 2023-03-22 16:59:46 +00:00
b-naber
da0fe80137 assertion for only collection nll region variable information for debug in non-canonicalization contexts 2023-03-22 16:59:41 +00:00
Guillaume Gomez
825f0888cc Move useless_anynous_reexport lint into unused_imports 2023-03-22 16:05:20 +01:00
est31
edd7d4a9f7 More general captures
This avoids repetition
2023-03-22 15:39:24 +01:00
Lukas Wirth
204807d8a9 Remove comment about re-using Rib allocations 2023-03-22 12:09:19 +01:00
lcnr
0882def9aa review 2023-03-22 11:58:08 +01:00
lcnr
73c79cd806 stop special-casing 'static in evaluate 2023-03-22 11:37:57 +01:00
Vadim Petrochenkov
67a2c5bec8 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
lcnr
45b44c7758 HirId to LocalDefId cleanup 2023-03-22 10:36:30 +01:00
Mu42
20f3f437d1 Fixes #109436: add parentheses properly 2023-03-22 13:52:24 +08:00
bors
9bdb4881c7 Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors
a general type system cleanup

removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.

changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR.

also removes some other small - and imo unnecessary - helpers.

r? types
2023-03-22 05:33:18 +00:00
bors
5fa73a75ce Auto merge of #109087 - cjgillot:sparse-bb-clear, r=davidtwco
Only clear written-to locals in ConstProp

This aims to revert the regression in https://github.com/rust-lang/rust/pull/108872

Clearing all locals at the end of each bb is very costly.
This PR goes back to the original implementation of recording which locals are modified.
2023-03-22 02:49:04 +00:00
Michael Goulet
c3e6f68931 RPITITs are DefKind::Opaque with new lowering strategy 2023-03-21 23:36:07 +00:00
Santiago Pastorino
c1f3529c91 Always encode RPITITs 2023-03-21 23:35:46 +00:00
León Orell Valerian Liehr
293f21c876
iat selection: erase regions in self type 2023-03-21 23:53:58 +01:00
Nilstrieb
29c11327c7 Use SmallVec in bitsets
This doesn't increase their size and means that we don't have to heap
allocate for small sets.
2023-03-21 22:20:09 +01:00
bors
1db9c061d3 Auto merge of #109453 - matthiaskrgr:rollup-odn02wu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #96391 (Windows: make `Command` prefer non-verbatim paths)
 - #108164 (Drop all messages in bounded channel when destroying the last receiver)
 - #108729 (fix: modify the condition that `resolve_imports` stops)
 - #109336 (Constrain const vars to error if const types are mismatched)
 - #109403 (Avoid ICE of attempt to add with overflow in emitter)
 - #109415 (Refactor `handle_missing_lit`.)
 - #109441 (Only implement Fn* traits for extern "Rust" safe function pointers and items)
 - #109446 (Do not suggest bounds restrictions for synthesized RPITITs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-21 20:56:38 +00:00
Santiago Pastorino
364a5d4b54
Do not consider synthesized RPITITs on missing items checks 2023-03-21 15:44:12 -03:00
Matthias Krüger
94d2028abd
Rollup merge of #109446 - spastorino:new-rpitit-17, r=compiler-errors
Do not suggest bounds restrictions for synthesized RPITITs

Before this PR we were getting ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> tests/ui/async-await/in-trait/missing-send-bound.rs:5:12
  |
5 | #![feature(async_fn_in_trait)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:17:20
   |
17 |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:13:5
   |
13 |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:21:27
   |
21 | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`
help: consider further restricting the associated type
   |
16 | fn test2<T: Foo>() where impl Future<Output = ()>: Send {
   |                    ++++++++++++++++++++++++++++++++++++

error: aborting due to previous error; 1 warning emitted
```

and we want this output ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/missing-send-bound.rs:5:12
   |
LL | #![feature(async_fn_in_trait)]
   |            ^^^^^^^^^^^^^^^^^
   |
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> $DIR/missing-send-bound.rs:17:20
   |
LL |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> $DIR/missing-send-bound.rs:13:5
   |
LL |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> $DIR/missing-send-bound.rs:21:27
   |
LL | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`

error: aborting due to previous error; 1 warning emitted
```

r? `@compiler-errors`
2023-03-21 19:00:15 +01:00
Matthias Krüger
fef1fc4349
Rollup merge of #109441 - oli-obk:fn_trait_new_solver, r=compiler-errors
Only implement Fn* traits for extern "Rust" safe function pointers and items

Since calling the function via an `Fn` trait will assume `extern "Rust"` ABI and not do any safety checks, only safe `extern "Rust"` function can implement the `Fn` traits. This syncs the logic between the old solver and the new solver.

r? `@compiler-errors`
2023-03-21 19:00:14 +01:00
Matthias Krüger
96f35ed720
Rollup merge of #109415 - nnethercote:refactor-handle_missing_lit, r=petrochenkov
Refactor `handle_missing_lit`.

A small code readability improvement.

r? ```@petrochenkov```
2023-03-21 19:00:14 +01:00
Matthias Krüger
25b062d586
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
Avoid ICE of attempt to add with overflow in emitter

Fixes #109396
r? ```@estebank```
2023-03-21 19:00:13 +01:00
Matthias Krüger
081c607b0a
Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwU
Constrain const vars to error if const types are mismatched

When equating two consts of different types, if either are const variables, constrain them to the correct const error kind.

This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection.

Fixes #109296

The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message...

r? `@BoxyUwU`
2023-03-21 19:00:12 +01:00
Matthias Krüger
ee330a3ff5
Rollup merge of #108729 - bvanjoi:fix-issue-97534, r=petrochenkov
fix: modify the condition that `resolve_imports` stops

close #97534
2023-03-21 19:00:12 +01:00
John Kåre Alsaker
6c57dda44d Remove unique and move VerboseTimingGuard fields into a new struct 2023-03-21 18:41:45 +01:00
John Kåre Alsaker
f60d2eb6c1 Add -Z time-passes-format to allow specifying a JSON output for -Z time-passes 2023-03-21 18:18:25 +01:00
John Kåre Alsaker
b0dc15c61b Reduce output spam 2023-03-21 18:18:25 +01:00
Santiago Pastorino
3b04ad2753
Do not suggest bounds restrictions for synthesized RPITITs 2023-03-21 13:18:32 -03:00
lcnr
f86b0358f8 woops 2023-03-21 16:39:24 +01:00
Michael Goulet
b1a957b0b9 query_keys_local is conditional on separate_provide_if_extern 2023-03-21 15:38:52 +00:00
Michael Goulet
d213114cb5 LocalCrate key 2023-03-21 15:38:52 +00:00
Michael Goulet
dcaf956de0 AsLocalKey trait 2023-03-21 15:38:52 +00:00
Michael Goulet
7e6506764b IdentitySubsts::identity_for_item takes Into<DefId> 2023-03-21 15:38:52 +00:00
Michael Goulet
979ef5981f Use LocalDefId in ItemCtxt 2023-03-21 15:38:52 +00:00
Michael Goulet
2eb1c08e43 Use local key in providers 2023-03-21 15:38:51 +00:00
lcnr
a7ec045be8 disable global caching during coherence 2023-03-21 16:38:40 +01:00
lcnr
938434ab82 enable intercrate in the solver InferCtxt 2023-03-21 16:34:04 +01:00
lcnr
47f24a881b new solver cleanup + coherence 2023-03-21 16:27:25 +01:00
Vadim Petrochenkov
d3a5541939 rustdoc: Cleanup parent module tracking for doc links
Keep ids of the documented items themselves, not their parent modules.
Parent modules can be retreived from those ids when necessary.
2023-03-21 17:36:57 +04:00
Oli Scherer
460ecd288a Eagerly intern and check CrateNum/StableCrateId collisions 2023-03-21 12:08:17 +00:00
yukang
7bffe945af add delay_span_bug 2023-03-21 20:05:34 +08:00
nils
925fbcdf8a
Rollup merge of #109408 - RalfJung:retags, r=compiler-errors
not *all* retags might be explicit in Runtime MIR

In https://github.com/rust-lang/rust/pull/105317 I made Miri treat `Rvalue::Ref/AddrOf` as implicit retagging sites. This updates the MIR docs accordingly.

For `Rvalue::Ref` I think this makes a lot more sense: creating a new reference is their entire point, so we can avoid bloating the MIR with retags. Also this seems to be the best way to handle cases like `*ptr = &[mut] ...`, where doing a retag is somewhat questionable since maybe `*ptr` points to another place now?

For `Rvalue::AddrOf`, Stacked Borrows needs this because even raw ptrs need some retagging, but Tree Borrows doesn't do ant retagging here and I hope we'll end up with a model where raw pointers don't get retagged.
2023-03-21 13:00:25 +01:00
nils
b2e48edded
Rollup merge of #109390 - cbeuw:aggregate-lit, r=oli-obk
Custom MIR: Support aggregate expressions

Add support for tuple, array and ADT expressions in custom mir

r? `````@oli-obk````` or `````@tmiasko````` or `````@JakobDegen`````
2023-03-21 13:00:25 +01:00
nils
c0adce567e
Rollup merge of #109385 - lcnr:typo, r=Dylan-DPC
fix typo
2023-03-21 13:00:24 +01:00
nils
66ba60a445
Rollup merge of #109240 - compiler-errors:dont-binder-twice, r=oli-obk
Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes #109239
2023-03-21 13:00:23 +01:00
nils
e79b182fca
Rollup merge of #108896 - BoxyUwU:new_solver_add_goal_fn, r=lcnr
new solver: make all goal evaluation able to be automatically rerun

It is generally wrong to call `evaluate_goal` multiple times or `evaluate_goal` and `evaluate_all` for the same `QueryResult` without correctly handling rerunning the goals when inference makes progress. Not doing so will result in the assertion in `evaluate_goal` firing because rerunning the goal will lead to a more accurate `QueryResult`.

Currently there are lots of places that get this wrong and generally it is complex and error prone to handle correctly everywhere. This PR introduces a way to add goals to the `EvalCtxt` and then run all the added goals in a loop so that `evaluate_goal`/`evaluate_all` is not necessary to call manually.

There are a few complications for making everything work "right":
1. the `normalizes-to` hack that replaces the rhs with an unconstrained infer var requires special casing in the new `try_evaluate_added_goals` function similar to how `evaluate_goal`'s assertion special cases that hack.

2. `assemble_candidates_after_normalizing_self_ty`'s normalization step needs to be reran for each candidate otherwise the found candidates will potentially get a more accurate `QueryResult` when rerunning the projection/trait goal which can effect the `QueryResult` of the projection/trait goal.
This is implemented via `EvalCtxt::probe`'s closure's `EvalCtxt` inheriting the added goals of the `EvalCtxt` that `probe` is called on, allowing us to add goals in a probe, and then enter a nested probe for each candidate and evaluate added goals which include the normalization step's goals.

I made `make_canonical_response` evaluate added goals so that it will be hard to mess up the impl of the solver by forgetting to evaluate added goals. Right now the only way to mess this up would be to call `response_no_constraints` (which from the name is obviously weird).

The visibility of `evaluate_goal` means that it can be called from various `compute_x_goal` or candidate assembly functions, this is generally wrong and we should never call `evaluate_goal` manually, instead we should be calling `add_goal`/`add_goals`. This is solved by moving `evaluate_goal` `evaluate_canonical_goal` and `compute_goal` into `eval_ctxt`'s module and making them private so they cannot be called from elsewhere, forcing people to call `add_goal/s` and `evaluate_added_goals_and_make_canonical_resposne`/`try_evaluate_added_goals`

---

Other changes:
- removed the `&& false` that was introduced to the assertion in `evaluate_goal` in #108839
- remove a `!self.did_overflow()` requirement in `search_graph.is_empty()` which causes goals that overflow to ICE
- made `EvalCtxt::eq` take `&mut self` and add all the nested goals via `add_goals` instead of returning them as 99% of call sites just immediately called `EvalCtxt::add_goals` manually.

r? `````@lcnr`````
2023-03-21 13:00:22 +01:00
nils
0ef4da126a
Rollup merge of #108842 - compiler-errors:non_lifetime_binders-object-safe, r=b-naber
Enforce non-lifetime-binders in supertrait preds are not object safe

We can't construct vtables for these supertraits.
2023-03-21 13:00:22 +01:00
Oli Scherer
a00413f680 Also check function items' signatures for Fn* trait compatibility 2023-03-21 11:50:14 +00:00
Oli Scherer
91d913168c Deduplicate fn trait compatibility checks 2023-03-21 11:38:13 +00:00
Oli Scherer
fb9e171ab7 Only implement Fn* traits for extern "Rust" safe function pointers. 2023-03-21 11:11:32 +00:00
Oli Scherer
f066d6785d Detect uninhabited types early in const eval. 2023-03-21 11:09:27 +00:00
lcnr
b8541eb767 use the correct param env 2023-03-21 09:57:22 +01:00
lcnr
c63861b9d5 evaluate: improve and fix recursion depth handling 2023-03-21 09:57:22 +01:00
lcnr
791ce0b7b5 remove some trait solver helpers
they add more complexity then they are worth. It's confusing
which of these helpers should be used in which context.
2023-03-21 09:57:20 +01:00
Oli Scherer
83dec62b26 Add a layout argument to enforce_validity.
This is in preparation of checking the validity only of certain types.
2023-03-21 08:52:31 +00:00
yukang
8126ccb77d Return equal for two identical projections 2023-03-21 15:28:11 +08:00
John Kåre Alsaker
ced33ad289 Refactor try_execute_query 2023-03-21 03:29:19 +01:00
bors
822c10feb7 Auto merge of #109046 - Zoxc:split-execute-job, r=cjgillot,michaelwoerister
Split `execute_job` into `execute_job_incr` and `execute_job_non_incr`

`execute_job` was a bit large, so this splits it in 2. Performance was neutral locally, but this may affect bootstrap times.
2023-03-20 23:53:09 +00:00
Michael Goulet
720cc40fa7 Enforce non-lifetime-binders in supertrait preds are not object safe 2023-03-20 22:38:57 +00:00
Nicholas Nethercote
93eeb12724 Refactor handle_missing_lit. 2023-03-21 09:28:52 +11:00
bors
44f5180584 Auto merge of #106610 - euclio:windows-rs, r=ChrisDenton
migrate compiler, bootstrap and compiletest to windows-rs

This PR migrates the compiler, bootstrap, and compiletest to use [windows-rs](https://github.com/microsoft/windows-rs) instead of winapi-rs. windows-rs is the bindings crate provided by Microsoft, and is actively maintained compared to winapi-rs. Not all ecosystem crates have migrated over yet, so there will be a period of time where both crates are used.

windows-rs also provides some nice ergonomics over winapi-rs to convert return values to `Result`s (which found a case where we forgot to check the return value of `CreateFileW`).
2023-03-20 20:05:45 +00:00
Ralf Jung
5058cc8e62 not *all* retags might be explicit in Runtime MIR 2023-03-20 19:36:01 +01:00
bors
febd59e122 Auto merge of #109384 - matthiaskrgr:rollup-hu348gs, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #109170 (Set `CMAKE_SYSTEM_NAME` for Linux targets)
 - #109266 (rustdoc: Correctly merge import's and its target's docs in one more case)
 - #109267 (Add tests for configure.py)
 - #109273 (Make `slice::is_sorted_by` implementation nicer)
 - #109277 (Fix generics_of for impl's RPITIT synthesized associated type)
 - #109307 (Ignore `Inlined` spans when computing caller location.)
 - #109364 (Only expect a GAT const param for `type_of` of GAT const arg)
 - #109365 (Update mdbook)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-20 17:33:20 +00:00
yukang
cbb8066321 Avoid ICE of attempt to add with overflow in emitter 2023-03-21 01:23:28 +08:00
Andy Russell
bb7c373fdf
migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
Andy Wang
f404f33c21
Use builtin_index instead of match
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2023-03-20 16:27:44 +01:00
Andy Wang
e24f5ac56b
Fix off-by-one in mir syntax doc 2023-03-20 15:27:40 +01:00
Andy Wang
8e4e55e524
Support aggregate expressions 2023-03-20 15:25:11 +01:00
bors
13b7aa4d7f Auto merge of #108524 - Zoxc:node-backtrace, r=cjgillot
Optimize dep node backtrace and ignore fatal errors

This attempts to optimize https://github.com/rust-lang/rust/pull/91742 while also passing through fatal errors.

r? `@cjgillot`
2023-03-20 11:54:00 +00:00
lcnr
5b4fa5bf98 fix typo 2023-03-20 10:46:43 +01:00
Matthias Krüger
f21c435801
Rollup merge of #109364 - compiler-errors:gat-const-arg, r=BoxyUwU
Only expect a GAT const param for `type_of` of GAT const arg

IDK why we were account for both `is_ty_or_const` instead of just for a const param, since we're computing the `type_of` a const param specifically.

Fixes #109300
2023-03-20 09:46:54 +01:00
Matthias Krüger
3efecba6e7
Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errors
Ignore `Inlined` spans when computing caller location.

Fixes https://github.com/rust-lang/rust/issues/105538
2023-03-20 09:46:54 +01:00
Matthias Krüger
d86fd83ef6
Rollup merge of #109277 - spastorino:new-rpitit-14, r=compiler-errors
Fix generics_of for impl's RPITIT synthesized associated type

The only useful commit is the last one.

This makes `generics_of` for the impl side RPITIT copy from the trait's associated type and avoid the fn on the impl side which was previously wrongly used.
This solution is better but we still need to fix resolution of the generated generics.

r? ``@compiler-errors``
2023-03-20 09:46:53 +01:00
Ezra Shaw
05b5046633
feat: implement error recovery in expected_ident_found 2023-03-20 20:54:41 +13:00
Mu42
20dc532085 Remove Ty::is_region_ptr 2023-03-20 15:32:21 +08:00
Matthias Krüger
eb1f8dc2cb
Rollup merge of #109370 - DaniPopes:issue-109334, r=Nilstrieb
fix ClashingExternDeclarations lint ICE

Fixes #109334

First "real" contribution, please let me know if I did something wrong.

As I understand it, it's OK if a `#[repr(transparent)]` type has no non-zero sized types (aka is a ZST itself) and the function should just return the type normally instead of panicking

r? `@Nilstrieb`
2023-03-20 07:10:34 +01:00
Matthias Krüger
cd9fadea5b
Rollup merge of #109362 - nnethercote:split-meta-stats-items, r=bjorn3
Split `items` from `-Zmeta-stats` in two.

Because it's one of the biggest sections.

r? `@bjorn3`
2023-03-20 07:10:34 +01:00
Matthias Krüger
5d3f460708
Rollup merge of #109301 - Ezrashaw:fix-ctf-ice, r=Nilstrieb
fix: fix ICE in `custom-test-frameworks` feature

Fixes #107454

Simple fix to emit error instead of ICEing. At some point, all the code in `tests.rs` should be refactored, there is a bit of duplication (this PR's code is repeated five times over lol).

r? `@Nilstrieb` (active on the linked issue?)
2023-03-20 07:10:31 +01:00
Matthias Krüger
ede3c39fe6
Rollup merge of #109249 - compiler-errors:new-rpitit-comments, r=spastorino
Update names/comments for new return-position impl trait in trait lowering strategy

r? `@spastorino`

totally cosmetic
2023-03-20 07:10:30 +01:00
Michael Goulet
4fd66d70cb Update some names and comments 2023-03-20 04:51:53 +00:00
Michael Goulet
239ec6cb11 drive-by: Fix a comment in TyCtxt::fold_regions and remove an unused method 2023-03-20 04:50:07 +00:00
Michael Goulet
9f80c75703 Walk un-shifted nested impl Trait in trait when setting up default trait method assumptions 2023-03-20 04:50:02 +00:00
bors
9d0eac4d02 Auto merge of #108148 - parthopdas:master, r=oli-obk
Implementing "<test_binary> --list --format json" for use by IDE test explorers / runners

Fixes #107307

PR 1 of 2 - wiring up just the new information + implement the command line changes i.e. --format json + tests

upcoming:
PR 2 of 2 - clean up "#[cfg(not(bootstrap))]" from PR 1

As per the discussions on
- MCP: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implementing.20.22.3Ctest_binary.3E.20--list.20--form.E2.80.A6.20compiler-team.23592/near/328747548
- preRFC: https://internals.rust-lang.org/t/pre-rfc-implementing-test-binary-list-format-json-for-use-by-ide-test-explorers-runners/18308
- FYI on Discord: https://discord.com/channels/442252698964721669/459149169546887178/1075581549409484820
2023-03-20 03:24:27 +00:00
DaniPopes
7ab612a7ee
remove bad comment 2023-03-20 00:55:36 +01:00
DaniPopes
8ca0f61fe3
fix ClashingExternDeclarations lint ICE 2023-03-20 00:50:03 +01:00
Michael Goulet
dbedf4003f Reformat type_of 2023-03-19 23:46:09 +00:00
Michael Goulet
252fa78283 Only expect a GAT const arg 2023-03-19 23:46:09 +00:00
Nicholas Nethercote
cb587e7f61 Split items from -Zmeta-stats in two.
Because it's one of the biggest sections.
2023-03-20 07:23:47 +11:00
许杰友 Jieyou Xu (Joe)
1f67949f0e
Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
Arpad Borsos
c8ead2e693
Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
John Kåre Alsaker
c4bcac628c Add some assertions 2023-03-19 17:39:34 +01:00
John Kåre Alsaker
486a38723b Split execute_job into execute_job_incr and execute_job_non_incr 2023-03-19 17:39:34 +01:00
bohan
1775722410 fix: modify the condition that resolve_imports stops 2023-03-19 20:18:45 +08:00
Dylan DPC
881c9898ad
Rollup merge of #109324 - cjgillot:fixed-unused-params, r=Nilstrieb
Implement FixedSizeEncoding for UnusedGenericParams.

Using a `Lazy` for actually a `u32` value is 50% overhead, so let's encode the bitset directly.
2023-03-19 15:33:59 +05:30
Dylan DPC
1f0fcf13f5
Rollup merge of #109243 - chenyukang:yukang/fix-ice-109144, r=petrochenkov
The name of NativeLib will be presented

Fixes #109144

I was working on a quick fix, but found change the name from `Option<Symbol>` to `Symbol` make life a little bit easier.
2023-03-19 15:33:59 +05:30
Dylan DPC
879d6f257b
Rollup merge of #109212 - Ezrashaw:no-similar-sugg-for-unstable, r=estebank
fix: don't suggest similar method when unstable

Fixes #109177

Don't display typo suggestions for unstable things, unless the feature flag is enabled.

AFAIK, there are two places this occurs:
- `rustc_resolve`: before type checking, effectively just `FnCtxt::Free`.
- `rustc_hir_typck`: during type checking, for `FnCtxt::Assoc(..)`s.

The linked issue is about the latter, obviously the issue is applicable to both.

r? `@estebank`
2023-03-19 15:33:58 +05:30
Dylan DPC
462e7e7a10
Rollup merge of #109003 - GuillaumeGomez:useless-anonymous-reexport-lint, r=cjgillot
Add `useless_anonymous_reexport` lint

This is a follow-up of https://github.com/rust-lang/rust/pull/108936. We once again show all anonymous re-exports in rustdoc, however we also wanted to add a lint to let users know that it very likely doesn't have the effect they think it has.
2023-03-19 15:33:57 +05:30
Dylan DPC
e9c25b4ad5
Rollup merge of #105793 - lukas-code:circular-deps, r=Mark-Simulacrum
Add note for mismatched types because of circular dependencies

If you have crate A with a dependency on crate B, and crate B with a dev-dependency on A, then you might see "mismatched types" errors on types that seem to be equal. This PR adds a note that explains that the types are different, because crate B is compiled twice, one time with `cfg(test)` and one time without.

I haven't found a good way to create circular dependencies in UI tests, so I abused the incremental tests instead. As a bonus, incremental tests support "cpass" now.

related to https://github.com/rust-lang/rust/issues/22750
2023-03-19 15:33:55 +05:30
Ezra Shaw
c05bebcd67
fix: fix ICE in custom-test-frameworks feature 2023-03-19 22:11:17 +13:00
Camille GILLOT
e5a55dc2c5 Prefer if cfg!. 2023-03-19 08:59:11 +00:00
Camille GILLOT
0e866af1f7 Only clear locals that are known to be written to. 2023-03-19 08:58:01 +00:00
Ezra Shaw
b4e17a5098
refactor: improve "ident starts with number" error 2023-03-19 20:24:06 +13:00
Ezra Shaw
c9ddb73184
refactor: refactor identifier parsing somewhat 2023-03-19 20:20:20 +13:00
Michael Goulet
9174edbae9 Delay overlap errors if errors are involved 2023-03-19 03:45:47 +00:00
Michael Goulet
322c7b6269 Constrain const vars to error if const types are mismatched 2023-03-19 03:45:47 +00:00
yukang
d5558e67ef The name of NativeLib will be presented 2023-03-19 11:23:19 +08:00
Camille GILLOT
38be6f2cbb Implement FixedSizeEncoding for UnusedGenericParams. 2023-03-18 18:53:07 +00:00
Ben Kimock
a98ddb6de1 Enable inlining of diverging functions 2023-03-18 14:29:13 -04:00
Ben Kimock
2a628bd99c Remove duplicate switch targets 2023-03-18 14:29:13 -04:00
Ben Kimock
41eda69516 Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
Eric Huss
572c56cb7e Update links for custom discriminants. 2023-03-18 10:22:37 -07:00
Camille GILLOT
be8b323929 Ignore Inlined spans when computing caller location. 2023-03-18 13:46:17 +00:00
Matthias Krüger
0aa0043141
Rollup merge of #109287 - scottmcm:hash-slice-size-of-val, r=oli-obk
Use `size_of_val` instead of manual calculation

Very minor thing that I happened to notice in passing, but it's both shorter and [means it gets `mul nsw`](https://rust.godbolt.org/z/Y9KxYETv5), so why not.
2023-03-18 12:04:24 +01:00
Matthias Krüger
8417c93092
Rollup merge of #109238 - spastorino:new-rpitit-12, r=compiler-errors
Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty

This PR stops reporting errors due to different count of generics on the new synthesized associated types for RPITITs. Those were already reported when we compare the function on the triat with the function on the impl.

r? ``@compiler-errors``
2023-03-18 12:04:23 +01:00
Matthias Krüger
a48d83d556
Rollup merge of #109234 - tmiasko:overflow-checks, r=cjgillot
Tweak implementation of overflow checking assertions

Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.

r? `@cjgillot`
2023-03-18 12:04:23 +01:00
Matthias Krüger
7ebf2cd2b8
Rollup merge of #108772 - jyn514:faster-tidy, r=the8472
Speed up tidy quite a lot

I highly recommend reviewing this commit-by-commit. Based on #106440 for convenience.

## Timings

These were collected by running `x test tidy -v` to copy paste the command, then using [`samply record`](https://github.com/mstange/samply).

before (8 threads)
![image](https://user-images.githubusercontent.com/23638587/222965319-352ad2c8-367c-4d74-960a-e4bb161a6aff.png)

after (8 threads) ![image](https://user-images.githubusercontent.com/23638587/222965323-fa846f4e-727a-4bf8-8e3b-1b7b40505cc3.png)

before (64 threads) ![image](https://user-images.githubusercontent.com/23638587/222965302-dc88020c-19e9-49d9-a87d-cad054d717f3.png)
after (64 threads) ![image](https://user-images.githubusercontent.com/23638587/222965335-e73d7622-59de-41d2-9cc4-1bd67042a349.png)

The last commit makes tidy use more threads, so comparing "before (8 threads)" to "after (64 threads)" is IMO the most realistic comparison. Locally, that brings the time for me to run tidy down from 4 to .9 seconds, i.e. the majority of the time for `x test tidy` is now spend running `fmt --check`.

r? `@the8472`
2023-03-18 12:04:21 +01:00
Matthias Krüger
9599f3cc54
Rollup merge of #107416 - czzrr:issue-80618, r=GuillaumeGomez
Error code E0794 for late-bound lifetime parameter error.

This PR addresses [#80618](https://github.com/rust-lang/rust/issues/80618).
2023-03-18 12:04:21 +01:00
bors
df61fcaec1 Auto merge of #108815 - the8472:process-obligations-fast-skip, r=nnethercote
fast path for process_obligations

Speeds up `keccak` and `cranelift-codegen` in perf.rlo.
2023-03-18 07:07:53 +00:00
Andre Bogus
27e9ee9bae move Option::as_slice to intrinsic 2023-03-18 07:15:15 +01:00
Joshua Nelson
675c4aa2c1 address review comments 2023-03-18 00:43:37 -05:00
Ezra Shaw
0dc36fcd5b
fix: don't suggest similar method when unstable 2023-03-18 16:19:00 +13:00
Scott McMurray
35088797ae Use size_of_val instead of manual calculation
Very minor thing that I happened to notice in passing, but it's both shorter and means it gets `mul nuw`, so why not.
2023-03-17 19:55:49 -07:00
Matthias Krüger
0d4a56cc21
Rollup merge of #109257 - petrochenkov:bindebug, r=WaffleLapkin
resolve: Improve debug impls for `NameBinding`

Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
Noticed while reviewing https://github.com/rust-lang/rust/pull/108729.
2023-03-18 00:05:55 +01:00
Matthias Krüger
7e5705e5c6
Rollup merge of #109251 - MU001999:master, r=Nilstrieb
Suggest surrounding the macro with `{}` to interpret as a statement

Fixes #109237
2023-03-18 00:05:54 +01:00
Matthias Krüger
d91858b080
Rollup merge of #109248 - compiler-errors:get_fn_decl-aaa, r=WaffleLapkin
Pass the right HIR back from `get_fn_decl`

Fixes #109232

Makes sure that the `fn_id: HirId` that we pass to `suggest_missing_return_type` matches up with the `fn_decl: hir::FnDecl` that we pass to it, so the late-bound vars that we fetch from the former match up with the types in the latter...

This HIR suggestion code really needs a big refactor. I've tried to do it in the past (a couple of attempts), but it's a super tangled mess. It really shouldn't be passing around things like `hir::Node` and just deal with `LocalDefId`s everywhere... Anyways, I'd rather fix this ICE, now.
2023-03-18 00:05:54 +01:00
Matthias Krüger
dfd2b6493a
Rollup merge of #109222 - chenyukang:yukang/fix-109143, r=petrochenkov
Do not ICE for unexpected lifetime with ConstGeneric rib

Fixes #109143
r? ````@petrochenkov````

Combining this test with the previous test will affect the previous diagnostics, so I added a separate test case.
2023-03-18 00:05:53 +01:00
Matthias Krüger
e7d6369ed4
Rollup merge of #109211 - mili-l:mili_l/update_e0206_description, r=WaffleLapkin
E0206 - update description

added `union` to description
2023-03-18 00:05:52 +01:00
Matthias Krüger
55d5cd5e95
Rollup merge of #109200 - compiler-errors:issue-109191, r=WaffleLapkin
Fix index out of bounds in `suggest_trait_fn_ty_for_impl_fn_infer`

Fixes #109191
2023-03-18 00:05:52 +01:00
Matthias Krüger
0ee7539e96
Rollup merge of #109102 - compiler-errors:ambig-assoc-in-non-lt-binder, r=jackh726
Erase escaping late-bound regions when probing for ambiguous associated types

Fixes #109090
2023-03-18 00:05:52 +01:00
Santiago Pastorino
640c20272e
Fix generics_of for impl's RPITIT synthesized associated type 2023-03-17 20:01:57 -03:00
Michael Goulet
6639538575 Remove VecMap 2023-03-17 20:49:28 +00:00
Santiago Pastorino
9139ed076d
Fix impl_trait_ty_to_ty substs 2023-03-17 16:28:00 -03:00
bors
13afbdaa06 Auto merge of #108862 - Mark-Simulacrum:bootstrap-bump, r=pietroalbini
Bump bootstrap compiler to 1.69 beta

r? `@pietroalbini`
2023-03-17 19:00:38 +00:00
The 8472
7cce618d18 Fast path that skips over unchanged obligations in process_obligations
- only borrow the refcell once per loop
- avoid complex matches to reduce branch paths in the hot loop
- use a by-ref fast path that avoids mutations at the expense of having false negatives
2023-03-17 19:56:03 +01:00
Santiago Pastorino
c7cc1c7442
Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty 2023-03-17 15:36:02 -03:00
Michael Goulet
08c913279f Pass the right HIR back from get_fn_decl 2023-03-17 15:39:05 +00:00
Michael Goulet
79ad7cca45 Erase escaping late-bound regions when probing for ambiguous associated types 2023-03-17 15:33:24 +00:00
Boxy
b85bc19705 move compute_goal and evaluate_x methods to inner module 2023-03-17 15:02:24 +00:00
bors
03b01c5bec Auto merge of #109253 - matthiaskrgr:rollup-2xmv5zk, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108958 (Remove box expressions from HIR)
 - #109044 (Prevent stable `libtest` from supporting `-Zunstable-options`)
 - #109155 (Fix riscv64 fuchsia LLVM target name)
 - #109156 (Fix linker detection for clang with prefix)
 - #109181 (inherit_overflow: adapt pattern to also work with v0 mangling)
 - #109198 (Install projection from RPITIT to default trait method opaque correctly)
 - #109215 (Use sort_by_key instead of sort_by)
 - #109229 (Fix invalid markdown link references)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-17 14:56:30 +00:00
Jamilya Shurukhova
c4bb47ac36
Update compiler/rustc_error_codes/src/error_codes/E0206.md
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-03-17 15:50:37 +01:00
Boxy
9df35a5050 fix bad assertion 2023-03-17 14:40:21 +00:00
Boxy
e624ef4d64 replace chain with two add_goal 2023-03-17 14:35:12 +00:00
Boxy
aa8de17928 fix let else unformatting 2023-03-17 14:13:10 +00:00
Boxy
e06c62cd5b UNACEPTABLE 2023-03-17 14:04:39 +00:00
Jamilya Shurukhova
05dc132adb E0206 - code review changes 2023-03-17 14:54:39 +01:00
Boxy
ce14a1eba0 add comments
Co-authored-by: lcnr <rust@lcnr.de>
2023-03-17 13:38:12 +00:00
Boxy
ea08d3a47c add assert 2023-03-17 13:37:47 +00:00
Boxy
ee31e5fc57 review nits 2023-03-17 13:33:57 +00:00
clubby789
ce2d52841b Drop subslices of arrays 2023-03-17 12:26:04 +00:00
Vadim Petrochenkov
2a5208011d resolve: Improve debug impls for NameBinding
Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
2023-03-17 13:34:15 +04:00
bors
2d64f229a0 Auto merge of #109085 - tmiasko:index-based, r=WaffleLapkin
Use index based drop loop for slices and arrays

Instead of building two kinds of drop pair loops, of which only one will be eventually used at runtime in a given monomorphization, always use index based loop.
2023-03-17 08:17:21 +00:00
Matthias Krüger
a530f72268
Rollup merge of #109215 - est31:sort_by_key, r=Nilstrieb
Use sort_by_key instead of sort_by

I went over the cases where sort_by is used and in these two, one can use sort_by_key instead.
2023-03-17 08:42:40 +01:00
Matthias Krüger
246d989a30
Rollup merge of #109198 - compiler-errors:new-rpitit-default-body, r=spastorino
Install projection from RPITIT to default trait method opaque correctly

1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass!

2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why.

3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt.

r? ````@spastorino,```` based off of #109140
2023-03-17 08:42:40 +01:00
Matthias Krüger
cd6d1653cc
Rollup merge of #109156 - taiki-e:linker-detection, r=petrochenkov
Fix linker detection for clang with prefix

https://github.com/rust-lang/rust/pull/106489 removed check for clang with prefix. It says:

> Also remove the check for -clang, since there are no architecture specific variants of clang (to my knowledge).

However, when doing cross-compilation, a wrapper script for clang with the target name as a prefix is sometimes used.

1716932743/src/ci/docker/host-x86_64/dist-various-2/Dockerfile (L62)

1716932743/src/ci/docker/scripts/freebsd-toolchain.sh (L76-L80)

1716932743/src/ci/docker/host-x86_64/dist-various-2/Dockerfile (L40)

1716932743/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs (L7)

It seems the regression did not occur on the targets mentioned above because the default linker flavor is gcc, but it did occur on targets where the default linker flavor is not gcc (fd352f3ffa).

r? ````@petrochenkov````
2023-03-17 08:42:39 +01:00
Matthias Krüger
023154e2ce
Rollup merge of #109155 - taiki-e:riscv64-fuchsia-fix-llvm-target, r=tmandry
Fix riscv64 fuchsia LLVM target name

Currently, riscv64gc-unknown-fuchsia (added in #108722) sets riscv64*gc*-unknown-fuchsia as the LLVM target.

1716932743/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs (L5)

However, riscv64*gc*-\* is not a valid LLVM target and causes the following error.

```console
$ rustc --print cfg --target riscv64gc-unknown-fuchsia
error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia"
```

As with other RISC-V targets, the LLVM target should use riscv64-\*, not riscv64*gc*-\*.

1716932743/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs (L5)
1716932743/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs (L5)

I confirmed that riscv64-unknown-fuchsia is recognized as a valid LLVM target by using custom targets.

```console
# create a custom target with `"llvm-target": "riscv64-unknown-fuchsia" from no-std riscv64gc target.
$ rustc --print target-spec-json -Z unstable-options --target riscv64gc-unknown-none-elf | grep -v is-builtin | sed 's/"llvm-target".*/"llvm-target": "riscv64-unknown-fuchsia",/' > riscv64gc-unknown-fuchsia.json

$ rustc --print cfg --target riscv64gc-unknown-fuchsia.json
debug_assertions
panic="abort"
target_abi=""
target_arch="riscv64"
target_endian="little"
target_env=""
target_feature="a"
target_feature="c"
target_feature="d"
target_feature="f"
target_feature="m"
...

$ cat riscv64gc-unknown-fuchsia.json
{
  "arch": "riscv64",
  "code-model": "medium",
  "cpu": "generic-rv64",
  "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
  "eh-frame-header": false,
  "emit-debug-gdb-scripts": false,
  "features": "+m,+a,+f,+d,+c",
  "linker": "rust-lld",
  "linker-flavor": "ld.lld",
  "llvm-abiname": "lp64d",
  "llvm-target": "riscv64-unknown-fuchsia",
  "max-atomic-width": 64,
  "panic-strategy": "abort",
  "relocation-model": "static",
  "supported-sanitizers": [
    "kernel-address"
  ],
  "target-pointer-width": "64"
}

# Check the current master's LLVM target name causes an error
$ sed -i 's/riscv64-unknown-fuchsia/riscv64gc-unknown-fuchsia/' riscv64gc-unknown-fuchsia.json
$ rustc --print cfg --target riscv64gc-unknown-fuchsia.json
error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia"
```

r? ````@tmandry````
2023-03-17 08:42:38 +01:00
Matthias Krüger
13ff2d42cd
Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
Remove box expressions from HIR

After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed.

This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!)

````@rustbot```` label +S-blocked
2023-03-17 08:42:37 +01:00
Mu42
550e3087d1 Suggest surrounding the macro with {} to interpret as a statement 2023-03-17 14:36:22 +08:00
yukang
c22f154e3f Do not ICE for native_lib without name 2023-03-17 07:59:08 +08:00
yukang
827a990255 Do not ICE for unexpected lifetime with ConstGeneric rib 2023-03-17 07:36:18 +08:00
Tomasz Miąsko
27b430bcb3 Tweak implementation of overflow checking assertions
Extract and reuse logic controlling behaviour of overflow checking
assertions instead of duplicating it three times.
2023-03-16 22:55:45 +01:00
John Kåre Alsaker
4f7cd3d459 Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
bors
511364e787 Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obk
Wrap the whole LocalInfo in ClearCrossCrate.

MIR contains a lot of information about locals. The primary purpose of this information is the quality of borrowck diagnostics.

This PR aims to drop this information after MIR analyses are finished, ie. starting from post-cleanup runtime MIR.
2023-03-16 19:59:56 +00:00
bors
e386217dd9 Auto merge of #107270 - cjgillot:remove-zst, r=oli-obk
Replace ZST operands and debuginfo by constants.

This is work that ConstProp will not have to do.
Split from https://github.com/rust-lang/rust/pull/107267
2023-03-16 16:40:53 +00:00
Oli Scherer
480e042097 Add Debug and Clone derives for stable mir datastructures 2023-03-16 16:17:25 +00:00
Oli Scherer
942cac1b8d Implement a minimal subset of MIR statements and terminators for smir 2023-03-16 16:06:12 +00:00
Boxy
ed63201224 replace usage of evaluate_goal with a new add_goal 2023-03-16 14:58:35 +00:00
Oli Scherer
6fe982283d Remove DefId from CrateItem in favor of a lookup table 2023-03-16 14:53:57 +00:00
Nikita Popov
30331828cb Use poison instead of undef
In cases where it is legal, we should prefer poison values over
undef values.

This replaces undef with poison for aggregate construction and
for uninhabited types. There are more places where we can likely
use poison, but I wanted to stay conservative to start with.

In particular the aggregate case is important for newer LLVM
versions, which are not able to handle an undef base value during
early optimization due to poison-propagation concerns.
2023-03-16 15:07:04 +01:00
bors
1203e0866e Auto merge of #106824 - m-ou-se:format-args-flatten, r=oli-obk
Flatten/inline format_args!() and (string and int) literal arguments into format_args!()

Implements https://github.com/rust-lang/rust/issues/78356

Gated behind `-Zflatten-format-args=yes`.

Part of #99012

This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:

```rust
println!("Hello, {}!", "World");
println!("Hello, World!");
```

```rust
println!("[info] {}", format_args!("error"));
println!("[info] error");
```

```rust
println!("[{}] {}", status, format_args!("error: {}", msg));
println!("[{}] error: {}", status, msg);
```

```rust
println!("{} + {} = {}", 1, 2, 1 + 2);
println!("1 + 2 = {}", 1 + 2);
```

And so on.

This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.

It also means that `dbg!(x)` will have its file, line, and expression name inlined:

```rust
eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
eprintln!("[example.rs:1] x = {:#?}", x); // after
```

Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.
2023-03-16 13:46:52 +00:00
Vadim Petrochenkov
18b59f5d6d resolve: Minor cleanup to Resolver::get_module 2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
52c73975b4 resolve: Use item_name and opt_parent in Resolver::get_module
This is a cleanup that doesn't introduce new query calls, but this way `def_key` is decoded twice which may matter for performance or may not
2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
d99e01fa7e resolve: Remove item_attrs_untracked 2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
f28f77f2d9 resolve: Remove item_generics_num_lifetimes 2023-03-16 17:22:18 +04:00
est31
a8839c3de7 Use sort_by_key instead of sort_by
I went over the cases where sort_by is used and in these two,
one can use sort_by_key instead.
2023-03-16 13:06:31 +01:00
Mara Bos
995e57b89e Gate fmt args flattening behind -Zflatten-format-args. 2023-03-16 11:21:50 +01:00
Mara Bos
f2f6bcc499 Don't allow new const panic through format flattening.
panic!("a {}", "b") is still not allowed in const,
even if the hir flattens to panic!("a b").
2023-03-16 11:21:50 +01:00
Mara Bos
6a535dfff4 Also inline integer literals into format_args!(). 2023-03-16 11:21:50 +01:00
Mara Bos
df8c14ca61 Check all arg indexes before removing inlined format args. 2023-03-16 11:21:50 +01:00
Mara Bos
0554401fcc Remove unreachable branch in format_args ast lowering. 2023-03-16 11:21:48 +01:00
Mara Bos
b6c988b041 Fix argument index remapping in format_args flattening. 2023-03-16 11:19:31 +01:00
Mara Bos
b7678d48b8 Only inline {} string literals in format_args.
Placeholders like {:123} would incorrectly get inlined.
2023-03-16 11:19:31 +01:00
Mara Bos
caa6ba9e86 Support flattening/inlining format_args through & and ().
E.g. format_args!("{}", &(format_args!("abc"))).
2023-03-16 11:19:31 +01:00
Mara Bos
85ef2f0cfe Inline string literals into format_args!(). 2023-03-16 11:19:31 +01:00
Mara Bos
94ad7e881d Coalesce adjacent literal pieces in expand_format_args. 2023-03-16 11:19:31 +01:00
Mara Bos
a769b30a93 Flatten nested format_args!() into one. 2023-03-16 11:19:30 +01:00
Jamilya Shurukhova
1f12c3e397 E0206 - removed space 2023-03-16 10:26:34 +01:00
Jamilya Shurukhova
dc39bf8efc E0206 - added union to description 2023-03-16 10:18:31 +01:00
Matthias Krüger
76962482e6
Rollup merge of #109180 - gimbles:master, r=compiler-errors
Unequal → Not equal

Fixes #109168
2023-03-16 08:57:09 +01:00
Matthias Krüger
113e815b36
Rollup merge of #109171 - oli-obk:normalization_cleanup, r=compiler-errors
Some cleanups in our normalization logic

Changed a match to be exhaustive and deduplicated some code.

r? ```@compiler-errors```

this pulls out the uncontroversial part of https://github.com/rust-lang/rust/pull/108860
2023-03-16 08:57:08 +01:00
Matthias Krüger
f0205d55ce
Rollup merge of #109166 - lcnr:define_opaque_types-explicit, r=oli-obk
make `define_opaque_types` fully explicit

based on the idea of #108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally.

Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way.

r? ```@oli-obk```
2023-03-16 08:57:07 +01:00
Matthias Krüger
36b82373e0
Rollup merge of #109158 - Ezrashaw:expand-sugg-for-unused-lint, r=Nilstrieb
error-msg: expand suggestion for `unused_def` lint

Fixes #108885

Expands `let _ = ..` suggestion into more positions.
2023-03-16 08:57:07 +01:00
Matthias Krüger
9d5d447421
Rollup merge of #109151 - compiler-errors:debug-assert-alias, r=WaffleLapkin
Assert def-kind is correct for alias types

Make sure we're not constructing alias types for the wrong def-kind, at least for debug cases 😅
2023-03-16 08:57:06 +01:00
Matthias Krüger
1385a32b62
Rollup merge of #108971 - Ezrashaw:E0532-better-binding-names, r=WaffleLapkin
error-msg: impl better suggestion for `E0532`

Fixes #106862

No test as there is already a test which is nearly identical to the example in the linked issue.
2023-03-16 08:57:05 +01:00
Michael Goulet
60da5de1c6 Fix index out of bounds in suggest_trait_fn_ty_for_impl_fn_infer 2023-03-16 04:02:56 +00:00
bors
18e305dfca Auto merge of #109183 - lqd:revert-107376, r=compiler-errors
Revert #107376 to fix potential `bincode` breakage and `rustc-perf` benchmark.

#107376 caused `rustc-perf`'s `webrender` benchmark to break, by regressing on the `bincode-1.3.3` crate.

~~This PR is a draft revert in case we can't land a fix soon enough, and we'd like to land the revert instead~~

(Though I myself think it'd be safer to do the revert, and run crater when relanding #107376.)

cc `@aliemjay`
2023-03-16 02:56:24 +00:00
Michael Goulet
8d922eba79 Fix on_unimplemented_note for RPITITs 2023-03-16 01:59:44 +00:00
Michael Goulet
ff7c3b854d Don't install default opaque projection predicates in RPITIT associated type's param-env 2023-03-16 01:59:41 +00:00
Michael Goulet
0949da8f4e Install projection from RPITIT to default trait method opaque correctly 2023-03-16 01:56:49 +00:00
bors
c90eb4825a Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiasko
Implement checked Shl/Shr at MIR building.

This does not require any special handling by codegen backends,
as the overflow behaviour is entirely determined by the rhs (shift amount).

This allows MIR ConstProp to remove the overflow check for constant shifts.

~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).`
I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~

EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15 21:31:06 +00:00
Santiago Pastorino
11f1810831
Feed is_type_alias_impl_trait for RPITITs on the trait side 2023-03-15 16:58:37 -03:00
Santiago Pastorino
e41491fe05
ImplTraitPlaceholder -> is_impl_trait_in_trait 2023-03-15 16:58:35 -03:00
bors
ab654863c3 Auto merge of #109169 - bjorn3:sync_cg_clif-2023-03-15, r=bjorn3
Sync rustc_codegen_cranelift

Bunch of bug fixes this time. Also an update to Cranelift 0.93 which adds a brand new optimization pass which cg_clif exposes when using `--release`. And various improvements to cg_clif's test suite, making it faster to run. And finally two small perf improvements.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-03-15 18:30:04 +00:00
gimbles
e5a5b90afc unequal → not equal 2023-03-15 23:55:48 +05:30
Partha P. Das
3720753632
Implementing "<test_binary> --list --format json" #107307 #49359 2023-03-15 14:20:20 -04:00
Camille GILLOT
2adf2cd2f7 Account for debuginfo on _0 without naming it. 2023-03-15 18:02:19 +01:00
Santiago Pastorino
39d19ca9f2
Make impl_trait_in_trait_container consider newly generated RPITITs 2023-03-15 12:27:16 -03:00
Santiago Pastorino
39ffe9699a
Properly implement generics_of for traits 2023-03-15 12:27:16 -03:00
Santiago Pastorino
26c4c1ea97
Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fn 2023-03-15 12:27:16 -03:00
Rémy Rakic
5ad1083e5b Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"
This reverts commit e84e5ff04a, reversing
changes made to 1716932743.
2023-03-15 15:09:29 +00:00
bors
a167cbddac Auto merge of #109164 - Dylan-DPC:rollup-0bwxwos, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108991 (add `enable-warnings` flag for llvm, and disable it by default.)
 - #109109 (Use `unused_generic_params` from crate metadata)
 - #109111 (Create dirs for build_triple)
 - #109136 (Simplify proc macro signature validity check)
 - #109150 (Update cargo)
 - #109154 (Fix MappingToUnit  to support no span of arg_ty)
 - #109157 (Remove mw from review rotation for a while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-15 14:50:03 +00:00
bjorn3
fce629d2e9 Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into sync_cg_clif-2023-03-15 2023-03-15 14:41:48 +00:00
lcnr
d2b7604db9 always make define_opaque_types explicit 2023-03-15 14:00:15 +01:00
Mark Rousskov
01d7af11e1 Bump version placeholders 2023-03-15 08:55:22 -04:00
Dylan DPC
19d575851a
Rollup merge of #109154 - chenyukang:yukang/fix-109152, r=compiler-errors
Fix MappingToUnit  to support no span of arg_ty

Fixes #109152
2023-03-15 17:51:33 +05:30
Dylan DPC
8c5ea6188f
Rollup merge of #109136 - compiler-errors:simplify-proc-macro-checking, r=oli-obk
Simplify proc macro signature validity check

Use an `ObligationCtxt` instead of `normalize_erasing_regions` + `DeepRejectCtxt`. This should both give us a more accurate error message, and also avoid issues like not-well-formed proc macro signatures. Also, let's fall back on the regular type mismatch error reporting for making these diagnostic notes, instead of hard-coding a bunch of specific diagnostics.

Fixes #109129
2023-03-15 17:51:32 +05:30
Dylan DPC
2aa3eea5fc
Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=Nilstrieb
Use `unused_generic_params` from crate metadata

Due to the way that `separate_provide_extern` interacted with the implementation of `<ty::InstanceDef<'tcx> as Key>::query_crate_is_local`, we actually never hit the foreign provider for `unused_generic_params`.

Additionally, since the *local* provider of `unused_generic_params` calls `should_polymorphize`, which always returns false if the def-id is foreign, this means that we never actually polymorphize monomorphic instances originating from foreign crates.

We don't actually encode `unused_generic_params` for items where all generics are used, so I had to tweak the foreign provider to fall back to `ty::UnusedGenericParams::new_all_used()` to avoid more ICEs when the above bugs were fixed.
2023-03-15 17:51:31 +05:30
Oli Scherer
d87fbb918c Deduplicate logic between projection normalization with and without escaping bound vars 2023-03-15 12:02:00 +00:00
Oli Scherer
d3d537b972 Exhaustively match over all alias kinds 2023-03-15 12:00:25 +00:00
bors
e4b9f86054 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen
Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does

I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`.  Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist.

The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`.  This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing.

Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them.

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936>

cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472`

Fixes #106369
Fixes #73258
2023-03-15 11:44:12 +00:00
Ezra Shaw
35103fe8ab
error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
Ezra Shaw
bd1732240b
error-msg: impl better suggestion for E0532 2023-03-15 22:19:54 +13:00
bors
992d154f3a Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino
Encode `opt_rpitit_info` for associated types

Follow-up, only last commit matters

r? `@spastorino`

This needs a perf run after the parent pr lands
2023-03-15 08:13:23 +00:00
yukang
b3af5e2f8b Fix #109152, fix the scenario that we may can not get span of func 2023-03-15 14:07:39 +08:00
Scott McMurray
e7c6ad89cf Improved implementation and comments after code review feedback 2023-03-14 22:24:28 -07:00
Taiki Endo
86a5e3632c Fix linker detection for clang with prefix 2023-03-15 13:30:45 +09:00
Taiki Endo
fb916a0132 Fix riscv64 fuchsia LLVM target name 2023-03-15 12:55:37 +09:00
bors
e84e5ff04a Auto merge of #107376 - aliemjay:remove-givens, r=lcnr
remove obsolete `givens` from regionck

Fixes #106567

r? `@lcnr` (feel free to reassign)
2023-03-15 02:50:58 +00:00
Michael Goulet
cf6424e881 Don't make projection tys out of anon consts 2023-03-14 23:12:42 +00:00
Michael Goulet
e482701998 Assert def-kind is correct for alias types 2023-03-14 22:56:24 +00:00
Michael Goulet
0404e264a2 Encode opt_rpitit_info for associated types 2023-03-14 22:10:09 +00:00
Tomasz Miąsko
cf0e78bd3b Use index based drop loop for slices and arrays
Instead of building two kinds of drop pair loops, of which only one will
be eventually used at runtime in a given monomorphization, always use
index based loop.
2023-03-14 21:29:32 +01:00
Camille GILLOT
526a2c7521 ICE when checking LocalInfo on runtime MIR. 2023-03-14 20:52:42 +01:00
Camille GILLOT
50d0959a2f Remove LocalKind::Var. 2023-03-14 20:52:42 +01:00
Camille GILLOT
d31386a52b Make is_block_tail a variant of LocalInfo. 2023-03-14 20:52:42 +01:00
Camille GILLOT
bcb161def7 Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
Michael Goulet
00dc3b24b7 Tighter spans 2023-03-14 19:12:42 +00:00
Michael Goulet
9eae77381e Simplify proc macro signature validity check 2023-03-14 19:05:21 +00:00
bors
1716932743 Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108722 (Support for Fuchsia RISC-V target)
 - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests)
 - #108909 (Fix object safety checks for new RPITITs)
 - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics)
 - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty)
 - #109101 (Fall back to old metadata computation when type references errors)
 - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`)
 - #109110 (Don't codegen impossible to satisfy impls)
 - #109116 (Emit diagnostic when calling methods on the unit type in method chains)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-14 17:40:52 +00:00
clubby789
9afffc5b61 Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
Matthias Krüger
b17ee106d8
Rollup merge of #109116 - MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov
Emit diagnostic when calling methods on the unit type in method chains

Fixes #104204.

What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message.

For example given input:

```
vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
```

the current output is:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`

```

after this PR it will be:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> ./hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`
  |

note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
 --> ./hello.rs:3:53
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                     ^^^^^^^^^^^ this call modifies its receiver in-place
```
2023-03-14 17:40:07 +01:00
Matthias Krüger
b88c675946
Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726
Don't codegen impossible to satisfy impls

Fixes #109098
2023-03-14 17:40:06 +01:00
Matthias Krüger
4c6b680955
Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obk
Don't ICE for late-bound consts across `AnonConstBoundary`

Fixes #108194
2023-03-14 17:40:06 +01:00
Matthias Krüger
1f159b4894
Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoerister
Fall back to old metadata computation when type references errors

Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation.

Fixes #109078
2023-03-14 17:40:05 +01:00
Matthias Krüger
21d15db1df
Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errors
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty

Only the last two commits are meaningful.

r? `@compiler-errors`
2023-03-14 17:40:05 +01:00
Matthias Krüger
6e3a3de778
Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errors
Remove some direct calls to local_def_id_to_hir_id on diagnostics

Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ...

```
error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future
   |
   = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>`
   = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited
note: required by a bound in `Foo::{opaque#1}`
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}`

error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>`
note: required by a bound in `Foo::{opaque#1}`
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}`

error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_>
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39
   |
10 |       async fn baz(&self) -> impl Debug {
   |  _______________________________________^
11 | |         ""
12 | |     }
   | |_____^
```

But I guess this is a little bit of progress anyway.

This one goes on top of #108700 and #108945
r? `@compiler-errors`
2023-03-14 17:40:04 +01:00
Matthias Krüger
48934c48c6
Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errors
Fix object safety checks for new RPITITs

This one goes on top of #108869

r? `@compiler-errors`
2023-03-14 17:40:04 +01:00
Matthias Krüger
e006ee9be8
Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkov
Support for Fuchsia RISC-V target

Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
2023-03-14 17:40:03 +01:00
Michael Goulet
ee2d42882f Use unused_generic_params from crate metadata 2023-03-14 16:33:12 +00:00
Michael Goulet
b36bbb0266 Don't codegen impossible to satisfy impls 2023-03-14 16:19:57 +00:00
Felix S. Klock II
e919f0f20e the fix
(fixed build by adding missing import.)
2023-03-14 11:44:08 -04:00
Maciej Wasilewski
6a2a6feca8 Emit "modifies receiver" diagnostic when no method is found
If no method is found when checking method call, we check  if we called a method with signature (&mut T, ...) -> (). If this is the case then we emit a diagnostic message
2023-03-14 16:39:45 +01:00
Santiago Pastorino
4824363e67
Remove some direct calls to local_def_id_to_hir_id on diagnostics 2023-03-14 11:38:12 -03:00
bors
2e7034ebf7 Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, r=petrochenkov
Properly allow macro expanded `format_args` invocations to uses captures

Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly.

This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me).

Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string.

The "source literal" checks were not strict enough and caused ICEs in certain cases (see #106191). So I tightened it up in #106195 to really only work if it's a direct source literal.

This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`).

This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again.

Fixes #106191

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 14:25:02 +00:00
Nilstrieb
427aceb9d4 Improve heuristics for format_args literal being suggestable
Sometimes, we want to create subspans and point at code in the literal
if possible. But this doesn't always make sense, sometimes the literal
may come from macro expanded code and isn't actually there in the
source. Then, we can't really make these suggestions.

This now makes sure that the literal is actually there as we see it so
that we will not run into ICEs on weird literal transformations.
2023-03-14 13:20:39 +00:00
Santiago Pastorino
a4e40370d0
Make fns from other crates with RPITIT work 2023-03-14 10:20:35 -03:00
Nilstrieb
729185338f Properly allow macro expanded format_args invocations to uses captures
Originally, this was kinda half-allowed. There were some primitive
checks in place that looked at the span to see whether the input was
likely a literal. These "source literal" checks are needed because the
spans created during `format_args` parsing only make sense when it is
indeed a literal that was written in the source code directly.

This is orthogonal to the restriction that the first argument must be a
"direct literal", not being exanpanded from macros. This restriction was
imposed by [RFC 2795] on the basis of being too confusing. But this was
only concerned with the argument of the invocation being a literal, not
whether it was a source literal (maybe in spirit it meant it being a
source literal, this is not clear to me).

Since the original check only really cared about source literals (which
is good enough to deny the `format_args!(concat!())` example), macros
expanding to `format_args` invocations were able to use implicit
captures if they spanned the string in a way that lead back to a source
string.

The "source literal" checks were not strict enough and caused ICEs in
certain cases (see # 106191 (the space is intended to avoid spammy
backreferences)). So I tightened it up in # 106195 to really only work
if it's a direct source literal.

This caused the `indoc` crate to break. `indoc` transformed the source
literal by removing whitespace, which made it not a "source literal"
anymore (which is required to fix the ICE). But since `indoc` spanned
the literal in ways that made the old check think that it's a literal,
it was able to use implicit captures (which is useful and nice for the
users of `indoc`).

This commit properly seperates the previously introduced concepts of
"source literal" and "direct literal" and therefore allows `indoc`
invocations, which don't create "source literals" to use implicit
captures again.

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 13:16:52 +00:00
Santiago Pastorino
b535da6841
Get impl defaultness using query 2023-03-14 10:16:19 -03:00
bors
669e751639 Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
Nilstrieb
1d70bd4970 Further codegen_attrs cleanups 2023-03-14 07:54:19 +00:00
Nilstrieb
e4ab642e8c Use match instead of if in codegen_attrs 2023-03-14 07:54:18 +00:00
bors
0058748944 Auto merge of #109057 - compiler-errors:rpitit-info-again, r=spastorino
Don't `opt_rpitit_info` as a separate query

... another attempt to undo regressions

r? `@ghost`
2023-03-14 06:42:15 +00:00
bors
bd43458d4c Auto merge of #108992 - petrochenkov:qcstore2, r=cjgillot
resolve: Querify most cstore access methods (subset)

A subset of https://github.com/rust-lang/rust/pull/108346 that is not on a hot path in any way.
2023-03-14 03:38:42 +00:00
Michael Goulet
8a53570008 Don't ICE for late-bound consts across AnonConstBoundary 2023-03-13 22:38:37 +00:00
Michael Goulet
0bb876ebe7 Layout of &dyn Trait<[type error]> is still wide 2023-03-13 21:35:20 +00:00
Matthias Krüger
30cd4b3a16
Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, r=compiler-errors
Gracefully handle `#[target_feature]` on statics

The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds.

I was sadly not able to fully bless the test locally because I'm on an aarch64 machine but I hope some manual editing made it work 😅

Fix #109079
2023-03-13 21:55:39 +01:00
Matthias Krüger
9fc8de0caa
Rollup merge of #109058 - tmiasko:is-checkable, r=jackh726
Document BinOp::is_checkable
2023-03-13 21:55:37 +01:00
Nilstrieb
34be05e097 Gracefully handle #[target_feature] on statics
The was careful around not calling `fn_sig` on not-functions but well,
it wasn't careful enough. This commit makes it a little more careful and
also adds tests for a bunch more item kinds.
2023-03-13 19:05:06 +00:00
Camille GILLOT
19a8bb16c8 Generalize operation. 2023-03-13 18:22:55 +00:00
Camille GILLOT
63ce733fe2 Rename method. 2023-03-13 18:19:59 +00:00
Camille GILLOT
9e3f091f2b Replace ZST operands and debuginfo by constants. 2023-03-13 18:19:57 +00:00
Michael Goulet
ce8dae5800 Don't opt_rpitit_info as a separate query 2023-03-13 17:02:47 +00:00
Michael Goulet
84d254ead0 Better names? 2023-03-13 16:34:16 +00:00
Michael Goulet
c32527fb92 Treat projections with infer as placeholder during fast reject in new solver 2023-03-13 16:34:16 +00:00
Vadim Petrochenkov
4a61922ef0 metadata/resolve: Minor refactoring to "tcx -> cstore" conversions 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
98cce81917 metadata: Remove some more untracked CStore methods 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
b3ee735993 resolve: Remove struct_field_names_untracked 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
2a716f3563 resolve: Centralize retrieval of items span and item name 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c7f424b80a resolve: Remove fn_has_self_parameter_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c05b7bd7d0 resolve: Remove struct_field_visibilities_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
901f1c9c62 resolve: Partially remove item_attrs_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
17127f3e78 resolve: Remove visibility_untracked 2023-03-13 17:31:54 +04:00
bors
f1b1ed7e18 Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31
Remove `box_syntax`

r? `@Nilstrieb`

This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected.
It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute.
As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new`

Closes #49733
2023-03-13 10:41:50 +00:00
bors
b05bb29008 Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk
Strengthen state tracking in const-prop

Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.

Behaviour changes:
- const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen.
- we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry.
- the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12 23:27:52 +00:00
bors
7b4f48927d Auto merge of #109056 - matthiaskrgr:rollup-9trny1z, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108651 (Forbid the use of `#[target_feature]` on `main`)
 - #109009 (rustdoc: use restricted Damerau-Levenshtein distance for search)
 - #109026 (Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner`)
 - #109029 (Gate usages of `dyn*` and const closures in macros)
 - #109031 (Rename `config.toml.example` to `config.example.toml`)
 - #109032 (Use `TyCtxt::trait_solver_next` in some places)
 - #109047 (typo)
 - #109052 (Add eslint check for rustdoc-gui tester)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-12 20:21:26 +00:00
Matthias Krüger
fb4bb1679a
Rollup merge of #109047 - tshepang:type, r=lcnr
typo
2023-03-12 20:44:52 +01:00
Matthias Krüger
4305c1a89d
Rollup merge of #109032 - compiler-errors:shorter, r=BoxyUwU
Use `TyCtxt::trait_solver_next` in some places

Also flip order of if statements to avoid `!`
2023-03-12 20:44:52 +01:00
Matthias Krüger
98fea68470
Rollup merge of #109029 - compiler-errors:parse-gating, r=jackh726
Gate usages of `dyn*` and const closures in macros

We silently accepted `dyn*` and const closures in macros as long as they didn't expand to anything containing these experimental features, unlike other gated features such as `for<'a>` binders on closures, etc. Let's not do that, to make sure nobody begins relying on this.
2023-03-12 20:44:51 +01:00
Matthias Krüger
f41796e6b4
Rollup merge of #108651 - LeSeulArtichaut:108645-target-feature-on-main, r=Nilstrieb
Forbid the use of `#[target_feature]` on `main`

Fixes #108645.
2023-03-12 20:44:49 +01:00
bors
938afba899 Auto merge of #108845 - Zoxc:par-fix-2, r=cjgillot
Check that a query has not completed and is not executing before starting it

This fixes a race in the query system where we only checked if the query was currently executing, but not if it was already completed, causing queries to re-execute.

r? `@cjgillot`
2023-03-12 17:03:44 +00:00
Guillaume Gomez
ac4ea52980 Add test for useless_anonymous_reexport lint 2023-03-12 16:33:37 +01:00
Guillaume Gomez
2df7770d5e Add lint for useless anonymous reexports 2023-03-12 15:12:42 +01:00
bors
f41927f309 Auto merge of #108820 - cjgillot:ensure-on-disk, r=oli-obk
Ensure value is on the on-disk cache before returning from `ensure()`.

The current logic for `ensure()` a query just checks that the node is green in the dependency graph.
However, a lot of places use `ensure()` to prevent the query from being called later. This is the case before stealing a query result.

If the query is actually green but the value is not available in the on-disk cache, `ensure` would return, but a subsequent call to the full query would run the code, and attempt to read from a stolen value.

This PR conforms the query system to the usage by checking whether the queried value is loadable from disk before returning.

Sadly, I can't manage to craft a proper test...

Should fix all instances of "attempted to read from stolen value".
2023-03-12 14:00:28 +00:00
Léo Lanteri Thauvin
29b1789a75 Allow #[target_feature] on main and start for WASM 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
963305bda8 Forbid the use of #[target_feature] on start 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
db26693982 Forbid the use of #[target_feature] on main 2023-03-12 14:57:38 +01:00