Commit Graph

3471 Commits

Author SHA1 Message Date
Deadbeef
04eec37dc2 Enable effects for libcore 2023-09-20 03:02:14 +00:00
bors
793d5eafc3 Auto merge of #115959 - nikic:update-llvm-13, r=cuviper
Update to LLVM 17.0.0

This rebases our LLVM fork to 17.0.0.

Fixes #115681.
2023-09-20 01:44:55 +00:00
WANG Rui
10d55c3e03 tests/ui/abi: Enable repr(transparent) union ABI tests on LoongArch64 2023-09-20 09:24:22 +08:00
Eduardo Sánchez Muñoz
85d61b01ae wrap fn sig binders in fn ptr 2023-09-19 21:15:58 +02:00
Guillaume Gomez
0060db74f9
Rollup merge of #115801 - compiler-errors:async-cycle-mono, r=oli-obk
Detect cycle errors hidden by opaques during monomorphization

Opaque types may reveal to projections, which themselves normalize to opaques. We don't currently normalize when checking that opaques are cyclical, and we may also not know that the opaque is cyclical until monomorphization (see `tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs`).

Detect cycle errors in `normalize_projection_ty` and report a fatal overflow (in the old solver). Luckily, this is already detected as a fatal overflow in the new solver.

Fixes #112047
2023-09-19 20:23:19 +02:00
Guillaume Gomez
edd7be59da
Rollup merge of #115499 - msizanoen1:riscv-fix-transparent-union-abi, r=bjorn3
rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member

This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function.

Fixes https://github.com/rust-lang/rust/issues/115481.

r? `@RalfJung`
2023-09-19 20:23:19 +02:00
Eduardo Sánchez Muñoz
c599761140 rustc_hir_analysis: add a helper to check function the signature mismatches
This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.
2023-09-19 18:15:23 +02:00
Matthew Jasper
b49140295c Add more if let guard tests 2023-09-19 12:48:40 +00:00
msizanoen
4d4c13bbd6 tests/ui/abi: Enable repr(transparent) union ABI tests on RISC-V 2023-09-19 12:22:45 +02:00
Guillaume Gomez
f1edecfaab
Rollup merge of #115924 - compiler-errors:non-exhaustive-1-zst, r=RalfJung
Don't complain on a single non-exhaustive 1-ZST

r? RalfJung, though you mentioned being busy, so feel free to reassign.

This doesn't actually attempt to make the diagnostic better, so when we have two non-exhaustive 1-ZSTs in a struct, we still just point to one. 🤷

Fixes #115922
2023-09-19 11:35:51 +02:00
Guillaume Gomez
c452090597
Rollup merge of #115625 - compiler-errors:hrtb-infer-err, r=b-naber
Explain HRTB + infer limitations of old solver

Add a helpful message when we hit the limitation of the old trait solver where we don't properly normalize GATs with infer vars + bound vars, leading to too-eagerly reporting trait errors that would be later satisfied due to inference.
2023-09-19 11:35:50 +02:00
Nikita Popov
531830cecd Update to LLVM 17.0.0
This rebases our LLVM fork to 17.0.0.

Fixes #115681.
2023-09-19 11:14:35 +02:00
Michael Goulet
fd36553aa7 Don't complain on a single non-exhaustive 1-zst 2023-09-19 06:01:24 +00:00
Michael Goulet
a30ad3a5a6 Don't resolve generic instances if they may be shadowed by dyn 2023-09-19 05:42:23 +00:00
Michael Goulet
976d377f7f Explain HRTB + infer limitations of old solver 2023-09-19 05:14:14 +00:00
Matthias Krüger
970ee09c22
Rollup merge of #115879 - clubby789:migrate-hir-typeck-cast, r=compiler-errors
Migrate diagnostics in `hir_typeck/src/cast.rs`
2023-09-19 01:29:42 +02:00
Matthias Krüger
48c605129b
Rollup merge of #115873 - BoxyUwU:tykind_adt_debug, r=oli-obk
Make `TyKind::Adt`'s `Debug` impl be more pretty

Currently `{:?}` on `Ty` for a `TyKind::Adt` would print as `Adt(Foo, [])`. This PR changes it to be `Foo` when there are no generics or `Foo<T>`/`Foo<T, U>` when there _are_ generics. Example from debug log:
`├─0ms DEBUG rustc_hir_analysis::astconv return=Bar<T/#0, U/#1>`

I should have done this in my initial PR for a prettier TyKind: Debug impl but I thought I would need to be accessing generics_of to figure out where in the "path" the generics would have to go??? but no, adts literally only have a single place the generics can go (on the end). Feel a bit silly about this :)

r? `@oli-obk`
2023-09-19 01:29:41 +02:00
Matthias Krüger
0eec5e3d0c
Rollup merge of #115869 - ferrocene:pa-fix-tests-cargo-remap, r=compiler-errors
Avoid blessing cargo deps's source code in ui tests

Before this PR, the source code of dependencies was included in UI test error messages whenever possible. Unfortunately, "whenever possible" means in some cases the source code wouldn't be injected, resulting in a test failure.

One such case is when `$CARGO_HOME` is remapped to something that is not present on disk [^1]. As the remapped path doesn't exist on disk, the source code wouldn't be showed in `tests/ui/issues/issue-21763.rs`:

```diff
    = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
 note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>`
   --> $HASHBROWN_SRC_LOCATION
-   |
-LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
-   |            ^^^^^^^
 note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
   --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
 note: required by a bound in `foo`
```

This PR fixes the problem by always hiding dependencies source code in the error messages generated during UI tests. This is implemented with a new internal flag, `-Z ignore-directory-in-diagnostics-source-blocks=$path`, which compiletest passes during UI tests. Once this is merged, remapping the Cargo home will be supported.

This PR is best reviewed commit-by-commit.

[^1]: After being puzzled for a bit, I discovered why this never impacted `rust-lang/rust`: we don't remap `$CARGO_HOME` 😅. Instead, we set `$CARGO_HOME` to `/cargo` in CI, which sort-of-but-not-really achieves the same effect.
2023-09-19 01:29:41 +02:00
bors
cebb9cfd4f Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
2023-09-18 19:41:21 +00:00
Eduardo Sánchez Muñoz
9102816bc4 Prevent using #[target_feature] on lang item functions 2023-09-18 20:11:01 +02:00
Boxy
b2bf4b66f8 make more pretty 2023-09-18 17:29:13 +01:00
Oli Scherer
1a01e57d27 Prototype using const generic for simd_shuffle IDX array 2023-09-18 15:10:28 +00:00
lcnr
e8b8ddd17e remove provisional cache 2023-09-18 17:01:29 +02:00
clubby789
c2841e2a1e Migrate 'cast to bool' diagnostic 2023-09-18 14:03:57 +00:00
bors
203c57dbe2 Auto merge of #115334 - RalfJung:transparent-aligned-zst, r=compiler-errors
repr(transparent): it's fine if the one non-1-ZST field is a ZST

This code currently gets rejected:
```rust
#[repr(transparent)]
struct MyType([u16; 0])
```
That clearly seems like a bug to me: `repr(transparent)` [got defined ](https://github.com/rust-lang/rust/issues/77841#issuecomment-716575747) as having any number of 1-ZST fields plus optionally one more field; `MyType` clearly satisfies that definition.

This PR changes the `repr(transparent)` logic to actually match that definition.
2023-09-17 15:20:44 +00:00
bors
db9c21fd94 Auto merge of #115909 - Dylan-DPC:rollup-uf96r2d, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #114965 (Remove Drop impl of mpsc Receiver and (Sync)Sender)
 - #115434 (make `Debug` impl for `ascii::Char` match that of `char`)
 - #115477 (Stabilize the `Saturating` type)
 - #115611 (add diagnostic for raw identifiers in format string)
 - #115654 (improve PassMode docs)
 - #115862 (Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-17 13:31:49 +00:00
Dylan DPC
f082f1dd30
Rollup merge of #115862 - clubby789:migrate-callee-translatable, r=compiler-errors
Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics
2023-09-17 11:23:26 +00:00
Dylan DPC
0c5f5b6db7
Rollup merge of #115654 - RalfJung:pass-mode-cast, r=compiler-errors
improve PassMode docs
2023-09-17 11:23:25 +00:00
Dylan DPC
0900712fe0
Rollup merge of #115611 - lukas-code:format!("{r#ident}"), r=compiler-errors
add diagnostic for raw identifiers in format string

Format strings don't support raw identifiers (e.g. `format!("{r#type}")`), but they do support keywords in the format string directly (e.g. `format!("{type}")`). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the `r#`.

fixes https://github.com/rust-lang/rust/issues/115466
2023-09-17 11:23:25 +00:00
Dylan DPC
7cbe7fa6bf
Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnay
Remove Drop impl of mpsc Receiver and (Sync)Sender

This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check.

This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-17 11:23:23 +00:00
bors
327e6cf55c Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, r=compiler-errors
`#[diagnostic::on_unimplemented]` without filters

This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-17 10:00:15 +00:00
bors
3ecc563628 Auto merge of #113748 - clarfonthey:ip-step, r=dtolnay
impl Step for IP addresses

