Commit graph

7473 commits

Author SHA1 Message Date
Esteban Küber ac56a2b564 Suggest boxing if then expr if that solves divergent arms
When encountering

```rust
let _ = if true {
    Struct
} else {
    foo() // -> Box<dyn Trait>
};
```

if `Struct` implements `Trait`, suggest boxing the then arm tail expression.

Part of #102629.
2024-01-22 20:53:41 +00:00
Esteban Küber 390ef9ba02 Fix incorrect suggestion for boxing tail expression in blocks 2024-01-22 20:51:19 +00:00
Erik Kaneda 42556b4e4d
assembly test: add riscv32im_risc0_zkvm_elf target 2024-01-22 12:04:56 -08:00
Erik Kaneda 05f8650fe8
update ui test result 2024-01-22 10:25:57 -08:00
bors d5fd099729 Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #117910 (Refactor uses of `objc_msgSend` to no longer have clashing definitions)
 - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler)
 - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in)
 - #120058 (bootstrap: improvements for compiler builds)
 - #120059 (Make generic const type mismatches not hide trait impls from the trait solver)
 - #120097 (Report unreachable subpatterns consistently)
 - #120137 (Validate AggregateKind types in MIR)
 - #120164 (`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`)
 - #120181 (Allow any `const` expression blocks in `thread_local!`)
 - #120218 (rustfmt: Check that a token can begin a nonterminal kind before parsing it as a macro arg)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 18:22:32 +00:00
Esteban Küber 29bdf9ea51 Account for single where bound being removed 2024-01-22 17:52:36 +00:00
Matthias Krüger 6e4933f94f
Rollup merge of #120164 - trevyn:is_downgradable, r=compiler-errors
`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`

https://github.com/rust-lang/rust/pull/119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
2024-01-22 16:54:59 +01:00
Matthias Krüger f194a84ce2
Rollup merge of #120097 - Nadrieril:consistent_unreachable_subpats, r=compiler-errors
Report unreachable subpatterns consistently

We weren't reporting unreachable subpatterns in function arguments and `let` expressions. This wasn't very important, but never patterns make it more relevant: a user might write `let (Ok(x) | Err(!)) = ...` in a case where `let Ok(x) = ...` is accepted, so we should report the `Err(!)` as redundant.

r? ```@compiler-errors```
2024-01-22 16:54:58 +01:00
Matthias Krüger d942357d7a
Rollup merge of #120059 - oli-obk:const_arg_type_mismatch, r=compiler-errors
Make generic const type mismatches not hide trait impls from the trait solver

pulled out of https://github.com/rust-lang/rust/pull/119895

It does improve diagnostics somewhat, but also causes some extraneous diagnostics in potentially misleading order.

The issue was that a const type mismatch, instead of reporting an error, would silently poison the constant, only for that information to be thrown away and the impl to be treated as "not matching". In #119895 this would cause ICEs as well as errors on impls stating that the impl needs to exist for itself to be valid.
2024-01-22 16:54:58 +01:00
Matthias Krüger a54c295665
Rollup merge of #118639 - fmease:deny-features-in-stable-rustc-crates, r=WaffleLapkin
Undeprecate lint `unstable_features` and make use of it in the compiler

See also #117937.

r? compiler
2024-01-22 16:54:56 +01:00
Nadrieril 3ff10242fe Test async fn 2024-01-22 16:24:37 +01:00
Nadrieril c5a4e074f0 Use -> ! to test divergence 2024-01-22 16:15:44 +01:00
Matthias Krüger ba542c823d
Rollup merge of #120213 - compiler-errors:dont-make-non-lifetime-binders-in-rtn, r=fmease
Don't actually make bound ty/const for RTN

Avoid creating an unnecessary non-lifetime binder when we do RTN on a method that has ty/const params.

Fixes #120208

r? oli-obk
2024-01-22 16:13:30 +01:00
Matthias Krüger 2346647daf
Rollup merge of #120152 - rowan-sl:help-message-for-range-pattern, r=oli-obk
add help message for `exclusive_range_pattern` error

Fixes #120047

this error
```
error[E0658]: exclusive range pattern syntax is experimental
 --> src/lib.rs:3:9
  |
3 |         0..42 => {},
  |         ^^^^^
  |
  = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
  = help: use an inclusive range pattern, like N..=M
  ```
now includes a help message

Not sure of proper procedure here but this seemed like a good help message (used the one suggested in the original issue), if you have a idea for one that is better or something I missed please comment!
2024-01-22 16:13:29 +01:00
Matthias Krüger 34bab29ef9
Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r=TaKO8Ki
Make `unsafe_op_in_unsafe_fn` migrated in edition 2024

fixes rust-lang/rust#119823
2024-01-22 16:13:28 +01:00
Matthias Krüger c5984caa44
Rollup merge of #119369 - bvanjoi:fix-119301, r=petrochenkov
exclude unexported macro bindings from extern crate

Fixes #119301

Macros that aren't exported from an external crate should not be defined.

r? ``@petrochenkov``
2024-01-22 16:13:25 +01:00
joboet 638439a440
update codegen tests 2024-01-22 15:46:32 +01:00
Oli Scherer 5e5d1350b6 Check that we forbid nested items, but not nested closures 2024-01-22 14:35:47 +00:00
Oli Scherer 4e0769956b Add some tests 2024-01-22 14:35:47 +00:00
Oli Scherer f75361fec7 Limit impl trait in assoc type defining scope 2024-01-22 14:35:46 +00:00
Oli Scherer 483382b93e Add regression test 2024-01-22 14:24:31 +00:00
Oli Scherer 9a20cf1697 Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin"
This reverts commit 6d2b84b3ed, reversing
changes made to 73bc12199e.
2024-01-22 14:24:31 +00:00
Nadrieril d1f1075931 Never pattern in let statement diverges 2024-01-22 15:12:57 +01:00
Nadrieril a9ea07d17c Never pattern in function arguments diverges 2024-01-22 15:12:57 +01:00
Oli Scherer 9454b51b05 Make generic const type mismatches not hide trait impls from the trait solver 2024-01-22 13:23:45 +00:00
bors 366d112fa6 Auto merge of #120226 - matthiaskrgr:rollup-9xwx0si, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #118714 ( Explanation that fields are being used when deriving `(Partial)Ord` on enums)
 - #119710 (Improve `let_underscore_lock`)
 - #119726 (Tweak Library Integer Division Docs)
 - #119746 (rustdoc: hide modals when resizing the sidebar)
 - #119986 (Fix error counting)
 - #120194 (Shorten `#[must_use]` Diagnostic Message for `Option::is_none`)
 - #120200 (Correct the anchor of an URL in an error message)
 - #120203 (Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests)
 - #120212 (Give nnethercote more reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 11:08:57 +00:00
Nicholas Nethercote 1fbabeeb2e Fix some cases in space_between.
There are a number of cases where we erroneously omit the space between
two tokens, all involving an exception to a more general case. The
affected tokens are `$`, `!`, `.`, `,`, and `let` followed by a
parenthesis.

This fixes a lot of FIXME comments.
2024-01-22 20:19:17 +11:00
Nicholas Nethercote 41e4a3e086 Don't insert spaces before most semicolons in print_tts.
This gives better output for code produced by proc macros.
2024-01-22 20:14:59 +11:00
Ralf Jung 0288a0bfa0 raw pointers are not references 2024-01-22 09:28:00 +01:00
Ralf Jung 2f1a8e2d7a const-eval interner: from-scratch rewrite using mutability information from provenance rather than types 2024-01-22 09:28:00 +01:00
Matthias Krüger 6687e8e460
Rollup merge of #119746 - notriddle:notriddle/resize-close-modals, r=fmease
rustdoc: hide modals when resizing the sidebar

Follow-up for
https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011

CC `@lukas-code`
2024-01-22 07:56:42 +01:00
Matthias Krüger 72dddeaeb7
Rollup merge of #119710 - Nilstrieb:let-_-=-oops, r=TaKO8Ki
Improve `let_underscore_lock`

- lint if the lock was in a nested pattern
- lint if the lock is inside a `Result<Lock, _>`

addresses https://github.com/rust-lang/rust/pull/119704#discussion_r1444044745
2024-01-22 07:56:41 +01:00
Zalathar 41dcba805d coverage: Don't instrument #[automatically_derived] functions 2024-01-22 12:18:57 +11:00
Michael Goulet 802d16ce3a Don't actually make bound ty/const for RTN 2024-01-21 23:08:03 +00:00
trevyn b58a8a98cd maybe_lint_impl_trait: separate is_downgradable from is_object_safe 2024-01-21 20:04:39 +04:00
Jaro Fietz 98f59817c2
Rename function in weird-exprs.rs for clarity 2024-01-21 13:47:45 +01:00
bohan 9c3091e9cf exclude unexported macro bindings from extern crate 2024-01-21 20:24:40 +08:00
Zalathar 6d7e80c5bc Add #[coverage(off)] to closures introduced by #[test]/#[bench] 2024-01-21 23:17:00 +11:00
Zalathar bdfc64ac98 coverage: Add a test that uses #[bench] 2024-01-21 23:17:00 +11:00
Matthias Krüger a72d6c114b
Rollup merge of #120128 - oli-obk:smir_internal_lift, r=celinval
Make stable_mir::with_tables sound

See the first commit for the actual soundness fix. The rest is just fallout from that and is entirely safe code. Includes most of #120120

The major difference to #120120 is that we don't need an unsafe trait, as we can now rely on the type system (the only unsafe part, and the actual source of the unsoundness was in `with_tables`)

r? `@celinval`
2024-01-21 12:28:52 +01:00
Nadrieril e8678b1030
Rollup merge of #120015 - Zalathar:format, r=dtolnay
coverage: Format all coverage tests with `rustfmt`

As suggested by <https://github.com/rust-lang/rust/pull/119984#discussion_r1452856806>.

Test files in `tests/` are normally ignored by `x fmt`, but sometimes those files end up being run through `rustfmt` anyway, either by `rust-analyzer` or by hand.

When that happens, it's annoying to have to manually revert formatting changes that are unrelated to the actual changes being made. So it's helpful for the tests in the repository to already have standard formatting beforehand.

