Commit Graph

23563 Commits

Author SHA1 Message Date
DaniPopes
677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
Dylan DPC
97921abc06
Rollup merge of #110124 - Nilstrieb:📎-told-me-so, r=compiler-errors
Some clippy fixes in the compiler

Best reviewed commit-by-commit 📎.
2023-04-10 14:13:16 +05:30
Dylan DPC
b8725520af
Rollup merge of #110021 - scottmcm:fix-110005, r=compiler-errors
Fix a couple ICEs in the new `CastKind::Transmute` code

Check the sizes of the immediates, rather than the overall types, when deciding whether we can convert types without going through memory.

Fixes #110005
Fixes #109992
Fixes #110032
cc `@matthiaskrgr`
2023-04-10 14:13:14 +05:30
lcnr
3fab7f7c13 review + some small stuff 2023-04-10 09:21:21 +02:00
lcnr
2186847f28 move structural_traits into assembly 2023-04-10 09:18:47 +02:00
lcnr
2b0f5721c1 prioritize param-env candidates 2023-04-10 09:16:33 +02:00
bors
3c2e2dd5c5 Auto merge of #110127 - matthiaskrgr:rollup-6ui12x5, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #108843 (Instantiate instead of erasing binder when probing param methods)
 - #109985 (Add little `is_test_crate` function)
 - #110028 (Migrate `rustc_hir_analysis` to session diagnostic [Part 3])
 - #110095 (Migrate remainder of rustc_ty_utils to `SessionDiagnostic`)
 - #110108 (Add renaming of ignore-git to changelog)
 - #110114 (compiletest: Give a better error message if `node` isn't installed)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-10 01:57:51 +00:00
Matthias Krüger
f4827459f8
Rollup merge of #110095 - matthewjasper:ty-utils-diagnostics, r=compiler-errors
Migrate remainder of rustc_ty_utils to `SessionDiagnostic`

This moves the remaining errors in `rust_ty_utils` to `SessionsDiagnostic`.

r? ``@davidtwco``
2023-04-09 23:40:05 +02:00
Matthias Krüger
164d70dc7a
Rollup merge of #110028 - obeis:hir-analysis-migrate-diagnostics-3, r=compiler-errors
Migrate `rustc_hir_analysis` to session diagnostic [Part 3]

Part 3: Finishing `collect.rs` file

r? ``@compiler-errors``
2023-04-09 23:40:04 +02:00
Matthias Krüger
3dfda2c72f
Rollup merge of #109985 - blyxyas:is_test_crate, r=compiler-errors
Add little `is_test_crate` function

