Commit Graph

24142 Commits

Author SHA1 Message Date
Michael Goulet
015acc2611 Provide RHS type hint when reporting operator error 2023-04-27 01:34:03 +00:00
Michael Goulet
3d80dd983d Clean up some builtin operator typeck logic 2023-04-27 00:57:22 +00:00
clubby789
1ce9d7254e Migrate trivially translatable rustc_parse diagnostics 2023-04-27 01:53:06 +01:00
Jules Bertholet
5b6e747f37
Nicer ICE for #67981 2023-04-26 19:46:10 -04:00
Michael Goulet
c18e7b765f IntoFuture::into_future is no longer unstable 2023-04-26 22:44:18 +00:00
bors
1c42cb4ef0 Auto merge of #110852 - matthiaskrgr:rollup-jz3eosr, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #108760 (Add lint to deny diagnostics composed of static strings)
 - #109444 (Change tidy error message for TODOs)
 - #110419 (Spelling library)
 - #110550 (Suggest deref on comparison binop RHS even if type is not Copy)
 - #110641 (Add new rustdoc book chapter to describe in-doc settings)
 - #110798 (pass `unused_extern_crates` in `librustdoc::doctest::make_test`)
 - #110819 (simplify TrustedLen impls)
 - #110825 (diagnostics: add test case for already-solved issue)
 - #110835 (Make some region folders a little stricter.)
 - #110847 (rustdoc-json: Time serialization.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-26 18:32:57 +00:00
Matthias Krüger
e47562c674
Rollup merge of #110835 - nnethercote:strict-region-folders-2, r=compiler-errors
Make some region folders a little stricter.

Because certain regions cannot occur in them.

r? ``@compiler-errors``
2023-04-26 18:51:44 +02:00
Matthias Krüger
8e6fffcbaa
Rollup merge of #110550 - compiler-errors:deref-on-binop-rhs, r=wesleywiser
Suggest deref on comparison binop RHS even if type is not Copy

Fixes #110500
2023-04-26 18:51:41 +02:00
Matthias Krüger
309496cf29
Rollup merge of #108760 - clubby789:autolintstuff, r=wesleywiser
Add lint to deny diagnostics composed of static strings

r? ghost

I'm hoping to have a lint that semi-automatically converts simple diagnostics such as `struct_span_err(span, "msg").help("msg").span_note(span2, "msg").emit()` to typed session diagnostics. It's quite hacky and not entirely working because of problems with `x fix` but should hopefully help reduce some of the work.
I'm going to start trying to apply what I can from this, but opening this as a draft in case anyone wants to develop on it.

cc #100717
2023-04-26 18:51:40 +02:00
bors
9c044d77a3 Auto merge of #110822 - scottmcm:lower-offset-to-mir, r=compiler-errors
Lower `intrinsics::offset` to `mir::BinOp::Offset`

They're [semantically the same](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html#variant.BinaryOp), so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-26 15:52:33 +00:00
bors
8763965a2c Auto merge of #97368 - tmandry:coverage-underflow, r=jyn514
coverage: Don't underflow column number

I noticed this when running coverage on a debug build of rustc. There
may be other places that do this but I'm just fixing the one I hit.

r? `@wesleywiser` `@richkadel`
2023-04-26 12:03:13 +00:00
clubby789
6a41cfe095 Migrate rustc_passes to translatable diagnostics 2023-04-26 11:40:21 +01:00
jyn
62b5beaf93
Rollup merge of #110594 - infdahai:cfg_chore, r=jyn514
`rustc --help` add `--cfg` SPEC declaration.

1. fixes #110462
2. add spec arguments based on https://doc.rust-lang.org/reference/conditional-compilation.html
2023-04-26 01:55:52 -05:00
Nicholas Nethercote
a82ad2fed4 Derive Type{Foldable,Visitable} for UserTypeProjection.
Because the derived versions are good enough.
2023-04-26 15:19:51 +10:00
Nicholas Nethercote
671de6d62a Remove unused TypeFoldable/TypeVisitable impls. 2023-04-26 15:19:50 +10:00
clundro
27c0d92f1d add cfg SPEC declaration.
use name[=value] syntax.

