Commit Graph

24179 Commits

Author SHA1 Message Date
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
Yuki Okushi
16e2096f0f
Rollup merge of #110660 - compiler-errors:placeholders-pretty, r=wesleywiser,BoxyUwU
Print ty placeholders pretty

Makes anon placeholders print like `!0` instead of `Placeholder { ... }`.

```
rustc_trait_selection::solve::compute_well_formed_goal goal=Goal{
    predicate: !0,
    param_env: ParamEnv{
      caller_bounds: [
        Binder(TraitPredicate(<!0 as std::marker::Copy>, polarity: Positive), []),
        Binder(TraitPredicate(<!0 as std::clone::Clone>, polarity: Positive), []),
        Binder(TraitPredicate(<!0 as std::marker::Sized>, polarity: Positive), []),
      ],
      reveal: UserFacing,
      constness: NotConst,
    }
  }
```

cc `@BoxyUwU` who might care about this formatting decision
2023-04-22 10:33:59 +09:00
Yuki Okushi
617ecd2a7a
Rollup merge of #110657 - miguelraz:cleanup-simplifycfg-refactor, r=compiler-errors
nit: consistent naming for SimplifyConstCondition

Fixing a small naming inconsistency that `@JakobDegen` brought up in https://github.com/rust-lang/rust/pull/110477#discussion_r1170783823.

Please signal for rollup.
2023-04-22 10:33:58 +09:00
Yuki Okushi
18c16b506d
Rollup merge of #110640 - glaubitz:m68k-baseline, r=oli-obk
compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020

Atomic operations require 68020 or later on m68k-linux-gnu.
2023-04-22 10:33:58 +09:00
Yuki Okushi
9a798e416c
Rollup merge of #110622 - WaffleLapkin:hashtag#, r=compiler-errors
Stable hash tag (discriminant) of `GenericArg`

