Commit Graph

34839 Commits

Author SHA1 Message Date
Jules Bertholet f37a4d55ee
Implement "&<pat> everywhere"
The original proposal allows reference patterns
with "compatible" mutability, however it's not clear
what that means so for now we require an exact match.

I don't know the type system code well, so if something
seems to not make sense it's probably because I made a
mistake
2024-03-30 12:57:54 -05:00
bors 70714e38f2 Auto merge of #123106 - maurer:cfi-closures, r=compiler-errors
CFI: Abstract Closures and Coroutines

This will abstract coroutines in a moment, it's just abstracting closures for now to show `@rcvalle`

This uses the same principal as the methods on traits - figure out the `dyn` type representing the fn trait, instantiate it, and attach that alias set. We're essentially just computing how we would be called in a dynamic context, and attaching that.
2024-03-30 17:56:26 +00:00
Matthew Maurer 8cc9a912d7 CFI: Rewrite closure and coroutine instances to their trait method
Similar to methods on a trait object, the most common way to indirectly
call a closure or coroutine is through the vtable on the appropriate
trait. This uses the same approach as we use for trait methods, after
backing out the trait arguments from the type.
2024-03-30 16:40:38 +00:00
Matthew Maurer e974570c42 CFI: Only encode Coroutine Parent Args
Fixes #122705
2024-03-30 16:39:51 +00:00
Nadrieril 75d2e67ed2 Sort `Eq` candidates in the failure case too 2024-03-30 17:37:15 +01:00
bors ef49365102 Auto merge of #123207 - Urgau:improve_ambi_non_null, r=Nadrieril
Add support for `NonNull`s in the `ambiguous_wide_ptr_comparisions` lint

This PR add support for `NonNull` pointers in the `ambiguous_wide_ptr_comparisions` lint.