Signed-off-by: clundro <859287553@qq.com>
2023-04-26 13:19:09 +08:00
bors
adaac6b166 Auto merge of #110634 - saethlin:pointy-decoder, r=cjgillot
Rewrite MemDecoder around pointers not a slice

This is basically https://github.com/rust-lang/rust/pull/109910 but I'm being a lot more aggressive. The pointer-based structure means that it makes a lot more sense to absorb more complexity into `MemDecoder`, most of the diff is just complexity moving from one place to another.

The primary argument for this structure is that we only incur a single bounds check when doing multi-byte reads from a `MemDecoder`. With the slice-based implementation we need to do those with `data[position..position + len]` , which needs to account for `position + len` wrapping. It would be possible to dodge the first bounds check if we stored a slice that starts at `position`, but that would require updating the pointer and length on every read.

This PR also embeds the failure path in a separate function, which means that this PR should subsume all the perf wins observed in https://github.com/rust-lang/rust/pull/109867.
2023-04-26 02:36:42 +00:00
Scott McMurray
05a665f21a Lower intrinsics::offset to mir::BinOp::Offset
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25 19:23:45 -07:00
Nicholas Nethercote
8216b7f229 Make some region folders a little stricter.
Because certain regions cannot occur in them.
2023-04-26 10:14:16 +10:00
bors
f33379b0a6 Auto merge of #110811 - compiler-errors:vars-are-question-mark, r=WaffleLapkin
Use `?0` notation for ty/ct/int/float/region vars

Aligns the notation for infer vars that T-types and friends most often uses for inference variables with the notation in the compiler (which is kinda a sigil nightmare IMO: `_#`) by adopting `?0` style infer vars.

This mostly affects debug output since verbose infer vars shouldn't show up in user-facing places.

Does this need an MCP? It's debug output, so I'm thinking no, but happy to open one. 🤔

r? types
2023-04-25 22:11:09 +00:00
Michael Goulet
bb99cdc7cd vars are ? 2023-04-25 19:53:09 +00:00
Matthias Krüger
f5a3039add
Rollup merge of #110783 - dtolnay:safeprint, r=petrochenkov
Fix ICE on --print=... i/o errors

`rustc --print=cfg > /dev/full`

**Before:** ICE (see below)

**After:** exits quietly with code 1.

