Commit Graph

16056 Commits

Author SHA1 Message Date
bors
e1b28cd2f1 Auto merge of #100740 - Dylan-DPC:rollup-0td6yq4, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #99576 (Do not allow `Drop` impl on foreign fundamental types)
 - #100081 (never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn))
 - #100208 (make NOP dyn casts not require anything about the vtable)
 - #100494 (Cleanup rustdoc themes)
 - #100522 (Only check the `DefId` for the recursion check in MIR inliner.)
 - #100592 (Manually implement Debug for ImportKind.)
 - #100598 (Don't fix builtin index when Where clause is found)
 - #100721 (Add diagnostics lints to `rustc_type_ir` module)
 - #100731 (rustdoc: count deref and non-deref as same set of used methods)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-19 18:45:41 +00:00
bors
468887ef91 Auto merge of #100209 - cjgillot:source-file-index, r=estebank
Lazily decode SourceFile from metadata

Currently, source files from foreign crates are decoded up-front from metadata.
Spans from those crates were matched with the corresponding source using binary search among those files.

This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
2022-08-19 15:31:25 +00:00
Dylan DPC
30e65cea07
Rollup merge of #100721 - JhonnyBillM:enable-diag-lint-in-type-ir, r=compiler-errors
Add diagnostics lints to `rustc_type_ir` module

Module is complete. It doesn’t have any diagnostics.
2022-08-19 12:26:46 +05:30
Dylan DPC
490d04bfbc
Rollup merge of #100598 - ouz-a:91633, r=compiler-errors
Don't fix builtin index when Where clause is found

Where clause shadows blanket impl for `Index` which causes normalization to not occur, which causes ICE to happen when we typeck.

r? `@compiler-errors`

Fixes #91633
2022-08-19 12:26:45 +05:30
Dylan DPC
769ad70129
Rollup merge of #100592 - cjgillot:debug-import-kind, r=TaKO8Ki
Manually implement Debug for ImportKind.

This avoids crashing due to an infinite loop when running with `RUSTC_LOG=rustc_resolve`.
2022-08-19 12:26:44 +05:30
Dylan DPC
d83abe8c12
Rollup merge of #100522 - cjgillot:inline-polymorphic-recursion, r=tmiasko
Only check the `DefId` for the recursion check in MIR inliner.

The current history check compares `Instance`s, so it cannot detect cases of polymorphic recursion where `Substs` change.
This PR makes it so we only compare `DefId`s, ignoring any change in `Substs`.

According to https://github.com/rust-lang/rust/pull/100522#issuecomment-1214769757, in practice only very few inlining decisions change.

Fixes https://github.com/rust-lang/rust/issues/100476
2022-08-19 12:26:43 +05:30
Dylan DPC
c4707ff8ef
Rollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkov
make NOP dyn casts not require anything about the vtable

As suggested [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/dyn-upcasting.20stabilization/near/292151439). This matches what the codegen backends already do, and what Miri did do until https://github.com/rust-lang/rust/pull/99420 when I made it super extra paranoid.
2022-08-19 12:26:41 +05:30
Dylan DPC
2fe2975391
Rollup merge of #100081 - RalfJung:unused-unsafe-in-unsafe-fn, r=jackh726
never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn)

Judging from https://github.com/rust-lang/rust/issues/71668#issuecomment-1200317370 the consensus nowadays seems to be that we should never consider an unsafe block unused if it was required with `deny(unsafe_op_in_unsafe_fn)`, no matter whether that lint is actually enabled or not. So let's adjust rustc accordingly.

The first commit does the change, the 2nd does some cleanup.
2022-08-19 12:26:40 +05:30
Dylan DPC
078844283c
Rollup merge of #99576 - compiler-errors:foreign-fundamental-drop-is-bad, r=TaKO8Ki
Do not allow `Drop` impl on foreign fundamental types

`Drop` should not be implemented on `Pin<T>` even if `T` is local.

