Commit Graph

28411 Commits

Author SHA1 Message Date
bors
eb0f3ed59c Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR

This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205

Addresses https://github.com/rust-lang/rust/issues/112651

r? `@lcnr`
2023-10-03 10:02:52 +00:00
Matthias Krüger
634e5c9ba2
Rollup merge of #116158 - compiler-errors:unconstrained-type-var-sugg, r=wesleywiser
Don't suggest nonsense suggestions for unconstrained type vars in `note_source_of_type_mismatch_constraint`

The way we do type inference for suggestions in `note_source_of_type_mismatch_constraint` is a bit strange. We compute the "ideal" method signature, which takes the receiver that we *want* and uses it to compute the types of the arguments that would have given us that receiver via type inference, and use *that* to suggest how to change an argument to make sure our receiver type is inferred correctly.

The problem is that sometimes we have totally unconstrained arguments (well, they're constrained by things outside of the type checker per se, like associated types), and therefore type suggestions are happy to coerce anything to that unconstrained argument. This leads to bogus suggestions, like #116155. This is partly due to above, and partly due to the fact that `emit_type_mismatch_suggestions` doesn't double check that its suggestions are actually compatible with the program other than trying to satisfy the type mismatch.

This adds a hack to make sure that at least the types are fully constrained, but I guess I could also rip out this logic altogether. There would be some sad diagnostics regressions though, such as `tests/ui/type/type-check/point-at-inference-4.rs`.

Fixes #116155
2023-10-03 08:58:48 +02:00
Matthias Krüger
ff3b15e2bf
Rollup merge of #115726 - compiler-errors:better-error-ref, r=estebank
For a single impl candidate, try to unify it with error trait ref

This allows us to point out an exact type mismatch when there's only one applicable impl.

cc `@asquared31415`
r? `@estebank`
2023-10-03 08:58:48 +02:00
Michael Goulet
07851679cd Point out the actual mismatch error 2023-10-02 23:14:29 +00:00
Michael Goulet
8be12f4ed7 For a single impl candidate, try to unify it with error trait ref 2023-10-02 23:14:29 +00:00
bors
2e5a9dd6c9 Auto merge of #102099 - InnovativeInventor:re-cold-land, r=nikic
Rebased: Mark drop calls in landing pads cold instead of noinline

I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from `@erikdesjardins` (PR #94823).

This PR reapplies https://github.com/rust-lang/rust/pull/92419, which was reverted in https://github.com/rust-lang/rust/pull/94402 due to https://github.com/rust-lang/rust/issues/94390.

Fixes https://github.com/rust-lang/rust/issues/46515, fixes https://github.com/rust-lang/rust/issues/87055.

Update: fixes #97217.
2023-10-02 22:02:12 +00:00
Michael Goulet
ac5aa8c1a4 Don't suggest nonsense suggestions for unconstrained type vars in note_source_of_type_mismatch_constraint 2023-10-02 21:13:46 +00:00
ouz-a
5d753abb30 have better explanation for relate_types 2023-10-02 23:39:45 +03:00
ouz-a
6f0c5ee2d4 change is_subtype to relate_types 2023-10-02 23:39:45 +03:00
ouz-a
cd7f471931 Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00
ouz-a
3148e6a993 subtyping_projections 2023-10-02 23:37:49 +03:00
Tyler Mandry
af77806bee
Rollup merge of #114454 - Nilstrieb:no-evil-sorting, r=cjgillot
Replace `HashMap` with `IndexMap` in pattern binding resolve

fixes https://github.com/rust-lang/rust/pull/114332#discussion_r1284189179
2023-10-02 16:09:42 -04:00
Nilstrieb
6ca07235a6 Replace HashMap with IndexMap in pattern binding resolve
It will be iterated over, so we should avoid using `HashMap`.
2023-10-02 19:12:42 +02:00
Matthias Krüger
cfe9e13627
Rollup merge of #116340 - lcnr:early-binder-skip_binder, r=compiler-errors
`skip_binder` to `instantiate_identity`
2023-10-02 16:23:54 +02:00
Matthias Krüger
e51a2aaa4e
Rollup merge of #116313 - nnethercote:rustc_abi, r=the8472
Some small cleanups in `rustc_abi`

Minor things I found while looking at this crate's code.

r? `@the8472`
2023-10-02 16:23:53 +02:00
lcnr
dbc2cc8717 skip_binder to instantiate_identity 2023-10-02 13:19:37 +02:00
Nikita Popov
5bcf4f26ac Limit to LLVM 17.0.2 to work around WinEH codegen bug 2023-10-02 11:06:38 +02:00
Erik Desjardins
31ee8b1818 Reapply: Mark drop calls in landing pads cold instead of noinline
Co-authored-by: Max Fan <git@max.fan>
Co-authored-by: Nikita Popov <npopov@redhat.com>
2023-10-02 10:37:53 +02:00
bors
781ebbec8a Auto merge of #115898 - onur-ozkan:config-change-tracking, r=Mark-Simulacrum
bootstrap major change detection implementation

The use of `changelog-seen` and `bootstrap/CHANGELOG.md` has not been functional in any way for many years. We often do major/breaking changes but never update the changelog file or the `changelog-seen`. This is an alternative method for tracking major or breaking changes and informing developers when such changes occur.

Example output when bootstrap detects a major change:
![image](https://github.com/rust-lang/rust/assets/39852038/ee802dfa-a02b-488b-a433-f853ce079b8a)
2023-10-02 07:41:52 +00:00
Nicholas Nethercote
17e3793eb1 Name some local variables more consistently.
By making every `alt_foo` exactly match a `foo`.
2023-10-02 09:12:47 +11:00
bors
e0d7ed1f45 Auto merge of #116281 - Nadrieril:eager-const-eval, r=cjgillot
Cleanup number handling in match exhaustiveness

Doing a little bit of cleanup; handling number constants was somewhat messy. In particular, this:

- evals float consts once instead of repetitively
- reduces `Constructor` from 88 bytes to 56 (`mir::Const` is big!)

The `fast_try_eval_bits` function was mostly constructed from inlining existing code but I don't fully understand it; I don't follow how consts work and are evaluated very well.
2023-10-01 22:01:44 +00:00
Nadrieril
eac7bcde5f Move eval_bits optimization upstream 2023-10-01 21:12:24 +02:00
bors
0e1dd179f1 Auto merge of #116259 - nnethercote:entry_point_type, r=cjgillot
Factor out duplicated `entry_point_type` functions

A small but nice cleanup.
2023-10-01 18:27:00 +00:00
bors
16b7b39fdd Auto merge of #116228 - bvanjoi:fix-116164, r=cjgillot
resolve: skip underscore character during candidate lookup

Fixes #116164

In use statement, an underscore is merely a placeholder symbol and does not bind to any name. Therefore, it can be safely ignored.
2023-10-01 16:41:03 +00:00
bors
6c29b45439 Auto merge of #116224 - nnethercote:rustc_arena-overhaul, r=cjgillot
`rustc_arena` overhaul

I find the `rustc_arena` a bit hard to read. These commits make it better.

r? `@cjgillot`
2023-10-01 14:38:51 +00:00
onur-ozkan
957de61594 implement major change tracking for the bootstrap configuration
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-01 16:54:52 +03:00
Nicholas Nethercote
2369adc5d8 Remove unnecessary pubs. 2023-10-01 21:57:09 +11:00
Nicholas Nethercote
ddb742225a Rename two parsing closures.
To match `parse_address_space` and `parse_bits` above.
2023-10-01 21:57:09 +11:00
Nicholas Nethercote
86ecfdd605 Minor comment and whitespace tweaks. 2023-10-01 21:57:06 +11:00
Nicholas Nethercote
7326cd98b9 Factor out the two entry_point_type functions.
They are very similar, and each one has a comment about the importance
of being kept in sync with the other. This commit removes the
duplication.
2023-10-01 20:45:09 +11:00
bors
8fa7bdf191 Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum
Partially outline code inside the panic! macro

This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-10-01 05:56:47 +00:00
Nadrieril
0a6d794d0b Cleanup number literal evaluation 2023-10-01 00:00:38 +02:00
Nadrieril
d6e9b321b3 No need to carry bias in IntRange 2023-10-01 00:00:38 +02:00
Nadrieril
fac50e8fb3 Evaluate float consts eagerly 2023-10-01 00:00:37 +02:00
bors
75d731eee9 Auto merge of #116254 - WaffleLapkin:nicen-traversal, r=cjgillot
Assorted improvements for `rustc_middle::mir::traversal`

r? `@cjgillot`

I'm not _entirely_ sure about all changes, although I do like all of them. If you'd like I can drop some commits. Best reviewed on a commit-by-commit basis, I think, since they are fairly isolated.
2023-09-30 12:38:12 +00:00
bors
9136560d32 Auto merge of #115933 - oli-obk:simd_shuffle_const, r=workingjubilee
Prototype using const generic for simd_shuffle IDX array

cc https://github.com/rust-lang/rust/issues/85229

r? `@workingjubilee` on the design

TLDR: there is now a `fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;` intrinsic that allows replacing

```rust
simd_shuffle(a, b, const { stuff })
```

with

```rust
simd_shuffle_generic::<_, _, {&stuff}>(a, b)
```

which makes the compiler implementations much simpler, if we manage to at some point eliminate `simd_shuffle`.

There are some issues with this today though (can't do math without bubbling it up in the generic arguments). With this change, we can start porting the simple cases and get better data on the others.
2023-09-30 04:05:26 +00:00
Matthias Krüger
26be5754c6
Rollup merge of #116024 - ouz-a:smir_region, r=oli-obk
Implement Region for smir

Adds Region and it's relevant types to smir and covers them with stable implementation

r? `@oli-obk`
2023-09-29 22:27:50 +02:00
Matthias Krüger
4a886462c9
Rollup merge of #112123 - bvanjoi:fix-98562, r=compiler-errors
fix(suggestion): insert projection to associated types

Fixes #98562

This PR has fixed some help suggestions for unsupported syntax, such as `fn f<T>(_:T) where T: IntoIterator, std::iter::IntoIterator::Item = () {}` to `fn f<T: IntoIterator<Item = ()>>(_T) {}`.
2023-09-29 22:27:49 +02:00
Maybe Waffle
814fbd89b6 Remove deleted docs + better link together MIR traversing docs 2023-09-29 19:16:02 +00:00
bors
56ada88e7e Auto merge of #113301 - Be-ing:stabilize_bundle_whole-archive, r=petrochenkov
stabilize combining +bundle and +whole-archive link modifiers

Per discussion on https://github.com/rust-lang/rust/issues/108081 combining +bundle and +whole-archive already works and can be stabilized independently of other aspects of the packed_bundled_libs feature. There is no risk of regression because this was not previously allowed.

r? `@petrochenkov`
2023-09-29 15:51:48 +00:00
bors
c5450191f3 Auto merge of #115759 - oli-obk:open_drop_from_non-ADT, r=lcnr
Reveal opaque types before drop elaboration

fixes https://github.com/rust-lang/rust/issues/113594

r? `@cjgillot`

cc `@JakobDegen`

This pass was introduced in https://github.com/rust-lang/rust/pull/110714

I moved it before drop elaboration (which only cares about the hidden types of things, not the opaque TAIT or RPIT type) and set it to run unconditionally (instead of depending on the optimization level and whether the inliner is active)
2023-09-29 11:59:51 +00:00
bohan
b83dfb5c5a fix(suggestion): insert projection to associated types 2023-09-29 18:51:59 +08:00
Matthias Krüger
95262e4602
Rollup merge of #116253 - asquared31415:adt_const_params_feature, r=compiler-errors
Make `adt_const_params` feature suggestion consistent with other features and improve when it is emitted

Makes the suggestion to add `adt_const_params` formatted like every other feature gate (notably this makes it such that the playground recognizes it). Additionally improves the situations in which that help is emitted so that it's only emitted when the type would be valid or the type *could* be valid (using a slightly incorrect heuristic that favors suggesting the feature over not) instead of, for example, implying that adding the feature would allow the use of `String`.

Also adds the "the only supported types are integers, `bool` and `char`" note to the errors on fn and raw pointers.

r? `@compiler-errors`
2023-09-29 10:11:15 +02:00
Matthias Krüger
4f09f80bcf
Rollup merge of #116239 - cjgillot:issue-116212, r=WaffleLapkin
Only visit reachable nodes in SsaLocals.

Fixes https://github.com/rust-lang/rust/issues/116212
2023-09-29 10:11:14 +02:00
Matthias Krüger
0c45018473
Rollup merge of #116231 - DaniPopes:simpler-lint-array, r=Nilstrieb
Remove `rustc_lint_defs::lint_array`
2023-09-29 10:11:13 +02:00
Matthias Krüger
e814f1e3c0
Rollup merge of #116201 - Jarcho:noop_fix, r=fee1-dead
Fix `noop_method_call` detection

This needs to be merged before #116198 can compile. The error occurs before the compiler is built so this needs to be a separate PR.
2023-09-29 10:11:12 +02:00
Nicholas Nethercote
373cc2160a Change depth arg to at_root.
This will facilitate a subsequent refactoring.
2023-09-29 17:49:16 +10:00
bors
c1f86f0bc8 Auto merge of #116089 - estebank:issue-115992-2, r=compiler-errors
When suggesting `self.x` for `S { x }`, use `S { x: self.x }`

Fix #115992.

r? `@compiler-errors`

Follow up to #116086.
2023-09-29 05:45:18 +00:00
bors
a327e753bc Auto merge of #115986 - onur-ozkan:fix-cross-compilation-lto-problem, r=wesleywiser
allow LTO on `proc-macro` crates with `-Zdylib-lto`

ref https://github.com/rust-lang/rust/pull/115986#issuecomment-1732316361

Fixes #110296
2023-09-29 03:57:17 +00:00
bors
60bb5192d1 Auto merge of #115843 - lcnr:bb-provisional-cache, r=compiler-errors
new solver: remove provisional cache

The provisional cache is a performance optimization if there are large, interleaving cycles. Such cycles generally do not exist. It is incredibly complex and unsound in all trait solvers which have one: the old solver, chalk, and the new solver ([link](https://github.com/rust-lang/rust/blob/master/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs)).

Given the assumption that it is not perf-critical and also incredibly complex, remove it from the new solver, only checking whether a goal is on the stack. While writing this, I uncovered two additional soundness bugs, see the inline comments for them.

r? `@compiler-errors`
2023-09-29 02:09:40 +00:00