```console
thread 'rustc' panicked at 'failed printing to stdout: No space left on device (os error 28)', library/std/src/io/stdio.rs:1019:9
stack backtrace:
   0:     0x7ffa84d68f33 - std::backtrace_rs::backtrace::libunwind::trace::h527d8d64d53ade2d
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ffa84d68f33 - std::backtrace_rs::backtrace::trace_unsynchronized::hfb55b01517dd6379
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ffa84d68f33 - std::sys_common::backtrace::_print_fmt::hd134e914eea0bd97
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ffa84d68f33 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1480db11ec399d77
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ffa84dc9d4f - core::fmt::write::h67ec4c4171c92b26
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/core/src/fmt/mod.rs:1247:17
   5:     0x7ffa84d5bed1 - std::io::Write::write_fmt::h3b12aef0fff2463b
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/io/mod.rs:1712:15
   6:     0x7ffa84d68d45 - std::sys_common::backtrace::_print::h584400135abdbd51
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7ffa84d68d45 - std::sys_common::backtrace::print::hce41d3c8bd91096b
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7ffa84d6b84f - std::panicking::default_hook::{{closure}}::h2043b657a3791225
   9:     0x7ffa84d6b507 - std::panicking::default_hook::h99252b8d3dd5719c
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/panicking.rs:293:9
  10:     0x7ffa87fdf915 - <rustc_driver_impl[d30cd2737d9d343a]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[cc19a662f3570270]::ops::function::FnOnce<(&core[cc19a662f3570270]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7ffa84d6c005 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h222a2b674b9f4762
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/alloc/src/boxed.rs:1976:9
  12:     0x7ffa84d6c005 - std::panicking::rust_panic_with_hook::h7f49b36bf7f8ff77
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/panicking.rs:704:13
  13:     0x7ffa84d6bd73 - std::panicking::begin_panic_handler::{{closure}}::haa23a7352589e31e
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/panicking.rs:595:13
  14:     0x7ffa84d69376 - std::sys_common::backtrace::__rust_end_short_backtrace::h3d0cf6e3c96e3fe9
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7ffa84d6ba72 - rust_begin_unwind
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/panicking.rs:584:5
  16:     0x7ffa84dc5fe3 - core::panicking::panic_fmt::hf4b4ea11e3fdb110
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/core/src/panicking.rs:67:14
  17:     0x7ffa84d5aa07 - std::io::stdio::print_to::h55760b9ede306280
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/io/stdio.rs:1019:9
  18:     0x7ffa84d5aa07 - std::io::stdio::_print::h93deb6099db33eab
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/io/stdio.rs:1095:5
  19:     0x7ffa871e163b - rustc_driver_impl[d30cd2737d9d343a]::print_crate_info
  20:     0x7ffa87fb8e01 - rustc_span[9551eaa044f53f4f]::set_source_map::<(), rustc_interface[c2b70c9b1dae0906]::interface::run_compiler<(), rustc_driver_impl[d30cd2737d9d343a]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  21:     0x7ffa87fb6d59 - std[71a32ca0600a6a04]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c2b70c9b1dae0906]::util::run_in_thread_pool_with_globals<rustc_interface[c2b70c9b1dae0906]::interface::run_compiler<(), rustc_driver_impl[d30cd2737d9d343a]::run_compiler::{closure#0}>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  22:     0x7ffa87fe25b4 - std[71a32ca0600a6a04]::panicking::try::<(), core[cc19a662f3570270]::panic::unwind_safe::AssertUnwindSafe<<std[71a32ca0600a6a04]:🧵:Builder>::spawn_unchecked_<rustc_interface[c2b70c9b1dae0906]::util::run_in_thread_pool_with_globals<rustc_interface[c2b70c9b1dae0906]::interface::run_compiler<(), rustc_driver_impl[d30cd2737d9d343a]::run_compiler::{closure#0}>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1}::{closure#0}>>
  23:     0x7ffa87fb0cf1 - <<std[71a32ca0600a6a04]:🧵:Builder>::spawn_unchecked_<rustc_interface[c2b70c9b1dae0906]::util::run_in_thread_pool_with_globals<rustc_interface[c2b70c9b1dae0906]::interface::run_compiler<(), rustc_driver_impl[d30cd2737d9d343a]::run_compiler::{closure#0}>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cc19a662f3570270]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7ffa84d763e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf15d802f31f86225
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/alloc/src/boxed.rs:1962:9
  25:     0x7ffa84d763e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hac564355b46c52d6
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/alloc/src/boxed.rs:1962:9
  26:     0x7ffa84d763e5 - std::sys::unix:🧵:Thread:🆕:thread_start::h86fb3aedb7811f07
                               at /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7ffa84a94b43 - start_thread
                               at ./nptl/pthread_create.c:442:8
  28:     0x7ffa84b26a00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.71.0-nightly (7f94b314c 2023-04-23) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
```
2023-04-25 21:06:34 +02:00
Matthias Krüger
95e9f68eb5
Rollup merge of #110671 - compiler-errors:polarity, r=lcnr
Consider polarity in new solver

It's kinda ugly to have a polarity check in all of the builtin impls -- I guess I could consider the polarity at the top of assemble-builtin but that would require adding a polarity fn to `GoalKind`...

🤷 putting this up just so i dont forget, since it's needed to bootstrap core during coherence (this alone does not allow core to bootstrap though, additional work is needed!)

r? ``@lcnr``
2023-04-25 21:06:34 +02:00
Matthias Krüger
8d00a8d11e
Rollup merge of #110615 - WaffleLapkin:impl_tag, r=cjgillot
Add `impl_tag!` macro to implement `Tag` for tagged pointer easily

r? `@Nilstrieb`