This does not trigger regular orphan rules is because `Pin` is `#[fundamental]`... but we don't allow specialized `Drop` impls anyways, so these rules are not sufficient to prevent this impl on stable. Let's just choose even stricter rules, since we shouldn't be implementing `Drop` on a foreign ADT ever.

Fixes #99575
2022-08-19 12:26:38 +05:30
bors
71ecf5d359 Auto merge of #98851 - klensy:encode_symbols, r=cjgillot
rustc_metadata: dedupe strings to prevent multiple copies in rmeta/query cache blow file size

r? `@cjgillot`

Encodes strings in rmeta/query cache so duplicated ones will be encoded as offsets to first strings, reducing file size.
2022-08-18 23:53:22 +00:00
Andy Wang
84a199369b
Reword "Required because of the requirements on the impl of ..." 2022-08-18 21:08:08 +01:00
Jhonny Bill Mena
05ed13b476 ADD - diagnostic lints to type_ir
Module is completed because it doesn’t have any diagnostics
2022-08-18 13:33:03 -04:00
bors
8064a49508 Auto merge of #99860 - oli-obk:revert_97346, r=pnkfelix
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, …

…r=oli-obk"

This reverts commit c703d11dcc, reversing
changes made to 64eb9ab869.

it didn't apply cleanly, so now it works the same for RPIT and for TAIT instead of just working for RPIT, but we should keep those in sync anyway. It also exposed a TAIT bug (see the feature gated test that now ICEs).

r? `@pnkfelix`

fixes #99536
2022-08-18 15:41:30 +00:00
bors
361c599fee Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay
Don't derive `PartialEq::ne`.

Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums
and empty structs, thus reyling on the default `ne`. This behaviour is
unnecessarily conservative, because the `PartialEq` docs say this:

> Implementations must ensure that eq and ne are consistent with each other:
>
> `a != b` if and only if `!(a == b)` (ensured by the default
> implementation).

This means that the default implementation (`!(a == b)`) is always good
enough. So this commit changes things such that `ne` is never derived.

The motivation for this change is that not deriving `ne` reduces compile
times and binary sizes.

Observable behaviour may change if a user has defined a type `A` with an
inconsistent `PartialEq` and then defines a type `B` that contains an
`A` and also derives `PartialEq`. Such code is already buggy and
preserving bug-for-bug compatibility isn't necessary.

Two side-effects of the change:
- There is only one error message produced for types where `PartialEq`
  cannot be derived, instead of two.
- For coverage reports, some warnings about generated `ne` methods not
  being executed have disappeared.

Both side-effects seem fine, and possibly preferable.
2022-08-18 10:11:11 +00:00
Matthias Krüger
c7a4942588
Rollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser
`ty::Error` does not match other types for region constraints

Fixes #100684
2022-08-18 05:10:51 +02:00
Matthias Krüger
3de034d401
Rollup merge of #100674 - PragmaTwice:mig-typeck-unused-crate-diag, r=davidtwco
Migrate lint reports in typeck::check_unused to LintDiagnostic

In this PR, I migrate two lint reports in `typeck::check_unused` by `LintDiagnostic`, all of which is about extern crates.

```@rustbot``` label +A-translation
r? rust-lang/diagnostics
2022-08-18 05:10:50 +02:00
Matthias Krüger
5548e585c1
Rollup merge of #100670 - Xiretza:parser-stmt-force-collect-docs, r=davidtwco
Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery

Something seems to have gotten out of sync during the creation of #81177, where both the argument and comment were introduced.
2022-08-18 05:10:49 +02:00
Matthias Krüger
3e057d1512
Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino
Attribute cleanups

r? `@ghost`
2022-08-18 05:10:48 +02:00
Matthias Krüger
8b180ed3c0
Rollup merge of #100651 - nidnogg:diagnostics_migration_expand_transcribe, r=davidtwco
Migrations for rustc_expand transcribe.rs

This PR includes some migrations to the new diagnostics API for the `rustc_expand` module.
r? ```@davidtwco```
2022-08-18 05:10:47 +02:00
Matthias Krüger
b295639f14
Rollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-another-type, r=estebank
Point at a type parameter shadowing another type