Ok, this is quite a story.
I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](https://github.com/rust-lang/rust-clippy/pull/10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such).

As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic...

I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that.

Then, I stumbled on [this function right here](2e486be8d2/compiler/rustc_driver_impl/src/lib.rs (L174-L181)), and noticed the argument `config: Config`. That's a hint.

So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`.

This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
2023-04-09 23:40:04 +02:00
Matthias Krüger
4e165c1c99
Rollup merge of #108843 - compiler-errors:non_lifetime_binders-method-probe, r=jackh726
Instantiate instead of erasing binder when probing param methods

Fixes #108836

There is a really old comment saying that a `WhereClauseCandidate` probe candidate "should not contain any inference variables", but I'm not really confident that that comment applies anymore. In contrast, other candidates that we assemble during method probe contain inference variables in their substitutions (e.g. `InherentImplCandidate`)...

Since this change is made only to support a nightly feature, I'm happy to gate the new behavior behind this feature flag or discuss it further.

r? types
2023-04-09 23:40:03 +02:00
Nilstrieb
9fc1555f74 Remove turbofish 2023-04-09 23:32:04 +02:00
Nilstrieb
73417b1e15
Inline format_args
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09 23:29:39 +02:00
Nilstrieb
cab94d29ff fixup! Improve `Allocation::hash 2023-04-09 23:23:33 +02:00
Nilstrieb
5853c28a7f Simply Abi::fmt 2023-04-09 23:22:14 +02:00
Nilstrieb
e5defd0102 Convert manual loop into while let 2023-04-09 23:22:14 +02:00
Nilstrieb
4b4948c2e3 Remove identity casts 2023-04-09 23:22:14 +02:00
Nilstrieb
81c320ea77 Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
Nilstrieb
6fceb0f645 Improve `Allocation::hash
Exhaustively destructure and ignore `()`
2023-04-09 23:22:14 +02:00
Nilstrieb
5a90de8f5e Delete useless loop 2023-04-09 23:22:14 +02:00
Nilstrieb
1c75724752 Properly compare previously shadowed values
The shadowing lead to an incorrect comparison. Rename it and compare it
properly. compiler-errors told me that I should just include the fix
here without a test.
2023-04-09 23:22:14 +02:00
bors
696aaad58c Auto merge of #109760 - MaciejWas:struct-tuple-field-names-suggestion, r=jackh726
Better diagnostic when pattern matching tuple structs

Fixes #108284

When trying to pattern match a tuple struct we might get a flawed error message if there are missing fields. E.g.

```
let x = Foo(100, 200);
if let Foo { 0: bar } = x { ... }
```

Produces this error:

```
error[E0769]: tuple variant `Foo` written as struct variant
 --> hello.rs:5:12
  |
5 |     if let Foo { 0: foo } = x {
  |            ^^^^^^^^^^^^^^
  |
help: use the tuple variant pattern syntax instead
  |
5 |     if let Foo(_, _) = x {
  |               ~~~~~~
```

Which doesn't highlight that we can still use the struct syntax but we need to fill missing fields. This pr changes this error to:

```
error[E0027]: pattern does not mention field `1`
 --> hello.rs:5:12
  |
5 |     if let Foo { 0: foo } = x {
  |            ^^^^^^^^^^^^^^ missing field `1`
  |
help: include the missing field in the pattern
  |
5 |     if let Foo { 0: foo, 1: _ } = x {
  |                        ~~~~~~~~
help: if you don't care about this missing field, you can explicitly ignore it
  |
5 |     if let Foo { 0: foo, .. } = x {
  |                        ~~~~~~
```
2023-04-09 20:57:06 +00:00
Nilstrieb
07cd3826e0 Small clippy::correctness fixes
Nothing was really incorrect before, but it did get nicer.
2023-04-09 22:39:23 +02:00
Nilstrieb
0a0968b207 Allow modulo_one on function using cfg consts 2023-04-09 22:30:24 +02:00
Nilstrieb
968be98756 Allow clippy::from_mut_ref
This pattern is fine for arena allocators.
2023-04-09 22:29:56 +02:00
Nilstrieb
f00366d191 Box large enum variants 2023-04-09 21:59:28 +02:00
Nilstrieb
54e1309c65 Use HashMap entry APIs more 2023-04-09 21:59:28 +02:00
Nilstrieb
f058d05fc2 Some simple clippy::perf fixes 2023-04-09 21:59:28 +02:00
blyxyas
2c976765b8
Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
Scott McMurray
d757c4b904 Handle not all immediates having abi::Scalars 2023-04-09 11:16:50 -07:00
bors
7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
blyxyas
28e19f19aa
Add little is_test_crate function 2023-04-09 13:04:59 +02:00
bors
56e0626836 Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors
Suggest defining const parameter when appropriate

Helps a bit with #91119.
Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion.
It should be easier for newcomers to parse.

`@rustbot` label A-diagnostics
r? diagnostics
2023-04-09 10:54:04 +00:00
bors
709a97fffe Auto merge of #109173 - flba-eb:add-i586-qnx70-target, r=compiler-errors
Add tier 3 no_std x86 support for QNX Neutrino RTOS, version 7.0

This PR adds the target `i586-pc-nto-qnx700`, which targets QNX Neutrino RTOS version 7.0 on x86 32-bit targets.

cc: `@flba-eb` `@gh-tr`

This target falls under the umbrella of Tier 3 QNX Neutrino RTOS support documented in `nto-qnx.md` and previously started with #102701.
2023-04-09 07:36:53 +00:00
bors
7cd6f55323 Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #110058 (Remove `box_syntax` usage)
 - #110059 (ignore_git → omit_git_hash)
 - #110060 (Document that `&T` and `&mut T` are `Sync` if `T` is)
 - #110074 (Make the "codegen" profile of `config.toml` download and build llvm from source.)
 - #110086 (Add `max_line_length` to `.editorconfig`, matching rustfmt)
 - #110096 (Tweak tuple indexing suggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-09 05:00:24 +00:00
Yuki Okushi
eed27ac7f4
Rollup merge of #110096 - compiler-errors:tweak-tuple-idx-msg, r=Nilstrieb
Tweak tuple indexing suggestion

Fixes #110091
2023-04-09 12:35:56 +09:00
bors
0030465bcc Auto merge of #109413 - compiler-errors:pointer-like-abi, r=cjgillot
Enforce that `PointerLike` requires a pointer-like ABI

At least temporarily, let's ban coercing things that are pointer-sized and pointer-aligned but *not* `Abi::Scalar(..)` into `dyn*`. See: https://github.com/rust-lang/rust/pull/104694#discussion_r1142522073

This can be lifted in the future if we decie that we *want* to be able to coerce something `repr(C)` into a `dyn*`, but we'll have to figure out what to do with Miri and codegen...

r? compiler
2023-04-09 02:41:58 +00:00
bors
f8ed97ecc1 Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
fbc3457d35 Tweak tuple indexing suggestion 2023-04-08 21:32:55 +00:00
Michael Goulet
920c51c526 Enforce that PointerLike requires a pointer-like ABI 2023-04-08 21:11:16 +00:00
matthewjasper
8e76c76149
Update compiler/rustc_ty_utils/src/layout.rs
Fix formatting that rustfmt can't handle currently.

Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-08 21:40:33 +01:00
bors
af06dce64b Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber
Add ability to transmute (somewhat) with generic consts in arrays

Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.

This is done by normalizing the forms of expressions into sorted order of multiplied terms, which is not generic over all expressions, but should handle most cases.

This allows for some _basic_ transmutations between types that are equivalent in size without requiring additional stack space at runtime.

I only see one other location at which `SizeSkeleton` is being used, and it checks for equality so this shouldn't affect anywhere else that I can tell.

See [this Stackoverflow post](https://stackoverflow.com/questions/73085012/transmute-nested-const-generic-array-rust) for what was previously necessary to convert between types. This PR makes converting nested `T -> [T; 1]` transmutes possible, and `[uB*2; N] -> [uB; N * 2]` possible as well.

I'm not sure whether this is something that would be wanted, and if it is it definitely should not be insta-stable, so I'd add a feature gate.
2023-04-08 19:47:22 +00:00
Matthew Jasper
804e93871d Move SIMD layout errors to SessionDiagnostic 2023-04-08 20:28:32 +01:00
bors
dd2b19539e Auto merge of #109862 - klensy:llvm-dd, r=nikic
llvm: replace some deprecated functions, add fixmes

Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.
2023-04-08 15:57:59 +00:00
bors
66f8dd1255 Auto merge of #110069 - ndrewxie:issue-104212-fix, r=cjgillot
Switched provisional evaluation cache map to FxIndexMap, and replaced map.drain_filter with map.retain

Switching ProvisionalEvaluationCache's map field from FxHashMap to FxIndexMap was previously blocked because doing so caused performance regressions that could be mitigated by the stabilization of drain_filter for FxIndexMap (#104212). However, the only use of drain_filter can be replaced with a retain, so I made the modification and put in a PR to see if this causes a performance regression as well.

This PR is part of a broader effort (#84447) of removing iteration through FxHashMaps, as the iteration order is unstable and can cause issues in incremental compilation.
2023-04-08 11:20:58 +00:00
Vadim Petrochenkov
9da9373bf0 rustc_middle: Remove Option from module_reexports query 2023-04-08 13:29:16 +03:00
Vadim Petrochenkov
d11b9165ee resolve: Preserve reexport chains in ModChildren
This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use`
- preserving documentation comments on all reexports
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics
2023-04-08 13:29:15 +03:00
klensy
fdfca765a7 fixup: use Bool instead of bool 2023-04-08 12:15:26 +03:00
bors
131211acd2 Auto merge of #110043 - ickk:fix_infer_message, r=eholk
Fix help message for `infer_source_kind_subdiag_let`

I discovered there's a double "the" in the help message for E0282.
2023-04-08 03:26:54 +00:00
bors
0f0dc29264 Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb
Yeet `owning_ref`

Based on the discussions from https://github.com/rust-lang/rust/pull/109948

This replaces `owning_ref` with a far simpler & safer abstraction.

Fixes #109974
2023-04-08 01:08:26 +00:00