This should also lifts the need to think about safety from the callers (`impl_tag!` is robust (ish, see the macro issue)) and removes the possibility of making a "weird" `Tag` impl.
2023-04-25 21:06:33 +02:00
Matthias Krüger
297b222066
Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, r=compiler-errors
Switch to `EarlyBinder` for `explicit_item_bounds`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`.

r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 😃)
2023-04-25 21:06:32 +02:00
clubby789
0138513635 Fix static string lints 2023-04-25 18:59:55 +01:00
clubby789
eeb527602a Add deny lint to prevent untranslatable diagnostics using static strings 2023-04-25 18:44:49 +01:00
Maybe Waffle
bec7ce4824 Add #[inline] in impl_tag 2023-04-25 17:37:12 +00:00
Maybe Waffle
021a12c00d Sprinkle some #[inline] in rustc_data_structures::tagged_ptr 2023-04-25 17:30:05 +00:00
Camille GILLOT
0ee32fb3c7 Move unstatisfaction check earlier. 2023-04-25 17:11:46 +00:00
David Tolnay
040e1b6b5f
Fix ICE on --print=... i/o errors 2023-04-25 08:17:18 -07:00
bors
a7aa20517c Auto merge of #110325 - obeis:hir-analysis-migrate-diagnostics-4, r=davidtwco
Migrate `rustc_hir_analysis` to session diagnostic [Part 4]

Part 4: Finishing `check/mod.rs` file

r? `@compiler-errors`
2023-04-25 13:45:20 +00:00
bors
999e6e5afb Auto merge of #101069 - zhaixiaojuan:loongarch64-inline-asm, r=Amanieu
Add loongarch64 asm! support
2023-04-25 09:18:58 +00:00
zhaixiaojuan
5f2fa4c11d Add loongarch64 asm! support 2023-04-25 14:15:31 +08:00
Matthias Krüger
2d72abc8f2
Rollup merge of #110782 - matthiaskrgr:revert_panic_oom, r=Amanieu
Revert panic oom

This temporarily reverts https://github.com/rust-lang/rust/pull/109507 until https://github.com/rust-lang/rust/issues/110771 is addressed

r? `@Amanieu`
2023-04-25 06:46:50 +02:00
Matthias Krüger
7e143e9043
Rollup merge of #110755 - TimNN:exp-tls, r=durin42
[LLVM17] Adapt to `ExplicitEmulatedTLS` removal.

0d333bf0e3 removed the `ExplicitEmulatedTLS` field from `TargetOptions`.

Before that commit, `TargetMachine::useEmulatedTLS()` fell back to `TheTriple.hasDefaultEmulatedTLS()` if `ExplicitEmulatedTLS` was `false`/unset.

After that commit, `TargetMachine::useEmulatedTLS()` directly returns `Options.EmulatedTLS`, and the fallback to `TheTriple.hasDefaultEmulatedTLS()` was moved to `InitTargetOptionsFromCodeGenFlags`.

Since `rustc` does not use `InitTargetOptionsFromCodeGenFlags` (AFAICT) and instead manually builds `TargetOptions`, this PR initializes `EmulatedTLS` to `TheTriple.hasDefaultEmulatedTLS()`.

(I'm not really familiar with the details of what this option does, or if there are any tests that depend on `hasDefaultEmulatedTLS` being used correctly, so this PR is mostly untested (it does compile against LLVM17, though)).

`@rustbot` label: +llvm-main
2023-04-25 06:46:49 +02:00
Matthias Krüger
5f33a8c026
Rollup merge of #110563 - bryangarza:refactor-trait-selection-error-reporting, r=compiler-errors
Break up long function in trait selection error reporting + clean up nearby code

- Move blocks of code into their own functions
- Replace a few function argument types with their type aliases
- Create "AppendConstMessage" enum to replace a nested `Option`.
2023-04-25 06:46:48 +02:00
Matthias Krüger
f54dbe6e31 Revert "Remove #[alloc_error_handler] from the compiler and library"
This reverts commit abc0660118.
2023-04-25 00:08:35 +02:00
Matthias Krüger
33253fa6a4 Revert "Rename -Zoom=panic to -Zoom=unwind"
This reverts commit 4b981c2648.
2023-04-25 00:08:33 +02:00
Michael Goulet
794cb890de Consider polarity in new solver 2023-04-24 18:59:42 +00:00
Camille GILLOT
0f857791ad Fully clear the body. 2023-04-24 18:53:47 +00:00
Yuki Okushi
16fdef7868
Rollup merge of #110750 - scottmcm:vardebug-size, r=cjgillot
Add size asserts for MIR `SourceScopeData` & `VarDebugInfo`

There's vectors of both of these in `mir::Body`, so might as well track them.

(I was pondering adding something to one or the other, so wanted this to see the memory impact.)
2023-04-25 02:33:31 +09:00
Yuki Okushi
4d3ab3da4e
Rollup merge of #110685 - cjgillot:clean-dcp, r=oli-obk
Some cleanups to DataflowConstProp

Mostly moving code around and short-circuiting useless cases.
2023-04-25 02:33:30 +09:00
Yuki Okushi
a373623d55
Rollup merge of #110681 - klensy:cut-dep, r=lcnr
drop few unused crates, gate libc under unix for rustc_codegen_ssa

Small cleanup.
2023-04-25 02:33:29 +09:00
Yuki Okushi
cefb479242
Rollup merge of #110539 - WaffleLapkin:split_index_vec&slice, r=cjgillot
Move around `{Idx, IndexVec, IndexSlice}` adjacent code

r? ``@scottmcm``
2023-04-25 02:33:25 +09:00
Maybe Waffle
2b8d27b402 Switch impl_tag! from explicit tags to ${index()} 2023-04-24 16:48:37 +00:00
Mara Bos
0a28977740 Restructure std::fmt::rt a bit.
This moves more of the internal/lang items into the private rt module.
2023-04-24 16:16:14 +02:00
Mara Bos
5cf3cbf3b7 Remove "V1" from ArgumentsV1 and FlagsV1. 2023-04-24 16:16:14 +02:00
Maybe Waffle
c0daff08c7 Fix rustc_index imports outside the compiler 2023-04-24 13:53:37 +00:00
Maybe Waffle
5d809b1764 Decorative changes to IndexVec 2023-04-24 13:53:37 +00:00
Maybe Waffle
7d23b52376 const-ify some {IndexVec, IndexSlice} methods 2023-04-24 13:53:37 +00:00
Maybe Waffle
99ebfe2f15 move index code around 2023-04-24 13:53:37 +00:00
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
bors
b72460fe46 Auto merge of #110672 - Ezrashaw:allow-array-simd-in-inline-asm, r=workingjubilee
allow array-style simd in inline asm

Required for [MCP#621](https://github.com/rust-lang/compiler-team/issues/621) to be implemented.

r? `@workingjubilee`
2023-04-24 13:51:04 +00:00
Tim Neumann
047ed32148 [LLVM17] Adapt to ExplicitEmulatedTLS removal. 2023-04-24 08:45:15 +00:00
Matthias Krüger
2ce9b574a4
Rollup merge of #110714 - cjgillot:reveal-consts, r=oli-obk
Normalize types and consts in MIR opts.

Some passes were using a non-RevealAll param_env, which is needlessly restrictive in mir-opts.

As a drive-by, we normalize all constants, since just normalizing their types is not enough.
2023-04-24 07:53:25 +02:00
Matthias Krüger
3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Matthias Krüger
8aab707131
Rollup merge of #110566 - compiler-errors:bad-projection-term, r=cjgillot,BoxyUwU
Don't create projection ty for const projection

Fixes #110549
2023-04-24 07:53:24 +02:00
Matthias Krüger
d60c64a0c5
Rollup merge of #110514 - compiler-errors:remove-find_map_relevant_impl, r=b-naber
Remove `find_map_relevant_impl`

Fixes #108895
2023-04-24 07:53:24 +02:00
Matthias Krüger
0f271619e4
Rollup merge of #110255 - clubby789:proc-macro-test-help, r=jackh726
Suggest using integration tests for test crate using own proc-macro

cc #110247
2023-04-24 07:53:23 +02:00
Scott McMurray
31531ce939 Add size asserts for MIR SourceScopeData & VarDebugInfo
There's vectors of both of these in `mir::Body`, so might as well track them.
2023-04-23 21:23:54 -07:00
bors
f65615f02d Auto merge of #109590 - Nilstrieb:copy-hir, r=oli-obk
Impl `Copy` for most HIR types

This simplifies the invocation of the `arena_types` macro and probably
makes working with HIR nicer in general.

Based on #109588
2023-04-24 03:10:55 +00:00
bors
8991768e67 Auto merge of #110736 - matthiaskrgr:rollup-gorv8zp, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110661 (rustdoc: clean up settings.css and settings.js)
 - #110663 (Add note about change in bootstrap defaults)
 - #110664 (stop `x fmt` formatting untracked directories)
 - #110668 (Fix printing native CPU on cross-compiled compiler.)
 - #110689 (Fix grammar in core::hint::unreachable_unchecked() docs)
 - #110700 (Don't infer fn return type to return itself)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-24 00:05:59 +00:00
Ben Kimock
1f67ba61a9 Rewrite MemDecoder around pointers not a slice 2023-04-23 17:25:11 -04:00
Michael Goulet
cde5bcafe8 Don't create projection ty for const projection 2023-04-23 18:09:30 +00:00
Matthias Krüger
12858d9a61
Rollup merge of #110700 - compiler-errors:fn-ret-fn, r=oli-obk
Don't infer fn return type to return itself

Fixes #110687
2023-04-23 20:06:33 +02:00
Matthias Krüger
12a539f484
Rollup merge of #110668 - ehuss:fix-native-cpu-list, r=cuviper
Fix printing native CPU on cross-compiled compiler.

If `rustc` is cross-compiled from a different host, then the "native" entry in `rustc --print=target-cpus` would not appear. There is a check in the printing code that will avoid printing the "native" entry if the user has passed `--target`. However, that check was comparing the `--target` value with the `LLVM_TARGET_TRIPLE` which is the triple of the host that `rustc` was built on (the "build" target in Rust lingo), not the target it was being built for (the "host" in Rust lingo). This fixes it to use the target that LLVM was built for (which I'm pretty sure this is the correct function to determine that).

This fixes the cpu listing for aarch64-apple-darwin which is built on CI using the x86_64-apple-darwin host.
2023-04-23 20:06:32 +02:00
bors
7f94b314ce Auto merge of #110281 - ozkanonur:multiarch-compatible-sysroot-finding, r=jackh726
make sysroot finding compatible with multiarch systems

Tested on Debian 11 multiarch, worked just fine.

resolves #109994
2023-04-23 18:03:00 +00:00
Eric Huss
e4e4110dc6 Fix printing native CPU on cross-compiled compiler. 2023-04-23 09:35:56 -07:00
Camille GILLOT
15e5072147 Do not bother optimizing impossible functions. 2023-04-23 16:35:49 +00:00
bors
915aa06700 Auto merge of #110705 - saethlin:ignore-locals-cost, r=cjgillot
Remove the size of locals heuristic in MIR inlining

This heuristic doesn't necessarily correlate to complexity of the MIR Body. In particular, a lot of straight-line code in MIR tends to never reuse a local, even though any optimizer would effectively reuse the storage or just put everything in registers. So it doesn't even necessarily make sense that this would be a stack size heuristic.

So... what happens if we just delete the heuristic? The benchmark suite improves significantly. Less heuristics better?

r? `@cjgillot`
2023-04-23 15:41:45 +00:00
bors
3462f79e94 Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases

These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.

This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23 13:34:31 +00:00
bors
9e540df793 Auto merge of #107404 - cjgillot:const-debuginfo, r=oli-obk
Turn on ConstDebugInfo pass.

Split from https://github.com/rust-lang/rust/pull/103657

Moving those constant into debuginfo allows to shrink the number of locals and the actual size of the MIR body.
2023-04-23 11:26:01 +00:00
Camille GILLOT
4fe51365d7 Use param_env_reveal_all_normalized in MIR opts. 2023-04-23 10:04:41 +00:00
Camille GILLOT
7efcf67a3b Also reveal constants before MIR opts. 2023-04-23 10:04:41 +00:00
bors
f12a7fa00f Auto merge of #110497 - cjgillot:span-ctxt, r=b-naber
Refactor `SyntaxContext::ctxt` logic.

I'm still trying to make a test from the issue.

cc `@deepink-mas` does this solve the issue?

Fixes https://github.com/rust-lang/rust/issues/110230
2023-04-23 09:13:33 +00:00
Ezra Shaw
d31e8a499b
allow array-style simd in inline asm 2023-04-23 19:28:50 +12:00
Scott McMurray
1de2257c3f Add intrinsics::transmute_unchecked
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Ben Kimock
173845ce0e Remove the size of locals heuristic in MIR inlining 2023-04-22 19:17:11 -04:00
bors
0af46a19b6 Auto merge of #110703 - clubby789:synstructure-remove, r=Nilstrieb
Remove unused `synstructure` dep

`synstructure` is no longer used now that this crate was split out from rustc_macros

`@rustbot` label +C-cleanup
2023-04-22 22:15:53 +00:00
Wesley Wiser
4e8b642646 Turn on ConstDebugInfo pass. 2023-04-22 23:41:48 +02:00
Camille GILLOT
4ad04ad841 Set debug location to debug operand spill. 2023-04-22 23:41:48 +02:00
clubby789
da5d01d53d Remove unused synstructure dep 2023-04-22 22:03:33 +01:00
Nilstrieb
74e31ec64c Also arena-allocate ast::MacroDef to make Item: Copy 2023-04-22 23:00:38 +02:00
Nilstrieb
ed8d67d8ba Impl Copy for almost all HIR types
This simplifies the invocation of the `arena_types` macro and probably
makes working with HIR nicer in general.
2023-04-22 23:00:28 +02:00
bors
b628260df0 Auto merge of #110523 - ecnelises:llvm_isa_fix, r=cuviper
Replace LLVM any_isa with any_cast

Per 585a6eb3eb/llvm/include/llvm/ADT/Any.h (L130) , `any_isa` has been deprecated in LLVM. Use `any_cast` instead to avoid warnings.
2023-04-22 20:03:44 +00:00
Michael Goulet
c8874e2445 Don't infer fn return type to return itself 2023-04-22 19:30:47 +00:00
bors
bb758cfc6d Auto merge of #110674 - compiler-errors:expect-projection-term-eq-succeeds, r=BoxyUwU
Expect that equating a projection term always succeeds in new solver

These should never fail. If they do, we have a problem with the logic that replaces a projection goal's term with an unconstrained infer var. Let's make sure we ICE in that case.
2023-04-22 17:59:16 +00:00
bors
4396ceca05 Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjay
Clone region var origins instead of taking them in borrowck

Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`.