This patch fixes a part of #97459.
2022-08-18 05:10:46 +02:00
Matthias Krüger
092f4600bb
Rollup merge of #99966 - RalfJung:try-dont-panic, r=lcnr
avoid assertion failures in try_to_scalar_int

Given that this is called `try_to_scalar_int`, we probably shouldn't `assert_int` here. Similarly `try_to_bits` also doesn't `assert!` that the size is correct.

Also add some `track_caller` for debugging, while we are at it.

r? ```@oli-obk```
2022-08-18 05:10:42 +02:00
Matthias Krüger
370bf1543d
Rollup merge of #97962 - eholk:drop-tracking-must-not-suspend, r=cjgillot
Make must_not_suspend lint see through references when drop tracking is enabled

See #97333.

With drop tracking enabled, sometimes values that were previously linted are now considered dropped and not linted. This change makes must_not_suspend traverse through references to still catch these values.

Unfortunately, this leads to duplicate warnings in some cases (e.g. [dedup.rs](9a74608543/src/test/ui/lint/must_not_suspend/dedup.rs (L4))), so we only use the new behavior when drop tracking is enabled.

cc ``@guswynn``
2022-08-18 05:10:41 +02:00
Camille GILLOT
86645c9cf7 Ignore substs when checking inlining history. 2022-08-17 19:25:09 +02:00
Michael Goulet
fc7fc0fae5 ty::Error does not match other types for region constraints 2022-08-17 17:23:52 +00:00
nidnogg
a468f13162 Hotfix for duplicated slug name on VarStillRepeating struct 2022-08-17 13:13:07 -03:00
nidnogg
caab20c431 Moved structs to rustc_expand::errors, added several more migrations, fixed slug name 2022-08-17 11:20:37 -03:00
nidnogg
c6f9a9c410 Moved structs to rustc_expand::errors, added several more migrations, fixed slug name 2022-08-17 11:18:19 -03:00
PragmaTwice
9efe979511 remove #[primary_span] 2022-08-17 22:08:06 +08:00
Twice
52418d661b
use suggestion_short in LintDiagnostic
Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
2022-08-17 20:45:18 +08:00
Matthias Krüger
6eed54a2c9
Rollup merge of #100652 - compiler-errors:no-defer-sized-checks, r=TaKO8Ki
Remove deferred sized checks (make them eager)

Improves diagnostics spans... this doesn't seem to be the case anymore:

```rust
// Some additional `Sized` obligations badly affect type inference.
// These obligations are added in a later stage of typeck.
pub(super) deferred_sized_obligations:
        RefCell<Vec<(Ty<'tcx>, Span, traits::ObligationCauseCode<'tcx>)>>,
```
2022-08-17 12:32:57 +02:00
Matthias Krüger
c0297e2330
Rollup merge of #100646 - finalchild:emoji-diag, r=compiler-errors
Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface

* Migrate emoji identifier diagnostics to `interface_ferris_identifier` and `interface_emoji_identifier`.

This is my first PR! I'm learning how to migrate these diagnostics. Thanks in advance.

r? rust-lang/diagnostics
2022-08-17 12:32:56 +02:00
Matthias Krüger
64cd65758c
Rollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi

Similar to 89582e8193, but for ARMv4t.
Pre-v6 ARM target does not have atomic CAS, except for Linux and Android where atomic CAS is provided by compiler-builtins. So, there is a similar issue as thumbv6m.