However, there are several coverage tests that deliberately use non-standard formatting, so that line counts reveal more information about where code regions begin and end. In those cases, we can use `#[rustfmt::skip]` to prevent that code from being disturbed.

``@rustbot`` label +A-code-coverage
2024-01-21 06:38:37 +01:00
Nadrieril 203cc6930e
Rollup merge of #119461 - cjgillot:jump-threading-interp, r=tmiasko
Use an interpreter in MIR jump threading

This allows to understand assignments of aggregate constants. This case appears more frequently with GVN promoting aggregates to constants.
2024-01-21 06:38:36 +01:00
yukang 3ed96e35c4 Suggest arry::from_fn for array initialization 2024-01-21 09:57:26 +08:00
bors 4cb17b4e78 Auto merge of #111803 - scottmcm:simple-swap-alternative, r=Mark-Simulacrum
Tweak the threshold for chunked swapping

Thanks to `@AngelicosPhosphoros` for the tests here, which I copied from #98892.

This is an experiment as a simple alternative to that PR that just tweaks the existing threshold, since that PR showed that 3×Align (like `String`) currently doesn't work as well as it could.
2024-01-20 21:54:44 +00:00
Guillaume Gomez 8f5f967031
Rollup merge of #120063 - clubby789:remove-box-handling, r=Nilstrieb
Remove special handling of `box` expressions from parser

#108471 added a temporary hack to parse `box expr`. It's been almost a year since then, so I think it's safe to remove the special handling.

As a drive-by cleanup, move `parser/removed-syntax*` tests to their own directory.
2024-01-20 20:06:34 +01:00
sfzhu93 7ad307dc9d finish a pattern in enum.rs 2024-01-20 08:22:07 -08:00
sfzhu93 edba94907d update misuse of check-label 2024-01-20 08:09:14 -08:00
jyn c3e4c457fe Track verbose and verbose_internals
bjorn3 says:
> On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik.
Otherwise we would have to replay the query in question, which we may not be able to do if the query
key is not reconstructible from the dep node fingerprint.

So we must track these flags to avoid replaying incorrect diagnostics.
2024-01-20 08:00:09 -05:00
Guillaume Gomez 0933f48ac0 Add regression test for #119015 and update tests 2024-01-20 13:21:03 +01:00
Matthias Krüger b7c2ba71c8
Rollup merge of #120148 - trevyn:issue-117965, r=cjgillot
`single_use_lifetimes`: Don't suggest deleting lifetimes with bounds

Closes #117965

```
9 |     pub fn get<'b: 'a>(&'b self) -> &'a str {
  |                ^^       -- ...is used only here
  |                |
  |                this lifetime...
```

In this example, I think the `&'b self` can be replaced with the bound itself, yielding `&'a self`, but this would require a deeper refactor. Happy to do as a follow-on PR if desired.
2024-01-20 09:37:28 +01:00
Matthias Krüger 177d51372c
Rollup merge of #119752 - estebank:ice-ice, r=fmease
Avoid ICEs in trait names without `dyn`

Check diagnostic is error before downgrading. Fix #119633.

 Account for traits using self-trait by name without `dyn`. Fix #119652.
2024-01-20 09:37:27 +01:00
Matthias Krüger 6f67208d72
Rollup merge of #118799 - GKFX:stabilize-simple-offsetof, r=wesleywiser
Stabilize single-field offset_of

This PR stabilizes offset_of for a single field. There has been some further discussion at https://github.com/rust-lang/rust/issues/106655 about whether this is advisable; I'm opening the PR anyway so that the code is available.
2024-01-20 09:37:26 +01:00
AngelicosPhosphoros 60208a0517 Tweak the threshold for chunked swapping
Thanks to 98892 for the tests I brought in here, as it demonstrated that 3×usize is currently suboptimal.
2024-01-19 23:00:34 -08:00
bors 5378c1cf07 Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnr
Always use RevealAll for const eval queries

implements what is described in https://github.com/rust-lang/rust/pull/116803#discussion_r1364089471

Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types.

New tests are copied from https://github.com/rust-lang/rust/pull/101478
2024-01-20 04:57:51 +00:00
bors 128148d4cf Auto merge of #120136 - matthiaskrgr:rollup-3zzb0z9, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #117561 (Stabilize `slice_first_last_chunk`)
 - #117662 ([rustdoc] Allows links in headings)
 - #119815 (Format sources into the error message when loading codegen backends)
 - #119835 (Exhaustiveness: simplify empty pattern logic)
 - #119984 (Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`.)
 - #120009 (never_patterns: typecheck never patterns)
 - #120122 (Don't add needs-triage to A-diagnostics)
 - #120126 (Suggest `.swap()` when encountering conflicting borrows from `mem::swap` on a slice)
 - #120134 (Restrict access to the private field of newtype indexes)

Failed merges:

 - #119968 (Remove unused/unnecessary features)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-20 02:58:08 +00:00
bors 0547c41f90 Auto merge of #116672 - maurer:128-align, r=nikic
LLVM 18 x86 data layout update

With https://reviews.llvm.org/D86310 LLVM now has i128 aligned to 16-bytes on x86 based platforms. This will be in LLVM-18. This patch updates all our spec targets to be 16-byte aligned, and removes the alignment when speaking to older LLVM.

This results in Rust overaligning things relative to LLVM on older LLVMs.

This implements MCP https://github.com/rust-lang/compiler-team/issues/683.

See #54341
2024-01-20 00:56:53 +00:00
Esteban Küber c85bb274f6 Account for trailing comma in removal suggestion 2024-01-19 23:55:05 +00:00
Esteban Küber 2c2f3ed2c4 Provide more context on recursive impl evaluation overflow
When an associated type `Self::Assoc` is part of a `where` clause,
we end up unable to evaluate the requirement and emit a E0275.

We now point at the associated type if specified in the `impl`. If
so, we also suggest using that type instead of `Self::Assoc`.
Otherwise, we explain that these are not allowed.

```
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
  --> $DIR/impl-wf-cycle-1.rs:15:1
   |
LL | / impl<T: Grault> Grault for (T,)
LL | |
LL | | where
LL | |     Self::A: Baz,
LL | |     Self::B: Fiz,
   | |_________________^
LL |   {
LL |       type A = ();
   |       ------ associated type `<(T,) as Grault>::A` is specified here
   |
note: required for `(T,)` to implement `Grault`
  --> $DIR/impl-wf-cycle-1.rs:15:17
   |
LL | impl<T: Grault> Grault for (T,)
   |                 ^^^^^^     ^^^^
...
LL |     Self::A: Baz,
   |              --- unsatisfied trait bound introduced here
   = note: 1 redundant requirement hidden
   = note: required for `(T,)` to implement `Grault`
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
   |
LL -     Self::A: Baz,
LL +     ,
   |
```
```
error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type`
  --> $DIR/impl-wf-cycle-3.rs:7:1
   |
LL | / impl<T> B for T
LL | | where
LL | |     T: A<Self::Type>,
   | |_____________________^