This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver.

Fixes compiler-errors/next-solver-hir-issues#12.

----

This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
2023-04-22 15:15:51 +00:00
Camille GILLOT
dd78b997b5 Reduce rightward drift. 2023-04-22 12:30:37 +00:00
Camille GILLOT
dd452ae70e Simplify logic. 2023-04-22 12:30:36 +00:00
Camille GILLOT
629cdb42d3 Move eval_discriminant. 2023-04-22 12:30:36 +00:00
Camille GILLOT
0e68cbd45d Remove useless special case. 2023-04-22 12:30:36 +00:00
bors
39cf520299 Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco
Report allocation errors as panics

OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`.

This should be review one commit at a time:
- The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics.
- The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API.

ACP: https://github.com/rust-lang/libs-team/issues/192

Closes #51540
Closes #51245
2023-04-22 12:27:45 +00:00
klensy
3338ee3ca7 drop unused deps, gate libc under unix for one crate 2023-04-22 15:22:21 +03:00
bors
21fab435da Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJung
Evaluate place expression in `PlaceMention`

https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics.

This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live.

Specifically, consider this code:
```rust
let _ = {
    let a = 5;
    &a
};
```

This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8).

This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`.

The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression.

For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it.

r? `@RalfJung`
2023-04-22 09:54:21 +00:00
bors
ccb6290e43 Auto merge of #110567 - JohnBobbo96:monomorphize-dyn-dispatch, r=b-naber
Remove some uses of dynamic dispatch during monomorphization/partitioning.

This removes a few uses of dynamic dispatch and instead uses generics, as well as an enum to allow for other partitioning methods to be added later.
2023-04-22 07:43:43 +00:00
Michael Goulet
6041030c0f Expect that equating a projection term always succeeds in new solver 2023-04-22 06:07:18 +00:00
bors
3128fd8ddf Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109949 (rustdoc: migrate `document_type_layout` to askama)
 - #110622 (Stable hash tag (discriminant) of `GenericArg`)
 - #110635 (More `IS_ZST` in `library`)
 - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - #110657 (nit: consistent naming for SimplifyConstCondition)
 - #110659 (rustdoc: clean up JS)
 - #110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-22 05:35:08 +00:00
bors
37b22cf2d5 Auto merge of #110469 - compiler-errors:encode-lt-param-span, r=oli-obk
Encode lifetime param spans too

Fixes #110464
Fixes #110591
2023-04-22 03:28:13 +00:00