This is a continuation of my quest of removing `transmute` if generic args and types (#110496, #110599).

r? `@compiler-errors`
2023-04-22 10:33:57 +09:00
Michael Goulet
1d7a2472bf Print ty placeholders pretty 2023-04-22 01:19:28 +00:00
Michael Goulet
24c2c075cc Encode lifetime param spans too 2023-04-22 01:13:54 +00:00
bors
80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Oli Scherer
334423263a Run check_match and check_liveness when MIR is built instead of having an explicit phase for them 2023-04-21 22:32:38 +00:00
Oli Scherer
5bb58a68de Make check_match and check_liveness take a LocalDefId 2023-04-21 22:27:20 +00:00
Oli Scherer
1ce80e210d Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
Oli Scherer
e18d1f8d2e Leave it to the query system to invoke the typeck query instead of invoking it eagerly.
Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-04-21 22:12:45 +00:00
miguelraz
6f29a3c980 nit: consistent naming for SimplifyConstCondition 2023-04-21 15:45:25 -06:00
Camille GILLOT
2870d269f5 Actually keep PlaceMention if requested. 2023-04-21 21:34:59 +00:00
Camille GILLOT
ddfa2463e2 Evaluate place expression in PlaceMention. 2023-04-21 21:34:59 +00:00
Bryan Garza
55e5a1d206 Create "AppendConstMessage" enum
This patch creates an enum to replace a nested `Option`.
2023-04-21 14:07:41 -07:00
Obei Sideg
06ff310cf9 Migrate rustc_hir_analysis to session diagnostic
Part 4: Finishing `check/mod.rs` file
2023-04-21 23:50:03 +03:00
bors
fec9adcdbc Auto merge of #110648 - Dylan-DPC:rollup-em3ovcq, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #110333 (rustc_metadata: Split `children` into multiple tables)
 - #110501 (rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence)
 - #110608 (Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`)
 - #110632 (Panic instead of truncating if the incremental on-disk cache is too big)
 - #110633 (More `mem::take` in `library`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-21 19:43:11 +00:00
bors
fa4cc63a6b Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
Ensure mir_drops_elaborated_and_const_checked when requiring codegen.

mir_drops_elaborated_and_const_checked may emit errors while codegen has started, and the compiler would exit leaving object code files around.

Found by `@cuviper` in https://github.com/rust-lang/rust/issues/109731
2023-04-21 17:28:37 +00:00
Camille GILLOT
ed7e50e08b Ensure mir_drops_elaborated_and_const_checked when requiring codegen. 2023-04-21 16:14:43 +00:00
Bryan Garza
d0d40d2a40 Break up long function in trait selection error reporting
- Move blocks of code into their own functions
- Replace a few function argument types with their type aliases
2023-04-21 09:04:02 -07:00
Kyle Matsuda
5a69b5d0f9 Changes from review 2023-04-21 09:57:37 -06:00
bors
4a03f14b09 Auto merge of #110569 - saethlin:mir-pass-cooperation, r=cjgillot
Deduplicate unreachable blocks, for real this time

In https://github.com/rust-lang/rust/pull/106428 (in particular 41eda69516) we noticed that inlining `unreachable_unchecked` can produce duplicate unreachable blocks. So we improved two MIR optimizations: `SimplifyCfg` was given a simplify to deduplicate unreachable blocks, then `InstCombine` was given a combiner to deduplicate switch targets that point at the same block. The problem is that change doesn't actually work.

Our current pass order is
```
SimplifyCfg (does nothing relevant to this situation)
Inline (produces multiple unreachable blocks)
InstCombine (doesn't do anything here, oops)
SimplifyCfg (produces the duplicate SwitchTargets that InstCombine is looking for)
```

So in here, I have factored out the specific function from `InstCombine` and placed it inside the simplify that produces the case it is looking for. This should ensure that it runs in the scenario it was designed for.

Fixes https://github.com/rust-lang/rust/issues/110551
r? `@cjgillot`
2023-04-21 15:08:02 +00:00
Dylan DPC
1d1453a2f6
Rollup merge of #110632 - saethlin:panic-if-dep-graph-too-big, r=lcnr
Panic instead of truncating if the incremental on-disk cache is too big

It seems _unlikely_ that anyone would hit this truncation, but if this `as` does actually truncate, that seems incredibly bad.
2023-04-21 20:35:29 +05:30
Dylan DPC
fbc905e16a
Rollup merge of #110501 - notriddle:notriddle/ice-110495, r=petrochenkov
rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence

Fixes #110495
2023-04-21 20:35:28 +05:30
Dylan DPC
ff4a5fbbe5
Rollup merge of #110333 - petrochenkov:notagain, r=compiler-errors
rustc_metadata: Split `children` into multiple tables

instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 20:35:27 +05:30
bors
409661936f Auto merge of #110542 - petrochenkov:qcstore4, r=cjgillot
resolve: Remove `module_children_untracked`

One of the expensive spans in `ModChild` was removed in https://github.com/rust-lang/rust/pull/109772, so let's try again.
2023-04-21 12:57:31 +00:00
Vadim Petrochenkov
cbc6ccb191 rustc_metadata: Split children into multiple tables
instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 14:38:59 +03:00
John Paul Adrian Glaubitz
b0692a626b compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020
Atomic operations require 68020 or later on m68k-linux-gnu.
2023-04-21 13:27:13 +02:00
bors
1151ea6006 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov
Added byte position range for `proc_macro::Span`

Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate.

The current implementation, of the referenced function, looks something like this:
```rust
fn debug(&mut self, span: Self::Span) -> String {
    if self.ecx.ecfg.span_debug {
        format!("{:?}", span)
    } else {
        format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
    }
}
```

It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string.

Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way.

The proposed `position()`, method implemented in this PR, gives the ability to directly get this info.
It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#).

I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right.

It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21 10:47:27 +00:00
DrMeepster
3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster
631ea7cc15 use P<[Ident]> instead of Vec<Ident> 2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
DrMeepster
b95852b93c test improvements 2023-04-21 02:14:03 -07:00
DrMeepster
61f23e0003 intern offsetof fields 2023-04-21 02:14:03 -07:00
DrMeepster
511e457c4b offset_of 2023-04-21 02:14:02 -07:00
bors
1f5768bc67 Auto merge of #96840 - cjgillot:query-feed, r=oli-obk
Allow to feed a value in another query's cache and remove `WithOptConstParam`

I used it to remove `WithOptConstParam` queries, as an example.

The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`.

There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle.  The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`.

When replayed, we may the following cases:
- `typeck` is green, in that case `type_of` is green too, and all is right;
- `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash;
- `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`.

As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly.

There is an open question about loading from the on-disk cache.  If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour.

I specifically allowed to feed the value to `type_of` from inside a call to `type_of`.  In that case, the dep-graph will check that the fingerprints of both values match.

This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`.  The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`.  The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21 08:04:58 +00:00
Matthias Krüger
77de5f0754
Rollup merge of #110618 - compiler-errors:eval-ctxt-tainted, r=BoxyUwU
Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after

Just some additional protection against missing probes or strange candidate assembly behavior in the new solver.

For background, we don't ever want to call `evaluate_added_goals_and_make_canonical_response` if a previous call to `try_evaluate_added_goals` has bailed with `NoSolution`, since our nested goals are left in an undefined state at that point. This most commonly suggests a missing `EvalCtxt::probe`, but could also signify some other shenanigans like dropping a `QueryResult` on the floor without properly `?`'ing it.

r? `@lcnr`
2023-04-21 06:44:31 +02:00
Matthias Krüger
a8e239468b
Rollup merge of #110597 - lcnr:not-pin-via-negative-bound, r=compiler-errors
remove unused ftl messages

r? `@davidtwco`

does it make sense to check via tidy that there exist no ftl message names which are never mentioned in `compiler/**.rs`
2023-04-21 06:44:30 +02:00
Matthias Krüger
637d9ddc35
Rollup merge of #110578 - bvanjoi:fix-issue-110547, r=jackh726
fix(error): normalize whitespace during msg_to_buffer

close https://github.com/rust-lang/rust/issues/110547
2023-04-21 06:44:30 +02:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
Ben Kimock
010deb5ba3 Panic instead of truncating if the dep graph is too big 2023-04-20 21:12:39 -04:00
Ben Kimock
8ec49ad19a Run combine_duplicate_switch_targets after the simplification that produces them 2023-04-20 20:40:01 -04:00
bohan
a2f275da51 fix(error): normalize whitespace during msg_to_buffer 2023-04-21 08:40:00 +08:00
Michael Goulet
964600b38e Clone region var origins instead of taking in borrowck 2023-04-21 00:31:43 +00:00
bors
d19b64fb54 Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00
bors
8bdcc62cb0 Auto merge of #110616 - m-ou-se:fmt-lang-items, r=jyn514
Remove public doc(hidden) core::fmt::rt::v1

All the types used by format_arg!() are now lang items, so they are no longer required as publicly exported items.

Part of #99012

After this change, the `rt` module is private, and contains only three lang items used by format_args (`Placeholder`, `Alignment`, and `Count`): 441682cca9/library/core/src/fmt/rt.rs
2023-04-20 21:11:54 +00:00
Maybe Waffle
ad8c7b6705 Simplify bits_for_tags impl 2023-04-20 19:54:10 +00:00
Maybe Waffle
4375af53af Derive HashStable on GenericArgKind instead of implementing it by hand 2023-04-20 19:52:37 +00:00
Maybe Waffle
7cfecf26f7 Remove confusing comment 2023-04-20 19:07:57 +00:00
Camille GILLOT
76d573b656 Add info for no_hash panic. 2023-04-20 18:56:12 +00:00
Maybe Waffle
96905d568a Use impl Tag for $T syntax for impl_tag! 2023-04-20 18:49:40 +00:00
Michael Goulet
3206100ed9 Result is just bool but special 2023-04-20 18:40:34 +00:00
Kyle Matsuda
e54854f6a9 add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls 2023-04-20 12:36:50 -06:00
Kyle Matsuda
f3b279fcc5 add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Kyle Matsuda
0892a7380b change usages of explicit_item_bounds to bound_explicit_item_bounds 2023-04-20 12:36:50 -06:00
Camille GILLOT
a395d2a5de Give more descriptive names to queries. 2023-04-20 18:01:07 +00:00
Camille GILLOT
f65f506d60 Remove opt_const_param_of. 2023-04-20 17:48:52 +00:00
Camille GILLOT
b275d2c30b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Maybe Waffle
77c83c0965 Add impl_tag! macro to implement Tag for tagged pointer easily 2023-04-20 17:14:32 +00:00
Camille GILLOT
0e017fc94a Feed type_of query instead of using WithOptconstParam. 2023-04-20 17:13:39 +00:00
Camille GILLOT
4224b4b1f5 Re-allow computing fed queries. 2023-04-20 17:09:26 +00:00
Michael Goulet
4fd7739aac Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after 2023-04-20 16:54:39 +00:00