Fixes https://github.com/rust-lang/rust/issues/121264
r? `@Nadrieril` (since you just reviewed #121268, feel free to reassign)
2024-03-30 15:53:28 +00:00
Nadrieril e1b8441899 Require enum indices to be contiguous 2024-03-30 16:22:43 +01:00
Michael Goulet bda301ead8 Stop calling visitors V 2024-03-30 11:13:33 -04:00
klensy 71ea506d3d bump tracing-tree to 0.3
Only change is https://github.com/davidbarsky/tracing-tree/pull/76
dedupes tracing-log
dupes nu-ansi-term
2024-03-30 17:39:43 +03:00
bors 1852728224 Auto merge of #123230 - matthiaskrgr:rollup-4twuzj4, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #121573 (unix_sigpipe: Add test for SIGPIPE disposition in child processes)
 - #123170 (Replace regions in const canonical vars' types with `'static` in next-solver canonicalizer)
 - #123200 (KCFI: Require -C panic=abort)
 - #123201 (Improve wording in std::any explanation)
 - #123224 (compiletest: print reason for failing to read tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-30 13:51:24 +00:00
Matthias Krüger 3afd111489
Rollup merge of #123200 - maurer:kcfi-abort, r=compiler-errors
KCFI: Require -C panic=abort

While the KCFI scheme is not incompatible with unwinding, LLVM's `invoke` instruction does not currently support KCFI bundles. While it likely will in the near future, we won't be able to assume that in Rust for a while.

We encountered this problem while [turning on closure support](https://github.com/rust-lang/rust/pull/123106#issuecomment-2027436640).

r? ``@workingjubilee``
2024-03-30 14:30:50 +01:00
Matthias Krüger 93f1443280
Rollup merge of #123170 - compiler-errors:const-statics, r=lcnr
Replace regions in const canonical vars' types with `'static` in next-solver canonicalizer

We shouldn't ever have non-static regions in consts on stable (or really any regions at all, lol).

The test I committed is less minimal than, e.g., https://github.com/rust-lang/rust/issues/123155?notification_referrer_id=NT_kwDOADgQyrMxMDAzNDU4MDI0OTozNjc0MzE0#issuecomment-2025472029 -- however, I believe that it actually portrays the underlying issue here a bit better than that one.

In the linked issue, we end up emitting a normalizes-to predicate for a const placeholder because we don't actually unify `false` and `""`. In the test I committed, we emit a normalizes-to predicate as a part of actually solving a negative coherence goal.

Fixes #123155
Fixes #118783

r? lcnr
2024-03-30 14:30:49 +01:00
bors 40116ad1ed Auto merge of #123214 - compiler-errors:subst, r=estebank
Assert that ADTs have the right number of args

We're doing it for many other types, let's also do ADTs 😇
2024-03-30 11:48:31 +00:00
Scott McMurray 0601f0c66d De-LLVM the unchecked shifts [MCP#693]
This is just one part of the MCP, but it's the one that IMHO removes the most noise from the standard library code.

Seems net simpler this way, since MIR already supported heterogeneous shifts anyway, and thus it's not more work for backends than before.
2024-03-30 03:32:11 -07:00
bors 7e0ed43287 Auto merge of #123202 - estebank:issue-123009, r=compiler-errors
Do not attempt to write `ty::Err` on binding that isn't from current HIR Owner

Fix #123009. Follow up to #122119.
2024-03-30 08:38:48 +00:00
bors 50e3d6296d Auto merge of #123012 - maurer:cfi-supertraits, r=compiler-errors
CFI: Support calling methods on supertraits

Automatically adjust `Virtual` calls to supertrait functions to use the supertrait's trait object type as the receiver rather than the child trait.

cc `@compiler-errors` - this is the next usage of `trait_object_ty` I intend to have, so I thought it might be relevant while reviewing the existing one.
2024-03-30 06:38:18 +00:00
Michael Goulet f487d83390 Stop doing so much to handle subdiagnostics 2024-03-29 22:23:10 -04:00
Michael Goulet bc1f1ef2c8 Stop removing substs from Adt type in coherence 2024-03-29 21:21:52 -04:00
Michael Goulet 5e2c549772 Assert that ADTs have the right number of substs 2024-03-29 20:40:47 -04:00
Aria Beingessner ea92faec49 stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate
This is an alternative to #121920
2024-03-29 19:59:46 -04:00
Urgau 16d11c539f Add support for NonNull in ambiguous_wide_ptr_comparisions 2024-03-29 22:02:07 +01:00
Esteban Küber d54e9833e3 Do not attempt to write `ty::Err` on binding that isn't from current HIR Owner
Fix #123009.
2024-03-29 19:05:54 +00:00
bors af4a5a13a1 Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrieril
Add detection of [Partial]Ord methods in the `ambiguous_wide_pointer_comparisons` lint

Partially addresses https://github.com/rust-lang/rust/issues/121264 by adding diagnostics items for PartialOrd and Ord methods, detecting such diagnostics items as "binary operation" and suggesting the correct replacement.

I also took the opportunity to change the suggestion to use new methods `.cast()` on `*mut T` an d `*const T`.
2024-03-29 18:23:57 +00:00
Matthew Maurer d301f40c84 CFI: Encode Virtual calls as calls through the defining trait
For example, if `trait Foo: Bar`, and we try to call a method from `Bar`
on `dyn Foo`, encode the callsite as passing a `dyn Bar`, not a `dyn
Foo`.
2024-03-29 18:15:41 +00:00
Matthew Maurer 29c1a2b9e9 KCFI: Require -C panic=abort
While the KCFI scheme is not incompatible with unwinding, LLVM's
`invoke` instruction does not currently support KCFI bundles. While it
likely will in the near future, we won't be able to assume that in Rust
for a while.
2024-03-29 16:35:58 +00:00
bors 399fa2f6e4 Auto merge of #123194 - matthiaskrgr:rollup-vhdc8hw, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #123176 (Normalize the result of `Fields::ty_with_args`)
 - #123186 (copy any file from stage0/lib to stage0-sysroot/lib)
 - #123187 (Forward port 1.77.1 release notes)
 - #123188 (compiler: fix few unused_peekable and needless_pass_by_ref_mut clippy lints)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-29 16:02:04 +00:00
Urgau d4b514f982 Add detection of [Partial]Ord methods to the ambiguous wide ptr cmp lint 2024-03-29 16:36:17 +01:00
Urgau 4a9f3cac88 Add diagnostic items for Ord and PartialOrd methods 2024-03-29 16:25:41 +01:00
Matthias Krüger 8d820c0c47
Rollup merge of #123188 - klensy:clippy-me2, r=Nilstrieb
compiler: fix few unused_peekable and needless_pass_by_ref_mut clippy lints

This fixes few instances of `unused_peekable` and `needless_pass_by_ref_mut`. While i expected to fix more warnings, `needless_pass_by_ref_mut` produced too much for one PR, so i stopped here.

Better reviewed commit by commit, as fixes splitted by chunks.
2024-03-29 15:17:11 +01:00
Matthias Krüger 73a4208638
Rollup merge of #123176 - celinval:smir-field-ty, r=oli-obk
Normalize the result of `Fields::ty_with_args`

We were only instantiating before, which would leak an AliasTy. I added a test case that reproduce the issue seen here:

https://github.com/model-checking/kani/issues/3113

r? ``@oli-obk``
2024-03-29 15:17:10 +01:00
bors 685927aae6 Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister
Simplify trim-paths feature by merging all debuginfo options together

This PR simplifies the trim-paths feature by merging all debuginfo options together, as described in https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274.

And also do some correctness fixes found during the review.

cc `@weihanglo`
r? `@michaelwoerister`
2024-03-29 14:00:21 +00:00
bors 45796d1c24 Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrieril
Match ergonomics 2024: implement mutable by-reference bindings

Implements the mutable by-reference bindings portion of match ergonomics 2024 (#123076), with the `mut ref`/`mut ref mut` syntax, under feature gate `mut_ref`.

r? `@Nadrieril`

`@rustbot` label A-patterns A-edition-2024
2024-03-29 11:08:11 +00:00
bors 58dcd1fdb9 Auto merge of #123071 - rcvalle:rust-cfi-fix-method-fn-ptr-cast, r=compiler-errors
CFI: Fix methods as function pointer cast

Fix casting between methods and function pointers by assigning a secondary type id to methods with their concrete self so they can be used as function pointers.

This was split off from #116404.

cc `@compiler-errors` `@workingjubilee`
2024-03-29 09:04:05 +00:00
bors 760e567af5 Auto merge of #122975 - DianQK:simplify_ub_check, r=saethlin
Eliminate `UbChecks` for non-standard libraries

 The purpose of this PR is to allow other passes to treat `UbChecks` as constants in MIR for optimization after #122629.

r? RalfJung
2024-03-29 02:25:43 +00:00
bors db2f9759f4 Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstrieb
Codegen const panic messages as function calls

This skips emitting extra arguments at every callsite (of which there
can be many). For a librustc_driver build with overflow checks enabled,
this cuts 0.7MB from the resulting shared library (see [perf]).

A sample improvement from nightly:

```
        leaq    str.0(%rip), %rdi
        leaq    .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdx
        movl    $25, %esi
        callq   *_ZN4core9panicking5panic17h17cabb89c5bcc999E@GOTPCREL(%rip)
```

to this PR:

```
        leaq    .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdi
        callq   *_RNvNtNtCsduqIKoij8JB_4core9panicking11panic_const23panic_const_div_by_zero@GOTPCREL(%rip)
```

[perf]: https://perf.rust-lang.org/compare.html?start=a7e4de13c1785819f4d61da41f6704ed69d5f203&end=64fbb4f0b2d621ff46d559d1e9f5ad89a8d7789b&stat=instructions:u
2024-03-29 00:24:01 +00:00
Celina G. Val a325bce3cd Normalize the result of Fields::ty_with_args
We were only instantiating before, which would leak an AliasTy.
I added a test case that reproduce the issue seen here:

https://github.com/model-checking/kani/issues/3113
2024-03-28 13:22:10 -07:00
Urgau fefb8f1f9c Replace Session should_remap_filepaths with filename_display_preference 2024-03-28 18:47:26 +01:00
Urgau 4f4fa42b0e Introduce `FileNameMapping::to_real_filename` and use it everywhere 2024-03-28 18:47:26 +01:00
Urgau ee2898d3f1 Make local_crate_source_file return a RealFileName
so it can be remapped (or not) by callers
2024-03-28 18:47:26 +01:00
Urgau 106146fd95 Replace `RemapFileNameExt::for_codegen` with explicit calls 2024-03-28 18:47:26 +01:00
Urgau 777c6b46cc Simplify trim-paths feature by merging all debuginfo options together 2024-03-28 18:47:26 +01:00
Matthias Krüger 1ec73f0c4c
Rollup merge of #123160 - bvanjoi:cleanup, r=compiler-errors
remove `def_id_to_node_id` in ast lowering
2024-03-28 17:40:50 +01:00
Matthias Krüger 69cfe80834
Rollup merge of #123096 - compiler-errors:postfix-match-parens, r=fmease
Don't check match scrutinee of postfix match for unused parens

We only check the scrutinees of block-like constructs and a few others (return/index/assign/method calls). Just don't do it for postfix match at all.

Fixes #123064

r? fmease
2024-03-28 17:40:49 +01:00
Matthias Krüger 732ded92a0
Rollup merge of #123063 - tmiasko:reachability-abi, r=michaelwoerister
Function ABI is irrelevant for reachability
2024-03-28 17:40:49 +01:00
Michael Goulet 6439c7fe23 Require foldability part of interner item bounds, remove redundant where clauses 2024-03-28 12:30:52 -04:00
Michael Goulet 08c7ff2264 Restrict const ty's regions to static when putting them in canonical var list 2024-03-28 12:30:52 -04:00
klensy 8245718503 and more
warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_mir_transform\src\coroutine.rs:1229:11
     |
1229 |     body: &mut Body<'tcx>,
     |           ^^^^^^^^^^^^^^^ help: consider changing to: `&Body<'tcx>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_mir_transform\src\nrvo.rs:123:11
    |
123 |     body: &mut mir::Body<'_>,
    |           ^^^^^^^^^^^^^^^^^^ help: consider changing to: `&mir::Body<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_mir_transform\src\nrvo.rs:87:34
   |
87 | fn local_eligible_for_nrvo(body: &mut mir::Body<'_>) -> Option<Local> {
   |                                  ^^^^^^^^^^^^^^^^^^ help: consider changing to: `&mir::Body<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 17:19:15 +03:00
bors c5e7f45b62 Auto merge of #115220 - Zoxc:revive-gcx-ptr, r=oli-obk
Add a `CurrentGcx` type to let the deadlock handler access `TyCtxt`

This brings back `GCX_PTR` (previously removed in https://github.com/rust-lang/rust/pull/74969) allowing the deadlock handler access to `GlobalCtxt`. This fixes https://github.com/rust-lang/rust/issues/111522.

r? `@cjgillot`
2024-03-28 14:00:08 +00:00
klensy 9a6b3dfc06 and few more
maybe bug here?

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_borrowck\src\diagnostics\conflict_errors.rs:3857:35
     |
3857 |     pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diag<'_>) -> String {
     |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&MirBorrowckCtxt<'_, 'tcx>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_borrowck\src\type_check\liveness\trace.rs:601:17
    |
601 |         typeck: &mut TypeChecker<'_, 'tcx>,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&TypeChecker<'_, 'tcx>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 16:57:32 +03:00
klensy 5488e492af and few more
warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_codegen_ssa\src\back\rpath.rs:80:41
   |
80 | fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> OsString {
   |                                         ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&RPathConfig<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_codegen_ssa\src\back\rpath.rs:76:42
   |
76 | fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>) -> Vec<OsString> {
   |                                          ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&RPathConfig<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_codegen_ssa\src\back\rpath.rs:55:23
   |
55 | fn get_rpaths(config: &mut RPathConfig<'_>) -> Vec<OsString> {
   |                       ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&RPathConfig<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_codegen_ssa\src\back\rpath.rs:15:32
   |
15 | pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<OsString> {
   |                                ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&RPathConfig<'_>`
   |
   = warning: changing this function will impact semver compatibility
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 16:26:37 +03:00
bors 4ea92e3c7a Auto merge of #123166 - bjorn3:sync_cg_clif-2024-03-28, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlight this time is debuginfo for statics. Not all types are supported yet. Those that aren't supported are represented as `[u8; mem::size_of::<T>()]` instead.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-03-28 11:57:39 +00:00
bjorn3 987ed345af Merge commit '09fae60a86b848a2fc0ad219ecc4e438dc1eef86' into sync_cg_clif-2024-03-28 2024-03-28 11:43:35 +00:00
klensy c64a440312 fix few more
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_trait_selection\src\traits\project.rs:511:12
    |
511 |     selcx: &mut SelectionContext<'a, 'tcx>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&SelectionContext<'a, 'tcx>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_trait_selection\src\traits\specialize\specialization_graph.rs:201:28
    |
201 | fn iter_children(children: &mut Children) -> impl Iterator<Item = DefId> + '_ {
    |                            ^^^^^^^^^^^^^ help: consider changing to: `&Children`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 13:16:22 +03:00
bors 551abd65be Auto merge of #116891 - aliemjay:opaque-region-infer-rework-2, r=compiler-errors,oli-obk
rework opaque type region inference

User-facing changes are documented in [this comment](https://github.com/rust-lang/rust/pull/116891#issuecomment-1973774412).

The design document is in [this comment](https://github.com/rust-lang/rust/pull/116891#issuecomment-1836900102).

---

\- Fix Ice in check_unique; ICE -> Error; fixes #122782.
\- Ignore uncaptured lifetime args; ICE -> Pass; fixes #111906, fixes #110623, fixes #109059, fixes #122307
\- Except equal parameters from the uniqueness check; Pass -> Error; fixes #113916.
\- Check RPITs for invalid args; Pass -> Error; fixes #111935; ICE -> Error; fixes #110726.
\- Rework opaque types region inference; Pass -> Error; fixes #113971, fixes #112841.
\- Reject external lifetimes as invalid args; Pass -> Error; fixes #105498.

r? `@ghost`
2024-03-28 09:51:39 +00:00
klensy afd0a8eb8f change BuiltinDeriveFn type to get ExtCtxt by immutable ref and fix signatures 2024-03-28 12:49:18 +03:00
klensy 615bb53a8d compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\clone.rs:160:9
    |
160 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\partial_ord.rs:72:9
   |
72 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\partial_eq.rs:19:18
   |
19 |     fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                  ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\ord.rs:42:19
   |
42 | pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                   ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:917:13
    |
917 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1406:13
     |
1406 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1157:13
     |
1157 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1103:13
     |
1103 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1080:13
     |
1080 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:859:13
    |
859 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:805:13
    |
805 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:467:13
    |
467 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:457:13
    |
457 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:36:45 +03:00
klensy ecb39926d8 compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\mod.rs:120:9
    |
120 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1573:13
     |
1573 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1556:13
     |
1556 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1463:13
     |
1463 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1433:36
     |
1433 |     fn summarise_struct(&self, cx: &mut ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
     |                                    ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:953:13
    |
953 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:932:13
    |
932 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:580:13
    |
580 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:989:13
    |
989 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\clone.rs:97:9
   |
97 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\eq.rs:52:9
   |
52 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\hash.rs:50:9
   |
50 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\encodable.rs:150:9
    |
150 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\default.rs:176:9
    |
176 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\default.rs:106:9
    |
106 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\default.rs:57:9
   |
57 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\default.rs:84:9
   |
84 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\debug.rs:212:9
    |
212 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\debug.rs:48:26
   |
48 | fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:16:08 +03:00
klensy 316bc1c67c compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\asm.rs:306:28
    |
306 | fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) {
    |                            ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\asm.rs:318:8
    |
318 |     p: &mut Parser<'a>,
    |        ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\assert.rs:114:25
    |
114 | fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<'a, Assert> {
    |                         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\asm.rs:32:10
   |
32 |     ecx: &mut ExtCtxt<'a>,
   |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\test.rs:99:9
   |
99 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\source_util.rs:237:9
    |
237 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:809:10
    |
809 |     ecx: &mut ExtCtxt<'_>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:737:10
    |
737 |     ecx: &mut ExtCtxt<'a>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\format.rs:68:24
   |
68 | fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
   |                        ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:607:10
    |
607 |     ecx: &mut ExtCtxt<'_>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\edition_panic.rs:43:9
   |
43 |     cx: &'cx mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\concat_bytes.rs:11:9
   |
11 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\cfg.rs:38:22
   |
38 | fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
   |                      ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\cfg_accessible.rs:13:28
   |
13 | fn validate_input<'a>(ecx: &mut ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {
   |                            ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:04:00 +03:00
bohan 90306cd841 remove `def_id_to_node_id` in ast lowering 2024-03-28 16:58:03 +08:00
klensy aa35530319 compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_session\src\config.rs:2013:16
     |
2013 |     early_dcx: &mut EarlyDiagCtxt,
     |                ^^^^^^^^^^^^^^^^^^ help: consider changing to: `&EarlyDiagCtxt`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_ast_passes\src\ast_validation.rs:1555:11
     |
1555 |     this: &mut AstValidator<'_>,
     |           ^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&AstValidator<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_infer\src\infer\snapshot\fudge.rs:16:12
   |
16 |     table: &mut UnificationTable<'_, 'tcx, T>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&UnificationTable<'_, 'tcx, T>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_expand\src\expand.rs:961:13
    |
961 |     parser: &mut Parser<'a>,
    |             ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'a>`
    |
    = warning: changing this function will impact semver compatibility
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 11:37:52 +03:00
klensy b6cfe71f38 compiler: fix some clippy needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_session\src\config.rs:2111:20
     |
2111 |     unstable_opts: &mut UnstableOptions,
     |                    ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&UnstableOptions`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 11:04:39 +03:00
klensy bf47641726 compiler: fix unused_peekable clippy lint
warning: `peek` never called on `Peekable` iterator
   --> compiler\rustc_session\src\utils.rs:130:13
    |
130 |     let mut args = std::env::args_os().map(|arg| arg.to_string_lossy().to_string()).peekable();
    |             ^^^^
    |
    = help: consider removing the call to `peekable`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_peekable

warning: `peek` never called on `Peekable` iterator
    --> compiler\rustc_trait_selection\src\traits\error_reporting\suggestions.rs:4934:17
     |
4934 |         let mut bounds = pred.bounds.iter().peekable();
     |                 ^^^^^^
     |
     = help: consider removing the call to `peekable`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_peekable
2024-03-28 10:50:09 +03:00
Ali MJ Al-Nasrawy 7c6876f9a9 simplify check_unique 2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy 6b6ed2ea28 reject external lifetimes as invalid arguments 2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy f4940e4d22 rework opaque types region inference 2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy 08c8caa524 convert all named regions in opaque types to nll vars
Do it in typeck before entering region inference routines
particularly because we will no longer be able to convert placeholders.
2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy 15c7e59c05 favor placeholders over existentials when choosing SCC representatives
... even when the existential has the least RegionVid.

universal regions (of root universe) > placeholders > existentials

The previous behavior, that chooses the minimal RegionVid index, naturally prefers universal regions over others
because they always have the least RegionVids, but there was no guranteed ordering between placeholders and existentials.
2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy ce91e46a1e check RPITs for invalid args 2024-03-28 06:00:26 +00:00
Ali MJ Al-Nasrawy c337825d6d ignore error params 2024-03-28 06:00:25 +00:00
Ali MJ Al-Nasrawy 4ecdf5ff00 except equal parameters from the uniqueness check 2024-03-28 06:00:25 +00:00
bors 2781687fe5 Auto merge of #122832 - oli-obk:no_ord_def_id3, r=michaelwoerister
Remove `DefId`'s `Partial/Ord` impls

work towards https://github.com/rust-lang/rust/issues/90317

based on https://github.com/rust-lang/rust/pull/122824 and https://github.com/rust-lang/rust/pull/122820

r? `@michaelwoerister`
2024-03-28 05:25:28 +00:00
bors 463a11bef4 Auto merge of #121833 - kornelski:parent_include, r=estebank
Suggest correct path in include_bytes!

`include_bytes!` paths are relative, and I'm often not sure how nested is the `.rs` file that I'm editing, so I have to guess the number of `"../.."`. This change searches `..` and `../..` for the given file and offers corrected path as a suggestion.

I wasn't sure how to get the right span, and how to properly escape it.

```text
error: couldn't read src/file.txt: No such file or directory (os error 2)
 --> src/main.rs:2:13
  |
2 |     let x = include_bytes!("file.txt");
  |             ^^^^^^^^^^^^^^^----------^
  |                            |
  |                            help: it's in a parent directory: `"../../file.txt"`
```
2024-03-28 02:47:46 +00:00
Ramon de C Valle 8e6b4e91b6 CFI: Fix methods as function pointer cast
Fix casting between methods and function pointers by assigning a
secondary type id to methods with their concrete self so they can be
used as function pointers.
2024-03-27 16:19:17 -07:00
Matthias Krüger 45cec32ac3
Rollup merge of #123133 - xiaoxiangxianzi:master, r=fmease
chore: fix some comments
2024-03-27 23:27:24 +01:00
Matthias Krüger 15fb2f214c
Rollup merge of #123130 - oli-obk:missing_type_taint, r=compiler-errors
Load missing type of impl associated constant from trait definition

fixes #123092

Also does some cleanups I discovered while analyzing this issue
2024-03-27 23:27:23 +01:00
Matthias Krüger ae33b9045b
Rollup merge of #123101 - Bryanskiy:delegation-fixes-2, r=petrochenkov
Delegation: fix ICE on wrong `Self` instantiation

fixes https://github.com/rust-lang/rust/issues/119921
fixes https://github.com/rust-lang/rust/issues/119919

There is no way to instantiate `Self` param for caller in delegation item if

1. callee is a trait method && callee contains `Self` param
2. delegation item isn't an associative item

In general, we can consider `Self` param as independent type param in these cases:

```rust

trait Trait {
    fn foo(_: Option<&Self>) {...}
}

reuse Trait::foo;
// will be desugared to:
fn foo<T: Trait>(x: Option<&T>) { Trait::foo(x) }
```

But this requires early bound parameters support. For now, I suggest banning such cases to avoid ICE's.

r? ``@petrochenkov``
2024-03-27 23:27:23 +01:00
Matthias Krüger 6464e5b78c
Rollup merge of #123075 - rcvalle:rust-cfi-fix-drop-drop-in-place, r=compiler-errors
CFI: Fix drop and drop_in_place

Fix drop and drop_in_place by transforming self of drop and drop_in_place methods into a Drop trait objects.

This was split off from https://github.com/rust-lang/rust/pull/116404.

cc `@compiler-errors` `@workingjubilee`
2024-03-27 23:27:22 +01:00
Nadrieril 7410f78e9a Use `create_or_subcandidates` for all or-pattern expansions 2024-03-27 20:53:29 +01:00
Ramon de C Valle 0b860818e6 CFI: Fix drop and drop_in_place
Fix drop and drop_in_place by transforming self of drop and
drop_in_place methods into Drop trait objects.
2024-03-27 12:52:14 -07:00
Nadrieril 23c9f698c0 Avoid recursion in creating and merging or-patterns
By calling back into `match_candidates`, we only need to expand one
layer at a time. Conversely, since we always try to simplify a layer
that we just expanded, we only have to merge one layer at a time.
2024-03-27 17:58:35 +01:00
Jules Bertholet 528d45af18
Feature gate 2024-03-27 11:20:28 -04:00
Kornel 826ddb3018 Suggest correct path in include_bytes! 2024-03-27 15:16:25 +00:00
Kornel 89ceced6f6 Helper function for resolve_path 2024-03-27 14:57:37 +00:00
xiaoxiangxianzi 3157114f0b chore: fix some comments
Signed-off-by: xiaoxiangxianzi <zhaoyizheng@outlook.com>
2024-03-27 22:32:53 +08:00
Oli Scherer bd6a96f04e Int constants must be valtrees in pattern lowering 2024-03-27 14:28:50 +00:00
Michael Goulet 864e1fbc81 Remove TypeVariableOriginKind::OpaqueInference 2024-03-27 10:08:14 -04:00
Michael Goulet 2fe936f17d Stop doing expensive work in opt_suggest_box_span eagerly 2024-03-27 10:08:14 -04:00
Oli Scherer cf3ab41c83 Ensure no one re-adds `Partial/Ord` impls for `DefId` 2024-03-27 14:02:17 +00:00
Oli Scherer 5f4ac61ebd Remove `DefId`'s `Partial/Ord` impls 2024-03-27 14:02:17 +00:00
Oli Scherer e522d2906d Stop sorting `DefId`s in the compiler 2024-03-27 14:02:17 +00:00
Oli Scherer 5676326c72 Sort somem diagnostics by `DefPathStr` instead of `DefId` 2024-03-27 14:02:16 +00:00
Oli Scherer 6be79cb103 Sort a diagnostic by `DefPathStr` instead of `DefId` 2024-03-27 14:02:16 +00:00
Oli Scherer 57f68c3555 Sort method suggestions by `DefPath` instead of `DefId` 2024-03-27 14:02:16 +00:00
Oli Scherer 727807293b Don't sort `DefId`s in suggestions 2024-03-27 14:02:16 +00:00
Oli Scherer 150a5e5f92 Do not sort `DefId`s in diagnostics 2024-03-27 14:02:16 +00:00
Oli Scherer 28363ea4eb Remove `Partial/Ord` from `EarlyParamRegion` 2024-03-27 14:02:16 +00:00
Oli Scherer 1d662c9eee Remove `Partial/Ord` from `AdtDef` 2024-03-27 14:02:16 +00:00
Oli Scherer 459ea32a27 Remove `Partial/Ord` from `BoundRegion` 2024-03-27 14:02:16 +00:00
Oli Scherer e87d10846e Remove `Ord` from `BoundTy` 2024-03-27 14:02:16 +00:00
Oli Scherer dd9fe01d06 Remove `Ord` from `Binder` 2024-03-27 14:02:16 +00:00
Oli Scherer dc95bd69f2 Remove `Ord` from `Ty`, `Const`, and `Region` 2024-03-27 14:02:16 +00:00
Oli Scherer 939df293d8 Sort diagnostics by rendered trait ref instead of its def ids 2024-03-27 14:02:16 +00:00
Oli Scherer 5ae546e108 Use FxIndexMap instead of BTreeMap to avoid sorting `DefId`s 2024-03-27 14:02:15 +00:00
Oli Scherer ae24fef028 Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter compares `DefId`s which we need to avoid 2024-03-27 14:02:15 +00:00
Oli Scherer 2707ac9606 Remove unnecessary `Partial/Ord` derive 2024-03-27 14:02:15 +00:00
Michael Woerister 7e4bc4a373 Remove and disallow HashStable impl of HashMap. 2024-03-27 14:57:01 +01:00
Jules Bertholet e0da13f25f
Implement `mut ref`/`mut ref mut` 2024-03-27 09:53:23 -04:00
DianQK 47ed73a7b5
Eliminate `UbCheck` for non-standard libraries 2024-03-27 21:02:40 +08:00
Bryanskiy 0cd9708de6 Delegation: fix ICE on wrong instantiation 2024-03-27 15:51:48 +03:00
Oli Scherer 86e750f0f7 Inline `primary_body_of` into its sole call site 2024-03-27 11:16:41 +00:00
Oli Scherer 7786ee3c92 Remove a call-site to `primary_body_of` as it is only interested in the body id 2024-03-27 11:13:34 +00:00
Oli Scherer d0eb9c86f1 move type inference for missing types on constants into its own method 2024-03-27 11:12:21 +00:00
Oli Scherer 804c047657 Load missing type of impl associated constant from trait definition 2024-03-27 11:02:53 +00:00
Oli Scherer 2d4b7f287d Use a `dyn Debug` trait object instead of a closure.
Simplifies the API a bit.
2024-03-27 10:59:18 +00:00
John Kåre Alsaker 9936a399df Add a `CurrentGcx` type to let the deadlock handler access `TyCtxt` 2024-03-27 11:44:32 +01:00
Guillaume Gomez dc4236d43b
Rollup merge of #123024 - maurer:kcfi-testing, r=workingjubilee
CFI: Enable KCFI testing of run-pass tests

This enables KCFI-based testing for all the CFI run-pass tests in the suite today. We can add the test header on top of in-flight CFI tests once they land. This is becoming more important as we get closer to leveraging CFI's multiple type attachment feature, as that is where the implementations will have a divergence.

It also enables KCFI as a sanitizer for x86_64 and aarch64 Linux to make this possible. The sanitizer should likely be available for all aarch64, x86_64, and riscv targets, but that isn't critical for initial testing.
2024-03-27 10:13:43 +01:00
Guillaume Gomez bffeb052d1
Rollup merge of #123021 - compiler-errors:coroutine-layout-lol, r=oli-obk
Make `TyCtxt::coroutine_layout` take coroutine's kind parameter

For coroutines that come from coroutine-closures (i.e. async closures), we may have two kinds of bodies stored in the coroutine; one that takes the closure's captures by reference, and one that takes the captures by move.

These currently have identical layouts, but if we do any optimization for these layouts that are related to the upvars, then they will diverge -- e.g. https://github.com/rust-lang/rust/pull/120168#discussion_r1536943728.

This PR relaxes the assertion I added in #121122, and instead make the `TyCtxt::coroutine_layout` method take the `coroutine_kind_ty` argument from the coroutine, which will allow us to differentiate these by-move and by-ref bodies.
2024-03-27 10:13:43 +01:00
Guillaume Gomez 8a7f285cbc
Rollup merge of #122860 - Zalathar:unused, r=cjgillot
coverage: Re-enable `UnreachablePropagation` for coverage builds

This is a sequence of 3 related changes:
- Clean up the existing code that scans for unused functions
- Detect functions that were instrumented for coverage, but have had all their coverage statements removed by later MIR transforms (e.g. `UnreachablePropagation`)
- Re-enable `UnreachablePropagation` in coverage builds

Because we now detect functions that have lost their coverage statements, and treat them as unused, we don't need to worry about `UnreachablePropagation` removing all of those statements. This is demonstrated by `tests/coverage/unreachable.rs`.

Fixes #116171.
2024-03-27 10:13:42 +01:00
Guillaume Gomez 2973f04076
Rollup merge of #121843 - ferrocene:builtin-path, r=petrochenkov
Implement `-L KIND=@RUSTC_BUILTIN/...`

Implements https://github.com/rust-lang/compiler-team/issues/659
2024-03-27 10:13:42 +01:00
Matthias Krüger fc51dbd379
Rollup merge of #123102 - durin42:llvm-19-pass-ptr, r=workingjubilee
RustWrapper: update call for llvm/llvm-project@44d037cc258dcf179d2c48…

…c93996bb406ecd0fae

Easy change.

`@rustbot` label: +llvm-main
2024-03-27 05:21:17 +01:00
Matthias Krüger a2122dc1e3
Rollup merge of #122439 - Nadrieril:store-built-place, r=compiler-errors
match lowering: build the `Place` instead of keeping a `PlaceBuilder` around

Outside of `MatchPair::new` we don't construct new places, so we don't need to keep a `PlaceBuilder` around.

A bit annoyingly we have to store an `Option<Place>` even though it's never `None` after simplification, but the alternative would be to re-entangle `MatchPair` construction and simplification and I'd rather not do that.
2024-03-27 05:21:15 +01:00
Matthias Krüger 781b225831
Rollup merge of #123103 - compiler-errors:inherited-is-a-weird-name, r=oli-obk
Rename `Inherited` -> `TypeckRootCtxt`

`Inherited` is a confusing name. Rename it to `TypeckRootCtxt`.

I don't think this needs a type MCP or anything since it's not nearly as pervasive as `FnCtxt` , for example.

r? `@lcnr` `@oli-obk`
2024-03-26 21:23:51 +01:00
Matthias Krüger b63dca138e
Rollup merge of #123049 - compiler-errors:coroutine-closure-rcvr, r=oli-obk
In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer

The receivers were compatible at codegen time, but did not necessarily have the same layouts due to niches, which was caught by miri.

Fixes rust-lang/miri#3400

r? oli-obk
2024-03-26 21:23:49 +01:00
Matthias Krüger 0029a11d7d
Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril
Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate

Waiting on the deref pattern syntax pr to merge

r? nadrieril
2024-03-26 21:23:48 +01:00
Matthias Krüger 20770ac3fc
Rollup merge of #122589 - wutchzone:121547, r=compiler-errors
Fix diagnostics for async block cloning

Closes #121547

r? diagnostics
2024-03-26 21:23:48 +01:00
Matthias Krüger ff8cdc9e14
Rollup merge of #122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, r=compiler-errors
Suggest associated type bounds on problematic associated equality bounds

Fixes #105056. TL;DR: Suggest `Trait<Ty: Bound>` on `Trait<Ty = Bound>` in Rust >=2021.

~~Blocked on #122055 (stabilization of `associated_type_bounds`), I'd say.~~ (merged)
2024-03-26 21:23:47 +01:00
Michael Goulet bf7a745077 Inherited -> TypeckRootCtxt 2024-03-26 15:22:46 -04:00
Nadrieril 14f186c756 Store `Place` instead of `PlaceBuilder` in `MatchPair` 2024-03-26 19:26:16 +01:00
Nadrieril 3878b3716d Rename 2024-03-26 19:26:16 +01:00
Augie Fackler 2a0107496e RustWrapper: update call for llvm/llvm-project@44d037cc25
Easy change.

@rustbot label: +llvm-main
2024-03-26 14:10:25 -04:00
Michael Goulet 22bc5c538d In ConstructCoroutineInClosureShim, pass receiver by ref, not pointer 2024-03-26 12:10:51 -04:00
Matthias Krüger 4d1fb9e98a
Rollup merge of #123091 - Bryanskiy:delegation-fixes, r=petrochenkov
Delegation: fix ICE on wrong `self` resolution

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

Delegation item should be wrapped in a `rib` to behave like a regular function during name resolution.

r? `@petrochenkov`
2024-03-26 17:06:43 +01:00
Matthias Krüger e7c983cca5
Rollup merge of #123090 - oli-obk:gatify, r=compiler-errors
Remove `CacheSelector` trait now that we can use GATs

No change in behaviour. Just noticed while digging around in the query infrastructure
2024-03-26 17:06:43 +01:00
Matthias Krüger 94e8c6c334
Rollup merge of #123067 - Nadrieril:always-simplify-or, r=oli-obk
match lowering: consistently merge simple or-patterns

There are two places where we expand or-patterns in match lowering: the main one is `test_candidates_with_or`, and there's one in `match_candidates` that's an optimization for the simple case where the whole pattern is just one or-pattern.

To reduce duplication, we merge or-pattern alternatives into a single block when possible, but we only to that in `test_candidates_with_or`. This PR fixes this oversight and merges them in `match_candidates` too.

This is a part of splitting up https://github.com/rust-lang/rust/pull/122046 into smaller bits.
2024-03-26 17:06:41 +01:00
Matthias Krüger 1fd3ee0660
Rollup merge of #123066 - maurer:cfi-erased-lifetime-ice, r=compiler-errors
CFI: (actually) check that methods are object-safe before projecting their receivers to `dyn Trait` in CFI

`trait_object_ty` assumed that associated types would be fully determined by the trait. This is *almost* true - const parameters and type parameters are no longer allowed, but lifetime parameters are. Since we erase all lifetime parameters anyways, instantiate it with as many erased regions as it needs.

Fixes: #123053

r? `@compiler-errors`
2024-03-26 17:06:40 +01:00
Matthias Krüger d549d4f5a7
Rollup merge of #122996 - RalfJung:simplify_branches, r=cjgillot
simplify_branches: add comment

I am not quite sure why this simplification is done here and not in InstSimplify but 🤷

r? `@cjgillot`
2024-03-26 17:06:39 +01:00
Matthias Krüger 03f5c4f05f
Rollup merge of #122766 - bvanjoi:fix-115185, r=petrochenkov
store segment and module in `UnresolvedImportError`

Fixes #115185

An easy fix. r? `@Nilstrieb`
2024-03-26 17:06:38 +01:00
Michael Goulet 950b40f111 Don't check match scrutinee of postfix match for unused parens 2024-03-26 11:16:49 -04:00
Oli Scherer 3b94f33c23 Remove `CacheSelector` trait now that we can use GATs 2024-03-26 11:03:23 +00:00
Bryanskiy 17c6101864 Delegation: fix ICE on wrong `self` resolution 2024-03-26 14:00:51 +03:00
bors 519d892f95 Auto merge of #121387 - oli-obk:eager_const_failures_regression, r=lcnr
Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from https://github.com/rust-lang/rust/pull/121087
2024-03-26 10:52:11 +00:00
Ali MJ Al-Nasrawy 4e1999d387 ignore uncaptured lifetimes when checking opaques 2024-03-26 09:26:23 +00:00
Ali MJ Al-Nasrawy 92f40b8059 fix ICE in check_unique 2024-03-26 09:26:23 +00:00
bors 73476d4990 Auto merge of #122849 - clubby789:no-metadata, r=petrochenkov
Don't emit load metadata in debug mode

r? `@ghost`
2024-03-26 06:46:43 +00:00
Matthew Maurer 2c0a8de0b9 CFI: Enable KCFI testing of run-pass tests
This enables KCFI-based testing for all the CFI run-pass tests in the
suite today. We can add the test header on top of in-flight CFI tests
once they land.

It also enables KCFI as a sanitizer for x86_64 and aarch64 Linux to make
this possible. The sanitizer should likely be available for all aarch64,
x86_64, and riscv targets, but that isn't critical for initial testing.
2024-03-26 03:16:41 +00:00
bors 8b9e47c136 Auto merge of #123065 - workingjubilee:rollup-bve45ex, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #122707 (Fix a typo in the alloc::string::String docs)
 - #122769 (extend comments for reachability set computation)
 - #122892 (fix(bootstrap/dist): use versioned dirs when vendoring)
 - #122896 (Update stdarch submodule)
 - #122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.)
 - #122950 (Add regression tests for #101903)
 - #123039 (Update books)
 - #123042 (Import the 2021 prelude in the core crate)
 - #123044 (`Instance` is `Copy`)
 - #123051 (did I mention that tests are super cool? )

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-26 02:07:49 +00:00
Zalathar 1cca2529d1 coverage: Re-enable `UnreachablePropagation` for coverage builds 2024-03-26 11:46:04 +11:00
Zalathar 54116c8cae coverage: Detect functions that have lost all their coverage statements
If a function was instrumented for coverage, but all of its coverage statements
have been removed by later MIR transforms, it should be treated as "unused"
even if the compiler generates an unreachable stub for it.
2024-03-26 11:46:04 +11:00
Zalathar e3f66b2493 coverage: Overhaul the search for unused functions 2024-03-26 11:46:04 +11:00
Zalathar 5ddc4f24cc coverage: Inline creating a dummy instance for unused functions 2024-03-26 11:29:38 +11:00
bors c98ea0d808 Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJung
Print a backtrace in const eval if interrupted

Demo:
```rust
#![feature(const_eval_limit)]
#![const_eval_limit = "0"]

const OW: u64 = {
    let mut res: u64 = 0;
    let mut i = 0;
    while i < u64::MAX {
        res = res.wrapping_add(i);
        i += 1;
    }
    res
};

fn main() {
    println!("{}", OW);
}
```
```
╭ ➜ ben@archlinux:~/rust
╰ ➤ rustc +stage1 spin.rs
^Cerror[E0080]: evaluation of constant value failed
 --> spin.rs:8:33
  |
8 |         res = res.wrapping_add(i);
  |                                 ^ Compilation was interrupted

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^
   |
   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
```
2024-03-26 00:04:03 +00:00
Michael Goulet fc1d7d275b Extract helper, fix comment on DerefPure 2024-03-25 19:39:45 -04:00
Michael Goulet 5fdc7555c1 Require DerefMut if deref pattern has nested ref mut binding 2024-03-25 19:39:45 -04:00
Michael Goulet b56279569b Require DerefPure for patterns 2024-03-25 19:39:45 -04:00
Nadrieril d1d9aa3108 Consistently merge simplifiable or-patterns 2024-03-25 23:52:17 +01:00
Matthew Maurer 70e1d23895 CFI: Pad out associated type resolution with erased lifetimes
`trait_object_ty` assumed that associated types would be fully
determined by the trait. This is *almost* true - const parameters and
type parameters are no longer allowed, but lifetime parameters are.
Since we erase all lifetime parameters anyways, instantiate it with as
many erased regions as it needs.

Fixes: #123053
2024-03-25 22:46:21 +00:00
Nadrieril 08d7379961 Use the correct span for simplifying or-patterns
We have to make sure we set it everywhere that we set `subcandidates`.
2024-03-25 23:46:18 +01:00
Lukas Wirth 3d65c92040 Replace implementation with @RUSTC_BUILTIN prefix substitution var 2024-03-25 22:20:13 +00:00
Lukas Wirth 2fae4ee92e Make sysroot mandatory for rustdoc 2024-03-25 22:19:41 +00:00
Lukas Wirth 91547573af Implement `-L builtin:$path` 2024-03-25 22:18:31 +00:00
Jubilee 77de550c61
Rollup merge of #123044 - compiler-errors:instance, r=oli-obk
`Instance` is `Copy`

No reason to take it by value; it was confusing ``@rcvalle`` to see it being mutated when it's also being passed by ref in some places.
2024-03-25 14:35:37 -07:00
Jubilee 9775296796
Rollup merge of #122923 - kpreid:print-async-def, r=compiler-errors
In `pretty_print_type()`, print `async fn` futures' paths instead of spans.

This makes `-Zprint-type-sizes`'s output easier to read, because the name of an `async fn` is more immediately recognizable than its span. This change will also synergize with my other `-Zprint-type-sizes` PR #122922 which prints the type of child futures being awaited.

I also deleted the comment "FIXME(eddyb) should use `def_span`." because it appears to have already been fixed by commit 67727aa7c3.
2024-03-25 14:35:35 -07:00
Jubilee 2f8c9bd651
Rollup merge of #122769 - RalfJung:reachable, r=tmiasko
extend comments for reachability set computation

I hope this is right. :) Please review carefully.

r? ``@tmiasko``
Cc ``@oli-obk`` ``@saethlin``
2024-03-25 14:35:34 -07:00
Ralf Jung d94f6576dd extend doc comment for reachability set computation
also extend the const fn reachability test
2024-03-25 19:57:57 +01:00
clubby789 b500693ad7 Don't emit load metadata in debug mode 2024-03-25 18:32:45 +00:00
Michael Goulet 99fbc6f8ef Instance is Copy 2024-03-25 13:58:40 -04:00
Matthias Krüger 4369718980
Rollup merge of #123034 - bjorn3:test_ignores, r=compiler-errors
Add a bunch of needs-unwind annotations to tests

To filter out tests that fail with cg_clif due to missing panic=unwind support.
2024-03-25 17:05:36 +01:00
Matthias Krüger 11f168ffa2
Rollup merge of #123022 - compiler-errors:clif-tests-async-closure, r=bjorn3
Add `async-closures/once.rs` back to cranelift tests

This was fixed afaict by #120717

r? `@bjorn3`
2024-03-25 17:05:35 +01:00
Matthias Krüger 10daf8aa99
Rollup merge of #123001 - Alexendoo:check-attributes, r=oli-obk
Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`

Several places in Clippy want to check all the attributes of a node, we end up using `hir().attrs()` from several different `check_` functions (e.g. [in our doc lints](95c62ffae9/clippy_lints/src/doc/mod.rs (L396))) but this is error prone, we recently found that doc lints weren't triggering on struct fields for example

I went to add a `check_attributes` function but realised `enter_lint_attrs` is already this, the rename is to encourage their use

Also removes `LateContextAndPass::visit_attribute` since it's unused - `visit_attribute` for HIR visitors is only called by `hir().walk_attributes()` which lint passes do not use
2024-03-25 17:05:35 +01:00
Matthias Krüger 9b4ee1be9e
Rollup merge of #122970 - cuviper:use-chunk_by, r=Mark-Simulacrum
Use `chunk_by` when building `ReverseSccGraph`

With stable `chunk_by` in Rust 1.77, this code doesn't need `Itertools::group_by` anymore.
2024-03-25 17:05:33 +01:00
Matthias Krüger e9ec44251c
Rollup merge of #122910 - compiler-errors:unit-struct-in-path-pat-only, r=petrochenkov
Validate that we're only matching on unit struct for path pattern

Resolution doesn't validate that we only really take `CtorKind::Unit` in path patterns, since all it sees is `Res::SelfCtor(def_id)`. Check this instead during pattern typeck.

r? petrochenkov

Fixes #122809
2024-03-25 17:05:33 +01:00
Matthias Krüger ccc5310922
Rollup merge of #122881 - Bryanskiy:delegation-fixes-2, r=petrochenkov
Delegation: fix ICE on `bound_vars` divergence

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

Bug was caused by divergence  between lowered type and corresponding `bound_vars` in `late_bound_vars_map`. In this patch `bound_vars` calculation for delegation item is moved from `lower_fn_ty` to `resolve_bound_vars` query.

r? `@petrochenkov`
2024-03-25 17:05:32 +01:00
Matthias Krüger ded16b3a97
Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name

Fixes #122509

You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example.

In case compilation produced more than a single file `rustc` runs following check to emit some warnings:

```rust
            if crate_output.outputs.contains_key(&output_type) {
                // 2) Multiple codegen units, with `--emit foo=some_name`. We have
                //    no good solution for this case, so warn the user.
                sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
            } else if crate_output.single_output_file.is_some() {
                // 3) Multiple codegen units, with `-o some_name`. We have
                //    no good solution for this case, so warn the user.
                sess.dcx().emit_warn(errors::IgnoringOutput { extension });
            } else {
                // 4) Multiple codegen units, but no explicit name. We
                //    just leave the `foo.0.x` files in place.
                // (We don't have to do any work in this case.)
            }
```

Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`.

To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-25 17:05:32 +01:00
bjorn3 5f5dcaefe6 Add needs-unwind for proc macro tests
Rustc gives a warning when compiling proc macros with panic=abort.
2024-03-25 15:02:55 +00:00
Kevin Reid 3010fa9afb In `pretty_print_type()`, print `async fn` futures' paths instead of spans.
This makes `-Zprint-type-sizes`'s output easier to read, because the
name of an `async fn` is more immediately recognizable than its span.

I also deleted the comment "FIXME(eddyb) should use `def_span`." because
it appears to have already been fixed by commit 67727aa7c3.
2024-03-25 08:01:15 -07:00
bjorn3 3733dcc72d Add needs-unwind annotations to a couple of tests 2024-03-25 14:19:07 +00:00
bors af98101ed8 Auto merge of #123029 - matthiaskrgr:rollup-6qsevhx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #122858 (Tweak `parse_dot_suffix_expr`)
 - #122982 (Add more comments to the bootstrap code that handles `tests/coverage`)
 - #122990 (Clarify transmute example)
 - #122995 (Clean up unnecessary headers/flags in coverage mir-opt tests)
 - #123003 (CFI: Handle dyn with no principal)
 - #123005 (CFI: Support complex receivers)
 - #123020 (Temporarily remove nnethercote from the review rotation.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-25 12:00:21 +00:00
Matthias Krüger fe0222be07
Rollup merge of #123005 - maurer:cfi-arbitrary-receivers, r=compiler-errors
CFI: Support complex receivers

Right now, we only support rewriting `&self` and `&mut self` into `&dyn MyTrait` and `&mut dyn MyTrait`. This expands it to handle the full gamut of receivers by calculating the receiver based on *substitution* rather than based on a rewrite. This means that, for example, `Arc<Self>` will become `Arc<dyn MyTrait>` appropriately with this change.

This approach also allows us to support associated type constraints as well, so we will correctly rewrite `&self` into `&dyn MyTrait<T=i32>`, for example.

r? ```@workingjubilee```
2024-03-25 11:00:14 +01:00
Matthias Krüger 84ec66e15b
Rollup merge of #123003 - maurer:dyn-empty, r=compiler-errors
CFI: Handle dyn with no principal

In user-facing Rust, `dyn` always has at least one predicate following it. Unfortunately, because we filter out marker traits from receivers at callsites and `dyn Sync` is, for example, legal, this results in us having `dyn` types with no predicates on occasion in our alias set encoding. This patch handles cases where there are no predicates in a `dyn` type which are relevant to its alias set.

Fixes #122998

r? workingjubilee
2024-03-25 11:00:14 +01:00
Matthias Krüger 4cae68b0cf
Rollup merge of #122858 - nnethercote:tweak-parse_dot_suffix_expr, r=est31
Tweak `parse_dot_suffix_expr`

I find this function hard to understand, so I rewrote it.

r? ```@est31```
2024-03-25 11:00:12 +01:00
bors dda2372cf3 Auto merge of #122802 - estebank:unconstrained-generic-const, r=Nadrieril
Provide structured suggestion for unconstrained generic constant

```
error: unconstrained generic constant
  --> $DIR/const-argument-if-length.rs:18:10
   |
LL |     pad: [u8; is_zst::<T>()],
   |          ^^^^^^^^^^^^^^^^^^^
   |
help: try adding a `where` bound
   |
LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: {
   |                                   ++++++++++++++++++++++++++
```

Detect when the constant expression isn't `usize` and suggest casting:

```
error: unconstrained generic constant
 --> f300.rs:6:10
  |
6 |     bb::<{!N}>();
  |          ^^^^
-Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36
  |
help: try adding a `where` bound
  |
5 | fn b<const N: bool>() where [(); {!N} as usize]: {
  |                       ++++++++++++++++++++++++++
```

Fix #122395.
2024-03-25 09:59:37 +00:00
Nicholas Nethercote dce0f7f5c2 Clarify `parse_dot_suffix_expr`.
For the `MiddleDot` case, current behaviour:
- For a case like `1.2`, `sym1` is `1` and `sym2` is `2`, and `self.token`
  holds `1.2`.
- It creates a new ident token from `sym1` that it puts into `self.token`.
- Then it does `bump_with` with a new dot token, which moves the `sym1`
  token into `prev_token`.
- Then it does `bump_with` with a new ident token from `sym2`, which moves the
  `dot` token into `prev_token` and discards the `sym1` token.
- Then it does `bump`, which puts whatever is next into `self.token`,
  moves the `sym2` token into `prev_token`, and discards the `dot` token
  altogether.

New behaviour:
- Skips creating and inserting the `sym1` and dot tokens, because they are
  unnecessary.
- This also demonstrates that the comment about `Spacing::Alone` is
  wrong -- that value is never used. That comment was added in #77250,
  and AFAICT it has always been incorrect.

The commit also expands comments. I found this code hard to read
previously, the examples in comments make it easier.
2024-03-25 13:08:07 +11:00
Nicholas Nethercote 9c091160dc Change `parse_expr_tuple_field_access`.
Pass in the span for the field rather than using `prev_token`.
Also rename it `mk_expr_tuple_field_access`, because it doesn't do any
actual parsing, it just creates an expression with what it's given.

Not much of a clarity win by itself, but unlocks additional subsequent
simplifications.
2024-03-25 13:05:59 +11:00
Nicholas Nethercote 90eeb3d681 Remove `next_token` handling from `parse_expr_tuple_field_access`.
It's clearer at the call site.
2024-03-25 13:05:59 +11:00
Nicholas Nethercote 42066b029f Inline and remove `Parser::parse_expr_tuple_field_access_float`.
It has a single call site, and afterwards all the calls to
`parse_expr_tuple_field_access` are in a single method, which is nice.
2024-03-25 13:05:59 +11:00
Michael Goulet e6918b1e5d Add async-closures/once.rs back to cranelift tests 2024-03-24 21:42:32 -04:00
bors 13dac8fb73 Auto merge of #122721 - oli-obk:merge_queries, r=davidtwco
Replace `mir_built` query with a hook and use mir_const everywhere instead

A small perf improvement due to less dep graph handling.

Mostly just a cleanup to get rid of one of our many mir queries
2024-03-25 01:33:46 +00:00
Michael Goulet 9bda9ac76e Relax validation now 2024-03-24 21:15:23 -04:00
Michael Goulet b7d67eace7 Require coroutine kind type to be passed to TyCtxt::coroutine_layout 2024-03-24 21:12:49 -04:00
Scott McMurray c59e93c753 Address PR feedback 2024-03-24 17:42:35 -07:00
Michael Goulet 847fd88df7 Always use tcx.coroutine_layout over calling optimized_mir directly 2024-03-24 20:06:05 -04:00
Tomasz Miąsko 955f762fc1 Function ABI is irrelevant for reachability 2024-03-25 00:00:00 +00:00
Matthew Maurer 40f41e7e89 CFI: Support arbitrary receivers
Previously, we only rewrote `&self` and `&mut self` receivers. By
instantiating the method from the trait definition, we can make this
work work with arbitrary legal receivers instead.
2024-03-24 22:46:48 +00:00
Matthew Maurer ea4518522f CFI: Handle dyn with no principal
In user-facing Rust, `dyn` always has at least one predicate following
it. Unfortunately, because we filter out marker traits from receivers at
callsites and `dyn Sync` is, for example, legal, this results in us
having `dyn` types with no predicates on occasion in our alias set
encoding. This patch handles cases where there are no predicates in a
`dyn` type which are relevant to its alias set.

Fixes #122998
2024-03-24 16:58:33 +00:00
Matthias Krüger 19d3827efe
Rollup merge of #122937 - Zalathar:unbox, r=oli-obk
Unbox and unwrap the contents of `StatementKind::Coverage`

The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`.

Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`.

This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.

``@rustbot`` label +A-code-coverage
2024-03-24 17:08:16 +01:00
Matthias Krüger 04eedb24c9
Rollup merge of #122757 - h1467792822:priv-dep, r=davidtwco
Fixed the `private-dependency` bug

Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency`

Fixes #122756
2024-03-24 17:08:15 +01:00
Matthias Krüger 3fe9f66133
Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, r=davidtwco
conditionally ignore fatal diagnostic in the SilentEmitter

This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to https://github.com/rust-lang/rustfmt/issues/6109.

These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
2024-03-24 17:08:15 +01:00
Alex Macleod 2cb53473d9 Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}` 2024-03-24 14:57:57 +00:00
Ralf Jung 42526e142a simplify_branches: add comment 2024-03-24 12:53:03 +01:00
bors 6a92312a1e Auto merge of #122891 - compiler-errors:encode-implied-predicates-always, r=oli-obk
Encode implied predicates for traits

In #112629, we decided to make associated type bounds in the "supertrait" AST position *implied* even though they're not supertraits themselves.

This means that the `super_predicates` and `implied_predicates` queries now differ for regular traits. The assumption that they didn't differ was hard-coded in #107614, so in cross-crate positions this means that we forget the implied predicates from associated type bounds.

This isn't unsound, just kind of annoying. This should be backported since associated type bounds are slated to stabilize for 1.78 -- either that, or associated type bounds can be reverted on beta and re-shipped in 1.79 with this patch.

Fixes #122859
2024-03-24 11:17:21 +00:00
Scott McMurray 3da115a93b Add+Use `mir::BinOp::Cmp` 2024-03-23 23:23:41 -07:00
Jubilee c94d229337
Rollup merge of #122969 - cuviper:borrowck-rposition, r=matthewjasper
Simplify an iterator search in borrowck diag

Rather than `.into_iter().rev().find_position(...)`, this case can
simply call `.iter().rposition(...)`.
2024-03-23 22:59:43 -07:00
Jubilee 992aa1edb6
Rollup merge of #122879 - maurer:callsite-instances, r=workingjubilee
CFI: Strip auto traits off Virtual calls

We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well.

The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.

This is needed for the "separate machinery" version of my approach to the vtable issues (#122573), because we need to respond differently to a `Virtual` call to the same type as a non-virtual call, specifically [stripping auto traits off the receiver's `Self`](54b15b0c36) because there isn't a separate vtable for `Foo` vs `Foo + Send`.

This would also make a more general underlying mechanism that could be used by rcvalle's [proposed drop detection / encoding](edcd1e20a1) if we end up using his approach, as we could condition out on the `def_id` in the CFI code rather than requiring the generating code to explicitly note whether it was calling drop.
2024-03-23 22:59:42 -07:00
Jubilee b9b65f816d
Rollup merge of #122875 - maurer:cfi-transparent-termination, r=workingjubilee
CFI: Support self_cell-like recursion

Current `transform_ty` attempts to avoid cycles when normalizing `#[repr(transparent)]` types to their interior, but runs afoul of this pattern used in `self_cell`:

```
struct X<T> {
  x: u8,
  p: PhantomData<T>,
}

 #[repr(transparent)]
struct Y(X<Y>);
```

When attempting to normalize Y, it will still cycle indefinitely. By using a types-visited list, this will instead get expanded exactly one layer deep to X<Y>, and then stop, not attempting to normalize `Y` any further.

This PR was split off from #121962 as part of fixing the larger vtable compatibility issues.

r? ``````@workingjubilee``````
2024-03-23 22:59:42 -07:00
Jubilee 862d870070
Rollup merge of #122762 - RoboSchmied:RoboSchmied-typo, r=workingjubilee
fix typo of endianness

fix typo
endianess -> endianness
2024-03-23 22:59:41 -07:00
Jubilee 97fcfaa103
Rollup merge of #121940 - veera-sivarajan:bugfix-121593, r=fmease
Mention Register Size in `#[warn(asm_sub_register)]`

Fixes #121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
2024-03-23 22:59:40 -07:00
Josh Stone 87808e71be Use `chunk_by` when building `ReverseSccGraph` 2024-03-23 17:30:12 -07:00
Josh Stone 66f1e14cc3 Simplify an iterator search in borrowck diag
Rather than `.into_iter().rev().find_position(...)`, this case can
simply call `.iter().rposition(...)`.
2024-03-23 17:24:13 -07:00
Matthias Krüger cb03714e6f
Rollup merge of #122907 - compiler-errors:uniquify-reerror, r=lcnr
Uniquify `ReError` on input mode in canonicalizer

See test descr

Fixes #122861

r? lcnr
2024-03-24 01:05:53 +01:00
Matthias Krüger 1164c2725e
Rollup merge of #122217 - estebank:issue-119685, r=fmease
Handle str literals written with `'` lexed as lifetime

Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal:

```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26
   |
LL |     println!('hello world');
   |                          ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("hello world");
   |              ~           ~
```
```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20
   |
LL |     println!('1 + 1');
   |                    ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("1 + 1");
   |              ~     ~
```

Fix #119685.
2024-03-24 01:05:51 +01:00
Matthias Krüger 3d9ee88ea2
Rollup merge of #122168 - compiler-errors:inline-coroutine-body-validation, r=cjgillot
Fix validation on substituted callee bodies in MIR inliner

When inlining a coroutine, we will substitute the MIR body with the args of the call. There is code in the MIR validator that attempts to prevent query cycles, and will use the coroutine body directly when it detects that's the body that's being validated. That means that when inlining a coroutine body that has been substituted, it may no longer be parameterized over the original args of the coroutine, which will lead to substitution ICEs.

Fixes #119064
2024-03-24 01:05:51 +01:00
Adam Gastineau 61fd74f486 Fixed bad formatting 2024-03-23 16:51:01 -07:00
Adam Gastineau 52960d499e Fixed builds with modified libc 2024-03-23 16:42:06 -07:00
Ralf Jung f2cff5ebb9 also rename the SIMD intrinsic 2024-03-23 23:03:37 +01:00
bors 2f090c30dd Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlin
refactor check_{lang,library}_ub: use a single intrinsic

This enacts the plan I laid out [here](https://github.com/rust-lang/rust/pull/122282#issuecomment-1996917998): use a single intrinsic, called `ub_checks` (in aniticpation of https://github.com/rust-lang/compiler-team/issues/725), that just exposes the value of `debug_assertions` (consistently implemented in both codegen and the interpreter). Put the language vs library UB logic into the library.

This makes it easier to do something like https://github.com/rust-lang/rust/pull/122282 in the future: that just slightly alters the semantics of `ub_checks` (making it more approximating when crates built with different flags are mixed), but it no longer affects whether these checks can happen in Miri or compile-time.

The first commit just moves things around; I don't think these macros and functions belong into `intrinsics.rs` as they are not intrinsics.

r? `@saethlin`
2024-03-23 21:11:00 +00:00
Daniel Sedlak 2c433d0e9c Fix typos 2024-03-23 20:25:54 +01:00
John Kåre Alsaker aa9c9a36c0 Add some comments and do some renames 2024-03-23 20:23:25 +01:00
Daniel Sedlak 0c7f8b0f89 Fix diagnostics for async block cloning 2024-03-23 20:22:51 +01:00
John Kåre Alsaker 6119763e19 Encode dep graph edges directly from the previous graph when promoting 2024-03-23 20:03:55 +01:00
Matthew Maurer f434c27067 CFI: Strip auto traits off Self for virtual calls
Additional trait bounds beyond the principal trait and its implications
are not possible in the vtable. This means that if a receiver is
`&dyn Foo + Send`, the function will only be expecting `&dyn Foo`.

This strips those auto traits off before CFI encoding.
2024-03-23 18:30:45 +00:00
Matthew Maurer 7967915c7b CFI: Use Instance at callsites
We already use `Instance` at declaration sites when available to glean
additional information about possible abstractions of the type in use.
This does the same when possible at callsites as well.

The primary purpose of this change is to allow CFI to alter how it
generates type information for indirect calls through `Virtual`
instances.
2024-03-23 18:30:39 +00:00
Ralf Jung 6177530420 refactor check_{lang,library}_ub: use a single intrinsic, put policy into library 2024-03-23 18:45:05 +01:00
Ralf Jung 987ef4c922 move assert_unsafe_preconditions to its own file
These macros and functions are not intrinsics, after all.
2024-03-23 18:44:17 +01:00
bors 020bbe46bd Auto merge of #122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #120577 (Stabilize slice_split_at_unchecked)
 - #122698 (Cancel `cargo update` job if there's no updates)
 - #122780 (Rename `hir::Local` into `hir::LetStmt`)
 - #122915 (Delay a bug if no RPITITs were found)
 - #122916 (docs(sync): normalize dot in fn summaries)
 - #122921 (Enable more mir-opt tests in debug builds)
 - #122922 (-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.)
 - #122927 (Change an ICE regression test to use the original reproducer)
 - #122930 (add panic location to 'panicked while processing panic')
 - #122931 (Fix some typos in the pin.rs)
 - #122933 (tag_for_variant follow-ups)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-23 15:58:17 +00:00
Matthias Krüger fce80392d2
Rollup merge of #122933 - RalfJung:tag_for_variant, r=oli-obk
tag_for_variant follow-ups

Follow-up to https://github.com/rust-lang/rust/pull/122784, mostly to clarify the doc comment.
2024-03-23 15:00:21 +01:00
Matthias Krüger 9418f69446
Rollup merge of #122922 - kpreid:print-async, r=compiler-errors
-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.

This should assist comprehending the size of coroutines. In particular, whenever a future is suspended while awaiting another future, the latter is given the special name `__awaitee`, and now the type of the awaited future will be printed, allowing identifying caller/callee — er, I mean, poller/pollee — relationships.

It would be possible to include the type name in more cases, but I thought that that might be overly verbose (`print-type-sizes` is already a lot of text) and ordinary named fields or variables are easier for readers to discover the types of.

This change will also synergize with my other PR #122923 which changes type printing to print the path of the `async fn` instead of the span.

Implementation note: I'm not sure if `Symbol::intern` is appropriate for this application, but it was the obvious way to not have to remove the `Copy` implementation from `FieldInfo`, or add a `'tcx` lifetime, while avoiding keeping a lot of possibly redundant strings in memory. I don't know what the proper tradeoff to make here is (though presumably it is not too important for a `-Z` debugging option).
2024-03-23 15:00:20 +01:00
Matthias Krüger f03326c579
Rollup merge of #122915 - fmease:lt-opaq-mismatch-delay-bug, r=compiler-errors
Delay a bug if no RPITITs were found

Fixes #122655. See the issue for context.

r? compiler-errors or compiler
2024-03-23 15:00:18 +01:00
Matthias Krüger 99e34b4f7a
Rollup merge of #122780 - GuillaumeGomez:rename-hir-local, r=oli-obk
Rename `hir::Local` into `hir::LetStmt`

Follow-up of #122776.

As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F).

I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far?

r? ```@oli-obk```
2024-03-23 15:00:18 +01:00
bors d6eb0f5a09 Auto merge of #122582 - scottmcm:swap-intrinsic-v2, r=oli-obk
Let codegen decide when to `mem::swap` with immediates

Making `libcore` decide this is silly; the backend has so much better information about when it's a good idea.

Thus this PR introduces a new `typed_swap` intrinsic with a fallback body, and replaces that fallback implementation when swapping immediates or scalar pairs.

r? oli-obk

Replaces #111744, and means we'll never need more libs PRs like #111803 or #107140
2024-03-23 13:57:55 +00:00
Ralf Jung 038e7c6c38 rename MIR int2ptr casts to match library name 2024-03-23 13:18:33 +01:00
Ralf Jung 67b9d7d184 rename ptr::from_exposed_addr -> ptr::with_exposed_provenance 2024-03-23 13:18:33 +01:00
Zalathar ab92699f4a Unbox and unwrap the contents of `StatementKind::Coverage`
The payload of coverage statements was historically a structure with several
fields, so it was boxed to avoid bloating `StatementKind`.

Now that the payload is a single relatively-small enum, we can replace
`Box<Coverage>` with just `CoverageKind`.

This patch also adds a size assertion for `StatementKind`, to avoid
accidentally bloating it in the future.
2024-03-23 22:05:11 +11:00
Ralf Jung 928bd3b4e0 tag_for_variant follow-ups 2024-03-23 10:45:42 +01:00
Kevin Reid 44d185b0d0 -Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.
This should assist comprehending the size of coroutines.
In particular, whenever a future is suspended while awaiting another
future, the latter is given the special name `__awaitee`, and now the
type of the awaited future will be printed, allowing identifying
caller/callee — er, I mean, poller/pollee — relationships.

It would be possible to include the type name in more cases, but I
thought that that might be overly verbose (`print-type-sizes` is already
a lot of text) and ordinary named fields or variables are easier for
readers to discover the types of.
2024-03-22 18:07:15 -07:00
Michael Goulet 08235b1603 Validate that we're only matching on unit struct for path pattern 2024-03-22 20:53:42 -04:00
bors c308726599 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection

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

Also included is a fix for an error now flagged by the lint
2024-03-23 00:37:05 +00:00
León Orell Valerian Liehr 3879acbec0
Suggest assoc ty bound on lifetime in eq constraint 2024-03-23 00:17:30 +01:00
León Orell Valerian Liehr 22b9e960d9
Suggest assoc ty bound on bare dyn trait in eq constraint 2024-03-23 00:17:30 +01:00
Matthew Maurer dec36c3d6e CFI: Support self_cell-like recursion
Current `transform_ty` attempts to avoid cycles when normalizing
`#[repr(transparent)]` types to their interior, but runs afoul of this
pattern used in `self_cell`:

```
struct X<T> {
  x: u8,
  p: PhantomData<T>,
}

 #[repr(transparent)]
struct Y(X<Y>);
```

When attempting to normalize Y, it will still cycle indefinitely. By
using a types-visited list, this will instead get expanded exactly
one layer deep to X<Y>, and then stop, not attempting to normalize `Y`
any further.
2024-03-22 23:02:05 +00:00
bors 0ad5e0d2de Auto merge of #122900 - matthiaskrgr:rollup-nls90mb, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #114009 (compiler: allow transmute of ZST arrays with generics)
 - #122195 (Note that the caller chooses a type for type param)
 - #122651 (Suggest `_` for missing generic arguments in turbofish)
 - #122784 (Add `tag_for_variant` query)
 - #122839 (Split out `PredicatePolarity` from `ImplPolarity`)
 - #122873 (Merge my contributor emails into one using mailmap)
 - #122885 (Adjust better spastorino membership to triagebot's adhoc_groups)
 - #122888 (add a couple more tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-22 22:35:11 +00:00
León Orell Valerian Liehr d3d77a8733
Update docs of hir::TypeBinding 2024-03-22 23:06:36 +01:00
León Orell Valerian Liehr 6b85f075cc
Small tweaks to the linting code for bare trait object types 2024-03-22 23:05:42 +01:00
León Orell Valerian Liehr 807bd98971
Delay a bug if no RPITITs were found 2024-03-22 22:56:28 +01:00
Michael Goulet 5333f2a9d1 Move check for error in impl header outside of reporting 2024-03-22 17:46:40 -04:00
Michael Goulet 78ebb939c1 Fix validation on substituted callee bodies in MIR inliner 2024-03-22 17:17:03 -04:00
Michael Goulet 1fcf2eaa9f Uniquify ReError on input mode in canonicalizer 2024-03-22 16:35:50 -04:00
bors 85e449a323 Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnr
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability`

Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout.

r? lcnr

cc rust-lang/types-team#124
2024-03-22 20:34:14 +00:00
Guillaume Gomez e0d3439226 Rename `hir::Node::Local` into `hir::Node::LetStmt` 2024-03-22 20:48:36 +01:00
Guillaume Gomez d318bf1009 Rename `hir::Node::expect_local` into `hir::Node::expect_let_stmt` 2024-03-22 20:36:21 +01:00
Guillaume Gomez b376f49e30 Rename `hir::Local` into `hir::LetStmt` 2024-03-22 20:36:21 +01:00