LL |   {
LL |       type Type = bool;
   |       --------- associated type `<T as B>::Type` is specified here
   |
note: required for `T` to implement `B`
  --> $DIR/impl-wf-cycle-3.rs:7:9
   |
LL | impl<T> B for T
   |         ^     ^
LL | where
LL |     T: A<Self::Type>,
   |        ------------- unsatisfied trait bound introduced here
help: replace the associated type with the type specified in this `impl`
   |
LL |     T: A<bool>,
   |          ~~~~
```
```
error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch`
  --> $DIR/impl-wf-cycle-4.rs:5:1
   |
LL | / impl<T> Filter for T
LL | | where
LL | |     T: Fn(Self::ToMatch),
   | |_________________________^
   |
note: required for `T` to implement `Filter`
  --> $DIR/impl-wf-cycle-4.rs:5:9
   |
LL | impl<T> Filter for T
   |         ^^^^^^     ^
LL | where
LL |     T: Fn(Self::ToMatch),
   |        ----------------- unsatisfied trait bound introduced here
note: associated types for the current `impl` cannot be restricted in `where` clauses
  --> $DIR/impl-wf-cycle-4.rs:7:11
   |
LL |     T: Fn(Self::ToMatch),
   |           ^^^^^^^^^^^^^
```

Fix #116925
2024-01-19 23:55:05 +00:00
Esteban Küber 7edbc95c27 Update tests after rebase
Fix #119652.
2024-01-19 23:49:40 +00:00
Esteban Küber 6b7e6ea590 Account for traits using self-trait by name without dyn
Fix #119652.
2024-01-19 23:37:39 +00:00
Esteban Küber b1688b48d2 Avoid ICE: Check diagnostic is error before downgrading
Fix #119633.
2024-01-19 23:36:20 +00:00
trevyn de2575f35d Don't delete any lifetimes with bounds 2024-01-20 02:30:58 +04:00
trevyn 0943a6b188 add test issue-117965 2024-01-20 01:22:52 +04:00
George Bateman 7924c9bcdf
Split remaining offset_of features into new tracking issues 2024-01-19 21:13:11 +00:00
George Bateman 803b810eac
Remove feature(offset_of) from tests 2024-01-19 20:38:51 +00:00
George Bateman 615946db4f
Stabilize simple offset_of 2024-01-19 20:38:51 +00:00
Catherine Flores 5a4561749a Add new intrinsic is_constant and optimize pow
Fix overflow check

Make MIRI choose the path randomly and rename the intrinsic

Add back test

Add miri test and make it operate on `ptr`

Define `llvm.is.constant` for primitives

Update MIRI comment and fix test in stage2

Add const eval test

Clarify that both branches must have the same side effects

guaranteed non guarantee

use immediate type instead

Co-Authored-By: Ralf Jung <post@ralfj.de>
2024-01-19 13:46:27 -05:00
Rowan S-L 1c77f8738f add help message for exclusive_range_pattern error 2024-01-19 13:38:24 -05:00
Matthias Krüger c851150236
Rollup merge of #120126 - sjwang05:issue-102269, r=compiler-errors
Suggest `.swap()` when encountering conflicting borrows from `mem::swap` on a slice

This PR modifies the existing suggestion by matching on `[ProjectionElem::Deref, ProjectionElem::Index(_)]` instead of just `[ProjectionElem::Index(_)]`, which caused us to miss many cases. Additionally, it adds a more specific, machine-applicable suggestion in the case we determine `mem::swap` was used to swap elements in a slice.

Closes #102269
2024-01-19 19:27:03 +01:00
Matthias Krüger 5761c36c0a
Rollup merge of #120009 - Nadrieril:never_patterns_tyck, r=compiler-errors
never_patterns: typecheck never patterns

This checks that a `!` pattern is only used on an uninhabited type (modulo match ergonomics, i.e. `!` is allowed on `&Void`).

r? `@compiler-errors`
2024-01-19 19:27:02 +01:00
Matthias Krüger 455382d8df
Rollup merge of #119984 - kpreid:waker-noop, r=dtolnay
Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`.

The advantage of this is that it does not need to be assigned to a variable to be used in a `Context` creation, which is the most common thing to want to do with a noop waker. It also avoids unnecessarily executing the dynamically dispatched drop function when the noop waker is dropped.

If an owned noop waker is desired, it can be created by cloning, but the reverse is harder to do since it requires declaring a constant. Alternatively, both versions could be provided, like `futures::task::noop_waker()` and `futures::task::noop_waker_ref()`, but that seems to me to be API clutter for a very small benefit, whereas having the `&'static` reference available is a large reduction in boilerplate.

[Previous discussion on the tracking issue starting here](https://github.com/rust-lang/rust/issues/98286#issuecomment-1862159766)
2024-01-19 19:27:01 +01:00
Matthias Krüger cad609d9e3
Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddle
[rustdoc] Allows links in headings

Reopening of https://github.com/rust-lang/rust/pull/94360.

# Explanations

Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this:

![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3)

<details>
<summary>previous version</summary>

![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee)

</details>

Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it.

You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html).

cc `@camelid`
r? `@notriddle`
2024-01-19 19:26:59 +01:00
bors 88189a71e4 Auto merge of #120123 - lcnr:sadboi-compat, r=jackh726
use implied bounds compat mode in MIR borrowck

cc
- #119956
- #118553

This should hopefully fix bevy 🤔 `cargo test` ends up freezing my computer though, cargo build went from err to ok however 😁

r? `@jackh726`
2024-01-19 18:25:19 +00:00
bors 32ec40c685 Auto merge of #120121 - matthiaskrgr:rollup-razammh, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #118665 (Consolidate all associated items on the NonZero integer types into a single impl block per type)
 - #118798 (Use AtomicU8 instead of AtomicUsize in backtrace.rs)
 - #119062 (Deny braced macro invocations in let-else)
 - #119138 (Docs: Use non-SeqCst in module example of atomics)
 - #119907 (Update `fn()` trait implementation docs)
 - #120083 (Warn when not having a profiler runtime means that coverage tests won't be run/blessed)
 - #120107 (dead_code treats #[repr(transparent)] the same as #[repr(C)])
 - #120110 (Update documentation for Vec::into_boxed_slice to be more clear about excess capacity)
 - #120113 (Remove myself from review rotation)
 - #120118 (Fix typo in documentation in base.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-19 16:26:37 +00:00
lcnr 058ab53dc5 use implied bounds compat mode in MIR borrowck 2024-01-19 15:27:32 +01:00
Oli Scherer 867831a170 Always use RevealAll for const eval queries 2024-01-19 11:32:34 +00:00
Celina G. Val 9aace67235 Ensure internal function is safe
The internal function was unsound, it could cause UB in rare cases where
the user inadvertly stored the returned object in a location that could
outlive the TyCtxt.

In order to make it safe, we now take a type context as an argument to
the internal fn, and we ensure that interned items are lifted using the
provided context.

Thus, this change ensures that the compiler can properly enforce
that the object does not outlive the type context it was lifted to.
2024-01-19 10:00:32 +00:00
Nikita Popov ce2d91dccd Directly use volatile_load intrinsic
This makes the test work if libstd is compiled with debug assertions.
2024-01-19 10:52:01 +01:00
Nikita Popov 7a0415ce37 Add codegen test for ScalarPair with i128 on LLVM 17 2024-01-19 10:52:01 +01:00
sjwang05 f9faf16181
Suggest .swap() instead of mem::swap() in more cases 2024-01-19 01:30:46 -08:00
bors 92d727796b Auto merge of #120112 - matthiaskrgr:rollup-48o3919, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119582 (bootstrap: handle vendored sources when remapping crate paths)
 - #119730 (docs: fix typos)
 - #119828 (Improved collapse_debuginfo attribute, added command-line flag)
 - #119869 (replace `track_errors` usages with bubbling up `ErrorGuaranteed`)
 - #120037 (Remove `next_root_ty_var`)
 - #120094 (tests/ui/asm/inline-syntax: adapt for LLVM 18)
 - #120096 (Set RUSTC_BOOTSTRAP=1 consistently)
 - #120101 (change `.unwrap()` to `?` on write where `fmt::Result` is returned)
 - #120102 (Fix typo in munmap_partial.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-19 08:42:17 +00:00
Matthias Krüger 332f8f73ea
Rollup merge of #120107 - shepmaster:dead-code-repr-transparent, r=Nilstrieb
dead_code treats #[repr(transparent)] the same as #[repr(C)]

In #92972 we enabled linting on unused fields in tuple structs. In #118297 that lint was enabled by default. That exposed issues like #119659, where the fields of a struct marked `#[repr(transparent)]` were reported by the `dead_code` lint. The language team [decided](https://github.com/rust-lang/rust/issues/119659#issuecomment-1885172045) that the lint should treat `repr(transparent)` the same as `#[repr(C)]`.

Fixes #119659
2024-01-19 08:15:05 +01:00
Matthias Krüger 2e4c6fc998
Rollup merge of #119062 - compiler-errors:asm-in-let-else, r=davidtwco,est31
Deny braced macro invocations in let-else

Fixes #119057

Pending T-lang decision

cc `@dtolnay`
2024-01-19 08:15:03 +01:00
bors d3c9082a44 Auto merge of #120006 - cjgillot:no-hir-owner, r=wesleywiser
Get rid of the hir_owner query.

This query was meant as a firewall between `hir_owner_nodes` which is supposed to change often, and the queries that only depend on the item signature. That firewall was inefficient, leaking the contents of the HIR body through `HirId`s.

`hir_owner` incurs a significant cost, as we need to hash HIR twice in multiple modes. This PR proposes to remove it, and simplify the hashing scheme.

For the future, `def_kind`, `def_span`... are much more efficient for incremental decoupling, and should be preferred.
2024-01-19 02:36:13 +00:00
Camille GILLOT be9668d398 Use an interpreter in jump threading. 2024-01-18 22:53:07 +00:00
Nadrieril ff6fa67a9d Split-off the passing tests to ensure they pass 2024-01-18 21:15:25 +01:00
Nadrieril d8b72e796e Typecheck never patterns 2024-01-18 21:15:24 +01:00
Nadrieril a947c4c2c3 Add tests 2024-01-18 21:14:31 +01:00
Matthias Krüger 135476b051
Rollup merge of #120094 - krasimirgg:inline-asm-llvm-18, r=nikic
tests/ui/asm/inline-syntax: adapt for LLVM 18

Fixes https://github.com/rust-lang/rust/issues/119120.
2024-01-18 20:56:21 +01:00
Matthias Krüger fa52edaa51
Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasper
replace `track_errors` usages with bubbling up `ErrorGuaranteed`

more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-18 20:56:20 +01:00
Matthias Krüger c0da80f418
Rollup merge of #119828 - azhogin:azhogin/collapse_debuginfo_improved_attr, r=petrochenkov
Improved collapse_debuginfo attribute, added command-line flag

Improved attribute collapse_debuginfo with variants: `#[collapse_debuginfo=(no|external|yes)]`.
Added command-line flag for default behaviour.
Work-in-progress: will add more tests.

cc https://github.com/rust-lang/rust/issues/100758
2024-01-18 20:56:19 +01:00
Matthias Krüger 16489f7b51
Rollup merge of #119730 - vuittont60:master, r=GuillaumeGomez
docs: fix typos
2024-01-18 20:56:19 +01:00
Jake Goulding 92cc57bafc Remove no-longer-needed allow(dead_code) from the tests
`repr(transparent)` now silences the lint.
2024-01-18 13:16:09 -05:00
Jake Goulding d95d6ceecb dead_code treats #[repr(transparent)] the same as #[repr(C)]
Fixes #119659
2024-01-18 13:04:31 -05:00
bors 8424f8e8cd Auto merge of #120089 - matthiaskrgr:rollup-xyfqrb5, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #119172 (Detect `NulInCStr` error earlier.)
 - #119833 (Make tcx optional from StableMIR run macro and extend it to accept closures)
 - #119967 (Add `PatKind::Err` to AST/HIR)
 - #119978 (Move async closure parameters into the resultant closure's future eagerly)
 - #120021 (don't store const var origins for known vars)
 - #120038 (Don't create a separate "basename" when naming and opening a MIR dump file)
 - #120057 (Don't ICE when deducing future output if other errors already occurred)
 - #120073 (Remove spastorino from users_on_vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-18 16:39:32 +00:00
Nadrieril 0a9bb97229 Consistently warn unreachable subpatterns 2024-01-18 17:29:54 +01:00
Nadrieril 12ebc3dd96 Add tests 2024-01-18 15:42:25 +01:00
bors a34faab155 Auto merge of #118553 - jackh726:lint-implied-bounds, r=lcnr
error on incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of #109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint. This is tracked in #119956.

Fixes #109628
2024-01-18 14:16:55 +00:00
Krasimir Georgiev 2cc81baaf4 tests/ui/asm/inline-syntax: adapt for LLVM 18 2024-01-18 12:48:38 +00:00
David Wood 46652dd254
llvm: simplify data layout check
Don't skip the inconsistent data layout check for custom LLVMs.

With #118708, all targets will have a simple test that would trigger this
check if LLVM's data layouts do change - so data layouts would be
corrected during the LLVM upgrade. Therefore, with builtin targets, this
check won't trigger with our LLVM because each target will have been
confirmed to work. With non-builtin targets, this check is probably
useful to have because you can change the data layout in your target and
if its wrong then that could lead to bugs.

When using a custom LLVM, the same justification makes sense for
non-builtin targets as with our LLVM, the user can update their target to
match their LLVM and that's probably a good thing to do. However, with
a custom LLVM, the user cannot change the builtin target data layouts if
they don't match - though given that the compiler's data layout is used
for layout computation and a bunch of other things - you could get some
bugs because of the mismatch and probably want to know about that.

`CFG_LLVM_ROOT` was also always set during local development with
`download-ci-llvm` so this bug would never trigger locally.

Signed-off-by: David Wood <david@davidtw.co>
2024-01-18 10:46:03 +00:00
Matthias Krüger 34362b826d
Rollup merge of #120057 - oli-obk:not_sure_wtf_is_going_on, r=compiler-errors
Don't ICE when deducing future output if other errors already occurred

The situation can't really happen outside of erroneous code. What was interesting is that it ICEd before emitting any other diagnostics. This was because the other errors were silenced due to cycle_delay_bug cycle errors.

r? ```@compiler-errors```

fixes #119890
2024-01-18 10:34:20 +01:00
Matthias Krüger 536fc22917
Rollup merge of #119978 - compiler-errors:async-closure-captures, r=oli-obk
Move async closure parameters into the resultant closure's future eagerly

Move async closure parameters into the closure's resultant future eagerly.

Before, we used to desugar `async |p1, p2, ..| { body }` as `|p1, p2, ..| { || async { body } }`. Now, we desugar the above like `|p1, p2, ..| { async move { let p1 = p1; let p2 = p2; ... body } }`. This mirrors the same desugaring that `async fn` does with its parameter types, and the compiler literally uses the same code via a shared helper function.

This removes the necessity for E0708, since now expressions like `async |x: i32| { x }` will not give you confusing borrow errors.

This does *not* fix the case where async closures have self-borrows. This will come with a general implementation of async closures, which is still in the works.

r? oli-obk
2024-01-18 10:34:18 +01:00
Matthias Krüger c3e237c3ac
Rollup merge of #119833 - celinval:smir-accept-closures, r=oli-obk
Make tcx optional from StableMIR run macro and extend it to accept closures

Change `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`, and introduce `run_with_tcx` to capture use cases where `tcx` is required. Additionally, extend both macros to accept closures that may capture variables.

I've also modified the `internal()` method to make it safer, by accepting the type context to force the `'tcx` lifetime to match the context lifetime.

These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-18 10:34:17 +01:00
Matthias Krüger ff8c7a7816
Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov
Detect `NulInCStr` error earlier.

By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.

r? ```@fee1-dead```
2024-01-18 10:34:17 +01:00
Celina G. Val 6a573cbc60 Revert changes to internal method for now
- Move fix to a separate PR
2024-01-17 19:59:57 -08:00
Jack Huey a9e30e6cdf Don't use compat versions of implied bounds in ImpliedOutlivesBounds query 2024-01-17 22:03:06 -05:00
Ali MJ Al-Nasrawy d96003dd2a Correctly handle normalization in implied bounds
Special-case Bevy dependents to not error
2024-01-17 21:27:34 -05:00
Michael Goulet ec263df5e4 Suggest wrapping mac args in parens rather than the whole expression 2024-01-18 00:01:13 +00:00
Michael Goulet c1c7707238 Deny braced macro invocations in let-else 2024-01-17 23:59:11 +00:00
Zalathar 99797bbd9f coverage: Format all remaining tests
These tests can simply be reformatted as normal, because the resulting changes
are unimportant.
2024-01-18 10:42:37 +11:00
clubby789 3f7c7842e6 Move removed-syntax tests to their own directory 2024-01-17 22:17:44 +00:00
Kevin Reid c48cdfe8ee Remove unnecessary lets and borrowing from Waker::noop() usage.
`Waker::noop()` now returns a `&'static Waker` reference, so it can be
passed directly to `Context` creation with no temporary lifetime issue.
2024-01-17 12:00:27 -08:00
Matthias Krüger 99a8b6aa67
Rollup merge of #120056 - oli-obk:arg_mismatch_ice, r=compiler-errors
Use FnOnceOutput instead of FnOnce where expected

fixes #119847
2024-01-17 20:21:24 +01:00
Matthias Krüger cd5eb6a896
Rollup merge of #120031 - compiler-errors:construct-closure-ty-eagerly, r=oli-obk
Construct closure type eagerly

Construct the returned closure type *before* checking the body, in the same match as we were previously deducing the coroutine types based off of the closure kind.

This simplifies some changes I'm doing in the async closure PR, and imo just seems easier to read (since we only need one match on closure kind, instead of two). There's no reason I can tell that we needed to create the closure type *after* the body was checked.

~~This also has the side-effect of making it so that the universe of the closure synthetic infer vars are lower than any infer vars that come from checking the body. We can also get rid of `next_root_ty_var` hack from closure checking (though in general we still need this, #119106). cc ```@lcnr``` since you may care about this hack 😆~~

r? ```@oli-obk```
2024-01-17 20:21:22 +01:00
Matthias Krüger 6ca77ff722
Rollup merge of #120020 - oli-obk:long_const_eval_err_taint, r=compiler-errors
Gracefully handle missing typeck information if typeck errored

fixes #116893

I created some logs and the typeck of `fn main` is exactly the same, no matter whether the constant's body is what it is, or if it is replaced with `panic!()`. The latter will cause the ICE not to be emitted though. The reason for that is that we abort compilation if *errors* were emitted, but not if *lint errors* were emitted. This took me way too long to debug, and is another reason why I would have liked https://github.com/rust-lang/compiler-team/issues/633
2024-01-17 20:21:21 +01:00
Matthias Krüger 22f19130df
Rollup merge of #119975 - lukas-code:inferring-return-types-and-opaque-types-do-mix-sometimes, r=compiler-errors
Don't ICE if TAIT-defining fn contains a closure with `_` in return type

The `delay_span_bug` got added in 0e82aaeb67 to reduce the amount of errors emitted for functions that have `_` in their return type, because inference doesn't apply to function items. But this logic shouldn't apply to closures, because their return types *can* be inferred.

Fixes https://github.com/rust-lang/rust/issues/119916.
2024-01-17 20:21:20 +01:00
Oli Scherer f1ef930c9d Don't ICE when deducing future output if other errors already occurred 2024-01-17 16:27:57 +00:00
bors 6ae4cfbbb0 Auto merge of #118708 - davidtwco:target-tier-assembly-test, r=Mark-Simulacrum
tests: add sanity-check assembly test for every target

Fixes #119910.

Adds a basic assembly test checking that each target can produce assembly and update the target tier policy to require this.

cc rust-lang/compiler-team#655
r? `@wesleywiser`
2024-01-17 16:18:28 +00:00
Andrew Zhogin 8507f5105b Improved collapse_debuginfo attribute, added command-line flag (no|external|yes) 2024-01-17 23:18:14 +07:00
Oli Scherer d6b99b9c92 Use FnOnceOutput instead of FnOnce where expected 2024-01-17 14:23:41 +00:00
bors c58a5da7d4 Auto merge of #119930 - Urgau:check-cfg-empty-values-means-empty, r=petrochenkov
Add way to express that no values are expected with check-cfg

This PR adds way to express no-values (no values expected) with `--check-cfg` by making empty `values()` no longer mean `values(none())` (internal: `&[None]`) and now be an empty list (internal: `&[]`).

### Context

Currently `--check-cfg` has a way to express that _any value is expected_ with `values(any())`, but has no way to do the inverse and say that _no value is expected_.

This would be particularly useful for build systems that control a config name and it's values as they could always declare a config name as expected and if in the current state they have values pass them and if not pass an empty list.

To give a more concrete example, Cargo `--check-cfg` currently needs to generate:
 - `--check-cfg=cfg(feature, values(...))` for the case with declared features
 - and `--check-cfg=cfg()` for the case without any features declared

This means that when there are no features declared, users will get an `unexpected config name` but from the point of view of Cargo the config name `feature` is expected, it's just that for now there aren't any values for it.

See [Cargo `check_cfg_args` function](92395d9010/src/cargo/core/compiler/mod.rs (L1263-L1281)) for more details.

### De-specializing *empty* `values()`

To solve this issue I propose that we "de-specialize" empty `values()` to no longer mean `values(none())` but to actually mean empty set/list. This is one of the last source of confusion for my-self and others with the `--check-cfg` syntax.

> The confusing part here is that an empty `values()` currently means the same as `values(none())`, i.e. an expected list of values with the _none_ variant (as in `#[cfg(name)]` where the value is none) instead of meaning an empty set.

Before the new `cfg()` syntax, defining the _none_ variant was only possible under certain circumstances, so in https://github.com/rust-lang/rust/pull/111068 I decided to make `values()` to mean the _none_ variant, but it is no longer necessary since https://github.com/rust-lang/rust/pull/119473 which introduced the `none()` syntax.

A simplified representation of the proposed "de-specialization" would be:

| Syntax                                  | List/set of expected values |
|-----------------------------------------|-----------------------------|
| `cfg(name)`/`cfg(name, values(none()))` | `&[None]`                   |
| `cfg(name, values())`                   | `&[]`                       |

Note that I have my-self made the mistake of using an empty `values()` as meaning empty set, see https://github.com/rust-lang/cargo/pull/13011.

`@rustbot` label +F-check-cfg
r? `@petrochenkov`
cc `@epage`
2024-01-17 14:01:05 +00:00
bors 52790a98e5 Auto merge of #119670 - cjgillot:gvn-arithmetic, r=oli-obk
Fold arithmetic identities in GVN

Extracted from https://github.com/rust-lang/rust/pull/111344

This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by https://github.com/rust-lang/rust/pull/116012.
2024-01-17 11:46:49 +00:00
Oli Scherer b1ce8a4ecd Move check_mod_impl_wf query call out of track_errors and bubble errors up instead. 2024-01-17 10:02:19 +00:00
David Wood a87034c297
tests: add sanity-check assembly test for every target
Adds a basic assembly test checking that each target can produce assembly
and update the target tier policy to require this.

Signed-off-by: David Wood <david@davidtw.co>
2024-01-17 09:44:11 +00:00
bors f45fe573a5 Auto merge of #119651 - novafacing:proc_macro_c_str_literals, r=Amanieu
proc_macro: Add Literal::c_string constructor

Adds a constructor for C string literals, hopefully starts addressing #118560.

Tracking issue: #119750
2024-01-17 05:07:38 +00:00
bors 6bf600bc98 Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwU
fix fn/const items implied bounds and wf check (rebase)

A rebase of #104098, see that PR for discussion. This is pretty much entirely the work of `@aliemjay.` I received his permission for this rebase.

---

These are two distinct changes (edit: actually three, see below):
1. Wf-check all fn item args. This is a soundness fix.
Fixes #104005

2. Use implied bounds from impl header in borrowck of associated functions/consts. This strictly accepts more code and helps to mitigate the impact of other breaking changes.
Fixes #98852
Fixes #102611

The first is a breaking change and will likely have a big impact without the the second one. See the first commit for how it breaks libstd.

Landing the second one without the first will allow more incorrect code to pass. For example an exploit of #104005 would be as simple as:
```rust
use core::fmt::Display;

trait ExtendLt<Witness> {
    fn extend(self) -> Box<dyn Display>;
}

impl<T: Display> ExtendLt<&'static T> for T {
    fn extend(self) -> Box<dyn Display> {
        Box::new(self)
    }
}

fn main() {
    let val = (&String::new()).extend();
    println!("{val}");
}
```

The third change is to to check WF of user type annotations before normalizing them (fixes #104764, fixes #104763). It is mutually dependent on the second change above: an attempt to land it separately in #104746 caused several crater regressions that can all be mitigated by using the implied from the impl header. It is also necessary for the soundness of associated consts that use the implied bounds of impl header. See #104763 and how the third commit fixes the soundness issue in `tests/ui/wf/wf-associated-const.rs` that was introduces by the previous commit.

r? types
2024-01-17 02:35:06 +00:00
Michael Goulet 37a5464bc8 Eagerly instantiate closure ty 2024-01-17 00:43:44 +00:00
Camille GILLOT 20a8a23cb3 Bless incremental tests. 2024-01-16 23:49:39 +00:00
Celina G. Val 2564811e7b Remove tcx function and make internal fn safer
I added `tcx` argument to `internal` to force 'tcx to be the same
lifetime as TyCtxt. The only other solution I could think is to change
this function to be `unsafe`.
2024-01-16 14:35:18 -08:00
Camille GILLOT 22ed51e136 Do not read a scalar on a non-scalar layout. 2024-01-16 22:32:48 +00:00
Camille GILLOT 3c48243b6f Simplify Len. 2024-01-16 22:20:54 +00:00
Camille GILLOT 5fc23ad8e6 Simplify unary operations. 2024-01-16 22:20:54 +00:00
Camille GILLOT 666030c51b Simplify binary ops. 2024-01-16 22:20:53 +00:00
novafacing ee007ab187 proc_macro_c_str_literals: Implement Literal::c_string constructor 2024-01-16 13:27:58 -08:00
LegionMammal978 bc3fb5245a Rename pointer field on Pin
The internal, unstable field of `Pin` can conflict with fields from the
inner type accessed via the `Deref` impl. Rename it from `pointer` to
`__pointer`, to make it less likely to conflict with anything else.
2024-01-16 14:58:42 -05:00
bors 92f2e0aa62 Auto merge of #116520 - Enselic:large-copy-into-fn, r=oli-obk
large_assignments: Lint on specific large args passed to functions

Requires lowering function call arg spans down to MIR, which is done in the second commit.

Part of #83518

Also see
* https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F
* https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/move_size_limit.20lint

r? `@oli-obk` (E-mentor)
2024-01-16 19:33:14 +00:00
Celina G. Val f91ccf9ace Remove tcx from SMIR run macro and accept closures
Simplify the `run` macro to avoid sometimes unnecessary dependency
on `TyCtxt`. Instead, users can use the new internal method `tcx()`.
Additionally, extend the macro to accept closures that may capture
variables.

These are non-backward compatible changes, but they only affect
internal APIs which are provided today as helper functions until we
have a stable API to start the compiler.
2024-01-16 11:17:51 -08:00
bors e64f8495e7 Auto merge of #120025 - matthiaskrgr:rollup-e9ai06k, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #118361 (stabilise bound_map)
 - #119816 (Define hidden types in confirmation)
 - #119900 (Inline `check_closure`, simplify `deduce_sig_from_projection`)
 - #119969 (Simplify `closure_env_ty` and `closure_env_param`)
 - #119990 (Add private `NonZero<T>` type alias.)
 - #119998 (Update books)
 - #120002 (Lint `overlapping_ranges_endpoints` directly instead of collecting into a Vec)
 - #120018 (Don't allow `.html` files in `tests/mir-opt/`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-16 17:33:12 +00:00
Michael Goulet f4e35c60b0 Fix async closure call suggestion 2024-01-16 17:12:10 +00:00
Michael Goulet f1ee076f81 Async closures will move params into the future always 2024-01-16 17:12:10 +00:00
Matthias Krüger d4b276caa4
Rollup merge of #119816 - oli-obk:tait_ice_unify_obligations, r=lcnr
Define hidden types in confirmation

fixes  #111470

r? `@lcnr` or `@compiler-errors`

explanation in the newly added test
2024-01-16 17:55:22 +01:00
Lukas Markeffsky 22833c177e add test for non-defining use of TAIT in foreign function item 2024-01-16 15:37:03 +00:00
Lukas Markeffsky 450cb5eda6 Don't ICE if TAIT-defining fn contains a closure with _ in return type 2024-01-16 15:37:03 +00:00
bors bf2637f4e8 Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkin
Split out `option::unwrap_failed` like we have `result::unwrap_failed`

...and like `option::expect_failed`
2024-01-16 15:32:39 +00:00
bors 533cfde67c Auto merge of #119947 - compiler-errors:old-solver-instantiate-response, r=lcnr
Make sure to instantiate placeholders correctly in old solver

When creating the query substitution guess for an input placeholder type like `!1_T` (in universe 1), we were guessing the response substitution with something like `!0_T`. This failed to unify with `!1_T`, causing an ICE.

This PR reworks the query substitution guess code to work a bit more like the new solver. I'm *pretty* sure this is correct, though I'd really appreciate some scrutiny from someone (*cough* lcnr) who knows a bit more about query instantiation :)

Fixes #119941

r? lcnr
2024-01-16 13:33:04 +00:00
bors fa0dc208d0 Auto merge of #119672 - cjgillot:dse-sandwich, r=oli-obk
Sandwich MIR optimizations between DSE.

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

- Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
- Run DSE before GVN, as it increases the probability to have single-assignment locals.
- Run DSE after the final CopyProp to turn copies into moves.

r? `@ghost`
2024-01-16 11:34:16 +00:00
Oli Scherer 3599c18874 Skip dead code checks on items that failed typeck 2024-01-16 10:52:28 +00:00
Ali MJ Al-Nasrawy aac2f84794 wf-check type annotations before normalization 2024-01-16 09:25:28 +01:00
Ali MJ Al-Nasrawy 8d4693c0f8 borrowck: use implied bounds from impl header 2024-01-16 09:25:28 +01:00
Ali MJ Al-Nasrawy a3fe3bbb2c borrowck: wf-check fn item args 2024-01-16 09:25:28 +01:00
bors f9c2421a2a Auto merge of #119439 - cjgillot:gvn-faster, r=oli-obk
Avoid some redundant work in GVN

The first 2 commits are about reducing the perf effect.

Third commit avoids doing redundant work: is a local is SSA, it already has been simplified, and the resulting value is in `self.locals`. No need to call any code on it.

The last commit avoids removing some storage statements.

r? wg-mir-opt
2024-01-16 05:17:49 +00:00
Zalathar 1f9353ae2c coverage: Tweak individual tests to be unaffected by rustfmt
Some of these tests use non-standard formatting that we can simulate by
strategically adding `//` line comments.

One contains `where` clauses that would be split across multiple lines, which
we can keep on one line by moving the bounds to the generic type instead.
2024-01-16 16:14:27 +11:00
Zalathar f1494425bb coverage: Add #[rustfmt::skip] to tests with non-standard formatting
These tests deliberately use non-standard formatting, so that the line
execution counts reported by `llvm-cov` reveal additional information about
where code regions begin and end.
2024-01-16 15:56:37 +11:00
asquared31415 a8bb418ae5 make unsafe_op_in_unsafe_fn MachineApplicable and add it to 2024 compatibility 2024-01-15 23:06:39 +00:00
bors 714b29a17f Auto merge of #119610 - Nadrieril:never_pattern_bindings, r=compiler-errors
never patterns: Check bindings wrt never patterns

Never patterns:
- Shouldn't contain bindings since they never match anything;
- Don't count when checking that or-patterns have consistent bindings.

r? `@compiler-errors`
2024-01-15 21:24:13 +00:00
Martin Nordholts 8f440f06c6 large_assignments: Lint on specific large args passed to functions 2024-01-15 19:07:12 +01:00
bors 67e7b84425 Auto merge of #119987 - matthiaskrgr:rollup-f7lkx4w, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #119818 (Silence some follow-up errors [3/x])
 - #119870 (std: Doc blocking behavior of LazyLock)
 - #119897 (`OutputTypeParameterMismatch` -> `SignatureMismatch`)
 - #119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - #119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - #119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-15 16:45:41 +00:00
bors 1ead4761e9 Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubilee
Tune the inlinability of `unwrap`

Fixes #115463
cc `@thomcc`

This tweaks `unwrap` on ~~`Option` &~~ `Result` to be two parts:
- `#[inline(always)]` for checking the discriminant
- `#[cold]` for actually panicking

The idea here is that checking the discriminant on a `Result` ~~or `Option`~~ should always be trivial enough to be worth inlining, even in `opt-level=z`, especially compared to passing it to a function.

As seen in the issue and codegen test, this will hopefully help particularly for things like `.try_into().unwrap()`s that are actually infallible, but in a way that's only visible with the inlining.

EDIT: I've restricted this to `Result` to avoid combining effects
2024-01-15 09:20:46 +00:00
Matthias Krüger 0891cb4d81
Rollup merge of #119963 - clubby789:spec-allow-internal-unstable, r=compiler-errors
Fix `allow_internal_unstable` for `(min_)specialization`

Fixes #119950

Blocked on #119949 (comment doesn't make sense until that merges)

I'd like to follow this up and look for more instances of not properly checking spans for features but I wanted to fix the motivating issue.
2024-01-15 08:44:49 +01:00
Matthias Krüger 73256c68b8
Rollup merge of #119818 - oli-obk:even_more_follow_up_errors3, r=compiler-errors
Silence some follow-up errors [3/x]

this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449

Keep error types around, even in obligations.

These help silence follow-up errors, as we now figure out that some types (most notably inference variables) are equal to an error type.

But it also allows figuring out more types in the presence of errors, possibly causing more errors.
2024-01-15 08:44:46 +01:00
sfzhu93 5747eceef8 add FIXME for default_boxed_slice.rs 2024-01-14 22:35:00 -08:00
Scott McMurray 23483664a2 Split out option::unwrap_failed like we have result::unwrap_failed
...and like `option::expect_failed`
2024-01-14 12:45:01 -08:00
Guillaume Gomez 8914ca722c
Rollup merge of #119561 - notriddle:master, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 5)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
* https://github.com/rust-lang/rust/pull/116824
* https://github.com/rust-lang/rust/pull/118105
2024-01-14 20:17:23 +01:00
clubby789 0529ccf341 Fix allow_internal_unstable for (min_)specialization 2024-01-14 13:50:02 +00:00
Guillaume Gomez 5ad0ed52e9
Rollup merge of #119944 - compiler-errors:no-match-due-to-gat-bounds, r=fmease
Don't ICE when noting GAT bounds in `report_no_match_method_error`

We can encounter `BindingObligation`s from GATs that we should handle in `report_no_match_method_error`. I assume we can encounter them from methods, though I didn't really feel like wasting my time creating a repro.

Fixes #119942
2024-01-14 14:02:28 +01:00
Young-Flash c0a5a859b9 test: add test case for impl trait arg suggestion 2024-01-14 18:54:07 +08:00
bors 8847bda592 Auto merge of #119361 - sjwang05:issue-119352, r=WaffleLapkin
Fix ICE when suggesting dereferencing binop operands

Fixes #119352
2024-01-14 09:39:03 +00:00
bors 0dab65b8a1 Auto merge of #119934 - compiler-errors:could-impl, r=jackh726
Make `InferCtxtExt::could_impl_trait` more precise, less ICEy

The implementation for `InferCtxtExt::could_impl_trait` was very wrong. Along with being pretty poorly named, way too specific to ADTs, it was also doing impl substitution wrong -- this caused an ICE (#119915).

This PR generalizes that code, gives it a clearer name, makes it stop using the new trait solver (lol), and fixes some fallout bad suggestions that are made worse with the code fix.

Fixes #119915
2024-01-14 06:37:15 +00:00
bors aa5f781bd4 Auto merge of #119341 - sjwang05:issue-58462, r=WaffleLapkin
Suggest quoting unquoted idents in attrs

Closes #58462
2024-01-14 04:37:45 +00:00
Michael Goulet 985e1e031b Add a simpler test 2024-01-13 23:09:37 +00:00
Michael Goulet 24c1f4aa80 Make sure to instantiate placeholders correctly in old solver 2024-01-13 22:57:44 +00:00
bors 3deb9bbf84 Auto merge of #119945 - matthiaskrgr:rollup-oy3e1j2, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119189 (Move section "Installing from Source" to seperate file)
 - #119925 (store the segment name when resolution fails)
 - #119935 (Move personality implementation out of PAL)
 - #119937 (Improve UEFI target docs)
 - #119938 (Allow unauthorized users to user the has-merge-commits label)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-13 22:05:46 +00:00
Michael Goulet 04a6fd241b Make InferCtxtExt::could_impl_trait less messed up 2024-01-13 22:00:34 +00:00
Matthias Krüger 70bc26d0e7
Rollup merge of #119925 - bvanjoi:fix-112672, r=Nilstrieb
store the segment name when resolution fails

Fixes #112672

The `find_cfg_stripped` does indeed get executed within `smart_resolve_report_errors`. However, this error is not reported as it is subsequently overridden by `parent_err`. (See: https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/late.rs#L3760)

This PR changes `last_segment` to `segment`, which stores the name of the failed resolution, and ensures that the result of `find_cfg_stripped` is also included in `parent_err`.

r? ```@Nilstrieb```
2024-01-13 22:35:08 +01:00
Michael Goulet 0b45ff5dac Don't ICE when noting GAT bounds in report_no_match_method_error 2024-01-13 20:55:54 +00:00
bors d78329b92e Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, r=Nilstrieb
Suggest Upgrading Compiler for Gated Features

This PR addresses #117318

I have a few questions:

1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag
  a. How can I handle the changing message in the tests?
3. Do we want to only show this message when the compiler is old?
  a. How can we determine when the compiler is old?

I'll wait until we figure out the message to bless the tests
2024-01-13 20:06:03 +00:00
George-lewis d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00
Urgau 41b69aae91 Add way to express no-values with check-cfg 2024-01-13 17:19:46 +01:00
bors c6c4abf584 Auto merge of #119927 - matthiaskrgr:rollup-885ws57, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #119587 (Varargs support for system ABI)
 - #119891 (rename `reported_signature_mismatch` to reflect its use)
 - #119894 (Allow `~const` on associated type bounds again)
 - #119896 (Taint `_` placeholder types in trait impl method signatures)
 - #119898 (Remove unused `ErrorReporting` variant from overflow handling)
 - #119902 (fix typo in `fn()` docs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-13 16:09:45 +00:00
bors 1d8d7b16cb Auto merge of #117285 - joboet:move_platforms_to_pal, r=ChrisDenton
Move platform modules into `sys::pal`

This is the initial step of #117276. `sys` just re-exports everything from the current `sys` for now, I'll move the implementations for the individual features one-by-one after this PR merges.
2024-01-13 14:10:56 +00:00
Matthias Krüger 9696ef7c12
Rollup merge of #119896 - oli-obk:variance_ice, r=compiler-errors
Taint `_` placeholder types in trait impl method signatures

We report an error right below for them, but that kind of broken type can cause subsequent ICEs.

fixes #119867
2024-01-13 15:10:29 +01:00
Matthias Krüger 2c7ce1c453
Rollup merge of #119894 - fmease:tilde-const-assoc-ty-bounds, r=compiler-errors
Allow `~const` on associated type bounds again

This follows from [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/419616-t-compiler.2Fproject-const-traits/topic/projections.20on.20.28~.29const.20Trait.20.26.20.28~.29const.20assoc.20ty.20bounds).

Basically in my opinion, it makes sense to allow `~const` on associated type bounds again since they're quite useful even though we haven't implemented the proposed syntax `<Ty as ~const Trait>::Proj`/`<Ty as const Trait>::Proj` yet; that can happen as a follow-up.

This already allows more code to compile since `T::Assoc` where `T` is a type parameter and where the predicate `<T as ~const Trait>` is in the environment gets elaborated to (pseudo) `<T as ~const Trait>::Assoc`.

```rs
#[const_trait]
trait Trait {
    type Assoc: ~const Trait;
    fn func() -> i32;
}

const fn function<T: ~const Trait>() -> i32 {
    T::Assoc::func()
}
```

`~const` associated type bounds also work together with `const` bounds:

```rs
struct Type<const N: i32>;

fn procedure<T: const Trait>() -> Type<{ T::Assoc::func() }> { // `Trait` comes from above
    Type
}
```

NB: This PR also starts allowing `~const` bounds in the generics and the where-clause of trait associated types since it's trivial to support them. However, I don't know if those bounds are actually useful. Maybe we should continue to reject them?
For reference, it wouldn't make any sense to allow `~const Trait` in GACs (generic associated constants, `generic_const_items`) because they'd be absolutely useless (contrary to `const Trait`).

~~[``@]rustbot`` ping project-const-traits~~
r? project-const-traits
2024-01-13 15:10:29 +01:00
Matthias Krüger 7b507db24b
Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov
Varargs support for system ABI

This PR allows functions with the `system` ABI to be variadic (under the `extended_varargs_abi_support` feature tracked in #100189). On x86 windows, the `system` ABI is equivalent to `C` for variadic functions. On other platforms, `system` is already equivalent to `C`.

Fixes #110505
2024-01-13 15:10:28 +01:00
bohan c288cb1f74 store the segment name when resolution fails 2024-01-13 21:06:38 +08:00
bors 284cb714d2 Auto merge of #119871 - nnethercote:overhaul-treat-err-as-bug, r=compiler-errors
Overhaul `-Ztreat-err-as-bug`

It's current behaviour is surprising, in a bad way. This also makes the implementation more complex than it needs to be.

r? `@oli-obk`
2024-01-13 08:15:52 +00:00
beepster4096 41e224b1bc allow system abi to be variadic 2024-01-12 23:19:54 -08:00
bors 7585c62658 Auto merge of #119473 - Urgau:check-cfg-explicit-none, r=petrochenkov
Add explicit `none()` value variant in check-cfg

This PR adds an explicit none value variant in check-cfg values: `values(none())`.

Currently the only way to define the none variant is with an empty `values()` which means that if someone has a cfg that takes none and strings they need to use two invocations: `--check-cfg=cfg(foo) --check-cfg=cfg(foo, values("bar"))`.
Which would now be `--check-cfg=cfg(foo, values(none(),"bar"))`, this is simpler and easier to understand.

`--check-cfg=cfg(foo)`, `--check-cfg=cfg(foo, values())` and `--check-cfg=cfg(foo, values(none()))` would be equivalent.

*Another motivation for doing this is to make empty `values()` actually means no-values, but this is orthogonal to this PR and adding `none()` is sufficient in it-self.*

`@rustbot` label +F-check-cfg
r? `@petrochenkov`
2024-01-13 06:17:46 +00:00
usamoi f25126e9c9 add avx512fp16 to x86 target features 2024-01-13 13:50:10 +08:00
sfzhu93 cd77d59f97 update enum.rs for code review 2024-01-12 20:50:28 -08:00
bors 89110dafe7 Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnr
Delegation implementation: step 1

See https://github.com/rust-lang/rust/issues/118212 for more details.

r? `@petrochenkov`
2024-01-13 04:19:17 +00:00
bors f1f8687b06 Auto merge of #118924 - Urgau:check-cfg-exclude-well-known-from-diag, r=petrochenkov
Exclude well known names from showing a suggestion in check-cfg

This PR adds an exclusion for well known names from showing in suggestions of check-cfg/`unexpected_cfgs`.

Follow-up to https://github.com/rust-lang/rust/pull/118213 and fixes https://github.com/rust-lang/rust/pull/118213#issuecomment-1854189934.

r? `@petrochenkov`
2024-01-13 02:13:20 +00:00
sjwang05 c36b5d5353
Fix ICE when suggesting dereferencing binop operands 2024-01-12 17:49:37 -08:00
Nicholas Nethercote f1ac54123f Don't consider delayed bugs for -Ztreat-err-as-bug.
`-Ztreat-err-as-bug` treats normal errors and delayed bugs equally,
which can lead to some really surprising results.

This commit changes `-Ztreat-err-as-bug` so it ignores delayed bugs,
unless they get promoted to proper bugs and are printed.

This feels to me much simpler and more logical. And it simplifies the
implementation:
- The `-Ztreat-err-as-bug` check is removed from in
  `DiagCtxt::{delayed_bug,span_delayed_bug}`.
- `treat_err_as_bug` doesn't need to count delayed bugs.
- The `-Ztreat-err-as-bug` panic message is simpler, because it doesn't
  have to mention delayed bugs.

Output of delayed bugs is now more consistent. They're always printed
the same way. Previously when they triggered `-Ztreat-err-as-bug` they
would be printed slightly differently, via `span_bug` in
`span_delayed_bug` or `delayed_bug`.

A minor behaviour change: the "no errors encountered even though
`span_delayed_bug` issued" printed before delayed bugs is now a note
rather than a bug. This is done so it doesn't get counted as an error
that might trigger `-Ztreat-err-as-bug`, which would be silly.
This means that if you use `-Ztreat-err-as-bug=1` and there are no
normal errors but there are delayed bugs, the first delayed bug will be
shown (and the panic will happen after it's printed).

Also, I have added a second note saying "those delayed bugs will now be
shown as internal compiler errors". I think this makes it clearer what
is happening, because the whole concept of delayed bugs is non-obvious.

There are some test changes.
- equality-in-canonical-query.rs: Minor output changes, and the error
  count reduces by one because the "no errors encountered even though
  `span_delayed_bug` issued" message is no longer counted as an error.
- rpit_tait_equality_in_canonical_query.rs: Ditto.
- storage-live.rs: The query stack disappears because these delayed bugs
  are now printed at the end, rather than when they are created.
- storage-return.rs, span_delayed_bug.rs: now need
  `-Zeagerly-emit-delayed-bugs` because they need the delayed bugs
  emitted immediately to preserve behaviour.
2024-01-13 09:59:56 +11:00
Nilstrieb a04ac4952c Improve let_underscore_lock
- lint if the lock was in a nested pattern
- lint if the lock is inside a `Result<Lock, _>`
2024-01-12 23:18:58 +01:00
bors 3071aefdb2 Auto merge of #117321 - chenyukang:yukang-fix-117142, r=petrochenkov
Fix unused_parens issue when cast is followed LT

Fixes #117142

The original check only checks `a as (i32) < 0`, this fix extends it to handle `b + a as (i32) < 0`.

A better way is maybe we suggest `(a as i32) < 0` instead of suppressing the warning, maybe following PR could improve it.
2024-01-12 22:15:55 +00:00
sjwang05 aa8ecd0652
Suggest quoting unquoted idents in attrs 2024-01-12 13:59:47 -08:00
bors 2319be8e26 Auto merge of #119452 - AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm
Add assume into `NonZeroIntX::get`

LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments.

Related to https://github.com/rust-lang/rust/issues/119422
Related to https://github.com/llvm/llvm-project/issues/76628
Related to https://github.com/rust-lang/rust/issues/49572
2024-01-12 20:18:04 +00:00
Scott McMurray b858c591dd Tune the inlinability of Result::unwrap 2024-01-12 10:57:58 -08:00
Urgau 29afbbd5a9 Exclude well known names from showing a suggestion in check-cfg 2024-01-12 18:47:05 +01:00
Oli Scherer 4586fdce47 Taint _ placeholder types 2024-01-12 16:33:29 +00:00
León Orell Valerian Liehr f28373978e
Allow ~const on assoc ty bounds again 2024-01-12 17:22:18 +01:00
Guillaume Gomez dafbe17a02
Rollup merge of #119885 - DianQK:revert-pr-113923, r=petrochenkov
Revert #113923

Per [#t-compiler/meetings > [weekly] 2024-01-11](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11) discussion, revert #113923. Also revert associated #118568.

The PR #113923 causes the regression issue #118609. We need more time to find a proper solution.

Discussions start at [412365838](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412365838) and continue to [412369643](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412369643).

Fixes #118609.

r? compiler
2024-01-12 15:16:58 +01:00
Guillaume Gomez c997b29a3a
Rollup merge of #119884 - GuillaumeGomez:rename-env-opt, r=davidtwco
Rename `--env` option flag to `--env-set`

As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Stabilizing.20.60--env.60.20option.20flag.3F). We rename `--env` to not conflicting names with the [RFC](https://github.com/rust-lang/rfcs/pull/2794).

r? `@davidtwco`
2024-01-12 15:16:58 +01:00
Guillaume Gomez 504794b908
Rollup merge of #119872 - compiler-errors:eagerly-emit-delayed-bugs, r=oli-obk,nnethercote
Give me a way to emit all the delayed bugs as errors (add `-Zeagerly-emit-delayed-bugs`)

This is probably a *better* way to inspect all the delayed bugs in a program that what exists currently (and therefore makes it very easy to choose the right number `N` with `-Zemit-err-as-bug=N`, though I guess the naming is a bit ironic when you pair both of the flags together, but that feels like naming bikeshed more than anything).

This pacifies my only concern with https://github.com/rust-lang/rust/pull/119871#issuecomment-1888170259, because (afaict?) that PR doesn't allow you to intercept a delayed bug's stack trace anymore, which as someone who debugs the compiler a lot, is something that I can *promise* that I do.

r? `@nnethercote` or `@oli-obk`
2024-01-12 15:16:57 +01:00
Guillaume Gomez 46c3c014eb
Rollup merge of #119817 - compiler-errors:normalize-opaques, r=lcnr
Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver

This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work:
```rust
fn main() {
    type Tait = impl Sized;
    struct S {
        i: i32,
    }
    let x: Tait = S { i: 0 };
    println!("{}", x.i);
}
```

Since `Tait` is defined in `main`, we are able to poke through the type of `x` with deref.

r? lcnr
2024-01-12 15:16:56 +01:00
bors 174e73a3f6 Auto merge of #119396 - Nadrieril:intersection-tracking, r=WaffleLapkin
Exhaustiveness: track overlapping ranges precisely

The `overlapping_range_endpoints` lint has false positives, e.g. https://github.com/rust-lang/rust/issues/117648. I expected that removing these false positives would have too much of a perf impact but never measured it. This PR is an experiment to see if the perf loss is manageable.

r? `@ghost`
2024-01-12 11:29:06 +00:00
Bryanskiy d69cd6473c Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
DianQK aa874c5513
Revert "Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix"
This reverts commit 8c2b577217, reversing
changes made to 9cf18e98f8.
2024-01-12 18:23:04 +08:00
DianQK 6d29eac04b
Revert "Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelix"
This reverts commit 503e129328, reversing
changes made to 0e7f91b75e.
2024-01-12 18:22:39 +08:00
Guillaume Gomez 462bcac629 Rename --env option flag to --env-set 2024-01-12 11:02:57 +01:00
bors bfd799f1a5 Auto merge of #119879 - matthiaskrgr:rollup-y710der, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #119781 (fix typo)
 - #119865 (Set `c_str_literals` stabilization version back to `CURRENT_RUSTC_VERSION`)
 - #119866 (Convert `effects` description to doc comment)
 - #119868 (Register even erroneous impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-12 09:11:57 +00:00
joboet df3cb23e01
update debuginfo tests on Windows 2024-01-12 08:50:14 +01:00
sfzhu93 1c886d794c resolve code reviews 2024-01-11 23:36:09 -08:00
Matthias Krüger d7a720a863
Rollup merge of #119868 - oli-obk:unknown_lifetime_ice, r=compiler-errors
Register even erroneous impls

Otherwise the specialization graph fails to pick it up, even though other code assumes that all impl blocks have an entry in the specialization graph.

also includes an unrelated cleanup of the specialization graph query

fixes  #119827
2024-01-12 08:23:59 +01:00
sfzhu93 d63f10b7ad resolve code reviews 2024-01-11 23:22:33 -08:00
bors 2b1365b34f Auto merge of #119735 - lcnr:provisional-cache-readd, r=compiler-errors
next solver: provisional cache

this adds the cache removed in #115843. However, it should now correctly track whether a provisional result depends on an inductive or coinductive stack.

While working on this, I was using the following doc: https://hackmd.io/VsQPjW3wSTGUSlmgwrDKOA. I don't think it's too helpful to understanding this, but am somewhat hopeful that the inline comments are more useful.

There are quite a few future perf improvements here. Given that this is already very involved I don't believe it is worth it (for now). While working on this PR one of my few attempts to significantly improve perf ended up being unsound again because I was not careful enough 

r? `@compiler-errors`
2024-01-12 07:04:42 +00:00
Nicholas Nethercote 9018d2c455 Detect NulInCStr error earlier.
By making it an `EscapeError` instead of a `LitError`. This makes it
like the other errors produced when checking string literals contents,
e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion,
which changes behaviour. It will be possible to move the check back to
the later point if desired. If that happens, it's likely that all the
string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in
`report_lit_error` to calculate the span of the nul char from a range.
This code used a hardwired `+2` to account for the `c"` at the start of
a C string literal, but this should have changed to a `+3` for raw C
string literals to account for the `cr"`, which meant that the caret in
`cr"` nul error messages was one short of where it should have been. The
new approach doesn't need any of this and avoids the off-by-one error.
2024-01-12 16:19:37 +11:00
bors 5431404b87 Auto merge of #118548 - Enselic:bench-padding, r=thomcc,ChrisDenton
libtest: Fix padding of benchmarks run as tests

### Summary

The first commit adds regression tests for libtest padding.

The second commit fixes padding for benches run as tests and updates the blessed output of the regression tests to make it clear what effect the fix has on padding.

Closes #104092 which is **E-help-wanted** and **regression-from-stable-to-stable**

### More details

Before this fix we applied padding _before_ manually doing what `convert_benchmarks_to_tests()` does which affects padding calculations. Instead use `convert_benchmarks_to_tests()` first if applicable and then apply padding afterwards so it becomes correct.

Benches should only be padded when run as benches to make it easy to compare the benchmark numbers. Not when run as tests.

r? `@ghost` until CI passes.
2024-01-12 05:06:03 +00:00
Michael Goulet 7df43d3c81 Give me a way to emit all the delayed bugs 2024-01-12 03:30:17 +00:00
Oli Scherer 6679e2c2f2 Register even erroneous impls
Otherwise the specialization graph fails to pick it up, even though other code assumes that all impl blocks have an entry in the specialization graph.
2024-01-11 20:34:59 +00:00
Matthias Krüger ca17ce4558
Rollup merge of #119852 - RalfJung:const-err4, r=compiler-errors
give const-err4 a more descriptive name

Also, doesn't look like this still needs to be per-bitwidth

r? ``@oli-obk``
2024-01-11 19:42:52 +01:00
Matthias Krüger 8294356a5d
Rollup merge of #119842 - Zalathar:kind, r=oli-obk
coverage: Add enums to accommodate other kinds of coverage mappings

Extracted from  #118305.

LLVM supports several different kinds of coverage mapping regions, but currently we only ever emit ordinary “code” regions.  This PR performs the plumbing required to add other kinds of regions as enum variants, but does not add any specific variants other than `Code`.

The main motivation for this change is branch coverage, but it will also allow separate experimentation with gap regions and skipped regions, which might help in producing more accurate and useful coverage reports.

---

``@rustbot`` label +A-code-coverage
2024-01-11 19:42:51 +01:00
Matthias Krüger f5387a1c38
Rollup merge of #119841 - nnethercote:rm-DiagnosticBuilder-buffer, r=oli-obk
Remove `DiagnosticBuilder::buffer`

`DiagnosticBuilder::buffer` doesn't do much, and part of what it does (for `-Ztreat-err-as-bug`) it shouldn't.

This PR strips it back, replaces its uses, and finally removes it, making a few cleanups in the vicinity along the way.

r? ``@oli-obk``
2024-01-11 19:42:51 +01:00
Matthias Krüger 6beb676990
Rollup merge of #119836 - hi-rustin:rustin-patch-docs-blank-line, r=ChrisDenton
chore: remove unnecessary blank line

It seems no need to add an unnecessary line here.
2024-01-11 19:42:50 +01:00
Matthias Krüger bd61caf58b
Rollup merge of #119813 - oli-obk:even_more_follow_up_errors2, r=estebank
Silence some follow-up errors [2/x]

this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449

the `type_of` query frequently uses astconv to convert a `hir::Ty` to a `ty::Ty`. This process is infallible, but may produce errors as it goes. All the error reporting sites that had access to the `ItemCtxt` are now tainting it, causing `type_of` to return a `ty::Error` instead of anything else.
2024-01-11 19:42:49 +01:00
Michael Goulet 68c2f11240 Remove special-casing around aliaskind in new solver 2024-01-11 16:54:11 +00:00
Ralf Jung db860566bc give const-err4 a more descriptive name 2024-01-11 14:57:12 +01:00
hi-rustin 90cc8ba4bc fix: update broken stderr
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-11 21:39:44 +08:00
Nadrieril a24f4db41b Only lint ranges that really overlap 2024-01-11 14:04:11 +01:00
Camille GILLOT bc35ee41fa Do not run simplify_locals inside DSE.
The full pass is run short after.
2024-01-11 09:58:22 +00:00
Camille GILLOT 974b727874 Bless ui-fulldeps. 2024-01-11 09:58:22 +00:00
Camille GILLOT 0aedd6e86f Sandwich MIR optimizations between DSE. 2024-01-11 09:58:19 +00:00
Oli Scherer fb44c848c3 Keep error types around, even in obligations.
These help silence follow up errors
2024-01-11 09:52:25 +00:00
Oli Scherer 55cab535e7 Taint more aggressively in astconv 2024-01-11 09:03:26 +00:00
Oli Scherer af7f8f9811 Silence follow up errors if astconv already errored 2024-01-11 09:03:26 +00:00
Takayuki Maeda 6794dc9a5f
Rollup merge of #116343 - Nilstrieb:maybe-dont-mention-all-the-weird-lang-items-just-saying, r=bjorn3
Stop mentioning internal lang items in no_std binary errors

When writing a no_std binary, you'll be greeted with nonsensical errors mentioning lang items like eh_personality and start. That's pretty bad because it makes you think that you need to define them somewhere! But oh no, now you're getting the `internal_features` lint telling you that you shouldn't use them! But you need a no_std binary! What now?

No problem! Writing a no_std binary is super easy. Just use panic=abort and supply your own platform specific entrypoint symbol (like `main`) and you're good to go. Would be nice if the compiler told you that, right?

This makes it so that it does do that.

I don't _love_ the new messages yet, but they're decent I think. They can probably be improved, please suggest improvements.
2024-01-11 15:41:46 +09:00
Nicholas Nethercote 2aac288c18 Use the right level with -Ztreat-err-as-bug.
Errors in `DiagCtxtInner::emit_diagnostic` are never set to
`Level::Bug`, because the condition never succeeds, because
`self.treat_err_as_bug()` is called *before* the error counts are
incremented.

This commit switches to `self.treat_next_err_as_bug()`, fixing the
problem. This changes the error message output to actually say "internal
compiler error".
2024-01-11 16:55:10 +11:00
Zalathar 124fff0777 coverage: Add enums to accommodate other kinds of coverage mappings 2024-01-11 16:43:12 +11:00
bors 3a6bf351a3 Auto merge of #119677 - cjgillot:early-cfg-opt, r=oli-obk
Reorder early post-inlining passes.

`RemoveZsts`, `RemoveUnneededDrops` and `UninhabitedEnumBranching` only depend on types, so they should be executed together early after MIR inlining introduces those types.

This does not change the end-result, but this makes the pipeline a bit more consistent.
2024-01-11 04:09:07 +00:00
Matthias Krüger d37de53425
Rollup merge of #119803 - oli-obk:even_more_follow_up_errors, r=compiler-errors
Silence some follow-up errors [1/x]

this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449

When we use `-> impl SomeTrait<_>` as a return type, we are both using the "infer return type suggestion" code path, and the infer opaque type code path within the same function. That can lead to confusing diagnostics, so silence all opaque type diagnostics in that case.
2024-01-11 03:02:43 +01:00
Matthias Krüger d93df41c1d
Rollup merge of #119790 - celinval:smir-all-traits, r=oli-obk
Fix all_trait* methods to return all traits available in StableMIR

Also provide a mechanism to retrieve traits and implementations for a given crate.

This fixes https://github.com/rust-lang/project-stable-mir/issues/37
2024-01-11 03:02:42 +01:00
Matthias Krüger 4dcc5a05ea
Rollup merge of #119715 - Nadrieril:graceful-type-error, r=compiler-errors
Exhaustiveness: abort on type error

This adds an error path to exhaustiveness checking so that we abort instead of ICEing when encountering a stray `ty::Error`.

Fixes https://github.com/rust-lang/rust/issues/119493
Fixes https://github.com/rust-lang/rust/issues/119778

r? `@compiler-errors`
2024-01-11 03:02:41 +01:00
Nadrieril 5ccd29d6f0 Add more tests 2024-01-10 23:25:27 +01:00
Nilstrieb da26317a8a Stop mentioning internal lang items in no_std binary errors
When writing a no_std binary, you'll be greeted with nonsensical errors
mentioning lang items like eh_personality and start. That's pretty bad
because it makes you think that you need to define them somewhere! But
oh no, now you're getting the `internal_features` lint telling you that
you shouldn't use them! But you need a no_std binary! What now?

No problem! Writing a no_std binary is super easy. Just use panic=abort
and supply your own platform specific entrypoint symbol (like `main`)
and you're good to go. Would be nice if the compiler told you that,
right?

This makes it so that it does do that.
2024-01-10 21:18:54 +01:00
Oli Scherer 0ae00444dc Make sure the new solver agrees 2024-01-10 16:05:24 +00:00
Oli Scherer 08fc5e8acd Define hidden types in confirmation 2024-01-10 16:03:05 +00:00
Nadrieril dee657f9f9 Add test case for #119778 2024-01-10 14:50:48 +01:00
Oli Scherer 0e82aaeb67 Avoid follow up errors 2024-01-10 08:52:44 +00:00
Matthias Krüger 4571ef9152
Rollup merge of #119772 - oli-obk:whackamole, r=compiler-errors
Fix an ICE that occurs after an error has already been reported

fixes #117491

cc `@jswrenn`
2024-01-10 06:28:45 +01:00
Matthias Krüger 7c378d0058
Rollup merge of #119769 - fmease:rustdoc-off-by-one-dyn-trait-def-gen-args, r=GuillaumeGomez
rustdoc: offset generic args of cross-crate trait object types when cleaning

Fixes #119529.

This PR contains several refactorings apart from the bug fix.
Best reviewed commit by commit.
r? GuillaumeGomez
2024-01-10 06:28:44 +01:00