Commit Graph

3375 Commits

Author SHA1 Message Date
Guillaume Gomez d05c5fecde
Rollup merge of #115936 - oli-obk:inline_const_promotion, r=RalfJung
Prevent promotion of const fn calls in inline consts

We don't wanna make that mistake we did for statics and consts worse by letting more code use it.

r? ``@RalfJung``

cc https://github.com/rust-lang/rust/issues/76001
2023-09-21 13:25:38 +02:00
Guillaume Gomez 9ce64bae94
Rollup merge of #115257 - Urgau:invalid-utf8-walk-up-hir, r=Nilstrieb
Improve invalid UTF-8 lint by finding the expression initializer

This PR introduce a small mechanism to walk up the HIR through bindings, if/else, consts, ... when trying lint on invalid UTF-8.

Fixes https://github.com/rust-lang/rust/issues/115208
2023-09-21 13:25:38 +02:00
Oli Scherer 9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Oli Scherer 44e199bf30 Add regression test 2023-09-21 08:50:08 +00:00
Urgau f156d3bc57 Improve invalid UTF-8 lint by finding the expression initializer 2023-09-21 10:16:29 +02:00
lcnr 8eade3aa71 update tests 2023-09-21 08:17:58 +02:00
bors ad36b5a622 Auto merge of #115987 - loongarch-rs:fix-transparent-union-abi, r=bjorn3
rustc_target/loongarch: 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/115509

r? `@bjorn3`
2023-09-20 19:55:38 +00:00
León Orell Valerian Liehr 8d81d5a909
Validate crate name in CLI option --extern 2023-09-20 18:50:40 +02:00
Obei Sideg 77e205a113 Migrate `rustc_hir_analysis` to session diagnostic
Part 5: Finishing `coherence/builtin.rs` file
2023-09-20 10:56:44 +03:00
Matthias Krüger 3304ea4218
Rollup merge of #115965 - matthewjasper:extra-if-let-guard-tests, r=compiler-errors
Add more if let guard tests

cc #51114
2023-09-20 09:24:30 +02:00
bors 0e11725809 Auto merge of #115734 - tmiasko:kcfi-no-core, r=compiler-errors
Use no_core for KCFI tests to exercise them in CI
2023-09-20 05:24:34 +00:00
bors 4b91288484 Auto merge of #115486 - compiler-errors:dont-capture-late-pls, r=cjgillot
Correctly deny late-bound lifetimes from parent in anon consts and TAITs

Reuse the `AnonConstBoundary` scope (introduced in #108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs.

Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657):
c4f25777a0/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs (L733-L754) but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched.

Fixes #115474
2023-09-20 03:34:51 +00:00
Deadbeef 2063ebc3ea bless the known-bug tests 2023-09-20 03:02:14 +00:00
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
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
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