I have confirmed that enabling the `atomics-32` target feature fixes the problem in the project affected by this issue. (https://github.com/taiki-e/portable-atomic/pull/28#discussion_r946604136)

Closes #100619

r? ``@nikic``
cc ``@Lokathor``
2022-08-17 12:32:55 +02:00
Matthias Krüger
d956734f9f
Rollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki
needless separation of impl blocks
2022-08-17 12:32:54 +02:00
Matthias Krüger
1e93994b4d
Rollup merge of #100489 - lcnr:is_knowable-Result, r=davidtwco
`is_knowable` use `Result` instead of `Option`
2022-08-17 12:32:52 +02:00
Matthias Krüger
1948288615
Rollup merge of #100389 - compiler-errors:return-type-suggestion-cycle, r=cjgillot
Do not report cycle error when inferring return type for suggestion

The UI test is a good example of a case where this happens. The cycle is due to needing the value of the return type `-> _` to compute the variances of items in the crate, but then needing the variances of the items in the crate to do typechecking to infer what `-> _`'s real type is.

Since we're already gonna emit an error in astconv, just delay the cycle bug as an error.
2022-08-17 12:32:51 +02:00
Matthias Krüger
989e4ffc7c
Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
triagebot: add translation-related mention groups

- Move some code around so that triagebot can ping relevant parties when translation logic is modified.
- Add mention groups to triagebot for translation-related files/folders.
- Auto-label pull requests with changes to translation-related files/folders with `A-translation`.

r? `@Mark-Simulacrum`
2022-08-17 12:32:50 +02:00
Matthias Krüger
d5dca26a94
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Clean up `LitKind`

r? ``@petrochenkov``
2022-08-17 12:32:49 +02:00
Matthias Krüger
bb77336c0a
Rollup merge of #99972 - RalfJung:1zst, r=lcnr
interpret: only consider 1-ZST when searching for receiver

`repr(transparent)` currently entirely rejects ZST with alignment larger than 1 (which is odd, arguably [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=02870f29396fa948c3123cb53d869ad1) should be accepted), so this should be safe. And if it ever isn't safe then that is very likely a bug elsewhere in the compiler.
2022-08-17 12:32:48 +02:00
PragmaTwice
98fb65eff9 Migrate lint reports in typeck::check_unused to LintDiagnostic 2022-08-17 17:47:44 +08:00
ouz-a
7b45718484 pass when where clause found 2022-08-17 12:25:52 +03:00
Xiretza
d3bf103d1b Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery
Something seems to have gotten out of sync during the creation of #81177,
where both the argument and comment were introduced.
2022-08-17 11:18:48 +02:00
lcnr
1cede2c126 is_knowable use Result instead of Option 2022-08-17 10:17:54 +02:00
Nicholas Nethercote
6cd40d0e51 Remove attrs arg from typaram and mk_ty_param.
Because it's always empty.
2022-08-17 12:33:42 +10:00
Nicholas Nethercote
2c24958cfd Remove TraitDef::attributes.
Because it's always empty.
2022-08-17 12:29:02 +10:00
Michael Goulet
33212bf7f5 Remove deferred sized checks 2022-08-16 22:30:56 +00:00
nidnogg
72ce216def Previous commit under x.py fmt 2022-08-16 19:19:59 -03:00
nidnogg
be18a9bf75 Migrated more diagnostics under transcribe.rs 2022-08-16 19:02:51 -03:00
nidnogg
7e15fbab75 Added first migration for repeated expressions without syntax vars 2022-08-16 18:34:13 -03:00
bors
86c6ebee8f Auto merge of #100644 - TaKO8Ki:rollup-n0o6a1t, r=TaKO8Ki
Rollup of 4 pull requests

Successful merges:

 - #100243 (Remove opt_remap_env_constness from rustc_query_impl)
 - #100625 (Add `IpDisplayBuffer` helper struct.)
 - #100629 (Use `merged_ty` method instead of rewriting it every time)
 - #100630 (rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-16 21:10:08 +00:00
Takayuki Maeda
033387a6af
Rollup merge of #100629 - GuillaumeGomez:merged-ty, r=compiler-errors
Use `merged_ty` method instead of rewriting it every time

`merged_ty` [source code](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/check/coercion.rs.html#1331-1333) is quite literally the same, so instead of rewriting it, makes more sense to use the method instead.

r? `@compiler-errors`
2022-08-17 05:08:04 +09:00