ACP: rust-lang/libs-team#235

Note: since this is insta-stable, it requires an FCP.

Separating out from the bit operations PR since it feels logically disjoint, and so their FCPs can be separate.
2023-09-17 06:27:09 +00:00
Matthias Krüger
ab90d708da
Rollup merge of #115860 - Soveu:varargs2, r=WaffleLapkin
Enable varargs support for AAPCS calling convention

Welp, I was looking for a reason why this shouldn't be stabilized after so long... and here it is.
2023-09-16 15:18:23 +02:00
Matthias Krüger
53cd9783c5
Rollup merge of #115866 - RalfJung:interpret-debug, r=compiler-errors
make interpreter and TyAndLayout type Debug impl independent of Ty debug impl

This fixes some (but not all) of the fallout from https://github.com/rust-lang/rust/pull/115661.

Second commit is taken from https://github.com/rust-lang/rust/pull/107084 (and slightly adjusted); I preserved the original git author information.
2023-09-16 11:48:18 +02:00
bors
790309b102 Auto merge of #115315 - RalfJung:field-capture-packed-alignment, r=oli-obk
closure field capturing: don't depend on alignment of packed fields

This fixes the closure field capture part of https://github.com/rust-lang/rust/issues/115305: field capturing always stops at projections into packed structs, no matter the alignment of the field. This means changing a private field type from `u8` to `u64` can never change how closures capture fields, which is probably what we want.

Here's an example where, before this PR, changing the type of a private field in a repr(Rust) struct can change the output of a program:

```rust
#![allow(dead_code)]

mod m {
    // before patch
    #[derive(Default)]
    pub struct S1(u8);
    // after patch
    #[derive(Default)]
    pub struct S2(u64);
}

struct NoisyDrop;
impl Drop for NoisyDrop {
    fn drop(&mut self) {
        eprintln!("dropped!");
    }
}

#[repr(packed)]
struct MyType {
    field: m::S1, // output changes when this becomes S2
    other_field: NoisyDrop,
    third_field: Vec<()>,
}

fn test(r: MyType) {
    let c = || {
        let _val = std::ptr::addr_of!(r.field);
        let _val = r.third_field;
    };
    drop(c);
    eprintln!("before dropping");
}

fn main() {
    test(MyType {
        field: Default::default(),
        other_field: NoisyDrop,
        third_field: Vec::new(),
    });
}
```

Of course this is a breaking change for the same reason that doing field capturing in the first place was a breaking change. Packed fields are relatively rare and depending on drop order is relatively rare, so I don't expect this to have much impact, but it's hard to be sure and even a crater run will only tell us so much.

Also see the [nomination comment](https://github.com/rust-lang/rust/pull/115315#issuecomment-1702807825).

Cc `@rust-lang/wg-rfc-2229` `@ehuss`
2023-09-16 05:29:23 +00:00
ltdk
8184c9c50d impl Step for IP addresses 2023-09-16 01:28:13 -04:00
bors
635c4a5e61 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
Make useless_ptr_null_checks smarter about some std functions

This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc.

This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`).

Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null.

Follow-up of PR #113657

Fixes #114442
2023-09-16 03:40:20 +00:00
Boxy
71cab64079 special case TyAndLayout debug impl 2023-09-15 22:57:07 +02:00
clubby789
6e2adbf6a3 Migrate 'explicit destructor call' diagnostic 2023-09-15 14:24:58 +00:00
Pietro Albini
c230637b92
avoid blessing cargo deps's source code in ui tests 2023-09-15 16:22:52 +02:00
Ralf Jung
89139d4c46 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Michael Goulet
280f058560 Canonicalize effect vars in new solver 2023-09-15 05:11:16 +00:00
bors
ae9465fee3 Auto merge of #115859 - compiler-errors:effect-fallback, r=fee1-dead
Fallback effects even if types also fallback

`||` is short circuiting, so if we do ty/int var fallback, we *don't* do effect fallback 😸

r? `@fee1-dead` or `@oli-obk`

Fixes #115791
Fixes #115842
2023-09-15 00:05:28 +00:00
Soveu
eea6149e03 Enable varargs support for AAPCS calling convention
This is the default calling convention for ARM - it is used for extern "C",
therefore it supports varargs.
2023-09-14 23:21:39 +02:00
Michael Goulet
5c907a7859 Fallback effects even if types also fall back 2023-09-14 21:08:42 +00:00
Ralf Jung
9ac8b363e3 don't point at const usage site for resolution-time errors
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Ralf Jung
89ac57db4d move required_consts check to general post-mono-check function 2023-09-14 22:30:42 +02:00
bors
dac91a82e1 Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling

- Move all of the checks for valid let expression positions to parsing.
- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location.
- Suppress some later errors and MIR construction for invalid let expressions.
- Fix a (drop) scope issue that was also responsible for #104172.

Fixes #104172
Fixes #104868
2023-09-14 19:56:55 +00:00
Matthias Krüger
9362604518
Rollup merge of #115844 - oli-obk:opaque_lifetime_ambiguity, r=jackh726
Paper over an accidental regression

r? types

cc https://github.com/rust-lang/rust/issues/115781 (do not close issue until beta backport has been performed)

The PR reasons are explained with comments in the source.

In order to keep the diff simple, this PR effectively reverts https://github.com/rust-lang/rust/pull/113661, but only for RPITs. I will submit a follow up PR that fixes this correctly instead of just disabling the newly added check for RPITs. This PR should be significantly easier to review for beta backport
2023-09-14 19:12:33 +02:00
Matthias Krüger
57370828b9
Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726
Properly consider binder vars in `HasTypeFlagsVisitor`

Given a PolyTraitRef like `for<'a> Ty: Trait` (where neither `Ty` nor `Trait` mention `'a`), we do *not* return true for `.has_type_flags(TypeFlags::HAS_LATE_BOUND)`, even though binders are supposed to act as if they have late-bound vars even if they don't mention them in their bound value: 31ae3b2bdb. This is because we use `HasTypeFlagsVisitor`, which only computes the type flags for `Ty`, `Const` and `Region` and `Predicates`, and we consequently skip any binders (and setting flags for their vars) that are not contained in one of these types.

This ends up causing a problem, because when we call `TyCtxt::erase_regions` (which both erases regions *and* anonymizes bound vars), we will skip such a PolyTraitRef, not anonymizing it, and therefore not making it structurally equal to other binders. This breaks vtable computations.

This PR computes the flags for all binders we enter in `HasTypeFlagsVisitor` if we're looking for `TypeFlags::HAS_LATE_BOUND` (or `TypeFlags::HAS_{RE,TY,CT}_LATE_BOUND`).

Fixes #115807
2023-09-14 19:12:32 +02:00
Matthias Krüger
3dbcc28884
Rollup merge of #115832 - Zalathar:fix-no-coverage, r=oli-obk
Fix the error message for `#![feature(no_coverage)]`

When #114656 was written, the feature flag to replace `no_coverage` was originally spelled `coverage`, but it was eventually changed to `coverage_attribute` instead.

That update happened to miss this error message in `removed.rs`, and unfortunately I only noticed just *after* the original PR was approved and merged.

cc ``@bossmc`` (original author) ``@oli-obk`` (original reviewer)
``@rustbot`` label +A-code-coverage
2023-09-14 19:12:32 +02:00
Oli Scherer
0277184977 Paper over an accidental regression 2023-09-14 15:16:48 +00:00
bors
df63c5f140 Auto merge of #112038 - Nemo157:edition-2024-unsafe_op_in_unsafe_fn, r=RalfJung
Change `unsafe_op_in_unsafe_fn` to be `warn`-by-default from edition 2024

This was previously FCPed: https://github.com/rust-lang/rust/issues/71668#issuecomment-1189396886

There were two blocking requirements:
* Fix the `unused_unsafe` lint, done in https://github.com/rust-lang/rust/pull/100081
* Have `cargo fix` able to fix the lint, done in https://github.com/rust-lang/rust/pull/112017
2023-09-14 11:52:08 +00:00
bors
d97e04fbfc Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obk
some ConstValue refactoring

In particular, use AllocId instead of Allocation in ConstValue::ByRef. This helps avoid redundant AllocIds when a  `ByRef` constant gets put back into the interpreter.

r? `@oli-obk`

Fixes https://github.com/rust-lang/rust/issues/105536
2023-09-14 10:04:45 +00:00
Ralf Jung
04a4df5f16 add regression test for something we fixed 2023-09-14 11:56:55 +02:00
bors
e17235105c Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errors
Visit ExprField for lint levels.

Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-14 06:29:23 +00:00
Michael Goulet
7ae301ec47 Properly consider binder vars in HasTypeFlagsVisitor 2023-09-14 03:49:59 +00:00
Zalathar
c397ca0677 Fix the error message for #![feature(no_coverage)] 2023-09-14 13:01:54 +10:00
bors
c728bf3963 Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk
Rework `no_coverage` to `coverage(off)`

As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation.

Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
2023-09-14 01:05:18 +00:00
Camille GILLOT
01d7bf09f3 Visit ExprField for lint levels. 2023-09-13 19:47:20 +00:00
Michael Goulet
8fbd78ccea Detect cycle errors hidden by opaques during monomorphization 2023-09-13 17:35:44 +00:00
Matthias Krüger
48d89a8759
Rollup merge of #115815 - bvanjoi:fix-115809, r=oli-obk
fix: return early when has tainted in mir pass

Fixes https://github.com/rust-lang/rust/issues/115809

As in #115643, `run_pass` is skipped if the body has tainted errors.

r? `@oli-obk`
2023-09-13 18:37:43 +02:00
Matthias Krüger
1ec29fb24f
Rollup merge of #115771 - RalfJung:no-more-const-err-lint, r=oli-obk
cleanup leftovers of const_err lint

Some code / comments seem to not have been updated when const_err was turned into a hard error, so we can do a bit of cleanup here.

r? `@oli-obk`
2023-09-13 18:37:42 +02:00
bohan
7c53e87d55 fix: skip opt if body has tainted error 2023-09-13 23:07:39 +08:00
Matthew Jasper
e324a59eb6 Address review comments
- Add doc comment to new type
- Restore "only supported directly in conditions of `if` and `while` expressions" note
- Rename variant with clearer name
2023-09-13 15:00:31 +00:00
bohan
f1536507e1 resolve: determined binding after parent module macro expand 2023-09-13 16:38:05 +08:00
bors
367db835dc Auto merge of #115785 - fmease:fix-pat-regression, r=wesleywiser
Only suggest turbofish in patterns if we may recover

Fixes [after backport] #115780.

CC #103534.
2023-09-13 00:05:33 +00:00
Georg Semmler
5b8a7a0917
#[diagnostic::on_unimplemented] without filters
This commit adds support for a `#[diagnostic::on_unimplemented]`
attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
Co-authored-by: Michael Goulet <michael@errs.io>
2023-09-12 20:03:18 +02:00
León Orell Valerian Liehr
3ed77e98fa
Only suggest turbofish in patterns if we may recover 2023-09-12 16:38:59 +02:00
bors
e5fedceabf Auto merge of #115215 - ouz-a:mir_issue, r=lcnr
Remove assert that checks type equality

https://github.com/rust-lang/rust/pull/112307 although this prevented `unsound` issues it also seems to introduce regressions https://github.com/rust-lang/rust/issues/114858 is example of this regression. I locally tested this https://github.com/rust-lang/rust/issues/114858#issuecomment-1686502262 issue and failing assert is [this](https://www.diffchecker.com/cjb7jSQm/).

This is also related to https://github.com/rust-lang/rust/pull/115025
2023-09-12 13:27:29 +00:00
Ralf Jung
fd91dfb494 cleanup leftovers of const_err lint 2023-09-12 13:41:42 +02:00
bors
deb708af12 Auto merge of #115678 - RalfJung:abi-compat-test, r=petrochenkov
test ABI compatibility for some unsized types as well

and test for what `DispatchFromDyn` needs.

Also I ran this on a whole bunch of targets via Miri and added enough `cfg` to make it all work, as documentation for what does and doesn't currently work. (Most of those targets do not have their tests run on CI anyway.)

Here's the shell rune I used for that:
```
for TARGET in x86_64-unknown-linux-gnu x86_64-pc-windows-gnu aarch64-unknown-linux-gnu s390x-unknown-linux-gnu mips64-unknown-linux-gnuabi64 sparc64-unknown-linux-gnu  powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu riscv64gc-unknown-linux-gnu loongarch64-unknown-linux-gnu wasm32-unknown-unknown; do
   BOOTSTRAP_SKIP_TARGET_SANITY=1 ./x.py run miri --stage 0 --args tests/ui/abi/compatibility.rs --target $TARGET;
done
```
2023-09-12 07:11:48 +00:00
Chinedu Francis Nwafili
7db9c3c1a6
Tests passing 2023-09-12 03:11:11 -04:00
Ralf Jung
6f2c051aba add some DispatchFromDyn ABI compatibility tests 2023-09-12 07:27:17 +02:00
Ralf Jung
4f606eb423 add enough cfg to make the test pass on problematic targets 2023-09-12 07:27:15 +02:00
Ralf Jung
721dfc5994 also test ABI-compatibility for some unsized types 2023-09-12 07:23:53 +02:00
Ralf Jung
10951f3500 make sure the types in the ABI compat test actually type-check 2023-09-12 07:23:52 +02:00
Matthias Krüger
32cf2c4b68
Rollup merge of #115765 - asquared31415:cast_diag, r=WaffleLapkin
Add source type for invalid bool casts

Also adds tests for casting various types to `bool` that were otherwise untested.

r? `@WaffleLapkin`
2023-09-12 06:34:46 +02:00
bors
b4e54c6e39 Auto merge of #115767 - matthiaskrgr:rollup-byf3lvq, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115548 (Extract parallel operations in `rustc_data_structures::sync` into a new `parallel` submodule)
 - #115591 (Add regression test for LLVM 17-rc3 miscompile)
 - #115631 (Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty)
 - #115708 (fix homogeneous_aggregate not ignoring some ZST)
 - #115730 (Some more small driver refactors)
 - #115749 (Allow loading the SMIR for constants and statics)
 - #115757 (Add a test for #108030)
 - #115761 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-11 20:53:42 +00:00
ouz-a
3ec0165f5f Remove assert that checks type equality 2023-09-11 23:08:40 +03:00
Matthias Krüger
279e2576a0
Rollup merge of #115708 - RalfJung:homogeneous, r=davidtwco
fix homogeneous_aggregate not ignoring some ZST

This is an ABI-breaking change, because it fixes bugs in our ABI code. I'm not sure what that means for this PR, we don't really have a process for such changes, do we? I can only hope nobody relied on the old buggy behavior.

Fixes https://github.com/rust-lang/rust/issues/115664
2023-09-11 21:16:22 +02:00
Matthias Krüger
5a2b589ac7
Rollup merge of #115631 - compiler-errors:ctypes-unsized, r=davidtwco
Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty

We may not always be able to compute the layout of a type like `&T` when `T: ?Sized`, even if we're able to estimate its size skeleton.

r? davidtwco

Fixes #115628
2023-09-11 21:16:21 +02:00
bors
e2b3676733 Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,compiler-errors
Bubble up opaque <eq> opaque operations instead of picking an order

In case we are in `Bubble` mode (meaning every opaque type that is defined in the current crate is treated as if it were in its defining scope), we don't try to register an opaque type as the hidden type of another opaque type, but instead bubble up an obligation to equate them at the query caller site. Usually that means we have a `DefiningAnchor::Bind` and thus can reliably figure out whether an opaque type is in its defining scope. Where we can't, we'll error out, so the default is sound.

With this change we start using `AliasTyEq` predicates in the old solver, too.

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

But also regresses `tests/ui/impl-trait/anon_scope_creep.rs`. Our use of `Bubble` for `check_opaque_type_well_formed` is going to keep biting us.

r? `@lcnr` `@compiler-errors`
2023-09-11 19:01:38 +00:00
Tomasz Miąsko
ce19bc3964 Use no_core for KCFI tests to exercise them in CI 2023-09-11 20:54:52 +02:00
asquared31415
e36adff4c2 add source type for invalid bool casts 2023-09-11 18:10:07 +00:00
Oli Scherer
930affa39d Bubble up opaque <eq> opaque operations instead of picking an order 2023-09-11 16:53:39 +00:00
bors
0a199e4e93 Auto merge of #115758 - matthiaskrgr:rollup-khwbjj7, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115335 (fix overflow in array length computation)
 - #115440 (bootstrap/format: remove unnecessary paths.push)
 - #115702 (Update mailmap)
 - #115727 (Implement fallback for effect param)
 - #115739 (Call `LateLintPass::check_attribute` from `with_lint_attrs`)
 - #115743 (Point out if a local trait has no implementations)
 - #115744 (Improve diagnostic for generic params from outer items (E0401))
 - #115752 (rustdoc: Add missing "Aliased type" title in the sidebar)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-11 16:50:22 +00:00
Matthew Jasper
b011a0a13b Reduce double errors for invalid let expressions
Previously some invalid let expressions would result in both a feature
error and a parsing error. Avoid this and ensure that we only emit the
parsing error when this happens.
2023-09-11 16:17:06 +00:00
Matthew Jasper
333388fd3c Move let expression checking to parsing
There was an incomplete version of the check in parsing and a second
version in AST validation. This meant that some, but not all, invalid
uses were allowed inside macros/disabled cfgs. It also means that later
passes have a hard time knowing when the let expression is in a valid
location, sometimes causing ICEs.

- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a
  valid location.
- Suppress later errors and MIR construction for invalid let
  expressions.
2023-09-11 15:51:18 +00:00
Matthew Jasper
7b61f7f002 Don't create drop scopes after item statements
These scopes would not exist in MIR and can cause ICEs with invalid uses
of let expressions.
2023-09-11 15:51:18 +00:00
Matthias Krüger
8b49731211
Rollup merge of #115744 - fmease:fix-e0401, r=compiler-errors
Improve diagnostic for generic params from outer items (E0401)

Generalize the wording of E0401 to talk about *outer items* instead of *outer functions* since the current phrasing is outdated. The outer item can be a function, constant, trait, ADT or impl block (see the new UI test for the more exotic examples).

Further, don't suggest introducing generic parameters to constant items unless the feature `generic_const_items` is enabled.

Lastly, make E0401 translatable while we're at it.

Fixes #115720.
2023-09-11 17:03:32 +02:00
Matthias Krüger
f279afb455
Rollup merge of #115743 - compiler-errors:no-impls, r=davidtwco
Point out if a local trait has no implementations

Slightly helps with #115741
2023-09-11 17:03:32 +02:00
Matthias Krüger
e7a347baf8
Rollup merge of #115727 - fee1-dead-contrib:effect-fallback, r=oli-obk
Implement fallback for effect param

r? `@oli-obk` or `@lcnr`

tracking issue for this ongoing work: https://github.com/rust-lang/rust/issues/110395
2023-09-11 17:03:31 +02:00
bors
3ebb5629d1 Auto merge of #115595 - surechen:114896, r=davidtwco
Fix incorrect mutable suggestion information for binding in ref pattern like:  `let &b = a;`

fixes #114896

I find we have to get pat_span but not local_decl.source_info.span for suggestion. In `let &b = a;`  pat_span is &b. I think check `let &b = a` in hir to make sure it is hir::Node::Local(hir::Local {pat: hir::Pat{kind: hir::PatKind::Ref(.......   can distinguish it from other situation, but I'm not sure.

If my processing method is not accurate, please guide me to modify it, thank you.

r? `@davidtwco`
2023-09-11 15:02:59 +00:00
bors
68c2f5ba0f Auto merge of #115308 - chenyukang:yukang-fix-62387-iter-mut, r=davidtwco
suggest iter_mut() where trying to modify elements from .iter()

Fixes https://github.com/rust-lang/rust/issues/115259
Fixes https://github.com/rust-lang/rust/issues/62387
2023-09-11 12:41:30 +00:00
bors
5d62ab8981 Auto merge of #115387 - weihanglo:merge-check-and-lint, r=oli-obk
Make unknown/renamed/removed lints passed via command line respect lint levels
2023-09-11 08:56:29 +00:00
Nicholas Nethercote
64ea8eb1a9 Disentangle Debug and Display for Ty.
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This
is surprising and annoying. In particular, it means `Debug` doesn't show
as much information as `Debug` for `TyKind` does. And `Debug` is used in
some user-facing error messages, which seems bad.

This commit changes the `Debug` impl for `Ty` to call the `Debug` impl
for `TyKind`. It also does a number of follow-up changes to preserve
existing output, many of which involve inserting
`with_no_trimmed_paths!` calls. It also adds `Display` impls for
`UserType` and `Canonical`.

Some tests have changes to expected output:
- Those that use the `rustc_abi(debug)` attribute.
- Those that use the `EMIT_MIR` annotation.

In each case the output is slightly uglier than before. This isn't
ideal, but it's pretty weird (particularly for the attribute) that the
output is using `Debug` in the first place. They're fairly obscure
attributes (I hadn't heard of them) so I'm not worried by this.

For `async-is-unwindsafe.stderr`, there is one line that now lacks a
full path. This is a consistency improvement, because all the other
mentions of `Context` in this test lack a path.
2023-09-11 12:51:07 +10:00
Michael Goulet
30e6cea0ae Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
León Orell Valerian Liehr
daf3c45531
Do not suggest generic const items unless enabled 2023-09-10 23:07:48 +02:00
León Orell Valerian Liehr
b00e408e61
Generalize E0401 2023-09-10 23:06:14 +02:00
Deadbeef
84a490712a Implement fallback for effect param 2023-09-10 07:48:47 +00:00
Ralf Jung
254e13d9f9 fix homogeneous_aggregate not ignoring some 1-ZST 2023-09-10 07:38:03 +02:00
bors
0d0ad42e27 Auto merge of #115712 - RalfJung:wf, r=compiler-errors
rustc_layout, rustc_abi: make sure the types are well-formed

Fixes https://github.com/rust-lang/rust/issues/115676
2023-09-10 01:36:15 +00:00
Ralf Jung
3bd8bcb8bb better spans for WF errors 2023-09-09 18:00:13 +02:00
Ralf Jung
c2a7e684cd use hir_crate_items(()).definitions() instead of hir().items() 2023-09-09 17:39:53 +02:00
Ralf Jung
a5b0311367 rustc_layout, rustc_abi: make sure the types are well-formed 2023-09-09 17:32:12 +02:00
Gurinder Singh
e7c51320db Fix ICE in improper_ctypes_definitions lint
The lint panicked for an input like 'extern "C" fn(Option<&<T as FooTrait>::FooType>)' because the type T therein cannot be normalized. The normalization failure caused SizeSkeleton::compute() to return an error and trigger a panic in the unwrap().
2023-09-09 12:30:25 +05:30
Matthias Krüger
2ae5dc9b65
Rollup merge of #115673 - tmiasko:sanitizer-cfg, r=compiler-errors
Fix sanitize/cfg.rs test

* Move needs-sanitizer conditions to specific revisions that require them (otherwise the conditions are mutually exclusive with needs-sanitizer-kcfi and test is always ignored).
* Add missing revisions
2023-09-09 00:28:21 +02:00
Matthias Krüger
69044a1693
Rollup merge of #115662 - ShE3py:E0220-note, r=compiler-errors
Improve "associated type not found" diagnostics

```rs
use core::ops::Deref;

fn foo<T>() where T: Deref<Output = u32> {}
```

Before:
```
error[E0220]: associated type `Output` not found for `Deref`
 --> E0220.rs:5:28
  |
5 | fn foo<T>() where T: Deref<Output = u32> {}
  |                            ^^^^^^ associated type `Output` not found
```

After:
```
error[E0220]: associated type `Output` not found for `Deref`
 --> E0220.rs:5:28
  |
5 | fn foo<T>() where T: Deref<Output = u32> {}
  |                            ^^^^^^ help: `Deref` has the following associated type: `Target`
```

---

`@rustbot` label +A-diagnostics +D-papercut
2023-09-09 00:28:20 +02:00
Matthias Krüger
b33ac52106
Rollup merge of #115630 - compiler-errors:dont-suggest-use-btw-use-and-attr, r=wesleywiser
Dont suggest use between `use` and cfg attr

Fixes #115618
2023-09-09 00:28:20 +02:00
Matthias Krüger
6b65d377c5
Rollup merge of #113807 - mojingran:master, r=WaffleLapkin
Tests crash from inappropriate use of common linkage

Follows up my proposal under the [tracking issue for the linkage feature](https://github.com/rust-lang/rust/issues/29603#issuecomment-1597662999). Adds test for [issue 109681](https://github.com/rust-lang/rust/issues/109681).
2023-09-09 00:28:19 +02:00
bors
309af3442a Auto merge of #115672 - GuillaumeGomez:rollup-mjiy56f, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #104299 (Clarify stability guarantee for lifetimes in enum discriminants)
 - #115088 (Fix Step Skipping Caused by Using the `--exclude` Option)
 - #115201 (rustdoc: list matching impls on type aliases)
 - #115633 (Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type)
 - #115638 (`-Cllvm-args` usability improvement)
 - #115643 (fix: return early when has tainted in mir-lint)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-08 13:43:08 +00:00
Tomasz Miąsko
7f45d16cb2 Fix sanitize/cfg.rs test
* Move needs-sanitizer conditions to specific revisions that
  require them (otherwise the conditions are mutually exclusive
  with needs-sanitizer-kcfi and test is always ignored).
* Add missing revisions
2023-09-08 15:12:17 +02:00
Guillaume Gomez
60327bb8b0
Rollup merge of #115643 - bvanjoi:fix-115203, r=RalfJung,oli-obk
fix: return early when has tainted in mir-lint

Fixes #115203

`a[..]` is of indeterminate size, it had been reported error during borrow check, therefore we skip the mir lint process.
2023-09-08 14:10:52 +02:00
Guillaume Gomez
e3b6122530
Rollup merge of #115633 - compiler-errors:PRIVATE_BOUNDS-lint-node, r=petrochenkov
Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type

The HIR that the `PRIVATE_BOUNDS` lint should be attached to is the item that has the *bounds*, not the private type. This PR also aligns this behavior with the `EXPORTED_PRIVATE_DEPENDENCIES` lint, which also requires putting the `allow` on the item that names the private type.

Fixes #115475

r? petrochenkov
2023-09-08 14:10:51 +02:00
bors
cd71a37f32 Auto merge of #115372 - RalfJung:abi-assert-eq, r=davidtwco
add rustc_abi(assert_eq) to test some guaranteed or at least highly expected ABI compatibility guarantees

This new repr(transparent) test is super useful, it would have found https://github.com/rust-lang/rust/issues/115336 and found https://github.com/rust-lang/rust/issues/115404, https://github.com/rust-lang/rust/issues/115481, https://github.com/rust-lang/rust/issues/115509.
2023-09-08 11:56:08 +00:00
Andy Caldwell
679267f2ac
Rename the feature, but not the attribute, to coverage_attribute 2023-09-08 12:46:09 +01:00
Andy Caldwell
de1600d110
Add no_coverage to the 'removed features' list 2023-09-08 12:46:08 +01:00
Andy Caldwell
8e03371fc3
Rework no_coverage to coverage(off) 2023-09-08 12:46:06 +01:00
Ralf Jung
e726be21ab need to disable part of this test on arm 2023-09-08 13:25:51 +02:00
Ralf Jung
243ef313a5 add a testcase for another MIPS64 bug 2023-09-08 08:59:55 +02:00
Ralf Jung
a53c6ee0ba also ensure that size and alignment are the same 2023-09-08 08:59:55 +02:00
Ralf Jung
f6ef555823 merge transparent-abi test into general abi compatibility test, and test repr(transparent) unions 2023-09-08 08:59:55 +02:00
Ralf Jung
02217d1a16 add tests for RFC 3391 2023-09-08 08:59:55 +02:00
Ralf Jung
c3e14edd8b accept some differences for rustc_abi(assert_eq), so that we can test more things to be compatible 2023-09-08 08:59:55 +02:00
Lieselotte
a0e0a3261e
E0220: only suggests associated types if there's only one candidate 2023-09-08 08:44:23 +02:00
Matthias Krüger
7ec813643a
Rollup merge of #115649 - notriddle:notriddle/82038, r=compiler-errors
diagnostics: add test case for trait bounds diagnostic

Closes #82038

It was fixed by https://github.com/rust-lang/rust/pull/89580, a wide-reaching obligation tracking improvement. This commit adds a test case.
2023-09-08 08:23:04 +02:00
Matthias Krüger
38adedc598
Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obk
Don't suggest dereferencing to unsized type

Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well.

Fixes #115569
2023-09-08 08:23:03 +02:00
Matthias Krüger
bef5187e8b
Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkin
Print the path of a return-position impl trait in trait when `return_type_notation` is enabled

When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
2023-09-08 08:23:03 +02:00
Lieselotte
96c96645c7
Improve "associated type not found" diagnostics 2023-09-08 06:52:17 +02:00
Michael Goulet
e4af4e5083 Stabilize impl_trait_projections 2023-09-08 03:45:36 +00:00
bohan
967410c640 fix: return ealry when has tainted in mir-lint 2023-09-08 09:30:23 +08:00
bors
1e746d7741 Auto merge of #115527 - oli-obk:drop_maybe_uninit_in_const, r=lcnr
Don't require `Drop` for `[PhantomData<T>; N]` where `N` and `T` are generic, if `T` requires `Drop`

fixes https://github.com/rust-lang/rust/issues/115403
fixes https://github.com/rust-lang/rust/issues/115410

This was accidentally regressed in https://github.com/rust-lang/rust/pull/114134, because it was accidentally stabilized in #102204 (cc `@rust-lang/lang,` seems like an innocent stabilization, considering this PR is more of a bugfix than a feature).

While we have a whole month to beta backport this change before the regression hits stable, I'd still prefer not to go through an FCP on this PR (which fixes a regression), if T-lang wants an FCP, I can can open an issue about the change itself.
2023-09-07 19:10:07 +00:00
Michael Howell
31e5dd3a79 diagnostics: add test case for trait bounds diagnostic
Closes #82038

It was fixed by b8e5ab20ed, a wide-reaching
obligation tracking improvement. This commit adds a test case.
2023-09-07 11:36:23 -07:00
Oli Scherer
320bb8116f Don't require Drop for [PhantomData<T>; N] where N and T are generic, if T requires Drop 2023-09-07 18:31:17 +00:00
bors
f06b7c59a3 Auto merge of #114183 - Urgau:stabilize-print-with-path, r=oli-obk
Stabilize `PATH` option for `--print KIND=PATH`

This PR propose stabilizing the `PATH` option for `--print KIND=PATH`. This option was previously added in https://github.com/rust-lang/rust/pull/113780 (as insta-stable before being un-stablized in https://github.com/rust-lang/rust/pull/114139).

Description of the `PATH` option:
> A filepath may optionally be specified for each requested information kind, in the format `--print KIND=PATH`, just like for `--emit`. When a path is specified, information will be written there instead of to stdout.

------

Description of the original PR [\[link\]](https://github.com/rust-lang/rust/pull/113780#issue-1807080607):
> **Support --print KIND=PATH command line syntax**
>
> As is already done for `--emit KIND=PATH` and `-L KIND=PATH`.
>
> In the discussion of https://github.com/rust-lang/rust/pull/110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o path` to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`.
>
> I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](d43cf3a51a/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system.
>
> From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". 31eda6f7c3/src/cargo/core/compiler/build_context/target_info.rs (L242)

-----

cc `@dtolnay`
r? `@jackh726`
2023-09-07 14:24:46 +00:00
Urgau
caf6ce5ea2 Stabilize PATH option for --print KIND=PATH
Description of the `PATH` option:
> A filepath may optionally be specified for each requested information
> kind, in the format `--print KIND=PATH`, just like for `--emit`. When
> a path is specified, information will be written there instead of to
> stdout.
2023-09-07 15:07:30 +02:00
bors
7f0fa485a6 Auto merge of #115582 - compiler-errors:refine-yeet, r=oli-obk
Implement refinement lint for RPITIT

Implements a lint that warns against accidentally refining an RPITIT in an implementation. This is not a hard error, and can be suppressed with `#[allow(refining_impl_trait)]`, since this behavior may be desirable -- the lint just serves as an acknowledgement from the impl author that they understand that the types they write in the implementation are an API guarantee.

This compares bounds syntactically, not semantically -- semantic implication is more difficult and essentially relies on adding the ability to keep the RPITIT hidden in the trait system so that things can be proven about the type that shows up in the impl without its own bounds leaking through, either via a new reveal mode or something else. This was experimentally implemented in #111931.

Somewhat opinionated choices:
1. Putting the lint behind `refining_impl_trait` rather than a blanket `refine` lint. This could be changed, but I like keeping the lint specialized to RPITITs so the explanation can be tailored to it.
2. This PR does not include the `#[refine]` attribute or the feature gate, since it's kind of orthogonal and can be added in a separate PR.

r? `@oli-obk`
2023-09-07 07:26:26 +00:00
Ralf Jung
8922c0c541 add support for rustc_abi(assert_eq) and use it to test some repr(transparent) cases 2023-09-07 09:14:29 +02:00
Michael Goulet
3bf3dadbc0 Ensure that dyn trait bounds stay sorted 2023-09-07 06:57:08 +00:00
Michael Goulet
14e59bb317 Lint node for PRIVATE_BOUNDS is the item which has the bounds 2023-09-07 06:48:24 +00:00
Michael Goulet
086cf34634 Don't ICE when computing ctype's repr_nullable_ptr for possibly-unsized ty 2023-09-07 06:04:37 +00:00
Michael Goulet
03bee1f53d Find lowest span out of use + attrs 2023-09-07 05:19:43 +00:00
Michael Goulet
4da6eb2ec6 Test showing it doesnt work 2023-09-07 05:18:54 +00:00
Michael Goulet
67e7d85ad2 Rename folder typo 2023-09-07 04:52:26 +00:00
Michael Goulet
ee9727e263 Don't suggest dereferencing to unsized type 2023-09-07 04:52:00 +00:00
surechen
a8f3c7684d fixes #114896 2023-09-07 11:07:33 +08:00
Michael Goulet
748476d94d Print the path of an RPITIT in RTN 2023-09-07 02:08:51 +00:00
Michael Goulet
7714db873e Add note 2023-09-07 01:31:33 +00:00
Michael Goulet
4d05da46e7 Don't emit refining_impl_trait for private items 2023-09-07 01:31:32 +00:00
Michael Goulet
4745d34bc3 Use self instead of the actual self ty 2023-09-07 00:49:09 +00:00
Michael Goulet
e10262ca0a Implement refinement lint for RPITIT 2023-09-07 00:49:09 +00:00
bors
4e5b31c2b0 Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31
Lint on invalid usage of `UnsafeCell::raw_get` in reference casting

This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint.

The goal of this is to catch those kind of invalid reference casting:
```rust
fn as_mut<T>(x: &T) -> &mut T {
    unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
    //~^ ERROR casting `&T` to `&mut T` is undefined behavior
}
```

r? `@est31`
2023-09-07 00:24:45 +00:00
Matthias Krüger
3e42a12a54
Rollup merge of #115587 - mojave2:issue-115348, r=oli-obk
fix #115348

fix #115348
It looks that:

- In `rustc_mir_build::build`, the body of function will not be built, when the `tcx.check_match(def)` fails due to `non-exhaustive patterns`
- In `rustc_mir_transform::check_unsafety`, the `UnsafetyChecker` collects all `used_unsafe_blocks` in the MIR of a function, and the `UnusedUnsafeVisitor` will visit all `UnsafeBlock`s in the HIR and collect `unused_unsafes`, which are not contained in `used_unsafe_blocks`, and report `unnecessary_unsafe`s
- So the unsafe block in the issue example code will be reported as `unnecessary_unsafe`.
2023-09-06 19:31:50 +02:00
Matthias Krüger
93543bc8bc
Rollup merge of #115578 - ouz-a:rustc_clarify, r=oli-obk
Clarify cryptic comments

Clarifies some unclear comments that lurked in the compiler.

r? ``@oli-obk``
2023-09-06 19:31:49 +02:00
Matthias Krüger
4a31cc859b
Rollup merge of #115473 - gurry:113110-expected-item, r=compiler-errors
Add explanatory note to 'expected item' error

Fixes #113110

It changes the diagnostic from this:

```
error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item
 ```
to this:
```
error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item
  |
  = note: items are things that can appear at the root of a module
  = note: for a full list see https://doc.rust-lang.org/reference/items.html
```
2023-09-06 19:31:48 +02:00
Matthias Krüger
b046541b62
Rollup merge of #114511 - chenyukang:yukang-fix-114374-fmt-args, r=b-naber
Remove the unhelpful let binding diag comes from FormatArguments

Fixes #114374
2023-09-06 19:31:48 +02:00
Lukas Markeffsky
d990eee0c8 add diagnostic for raw identifiers in format string 2023-09-06 18:55:45 +02:00
yukang
3988ff25bc suggest iter_mut() where trying to modify elements from .iter() 2023-09-07 00:20:38 +08:00
mojave2
cfa2119563
add a regression test 2023-09-06 17:46:46 +08:00
Ralf Jung
e66913f8fe rustc_layout/abi: error when attribute is applied to the wrong thing 2023-09-06 11:11:06 +02:00
Ralf Jung
9570cac019 rustc_abi: also support debugging function pointers 2023-09-06 11:11:06 +02:00
ouz-a
7928c5f830 make comments less cryptic 2023-09-06 12:09:29 +03:00
Wim Looman
119e0fff8a
Change unsafe_op_in_unsafe_fn to be warn-by-default from edition 2024 2023-09-06 09:30:04 +02:00
Ralf Jung
ad7045e160 still accept references to u8 slices and str in packed fields 2023-09-06 08:32:30 +02:00
Gurinder Singh
6a286e775c Add explanatory note to 'expected item' error 2023-09-06 09:05:07 +05:30
bors
aeddd2ddfd Auto merge of #115529 - chenyukang:yukang-fix-115402-overflowsize, r=compiler-errors
Fix error report for size overflow from transmute

Fixes #115402

The span in the error reporting always points to the `dst`, this is an old issue, I may open another PR to fix it.
2023-09-06 02:37:41 +00:00
bors
25283f4e13 Auto merge of #115371 - matthewjasper:if-let-guard-parsing, r=cjgillot
Make if let guard parsing consistent with normal guards

- Add tests that struct expressions are not allowed in `if let` and `while let` (no change, consistent with `if` and `while`)
- Allow struct expressions in `if let` guards (consistent with `if` guards).

r? `@cjgillot`

Closes #93817
cc #51114
2023-09-06 00:46:21 +00:00
yukang
00010eda8b Fix error report for size overflow from transmute 2023-09-06 06:48:34 +08:00
Ralf Jung
8b3435c10f fix detecting references to packed unsized fields 2023-09-05 22:29:51 +02:00
Michael Goulet
f479a7aa8d Restore some removed tests 2023-09-05 20:20:55 +00:00
Michael Goulet
52aff53812 Correctly deny late-bound lifetimes from parent in anon consts and TAITs 2023-09-05 20:20:55 +00:00
lcnr
98fa0c93ee unconstrained region vars: do not ICE ICE baby 2023-09-05 11:15:05 +02:00
bors
8cfaf70c32 Auto merge of #115553 - matthiaskrgr:rollup-c0045hz, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #115353 (Emit error instead of ICE when optimized MIR is missing)
 - #115488 (Take `&mut Results` in `ResultsVisitor`)
 - #115492 (Allow `large_assignments` for Box/Arc/Rc initialization)
 - #115519 (Don't ICE on associated type projection without feature gate in new solver)
 - #115534 (Expose more information with DefId in smir)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-05 05:34:18 +00:00
Matthias Krüger
f5e6aa3c4a
Rollup merge of #115519 - compiler-errors:next-solver-assoc-ice, r=lcnr
Don't ICE on associated type projection without feature gate in new solver

Self-explanatory, we should avoid ICEs when the feature gate is not enabled. Continue to ICE when the feature gate *is* enabled, though.

Fixes #115500
2023-09-05 07:15:16 +02:00
Matthias Krüger
6f180ea954
Rollup merge of #115492 - Enselic:large-box-move, r=oli-obk
Allow `large_assignments` for Box/Arc/Rc initialization

Does the `stop linting in box/arc initialization` task of #83518.

r? `@oli-obk` who is E-mentor.
2023-09-05 07:15:16 +02:00
Matthias Krüger
a73c663ec4
Rollup merge of #115353 - Enselic:no-optimized-mir, r=oli-obk
Emit error instead of ICE when optimized MIR is missing

Closes #51388
2023-09-05 07:15:15 +02:00
bors
626a6ab93f Auto merge of #115531 - RalfJung:read_via_copy, r=scottmcm
read_via_copy: don't prematurely optimize away the read

Always do the read to ensure consistent UB error messages in const-eval/Miri.

r? `@scottmcm`
2023-09-05 03:45:17 +00:00
bors
9c609ae158 Auto merge of #115467 - compiler-errors:assoc-ty-object-safety, r=oli-obk
Do not require associated types with Self: Sized to uphold bounds when confirming object candidate

RPITITs and associated types that have `Self: Sized` bounds are opted out of the `dyn Trait` well-formedness check that happens during confirmation. This ensures that we can actually *use* `dyn Trait`s that have associated types that, e.g., have GATs and RPITITs and other naughty things as long as those are opted-out of object safety via a `Self: Sized` bound.

Fixes #115464

This seems like a natural part of https://github.com/rust-lang/rust/pull/112319#issuecomment-1592574451, and I don't think needs re-litigation.

r? `@oli-obk`
2023-09-05 01:09:48 +00:00
Ralf Jung
7093903ba7 read_via_copy: don't prematurely optimize away the read 2023-09-04 18:27:34 +02:00
Urgau
efbe445ba7 Add help to allow lint for the implied by suggestion 2023-09-04 14:21:38 +02:00
bors
bf1e3f31f9 Auto merge of #115513 - Urgau:normalize-msg-after-translate, r=petrochenkov
Don't forget to normalize the translated message

This PR adds a missing call to `normalize_whitespace` after translating an label.

Fixes https://github.com/rust-lang/rust/issues/115498
2023-09-04 10:02:57 +00:00
Michael Goulet
8c667febbd Don't ICE on associated type projection without feature gate 2023-09-03 19:43:58 +00:00
bors
21305f4d5f Auto merge of #115270 - sebastiantoh:issue-105479, r=Nadrieril
Add note on non-exhaustiveness when matching on str and nested non-exhaustive enums

Fixes https://github.com/rust-lang/rust/issues/105479

r? `@Nadrieril`
2023-09-03 19:31:47 +00:00
Urgau
ec0975dd6b Don't forget to normalize the translated message 2023-09-03 17:10:42 +02:00
Guillaume Gomez
3db7fc1481
Rollup merge of #115478 - gurry:115462-exprfield-no-warn, r=compiler-errors
Emit unused doc comment warnings for pat and expr fields

Fixes #115462
2023-09-03 15:42:11 +02:00
Sebastian Toh
d87b87d10e Improve clarity of diagnostic message on non-exhaustive matches 2023-09-03 19:55:11 +08:00
Martin Nordholts
789451b43a Allow large_assignments for Box/Arc/Rc initialization
Does the `stop linting in box/arc initialization` task of 83518.
2023-09-03 08:15:25 +02:00
Gurinder Singh
10f4917568 Emit unused doc comment warnings for pat and expr fields 2023-09-03 08:21:18 +05:30
bors
9229b1eab4 Auto merge of #115429 - compiler-errors:assoc-ct-lt-fallthrough, r=cjgillot
Fall through when resolving elided assoc const lifetimes

`@QuineDot` makes a good point in https://github.com/rust-lang/rust/issues/115010#issuecomment-1702127634 that we probably should not accept *more* code due to #115011 even though that code will eventually become a forbid-warning in a few versions (https://github.com/rust-lang/rust/issues/115010#issuecomment-1701598067).

Fall through when walking thru the `AnonymousWarnToStatic` (renamed to `AnonymousWarn`) rib so that we can resolve as a fresh lifetime like we did before.
2023-09-02 10:55:49 +00:00
Michael Goulet
07fc644132 Do not require associated types with Self: Sized to uphold bounds when confirming object candidate 2023-09-02 05:08:38 +00:00
Michael Goulet
7a6b52bf0d RPITITs are considered object-safe, they're always on Self:Sized methods 2023-09-02 04:58:23 +00:00
bors
f9ba43ce14 Auto merge of #113295 - clarfonthey:ascii-step, r=cuviper
Implement Step for ascii::Char

This allows iterating over ranges of `ascii::Char`, similarly to ranges of `char`.

Note that `ascii::Char` is still unstable, tracked in #110998.
2023-09-02 00:02:50 +00:00
David Mo
4160337c85 Tests crash from inappropriate use of common linkage
Normally, variables with common linkage must be zero-initialized. In Rust,
common linkage variables that are not zero-initialized causes a crash in the
compiler backend.

This commit adds a test case to confirm this behavior, which will inform us if
it changes in the future.
2023-09-01 14:08:31 -07:00
Matthias Krüger
888dc2e3b0
Rollup merge of #115424 - notriddle:notriddle/issue-106413, r=oli-obk
diagnostics: avoid wrong `unused_parens` on `x as (T) < y`

Fixes #106413
Fixes #80636
2023-09-01 21:41:39 +02:00
bors
1accf068d8 Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkov
Replace old private-in-public diagnostic with type privacy lints

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-09-01 12:40:01 +00:00
bors
f4555ef5e1 Auto merge of #111752 - dingxiangfei2009:lower-or-pattern, r=cjgillot
Lower `Or` pattern without allocating place

cc `@azizghuloum` `@cjgillot`

Related to #111583 and #111644

While reviewing #111644, it occurs to me that while we directly lower conjunctive predicates, which are connected with `&&`, into the desirable control flow, today we don't directly lower the disjunctive predicates, which are connected with `||`, in the similar fashion. Instead, we allocate a place for the boolean temporary to hold the result of evaluating the `||` expression.

Usually I would expect optimization at later stages to "inline" the evaluation of boolean predicates into simple CFG, but #111583 is an example where `&&` is failing to be optimized away and the assembly shows that both the expensive operands are evaluated. Therefore, I would like to make a small change to make the CFG a bit more straight-forward without invoking the `as_temp` machinery, and plus avoid allocating the place to hold the boolean result as well.
2023-09-01 10:54:56 +00:00
Michael Goulet
b62eeb2aac Fall through when resolving elided assoc const lifetimes 2023-09-01 07:23:39 +00:00
bors
96f62fce00 Auto merge of #113201 - oli-obk:recursive_type_alias, r=estebank,compiler-errors
Permit recursive weak type aliases

I saw #63097 and thought "we can do ~~better~~ funnier". So here it is. It's not useful, but it's certainly something. This may actually become feasible with lazy norm (so in 5 years (constant, not reducing over time)).

r? `@estebank`

cc `@GuillaumeGomez`
2023-09-01 07:10:21 +00:00
bors
88d9b37a15 Auto merge of #115400 - gurry:issue-115264-ice, r=compiler-errors
Return ident for ExprField and PatField HIR nodes

Fixes #115264
2023-09-01 03:36:48 +00:00
Michael Howell
62835c9531 diagnostics: avoid wrong unused_parens on x as (T) < y 2023-08-31 20:14:49 -07:00
Gurinder Singh
19574d216a Return ident for ExprField and PatField HIR nodes 2023-09-01 06:36:02 +05:30
bors
2f5df8a94b Auto merge of #115366 - compiler-errors:associated-type-bound-implicit-lifetimes, r=jackh726
Capture lifetimes for associated type bounds destined to be lowered to opaques

Some associated type bounds get lowered to opaques, but they're not represented in the AST as opaques.

That means that we never collect lifetimes for them (`record_lifetime_params_for_impl_trait`) which are used currently for RPITITs, which capture all of their in-scope lifetimes[^1]. This means that the nested RPITITs that arise from some type like `impl Foo<Type: Bar>` (~> `impl Foo<Type = impl Bar>`) don't capture any lifetimes, leading to ICEs.

This PR makes sure we collect the lifetimes for associated type bounds as well, and make sure that they are set up correctly for opaque type lowering later.

Fixes #115360

[^1]: #114489
2023-08-31 21:13:54 +00:00
bors
91942134c6 Auto merge of #115389 - bvanjoi:fix-115380, r=petrochenkov
fix(resolve): update def if binding is warning ambiguity

Fixes #115380
2023-08-31 16:57:11 +00:00
bors
4b71f03039 Auto merge of #115384 - lqd:default-universe-info, r=matthewjasper
Work around ICE in diagnostics for local super-universes missing `UniverseInfo`s

In issue #114907, canonicalization of liveness dropck-outlives results (IIUC) encounters universes absent from the original query.  Some local universes [are created](f3a1bae88c/compiler/rustc_infer/src/infer/canonical/query_response.rs (L417-L425)) for the mapping, but importantly, they won't have associated causes.

These missing `UniverseInfo`s can be [needed](f3a1bae88c/compiler/rustc_borrowck/src/diagnostics/region_errors.rs (L376)) during diagnostics, [causing the `IndexMap: key not found` ICE](d55522aad8/compiler/rustc_borrowck/src/region_infer/mod.rs (L2252)) seen in the issue.

This PR works around this by returning the suboptimal catch-all cause, to avoid the ICE. It does results in suboptimal diagnostics right now, but it's better than an ICE.

r? `@matthewjasper.`

Let me know if there's a good easy-ish way to fix this, but I believe that for some of these erroneous cases and diagnostics, that inference/canonicalization/higher-ranked subtyping/etc may not behave exactly the same with the new trait solver? If that's the case then it'd probably be best to wait a bit more to do the correct fix.

Fixes #114907.

cc `@aliemjay`
2023-08-31 15:13:05 +00:00
bohan
107152141b fix(resolve): update def if binding is warning ambiguity 2023-08-31 20:00:04 +08:00
bors
784916ce24 Auto merge of #115290 - compiler-errors:ctor-unsafe, r=cjgillot
`rustc_layout_scalar_valid_range` makes ctors unsafe

We already validate this when we use the ctor in a call, e.g. `Variant(1)`, but not if we use the ctor as a fn ptr, e.g. `.map(Variant)`. The easiest way to fix the latter is (afaict) is by marking the ctor as unsafe itself.

Fixes #115284
2023-08-31 11:16:37 +00:00
bors
e51c5ea16f Auto merge of #115392 - compiler-errors:coherence-spans, r=aliemjay
Don't record spans for predicates in coherence

Should improve perf (https://github.com/rust-lang/rust/pull/115107#issuecomment-1695090589) for https://github.com/rust-lang/rust/pull/114023#issuecomment-1688514709

r? aliemjay
2023-08-31 00:34:04 +00:00
bors
b1b244da65 Auto merge of #115194 - tmiasko:inline-always-encode-mir, r=compiler-errors
Fix inlining with -Zalways-encode-mir

Only inline functions that are considered eligible for inlining
by the reachability pass.

This constraint was previously indirectly enforced by only exporting MIR
of eligible functions, but that approach doesn't work with
-Zalways-encode-mir enabled.
2023-08-30 22:51:12 +00:00
Michael Goulet
bf66723c0e Test and note unsafe ctor to fn ptr coercion
Also remove a note that I don't consider to be very useful in context.
2023-08-30 15:09:40 -07:00
Michael Goulet
0100a94231 rustc_layout_scalar_valid_range makes ctors unsafe 2023-08-30 15:01:58 -07:00
bors
59a8294849 Auto merge of #115144 - Zoxc:parallel-guard, r=compiler-errors
Add `ParallelGuard` type to handle unwinding in parallel sections

This adds a `ParallelGuard` type to handle unwinding in parallel sections instead of manually dealing with panics in each parallel operation. This also adds proper panic handling to the `join` operation.

cc `@SparrowLii`
2023-08-30 19:33:13 +00:00
Martin Nordholts
456007af12 Emit error instead of ICE when optimized MIR is missing
Closes 51388.
2023-08-30 20:43:31 +02:00
Weihang Lo
a11805ae46
feat(rustc_lint): make CheckLintName respect lint level 2023-08-30 19:24:44 +01:00
Michael Goulet
4647aea7aa Don't record spans for predicates in coherence 2023-08-30 18:24:18 +00:00
John Kåre Alsaker
242805442b Update failure status 2023-08-30 18:13:09 +02:00
Rémy Rakic
f3a1bae88c add test for issue 114907 2023-08-30 14:10:52 +00:00
Weihang Lo
ecff1c012e
test(ui/lint): demonstrate the current cmdline lint behavior
This demonstrates the current behavior of adding lint form the command
line. generally the lint levels are ignored as the current implementation
unconditionally emit errors for those lints.
2023-08-30 15:10:35 +01:00
Oli Scherer
5d850e0f50 Permit recursive weak type aliases 2023-08-30 11:55:03 +00:00
Oli Scherer
e82ccd52db Test variances of TAITs 2023-08-30 11:23:42 +00:00
Oli Scherer
e0a60f0740 Revert "Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726"
This reverts commit cb9467515b, reversing
changes made to 57781b24c5.
2023-08-30 11:06:46 +00:00
Ding Xiang Fei
d9ed11872f
lower bare boolean expression with if-construct 2023-08-30 17:24:11 +08:00
Ding Xiang Fei
e5453b4806
lower ExprKind::Use, LogicalOp::Or and UnOp::Not
Co-authored-by: Abdulaziz Ghuloum <aghuloum@gmail.com>
2023-08-30 17:24:10 +08:00
Matthias Krüger
ea2347843c
Rollup merge of #115363 - kpreid:suggest-private, r=compiler-errors
Don't suggest adding parentheses to call an inaccessible method.

Previously, code of this form would emit E0615 (attempt to use a method as a field), thus emphasizing the existence of private methods that the programmer probably does not care about. Now it ignores their existence instead, producing error E0609 (no field). The motivating example is:

```rust
let x = std::rc::Rc::new(());
x.inner;
```

which would previously mention the private method `Rc::inner()`, even though `Rc<T>` intentionally has no public methods so that it can be a transparent smart pointer for any `T`.

```rust
error[E0615]: attempted to take value of method `inner` on type `Rc<()>`
 --> src/main.rs:3:3
  |
3 | x.inner;
  |   ^^^^^ method, not a field
  |
help: use parentheses to call the method
  |
3 | x.inner();
  |        ++
  ```

  With this change, it emits E0609 and no suggestion.
2023-08-30 07:18:13 +02:00
Matthias Krüger
36182f1f13
Rollup merge of #115355 - lqd:issue-115351, r=compiler-errors
new solver: handle edge case of a recursion limit of 0

Apparently a recursion limit of 0 is possible/valid/useful/used/cute, the more you know 🌟 .

(It's somewhat interesting to me that the old solver seemingly handles this, and that the new solver currently requires a recursion limit of 2 here)

r? `@compiler-errors.`

Fixes #115351.
2023-08-30 07:18:13 +02:00
Matthias Krüger
58c690729c
Rollup merge of #115347 - y21:generic-bound-impl-trait-ty, r=compiler-errors
suggest removing `impl` in generic trait bound position

rustc already does this recovery in type param position (`<T: impl Trait>` -> `<T: Trait>`).
This PR also adds that suggestion in trait bound position (e.g. `where T: impl Trait` or `trait Trait { type Assoc: impl Trait; }`)
2023-08-30 07:18:12 +02:00
Matthias Krüger
2128efd87f
Rollup merge of #115313 - gurry:issue-114918-cycle-detected, r=compiler-errors
Make `get_return_block()` return `Some` only for HIR nodes in body

Fixes #114918

The issue occurred while compiling the following input:

```rust
fn uwu() -> [(); { () }] {
    loop {}
}
```

It was caused by the code below trying to suggest a missing return type which resulted in a const eval cycle: 1bd043098e/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs (L68-L75)

The root cause was `get_return_block()` returning an `Fn` node for a node in the return type (i.e. the second `()` in the return type `[(); { () }]` of the input) although it is supposed to do so only for nodes that lie in the body of the function and return `None` otherwise (at least as per my understanding).

The PR fixes the issue by fixing this behaviour of `get_return_block()`.
2023-08-30 07:18:11 +02:00
Matthias Krüger
639116505a
Rollup merge of #114704 - bvanjoi:fix-114636, r=compiler-errors
parser: not insert dummy field in struct

Fixes #114636

This PR eliminates the dummy field, initially introduced in #113999, thereby enabling unrestricted use of `ident.unwrap()`. A side effect of this action is that we can only report the error of the first macro invocation field within the struct node.

An alternative solution might be giving a virtual name to the macro, but it appears more complex.(https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715). Furthermore, if you think https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 is a better solution, feel free to close this PR.
2023-08-30 07:18:10 +02:00
Gurinder Singh
136f0579d8 Make get_return_block() return Some only for HIR nodes in body
Fixes # 114918
2023-08-30 07:40:08 +05:30
Michael Goulet
f1679f7dd6 Capture lifetimes for associated type bounds destined to be lowered to opaques 2023-08-30 00:31:00 +00:00
Kevin Reid
7b837e075a Don't suggest adding parentheses to call an inaccessible method.
Previously, the test code would emit E0615, thus revealing the existence
of private methods that the programmer probably does not care about.
Now it ignores their existence instead, producing error E0609 (no field).

The motivating example is:

```rust
let x = std::rc::Rc::new(());
x.inner;
```

which would previously mention the private method `Rc::inner()`, even
though `Rc<T>` intentionally has no public methods so that it can be a
transparent smart pointer for any `T`.
2023-08-29 14:47:28 -07:00
Rémy Rakic
325b585259 add non-regression test for issue 115351 2023-08-29 19:03:08 +00:00
Matthias Krüger
56d7d93a4b
Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obk
Don't ICE on layout computation failure

Fixes #111176 regression.

r? `@oli-obk`
2023-08-29 20:49:02 +02:00
y21
507f10baee suggest removing impl in generic trait bound position 2023-08-29 20:27:38 +02:00
bors
bb90f81070 Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkov
Move tests

r? `@petrochenkov`
2023-08-29 13:53:34 +00:00
Ralf Jung
9dd682803f repr(transparent): it's fine if the one non-1-ZST field is a ZST 2023-08-29 14:11:50 +02:00
Ralf Jung
bf91321e0f there seems to be no reason to treat ZST specially in these cases 2023-08-29 08:58:58 +02:00
Ralf Jung
0da9409e08 rustc_abi: audit uses of is_zst; fix a case of giving an enum insufficient alignment 2023-08-29 08:58:58 +02:00
Caio
5a69151d7d Move tests 2023-08-28 17:47:37 -03:00
bors
4e78abb437 Auto merge of #115326 - matthiaskrgr:rollup-qsoa8ar, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115164 (MIR validation: reject in-place argument/return for packed fields)
 - #115240 (codegen_llvm/llvm_type: avoid matching on the Rust type)
 - #115294 (More precisely detect cycle errors from type_of on opaque)
 - #115310 (Document panic behavior across editions, and improve xrefs)
 - #115311 (Revert "Suggest using `Arc` on `!Send`/`!Sync` types")
 - #115317 (Devacationize oli-obk)
 - #115319 (don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead)
 - #115322 (Tweak output of `to_pretty_impl_header` involving only anon lifetimes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-28 19:57:32 +00:00
Katherine Philip
56b767322b Don't ICE on layout computation failure 2023-08-28 12:40:39 -07:00
bors
93dd620241 Auto merge of #114489 - compiler-errors:rpitit-capture-all, r=oli-obk
Make RPITITs capture all in-scope lifetimes

Much like #114616, this implements the lang team decision from this T-lang meeting on [opaque captures strategy moving forward](https://hackmd.io/sFaSIMJOQcuwCdnUvCxtuQ?view). This will be RFC'd soon, but given that RPITITs are a nightly feature, this shouldn't necessarily be blocked on that.

We unconditionally capture all lifetimes in RPITITs -- impl is not as simple as #114616, since we still need to duplicate RPIT lifetimes to make sure we reify any late-bound lifetimes in scope.

Closes #112194
2023-08-28 18:05:16 +00:00
Matthias Krüger
07a32e2dbd
Rollup merge of #115322 - estebank:list-tweak, r=compiler-errors
Tweak output of `to_pretty_impl_header` involving only anon lifetimes

Do not print `impl<> Foo for &Bar`.
2023-08-28 19:53:59 +02:00
Matthias Krüger
9b0abe3537
Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errors
Revert "Suggest using `Arc` on `!Send`/`!Sync` types"

Closes https://github.com/rust-lang/rust/issues/114687. This is a clean revert of https://github.com/rust-lang/rust/pull/88936 + https://github.com/rust-lang/rust/pull/115210. The suggestion to Arc\<{Self}\> when Self does not implement Send is *always* wrong.

https://github.com/rust-lang/rust/pull/114842 is considering a way to make a more refined suggestion.
2023-08-28 19:53:57 +02:00
Matthias Krüger
b4c63f06e8
Rollup merge of #115294 - compiler-errors:cycle-err, r=oli-obk
More precisely detect cycle errors from type_of on opaque

Not sure if this still needs work. Just putting it up for initial impressions, since it seems that a few people are frustrated with the increased error verbosity due to #113320.

Essentially we introduce a new sub-query for `type_of` specifically for opaques which returns a value that is able to distinguish "has errors" from "due to cycle recovery".

Fixes #115188

r? `@oli-obk`
2023-08-28 19:53:56 +02:00
Esteban Küber
ecf2f68e45 Tweak output of to_pretty_impl_header involving only anon lifetimes
Do not print `impl<> Foo for &Bar`.
2023-08-28 17:17:11 +00:00
Ralf Jung
a671127941 closure field capturing: don't depend on alignment of packed fields 2023-08-28 18:25:37 +02:00
bors
c587fd4185 Auto merge of #114774 - Enselic:less-move-size-noise, r=oli-obk
Avoid duplicate `large_assignments` lints

By checking for overlapping spans.

This PR does the "reduce noisiness" task in #83518.

r? `@oli-obk` who added E-mentor and E-help-wanted and wrote the initial code.

(The fix itself is in dc82736677. The two commits before that are just small refactorings.)
2023-08-28 13:36:19 +00:00
David Tolnay
823bacb6e3
Revert "Suggest using Arc on !Send/!Sync types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
Matthew Jasper
89235fd837 Allow stuct literals in if let guards
This is consistent with normal match guards.
2023-08-28 10:31:45 +01:00