Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when triggering a malformed diagnostic::on_unimplemented across crate boundaries (DefId(20:3 ~ ice_lib_test[60d0]::Test) isn't local) #124651

Closed
13ros27 opened this issue May 3, 2024 · 1 comment · Fixed by #124683
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. F-on_unimplemented Error messages that can be tackled with `#[rustc_on_unimplemented]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@13ros27
Copy link

13ros27 commented May 3, 2024

Code

The simplest version uses tests/benches however I have also tested this via a sub-crate.
lib.rs:

#[diagnostic::on_unimplemented(aa = "broken")]
pub trait Test {}

tests/test.rs:

use ice_lib_test::*;

fn breakage<T: Test>(test: T) {}

#[test]
fn test() {
    breakage(1);
}

Meta

rustc --version --verbose:

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

I can also reproduce this on 1.79.0-beta.2 and 1.80.0-nightly on debug and release.

Error output

When running cargo test

warning: malformed `on_unimplemented` attribute
 --> src/lib.rs:1:32
  |
1 | #[diagnostic::on_unimplemented(aa = "broken")]
  |                                ^^^^^^^^^^^^^ invalid option found here
  |
  = help: only `message`, `note` and `label` are allowed as options
  = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default

warning: `ice-lib-test` (lib) generated 1 warning
   Compiling ice-lib-test v0.1.0 (/home/<me>/Documents/Programming/Rust/ice-lib-test)
warning: `ice-lib-test` (lib test) generated 1 warning (1 duplicate)
thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs:503:60:                                                                         
DefId::expect_local: `DefId(20:3 ~ ice_lib_test[60d0]::Test)` isn't local
stack backtrace: <see below>
Backtrace

   0:     0x7942adf8c892 - std::backtrace_rs::backtrace::libunwind::trace::he4ee80166a02c846                                                                                             
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5                                       
   1:     0x7942adf8c892 - std::backtrace_rs::backtrace::trace_unsynchronized::h476faccf57e88641
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7942adf8c892 - std::sys_common::backtrace::_print_fmt::h430c922a77e7a59c                                                                                                     
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7942adf8c892 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988                                                          
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7942adfdda6c - core::fmt::rt::Argument::fmt::hf3df69369399bfa9                                                                                                               
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9                                                                       
   5:     0x7942adfdda6c - core::fmt::write::hd9a8d7d029f9ea1a
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1153:17                                                                    
   6:     0x7942adf8178f - std::io::Write::write_fmt::h0e1226b2b8d973fe                                                                                                                  
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15
   7:     0x7942adf8c664 - std::sys_common::backtrace::_print::hd2df4a083f6e69b8                                                                                                         
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7942adf8c664 - std::sys_common::backtrace::print::he907f6ad7eee41cb
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7942adf8f35b - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b                                                                                                  
  10:     0x7942adf8f0b3 - std::panicking::default_hook::h25ba2457dea68e65                                                                                                               
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:292:9                                                                     
  11:     0x7942b0e2845d - std[e4dfbc2c3f4b09f1]::panicking::update_hook::<alloc[1adba907b9db1888]::boxed::Box<rustc_driver_impl[24a943716c49befe]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7942adf8fac0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h022ca2c0d8c21c9e                                                                            
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9                                                                      
  13:     0x7942adf8fac0 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13                                                                    
  14:     0x7942adf8f802 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647                                                                                           
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13                                                                    
  15:     0x7942adf8cd66 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904                                                                                     
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18                                                         
  16:     0x7942adf8f534 - rust_begin_unwind
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5                                                                     
  17:     0x7942adfd9f85 - core::panicking::panic_fmt::h940d4fd01a4b4fd1                                                                                                                 
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
  18:     0x7942b18a29ae - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::parse                                         
  19:     0x7942b090c044 - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::parse_attribute                               
  20:     0x7942b2127a94 - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::of_item                                       
  21:     0x7942b18c756d - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::TypeErrCtxtExt>::on_unimplemented_note
  22:     0x7942b18e9f4c - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  23:     0x7942b18fe090 - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  24:     0x7942b18e70a1 - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  25:     0x7942aefd0503 - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_call                                                                                             
  26:     0x7942b2a71d24 - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args                                                                   
  27:     0x7942b2a6d68e - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_block_with_expected                                                                              
  28:     0x7942b2a7220c - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7942b27c980a - rustc_hir_typeck[bd9e9ef04feb2a99]::check::check_fn                                                                                                           
  30:     0x7942b27bf6b7 - rustc_hir_typeck[bd9e9ef04feb2a99]::typeck                                                                                                                    
  31:     0x7942b27be90b - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7942b213deed - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::VecCache<rustc_span[a4517f2b2e65298c]::def_id::LocalDefId, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, false>
  33:     0x7942b213d80c - rustc_query_impl[e4152ad88c3d6c78]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace                                                        
  34:     0x7942b213b995 - rustc_hir_analysis[7e49c3c0c7bed18]::check_crate                                                                                                              
  35:     0x7942b2911ef2 - rustc_interface[ba2b6dc4c96cb491]::passes::analysis                                                                                                           
  36:     0x7942b29118e5 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7942b2d7f3a2 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::SingleCache<rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, false>
  38:     0x7942b2d7f149 - rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace                                                      
  39:     0x7942b2bfc814 - rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler::<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7942b2f3eb6e - std[e4dfbc2c3f4b09f1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>
  41:     0x7942b2f3e9ca - <<std[e4dfbc2c3f4b09f1]::thread::Builder>::spawn_unchecked_<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#1} as core[836963c7c1decc11]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7942adf99145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h19b9e642d37e7272                                                                   
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  43:     0x7942adf99145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h97265befc434d3ae                                                                   
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  44:     0x7942adf99145 - std::sys::pal::unix::thread::Thread::new::thread_start::h420dad5cf01a9f35
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17
  45:     0x7942adc94ac3 - start_thread                                                                                                                                                  
                               at ./nptl/pthread_create.c:442:8
  46:     0x7942add26850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  47:                0x0 - <unknown>

@13ros27 13ros27 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 3, 2024
@13ros27 13ros27 changed the title ICE when triggering a malformed diagnostic::on_unimplemented across crate boundaries (DefId(20:3 ~ ice_lib_test[60d0]::Test) isn't local`) ICE when triggering a malformed diagnostic::on_unimplemented across crate boundaries (DefId(20:3 ~ ice_lib_test[60d0]::Test) isn't local) May 3, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 3, 2024
@fmease
Copy link
Member

fmease commented May 3, 2024

cc @weiznich

@fmease fmease added the F-on_unimplemented Error messages that can be tackled with `#[rustc_on_unimplemented]` label May 3, 2024
@workingjubilee workingjubilee added the A-diagnostics Area: Messages for errors, warnings, and lints label May 3, 2024
estebank added a commit to estebank/rust that referenced this issue May 7, 2024
estebank added a commit to estebank/rust that referenced this issue May 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue May 8, 2024
…rors

Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix rust-lang#124651.
@bors bors closed this as completed in 4847f22 May 8, 2024
Billy-Sheppard added a commit to Billy-Sheppard/rust that referenced this issue May 13, 2024
reorganised attrs

removed OsStr impls

added backticks

Add note about possible allocation-sharing to Arc/Rc<str/[T]/CStr>::default.

Use shared statics for the ArcInner for Arc<str, CStr>::default, and for Arc<[T]>::default where alignof(T) <= 16.

fixed unsafe block

Revert "fixed unsafe block"

This reverts commit 6eb6aee.

Return coherent description for boolean instead of panicking

Improve check-cfg CLI errors with more structured diagnostics

Move various stdlib tests to library/std/tests

Run tidy on tests

Rename test for issue 21058

Implement `edition` method on `Rustdoc` type as well

Migrate `run-make/doctests-runtool` to rmake

Rename `run-make-support` library `output` method to `command_output`

Add new `output` method to `Rustc` and `Rustdoc` types

Migrate `run-make/rustdoc-error-lines` to `rmake.rs`

add f16 associated constants

NaN and infinity are not included as they require arithmetic.

add f128 associated constants

NaN and infinity are not included as they require arithmetic.

add constants in std::f16::consts

add constants in std::f128::consts

update error messages in ui tests

Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times

Also mention that there might be leftover directories in the error case.

Prefer lower vtable candidates in select in new solver

Don't consider candidates with no failing where clauses

Use super_fold in RegionsToStatic visitor

Make check-cfg docs more user-friendly

Record impl args in the InsepctCandiate rather than rematching during select

Use correct ImplSource for alias bounds

BorrowckInferCtxt: infcx by value

borrowck: more eagerly prepopulate opaques

switch new solver to directly inject opaque types

Update books

Adjust dbg.value/dbg.declare checks for LLVM update

llvm/llvm-project#89799 changes llvm.dbg.value/declare intrinsics to be in a different, out-of-instruction-line representation. For example
  call void @llvm.dbg.declare(...)
becomes
  #dbg_declare(...)

Update tests accordingly to work with both the old and new way.

Adjust 64-bit ARM data layouts for LLVM update

LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid
C++ accidentally underaligning functions when trying to comply with
member function ABIs.

This should only affect Rust in cases where we had a similar bug (I
don't believe we have one), but our data layout must match to generate
code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32`
gets voided from the data layout.

See llvm/llvm-project#90415

Update version of cc crate to v1.0.97

Reason:

In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: rust-lang/cc-rs@57853c4

This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix.

We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream.

Furthermore, beyond the specific reason, the cc crate in bootstrap is currently pinned at an old version due to problems in the past when trying to update it. It is worthwhile to figure out and resolve these problems so we can keep the dependency up-to-date.

Other fixes:

As of cc v1.0.78, object files are prefixed with a 16-character hash.
Update src/bootstrap/src/core/build_steps/llvm.rs to account for this to
avoid failures when building libunwind and libcrt. Note that while the hash
prefix was introduced in v1.0.78, in order to determine the names of the
object files without scanning the directory, we rely on the compile_intermediates
method, which was introduced in cc v1.0.86

As of cc v1.0.86, compilation on MacOS uses the -mmacosx-version-min flag.
A long-standing bug in the CMake rules for compiler-rt causes compilation
to fail when this flag is specified. So we add a workaround to suppress this
flag.

Updating to cc v1.0.91 and newer requires fixes to bootstrap unit tests.
The unit tests use targets named "A", "B", etc., which fail a validation
check introduced in 1.0.91 of the cc crate.

Implement lldb formattter for "clang encoded" enums (LLDB 18.1+)
Summary:
I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.
This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.
I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.

Test Plan:
ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode

Other Thoughs
A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.

f16::is_sign_{positive,negative} were feature-gated on f128

Correct the const stabilization of `last_chunk` for slices

`<[T]>::last_chunk` should have become const stable as part of
<rust-lang#117561>. Update the const
stability gate to reflect this.

Add tests

Lower never patterns to Unreachable in mir

rustdoc: dedup search form HTML

This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because

- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size

[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

This shrinks the standard library by about 60MiB, by my test.

rustdoc: allow custom element rustdoc-search

generalize hr alias: avoid unconstrainable infer vars

narrow down visibilities in `rustc_parse::lexer`

replace another Option<Span> by DUMMY_SP

Don't ICE when we cannot eval a const to a valtree in the new solver

Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`

coverage: Add branch coverage support for let-else

coverage: Add branch coverage support for if-let and let-chains

Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix rust-lang#124651.

Add test for rust-lang#124651

Update cargo

compiler: Privatize `Parser::current_closure`

This was added as pub in 2021 and remains only privately used in 2024!

compiler: derive Debug in parser

It's annoying to debug the parser if you have to stop every five seconds
to add a Debug impl.

compiler: add `Parser::debug_lookahead`

I tried debugging a parser-related issue but found it annoying to not be
able to easily peek into the Parser's token stream.

Add a convenience fn that offers an opinionated view into the parser,
but one that is useful for answering basic questions about parser state.

Fuchsia test runner: fixup script

This commit fixes several issues in the fuchsia-test-runner.py script:

1. Migrate from `pm` to `ffx` for package management, as `pm` is now
deprecated. Furthermore, the `pm` calls used in this script no longer
work at Fuchsia's HEAD. This is the largest change in this commit, and
impacts all steps around repository management (creation and
registration of the repo, as well as package publishing).

2. Allow for `libtest` to be either statically or dynamically linked.
The script assumed it was dynamically linked, but the current Rust
behavior at HEAD is to statically link it.

3. Minor cleanup to use `ffx --machine json` rather than string parsing.

4. Minor cleanup to the docs around the script.

std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly.

add note about `AlreadyExists` to `create_new`

Apply suggestions from code review

Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>

iOS/tvOS/watchOS/visionOS: Default to kernel-defined backlog in listen

This behavior is defined in general for the XNU kernel, not just macOS:
https://github.com/apple-oss-distributions/xnu/blob/rel/xnu-10002/bsd/kern/uipc_socket.c

iOS/tvOS/watchOS/visionOS: Set the main thread name

Tested in the iOS simulator that the thread name is not set by default,
and that setting it improves the debugging experience in lldb / Xcode.

iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions

Tested on an old MacBook and the iOS simulator.

iOS/tvOS/watchOS/visionOS: Fix reading large files

Tested in the iOS simulator with something like:
```
let mut buf = vec![0; c_int::MAX as usize - 1 + 2];
let read_bytes = f.read(&mut buf).unwrap();
```

iOS/tvOS/watchOS/visionOS: Improve File Debug impl

This uses `libc::fcntl`, which, while not explicitly marked as available
in the headers, is already used by `File::sync_all` and `File::sync_data`
on these platforms, so should be fine to use here as well.

next_power_of_two: add a doctest to show what happens on 0

rustc: Change LLVM target for the wasm32-wasip2 Rust target

This commit changes the LLVM target of for the Rust `wasm32-wasip2`
target to `wasm32-wasip2` as well. LLVM does a bit of detection on the
target string to know when to call `wasm-component-ld` vs `wasm-ld` so
otherwise clang is invoking the wrong linker.

rustc: Don't pass `-fuse-ld=lld` on wasm targets

This argument isn't necessary for WebAssembly targets since `wasm-ld` is
the only linker for the targets. Passing it otherwise interferes with
Clang's linker selection on `wasm32-wasip2` so avoid it altogether.

rustc: Change wasm32-wasip2 to PIC-by-default

This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.

Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes an ICE that occurred when the struct in question has an error

Fix insufficient logic when searching for the underlying allocation

in the `invalid_reference_casting` lint, when trying to lint on
bigger memory layout casts.

rustdoc: use stability, instead of features, to decide what to show

To decide if internal items should be inlined in a doc page,
check if the crate is itself internal, rather than if it has
the rustc_private feature flag. The standard library uses
internal items, but is not itself internal and should not show
internal items on its docs pages.

Avoid a cast in `ptr::slice_from_raw_parts(_mut)`

Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not.

If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.

add enum variant field names to make the code clearer

remove redundant flat vs nested distinction to simplify enum

turn all_nested_unused into used_childs

store the span of the nested part of the use tree in the ast

 remove braces when fixing a nested use tree into a single use

Use generic `NonZero` in examples.

Simplify `clippy` lint.

Simplify suggestion.

Use generic `NonZero`.

crashes: add lastest batch of crash tests

Make sure we don't deny macro vars w keyword names

Simplify `use crate::rustc_foo::bar` occurrences.

They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)

Update cc crate to v1.0.97

Ignore empty RUSTC_WRAPPER in bootstrap

This change ignores the RUSTC_WRAPPER_REAL environment variable if it's
set to the empty string. This matches cargo behaviour and allows users
to easily shadow a globally set RUSTC_WRAPPER (which they might have set
for non-rustc projects).

Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes an ICE that occurred when the struct in question has an error

Implement `as_chunks` with `split_at_unchecked`

Remove `macro_use` from `stable_hasher`.

Normal `use` items are nicer.

Reorder top-level crate items.

- `use` before `mod`
- `pub` before `non-pub`
- Alphabetical order within sections

Remove `extern crate tracing`.

`use` is a nicer way of doing things.

Document `Pu128`.

And move the `repr` line after the `derive` line, where it's harder to
overlook. (I overlooked it initially, and didn't understand how this
type worked.)

Remove `TinyList`.

It is optimized for lists with a single element, avoiding the need for
an allocation in that case. But `SmallVec<[T; 1]>` also avoids the
allocation, and is better in general: more standard, log2 number of
allocations if the list exceeds one item, and a much more capable API.

This commit removes `TinyList` and converts the two uses to
`SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant
file so they are in just two sections (`pub` and non-`pub`), ordered
alphabetically, instead of many sections. (This is a relevant part of
the change because I had to decide where to add a `use` item for
`SmallVec`.)

Remove `vec_linked_list`.

It provides a way to effectively embed a linked list within an
`IndexVec` and also iterate over that list. It's written in a very
generic way, involving two traits `Links` and `LinkElem`. But the
`Links` trait is only impl'd for `IndexVec` and `&IndexVec`, and the
whole thing is only used in one module within `rustc_borrowck`. So I
think it's over-engineered and hard to read. Plus it has no comments.

This commit removes it, and adds a (non-generic) local iterator for the
use within `rustc_borrowck`. Much simpler.

Remove `enum_from_u32`.

It's a macro that just creates an enum with a `from_u32` method. It has
two arms. One is unused and the other has a single use.

This commit inlines that single use and removes the whole macro. This
increases readability because we don't have two different macros
interacting (`enum_from_u32` and `language_item_table`).

Update Tests

Fix Error Messages for `break` Inside Coroutines

Previously, `break` inside `gen` blocks and functions
were incorrectly identified to be enclosed by a closure.

This PR fixes it by displaying an appropriate error message
for async blocks, async closures, async functions, gen blocks,
gen closures, gen functions, async gen blocks, async gen closures
and async gen functions.

Note: gen closure and async gen closure are not supported by the
compiler yet but I have added an error message here assuming that
they might be implemented in the future.

Also, fixes grammar in a few places by replacing
`inside of a $coroutine` with `inside a $coroutine`.

Migrate `run-make/rustdoc-map-file` to rmake

Add more ICEs due to malformed diagnostic::on_unimplemented

Fix ICEs in diagnostic::on_unimplemented

Handle field projections like slice indexing in invalid_reference_casting

Fix typos

Do not add leading asterisk in the `PartialEq`

Adding leading asterisk can cause compilation failure for
the _types_ that don't implement the `Copy`.

Use sum type for `WorkflowRunType`

Parse try build CI job name from commit message

Make the regex more robust

Address review comments

CI: fix auto builds and make sure that we always have at least a single CI job

Include the line number in tidy's `iter_header`

Tidy check for test revisions that are mentioned but not declared

If a `[revision]` name appears in a test header directive or error annotation,
but isn't declared in the `//@ revisions:` header, that is almost always a
mistake.

In cases where a revision needs to be temporarily disabled, adding it to an
`//@ unused-revision-names:` header will suppress these checks for that name.

Adding the wildcard name `*` to the unused list will suppress these checks for
the entire file.

Fix test problems discovered by the revision check

Most of these changes either add revision names that were apparently missing,
or explicitly mark a revision name as currently unused.

fix rust-lang#124714 str.to_lowercase sigma handling

Make a minimal amount of region APIs public

Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.

The starting point for this was identical comments on two different
fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`:
```
    // FIXME: investigate making this a `Option<ErrorGuaranteed>`
    recovered: bool
```
I tried that, and then found that I needed to add an `ErrorGuaranteed`
to `Recovered::Yes`. Then I ended up using `Recovered` instead of
`Option<ErrorGuaranteed>` for these two places and elsewhere, which
required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`.

This makes things more consistent, because `Recovered` is used in more
places, and there are fewer uses of `bool` and
`Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible
to set `recovered` to `Recovered::Yes` without having emitted an error.

interpret/miri: better errors on failing offset_from

chore: remove repetitive words

Make `#![feature]` suggestion MaybeIncorrect

Update Makefiles with explanatory comments

correct comments

add FIXME

Upgrade the version of Clang used in the build, move MSVC builds to Server 2022

Rename Generics::params to Generics::own_params

Add benchmarks for `impl Debug for str`

In order to inform future perf improvements and prevent regressions,
lets add some benchmarks that stress `impl Debug for str`.

Remove unused `step_trait` feature.

Also sort the features.

Remove unused `LinkSelfContainedDefault::is_linker_enabled` method.

Correct a comment.

I tried simplifying `RegionCtxt`, which led me to finding that the
fields are printed in `sccs_info`.

Fix up `DescriptionCtx::new`.

The comment mentions that `ReBound` and `ReVar` aren't expected here.
Experimentation with the full test suite indicates this is true, and
that `ReErased` also doesn't occur. So the commit introduces `bug!` for
those cases. (If any of them show up later on, at least we'll have a
test case.)

The commit also remove the first sentence in the comment.
`RePlaceholder` is now handled in the match arm above this comment and
nothing is printed for it, so that sentence is just wrong. Furthermore,
issue rust-lang#13998 was closed some time ago.

Fix out-of-date comment.

The type name has changed.

Remove `TyCtxt::try_normalize_erasing_late_bound_regions`.

It's unused.

Remove out-of-date comment.

The use of `Binder` was removed in the recent rust-lang#123900, but the comment
wasn't removed at the same time.

De-tuple two `vtable_trait_first_method_offset` args.

Thus eliminating a `FIXME` comment.

opt-dist: use xz2 instead of xz crate

xz crate consist of simple reexport of xz2 crate. Why? Idk.

analyse visitor: build proof tree in probe

update crashes

always use `GenericArgsRef`

Inline and remove unused methods.

`InferCtxt::next_{ty,const,int,float}_var_id` each have a single call
site, in `InferCtt::next_{ty,const,int,float}_var` respectively.

The only remaining method that creates a var_id is
`InferCtxt::next_ty_var_id_in_universe`, which has one use outside the
crate.

Use fewer origins when creating type variables.

`InferCtxt::next_{ty,const}_var*` all take an origin, but the
`param_def_id` is almost always `None`. This commit changes them to just
take a `Span` and build the origin within the method, and adds new
methods for the rare cases where `param_def_id` might not be `None`.
This avoids a lot of tedious origin building.

Specifically:
- next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of
  `TypeVariableOrigin`
- next_ty_var_with_origin: added

- next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin
- next_const_var_with_origin: added

- next_region_var, next_region_var_in_universe: these are unchanged,
  still take RegionVariableOrigin

The API inconsistency (ty/const vs region) seems worth it for the
large conciseness improvements.

print walltime benchmarks with subnanosecond precision

example results when benchmarking 1-4 serialized ADD instructions

```
running 4 tests
test add  ... bench:           0.24 ns/iter (+/- 0.00)
test add2 ... bench:           0.48 ns/iter (+/- 0.01)
test add3 ... bench:           0.72 ns/iter (+/- 0.01)
test add4 ... bench:           0.96 ns/iter (+/- 0.01)
```

emit fractional benchmark nanoseconds in libtest's JSON output format

bootstrap should also render fractional nanoseconds for benchmarks

from_str_radix: outline only the panic function

codegen: memmove/memset cannot be non-temporal

coverage: Separately compute the set of BCBs with counter mappings

coverage: Make the special case for async functions exit early

coverage: Don't recompute the number of test vector bitmap bytes

The code in `extract_mcdc_mappings` that allocates these bytes already knows
how many are needed in total, so there's no need to immediately recompute that
value in the calling function.

coverage: Destructure the mappings struct to make sure we don't miss any

coverage: Rename `CoverageSpans` to `ExtractedMappings`

coverage: Tidy imports in `rustc_mir_transform::coverage`

Fix parse error message for meta items

Refactor float `Primitive`s to a separate `Float` type

Migrate `run-make/rustdoc-output-path` to rmake

Make builtin_deref just return a Ty

rename some variants in FulfillmentErrorCode

Remove glob imports for ObligationCauseCode

Rename some ObligationCauseCode variants

More rename fallout

Name tweaks

Add a codegen test for transparent aggregates

Aggregating arrays can always take the place path

Make SSA aggregates without needing an alloca

Lift `Lift`

Lift `TraitRef` into `rustc_type_ir`

Also debug

Apply nits, make some bounds into supertraits on inherent traits

Add `-lmingwex` second time in `mingw_libs`

Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around.
As a result functions like `lgamma`
now depend on libraries in this order:
`libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`.

Fixes rust-lang#124221

ignore generics args in attribute paths

bootstrap: add comments for the automatic dry run

fix typo

Co-authored-by: jyn <github@jyn.dev>

reachable computation: extend explanation of what this does, and why

Make sure we consume a generic arg when checking mistyped turbofish

Update cargo

std::rand: adding solaris/illumos for getrandom support.

To help solarish support for miri https://rust-lang/miri/issues/3567

Update ena to 0.14.3

Fix typo in ManuallyDrop's documentation

Add @saethlin to some triagebot groups

Refactor Apple `target_abi`

This was bundled together with `Arch`, which complicated a few code
paths and meant we had to do more string matching than necessary.

Match ergonomics 2024: let `&` patterns eat `&mut`

Various fixes:

- Only show error when move-check would not be triggered
- Add structured suggestion

Fix spans when macros are involved

Comments and fixes

Rename `explicit_ba`

No more `Option<Option<>>`

Remove redundant comment

Move all ref pat logic into `check_pat_ref`

Add comment on `cap_to_weakly_not`

Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>

Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`

Remove feature from documentation examples
Add rustc_const_stable attribute to stabilized functions
Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions

Document proper usage of `fmt::Error` and `fmt()`'s `Result`.

Documentation of these properties previously existed in a lone paragraph
in the `fmt` module's documentation:
<https://doc.rust-lang.org/1.78.0/std/fmt/index.html#formatting-traits>
However, users looking to implement a formatting trait won't necessarily
look there. Therefore, let's add the critical information (that
formatting per se is infallible) to all the involved items.

check if `x test tests` missing any test directory

Signed-off-by: onur-ozkan <work@onurozkan.dev>

remap missing path `tests/crashes` to `tests`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

add "tidy-alphabetical" check on "tests" remap list

Signed-off-by: onur-ozkan <work@onurozkan.dev>

Handle Deref expressions in invalid_reference_casting

unix/fs: a bit of cleanup around host-specific code

solaris support start.

reduce tokio features

remove rand test

the actual target-specific things we want to test are all in getrandom,
and rand already tests miri itself

getrandom: test with and without isolation

also add some comments for why we keep certain old obscure APIs supported

avoid code duplication between realloc and malloc

Implement wcslen

organize libc tests into a proper folder, and run some of them on Windows

README: update introduction

remove problems that I do not think we have seen in a while

io::Error handling: keep around the full io::Error for longer so we can give better errors

Implement non-null pointer for malloc(0)

Allow test targets to be set via CLI args

Update CI script for the miri-script test changes

Update documentation for miri-script test changes

minor tweaks

make MIRI_TEST_TARGET entirely an internal thing

make RUSTC_BLESS entirely an internal thing

do not run symlink tests on Windows hosts

rename 'extern-so' to 'native-lib'

Preparing for merge from rustc

alloc: update comments around malloc() alignment

separate windows heap functions from C heap shims

Add windows_i686_gnullvm to the list

Pin libc back to 0.2.153

Update Cargo.lock

fix few typo in filecheck annotations

Consolidate obligation cause codes for where clauses

Clean up users of rust_dbg_call

Enable profiler for armv7-unknown-linux-gnueabihf.

Always hide private fields in aliased type

Migrate `run-make/rustdoc-shared-flags` to rmake

Relax allocator requirements on some Rc APIs.

* Remove A: Clone bound from Rc::assume_init, Rc::downcast, and Rc::downcast_unchecked.
* Make From<Rc<[T; N]>> for Rc<[T]> allocator-aware.

Internal changes:

* Made Arc::internal_into_inner_with_allocator method into Arc::into_inner_with_allocator associated fn.
* Add private Rc::into_inner_with_allocator (to match Arc), so other fns don't have to juggle ManuallyDrop.

Relax A: Clone requirement on Rc/Arc::unwrap_or_clone.

Add test for rust-lang#122775

Refactoring after the `PlaceValue` addition

I added `PlaceValue` in 123775, but kept that one line-by-line simple because it touched so many places.

This goes through to add more helpers & docs, and change some `PlaceRef` to `PlaceValue` where the type didn't need to be included.

No behaviour changes.

Make it possible to derive Lift/TypeVisitable/TypeFoldable in rustc_type_ir

Uplift `TraitPredicate`

Uplift `ExistentialTraitRef`, `ExistentialProjection`, `ProjectionPredicate`

Uplift `NormalizesTo`, `CoercePredicate`, and `SubtypePredicate`

Apply nits, uplift ExistentialPredicate too

And `ImplPolarity` too

Expand on expr_requires_semi_to_be_stmt documentation

Mark expr_requires_semi_to_be_stmt call sites

For each of these, we need to decide whether they need to be using
`expr_requires_semi_to_be_stmt`, or `expr_requires_comma_to_be_match_arm`,
which are supposed to be 2 different behaviors. Previously they were
conflated into one, causing either too much or too little
parenthesization.

Macro call with braces does not require semicolon to be statement

This commit by itself is supposed to have no effect on behavior. All of
the call sites are updated to preserve their previous behavior.

The behavior changes are in the commits that follow.

Add ExprKind::MacCall statement boundary tests

Fix pretty printer statement boundaries after braced macro call

Delete MacCall case from pretty-printing semicolon after StmtKind::Expr

I didn't figure out how to reach this condition with `expr` containing
`ExprKind::MacCall`. All the approaches I tried ended up with the macro
call ending up in the `StmtKind::MacCall` case below instead.

In any case, from visual inspection this is a bugfix. If we do end up
with a `StmtKind::Expr` containing `ExprKind::MacCall` with brace
delimiter, it would not need ";" printed after it.

Add test of unused_parens lint involving macro calls

Document the situation with unused_parens lint and braced macro calls

Add parser tests for statement boundary insertion

Mark Parser::expr_is_complete call sites

Document MacCall special case in Parser::expr_is_complete

Document MacCall special case in Parser::parse_arm

Add macro calls to else-no-if parser test

Remove MacCall special case from recovery after missing 'if' after 'else'

The change to the test is a little goofy because the compiler was
guessing "correctly" before that `falsy! {}` is the condition as opposed
to the else body. But I believe this change is fundamentally correct.
Braced macro invocations in statement position are most often item-like
(`thread_local! {...}`) as opposed to parenthesized macro invocations
which are condition-like (`cfg!(...)`).

Remove MacCall special cases from Parser::parse_full_stmt

It is impossible for expr here to be a braced macro call. Expr comes
from `parse_stmt_without_recovery`, in which macro calls are parsed by
`parse_stmt_mac`. See this part:

    let kind = if (style == MacStmtStyle::Braces
        && self.token != token::Dot
        && self.token != token::Question)
        || self.token == token::Semi
        || self.token == token::Eof
    {
        StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
    } else {
        // Since none of the above applied, this is an expression statement macro.
        let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac));
        let e = self.maybe_recover_from_bad_qpath(e)?;
        let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?;
        let e = self.parse_expr_assoc_with(
            0,
            LhsExpr::AlreadyParsed { expr: e, starts_statement: false },
        )?;
        StmtKind::Expr(e)
    };

A braced macro call at the head of a statement is always either extended
into ExprKind::Field / MethodCall / Await / Try / Binary, or else
returned as StmtKind::MacCall. We can never get a StmtKind::Expr
containing ExprKind::MacCall containing brace delimiter.

Add classify::expr_is_complete

Fix redundant parens around braced macro call in match arms

use key-value format in stage0 file

Currently, we are working on the python removal task on bootstrap. Which means
we have to extract some data from the stage0 file using shell scripts. However,
parsing values from the stage0.json file is painful because shell scripts don't
have a built-in way to parse json files.

This change simplifies the stage0 file format to key-value pairs, which makes
it easily readable from any environment.

Signed-off-by: onur-ozkan <work@onurozkan.dev>

awk stage0 file on CI

Signed-off-by: onur-ozkan <work@onurozkan.dev>

use stage0 file in `bootstrap.py`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

use shared stage0 parser from `build_helper`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

remove outdated stage0.json parts

Signed-off-by: onur-ozkan <work@onurozkan.dev>

move comments position in `src/stage0`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

io::Write::write_fmt: panic if the formatter fails when the stream does not fail

std::alloc: using posix_memalign instead of memalign on solarish.

simpler code path since small alignments are already taking care of.
close rust-langGH-124787

Relax slice safety requirements

Per rust-lang#116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when rust-lang#117945 is implemented, we can revert to the old language.

References must also be non-null

Add `crate_type` method to `Rustdoc`

Add `crate_name` method to `Rustdoc` and `Rustc`

Add `python_command` and `source_path` functions

Add `extern_` method to `Rustdoc`

Migrate `rustdoc-scrape-examples-ordering` to `rmake`

Fix some minor issues from the ui-test auto-porting

solve: replace all `debug` with `trace`

structurally important functions to `debug`

fix hidden title in command-line-arguments docs

Assert that MemCategorizationVisitor actually errors when it bails ungracefully

Inline MemCategorization into ExprUseVisitor

Remove unncessary mut ref

Introduce TypeInformationCtxt to abstract over LateCtxt/FnCtxt

Make LateCtxt be a type info delegate for EUV for clippy

Try structurally resolve

Apply nits

Propagate errors rather than using return_if_err

Match ergonomics 2024: migration lint

Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion.

Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>

Add AST pretty-printer tests for let-else

Pretty-print let-else with added parenthesization when needed

rename
Billy-Sheppard added a commit to Billy-Sheppard/rust that referenced this issue May 13, 2024
reorganised attrs

removed OsStr impls

added backticks

Add note about possible allocation-sharing to Arc/Rc<str/[T]/CStr>::default.

Use shared statics for the ArcInner for Arc<str, CStr>::default, and for Arc<[T]>::default where alignof(T) <= 16.

fixed unsafe block

Revert "fixed unsafe block"

This reverts commit 6eb6aee.

Return coherent description for boolean instead of panicking

Improve check-cfg CLI errors with more structured diagnostics

Move various stdlib tests to library/std/tests

Run tidy on tests

Rename test for issue 21058

Implement `edition` method on `Rustdoc` type as well

Migrate `run-make/doctests-runtool` to rmake

Rename `run-make-support` library `output` method to `command_output`

Add new `output` method to `Rustc` and `Rustdoc` types

Migrate `run-make/rustdoc-error-lines` to `rmake.rs`

add f16 associated constants

NaN and infinity are not included as they require arithmetic.

add f128 associated constants

NaN and infinity are not included as they require arithmetic.

add constants in std::f16::consts

add constants in std::f128::consts

update error messages in ui tests

Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times

Also mention that there might be leftover directories in the error case.

Prefer lower vtable candidates in select in new solver

Don't consider candidates with no failing where clauses

Use super_fold in RegionsToStatic visitor

Make check-cfg docs more user-friendly

Record impl args in the InsepctCandiate rather than rematching during select

Use correct ImplSource for alias bounds

BorrowckInferCtxt: infcx by value

borrowck: more eagerly prepopulate opaques

switch new solver to directly inject opaque types

Update books

Adjust dbg.value/dbg.declare checks for LLVM update

llvm/llvm-project#89799 changes llvm.dbg.value/declare intrinsics to be in a different, out-of-instruction-line representation. For example
  call void @llvm.dbg.declare(...)
becomes
  #dbg_declare(...)

Update tests accordingly to work with both the old and new way.

Adjust 64-bit ARM data layouts for LLVM update

LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid
C++ accidentally underaligning functions when trying to comply with
member function ABIs.

This should only affect Rust in cases where we had a similar bug (I
don't believe we have one), but our data layout must match to generate
code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32`
gets voided from the data layout.

See llvm/llvm-project#90415

Update version of cc crate to v1.0.97

Reason:

In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: rust-lang/cc-rs@57853c4

This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix.

We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream.

Furthermore, beyond the specific reason, the cc crate in bootstrap is currently pinned at an old version due to problems in the past when trying to update it. It is worthwhile to figure out and resolve these problems so we can keep the dependency up-to-date.

Other fixes:

As of cc v1.0.78, object files are prefixed with a 16-character hash.
Update src/bootstrap/src/core/build_steps/llvm.rs to account for this to
avoid failures when building libunwind and libcrt. Note that while the hash
prefix was introduced in v1.0.78, in order to determine the names of the
object files without scanning the directory, we rely on the compile_intermediates
method, which was introduced in cc v1.0.86

As of cc v1.0.86, compilation on MacOS uses the -mmacosx-version-min flag.
A long-standing bug in the CMake rules for compiler-rt causes compilation
to fail when this flag is specified. So we add a workaround to suppress this
flag.

Updating to cc v1.0.91 and newer requires fixes to bootstrap unit tests.
The unit tests use targets named "A", "B", etc., which fail a validation
check introduced in 1.0.91 of the cc crate.

Implement lldb formattter for "clang encoded" enums (LLDB 18.1+)
Summary:
I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.
This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.
I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.

Test Plan:
ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode

Other Thoughs
A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.

f16::is_sign_{positive,negative} were feature-gated on f128

Correct the const stabilization of `last_chunk` for slices

`<[T]>::last_chunk` should have become const stable as part of
<rust-lang#117561>. Update the const
stability gate to reflect this.

Add tests

Lower never patterns to Unreachable in mir

rustdoc: dedup search form HTML

This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because

- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size

[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

This shrinks the standard library by about 60MiB, by my test.

rustdoc: allow custom element rustdoc-search

generalize hr alias: avoid unconstrainable infer vars

narrow down visibilities in `rustc_parse::lexer`

replace another Option<Span> by DUMMY_SP

Don't ICE when we cannot eval a const to a valtree in the new solver

Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`

coverage: Add branch coverage support for let-else

coverage: Add branch coverage support for if-let and let-chains

Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix rust-lang#124651.

Add test for rust-lang#124651

Update cargo

compiler: Privatize `Parser::current_closure`

This was added as pub in 2021 and remains only privately used in 2024!

compiler: derive Debug in parser

It's annoying to debug the parser if you have to stop every five seconds
to add a Debug impl.

compiler: add `Parser::debug_lookahead`

I tried debugging a parser-related issue but found it annoying to not be
able to easily peek into the Parser's token stream.

Add a convenience fn that offers an opinionated view into the parser,
but one that is useful for answering basic questions about parser state.

Fuchsia test runner: fixup script

This commit fixes several issues in the fuchsia-test-runner.py script:

1. Migrate from `pm` to `ffx` for package management, as `pm` is now
deprecated. Furthermore, the `pm` calls used in this script no longer
work at Fuchsia's HEAD. This is the largest change in this commit, and
impacts all steps around repository management (creation and
registration of the repo, as well as package publishing).

2. Allow for `libtest` to be either statically or dynamically linked.
The script assumed it was dynamically linked, but the current Rust
behavior at HEAD is to statically link it.

3. Minor cleanup to use `ffx --machine json` rather than string parsing.

4. Minor cleanup to the docs around the script.

std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly.

add note about `AlreadyExists` to `create_new`

Apply suggestions from code review

Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>

iOS/tvOS/watchOS/visionOS: Default to kernel-defined backlog in listen

This behavior is defined in general for the XNU kernel, not just macOS:
https://github.com/apple-oss-distributions/xnu/blob/rel/xnu-10002/bsd/kern/uipc_socket.c

iOS/tvOS/watchOS/visionOS: Set the main thread name

Tested in the iOS simulator that the thread name is not set by default,
and that setting it improves the debugging experience in lldb / Xcode.

iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions

Tested on an old MacBook and the iOS simulator.

iOS/tvOS/watchOS/visionOS: Fix reading large files

Tested in the iOS simulator with something like:
```
let mut buf = vec![0; c_int::MAX as usize - 1 + 2];
let read_bytes = f.read(&mut buf).unwrap();
```

iOS/tvOS/watchOS/visionOS: Improve File Debug impl

This uses `libc::fcntl`, which, while not explicitly marked as available
in the headers, is already used by `File::sync_all` and `File::sync_data`
on these platforms, so should be fine to use here as well.

next_power_of_two: add a doctest to show what happens on 0

rustc: Change LLVM target for the wasm32-wasip2 Rust target

This commit changes the LLVM target of for the Rust `wasm32-wasip2`
target to `wasm32-wasip2` as well. LLVM does a bit of detection on the
target string to know when to call `wasm-component-ld` vs `wasm-ld` so
otherwise clang is invoking the wrong linker.

rustc: Don't pass `-fuse-ld=lld` on wasm targets

This argument isn't necessary for WebAssembly targets since `wasm-ld` is
the only linker for the targets. Passing it otherwise interferes with
Clang's linker selection on `wasm32-wasip2` so avoid it altogether.

rustc: Change wasm32-wasip2 to PIC-by-default

This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.

Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes an ICE that occurred when the struct in question has an error

Fix insufficient logic when searching for the underlying allocation

in the `invalid_reference_casting` lint, when trying to lint on
bigger memory layout casts.

rustdoc: use stability, instead of features, to decide what to show

To decide if internal items should be inlined in a doc page,
check if the crate is itself internal, rather than if it has
the rustc_private feature flag. The standard library uses
internal items, but is not itself internal and should not show
internal items on its docs pages.

Avoid a cast in `ptr::slice_from_raw_parts(_mut)`

Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not.

If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.

add enum variant field names to make the code clearer

remove redundant flat vs nested distinction to simplify enum

turn all_nested_unused into used_childs

store the span of the nested part of the use tree in the ast

 remove braces when fixing a nested use tree into a single use

Use generic `NonZero` in examples.

Simplify `clippy` lint.

Simplify suggestion.

Use generic `NonZero`.

crashes: add lastest batch of crash tests

Make sure we don't deny macro vars w keyword names

Simplify `use crate::rustc_foo::bar` occurrences.

They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)

Update cc crate to v1.0.97

Ignore empty RUSTC_WRAPPER in bootstrap

This change ignores the RUSTC_WRAPPER_REAL environment variable if it's
set to the empty string. This matches cargo behaviour and allows users
to easily shadow a globally set RUSTC_WRAPPER (which they might have set
for non-rustc projects).

Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes an ICE that occurred when the struct in question has an error

Implement `as_chunks` with `split_at_unchecked`

Remove `macro_use` from `stable_hasher`.

Normal `use` items are nicer.

Reorder top-level crate items.

- `use` before `mod`
- `pub` before `non-pub`
- Alphabetical order within sections

Remove `extern crate tracing`.

`use` is a nicer way of doing things.

Document `Pu128`.

And move the `repr` line after the `derive` line, where it's harder to
overlook. (I overlooked it initially, and didn't understand how this
type worked.)

Remove `TinyList`.

It is optimized for lists with a single element, avoiding the need for
an allocation in that case. But `SmallVec<[T; 1]>` also avoids the
allocation, and is better in general: more standard, log2 number of
allocations if the list exceeds one item, and a much more capable API.

This commit removes `TinyList` and converts the two uses to
`SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant
file so they are in just two sections (`pub` and non-`pub`), ordered
alphabetically, instead of many sections. (This is a relevant part of
the change because I had to decide where to add a `use` item for
`SmallVec`.)

Remove `vec_linked_list`.

It provides a way to effectively embed a linked list within an
`IndexVec` and also iterate over that list. It's written in a very
generic way, involving two traits `Links` and `LinkElem`. But the
`Links` trait is only impl'd for `IndexVec` and `&IndexVec`, and the
whole thing is only used in one module within `rustc_borrowck`. So I
think it's over-engineered and hard to read. Plus it has no comments.

This commit removes it, and adds a (non-generic) local iterator for the
use within `rustc_borrowck`. Much simpler.

Remove `enum_from_u32`.

It's a macro that just creates an enum with a `from_u32` method. It has
two arms. One is unused and the other has a single use.

This commit inlines that single use and removes the whole macro. This
increases readability because we don't have two different macros
interacting (`enum_from_u32` and `language_item_table`).

Update Tests

Fix Error Messages for `break` Inside Coroutines

Previously, `break` inside `gen` blocks and functions
were incorrectly identified to be enclosed by a closure.

This PR fixes it by displaying an appropriate error message
for async blocks, async closures, async functions, gen blocks,
gen closures, gen functions, async gen blocks, async gen closures
and async gen functions.

Note: gen closure and async gen closure are not supported by the
compiler yet but I have added an error message here assuming that
they might be implemented in the future.

Also, fixes grammar in a few places by replacing
`inside of a $coroutine` with `inside a $coroutine`.

Migrate `run-make/rustdoc-map-file` to rmake

Add more ICEs due to malformed diagnostic::on_unimplemented

Fix ICEs in diagnostic::on_unimplemented

Handle field projections like slice indexing in invalid_reference_casting

Fix typos

Do not add leading asterisk in the `PartialEq`

Adding leading asterisk can cause compilation failure for
the _types_ that don't implement the `Copy`.

Use sum type for `WorkflowRunType`

Parse try build CI job name from commit message

Make the regex more robust

Address review comments

CI: fix auto builds and make sure that we always have at least a single CI job

Include the line number in tidy's `iter_header`

Tidy check for test revisions that are mentioned but not declared

If a `[revision]` name appears in a test header directive or error annotation,
but isn't declared in the `//@ revisions:` header, that is almost always a
mistake.

In cases where a revision needs to be temporarily disabled, adding it to an
`//@ unused-revision-names:` header will suppress these checks for that name.

Adding the wildcard name `*` to the unused list will suppress these checks for
the entire file.

Fix test problems discovered by the revision check

Most of these changes either add revision names that were apparently missing,
or explicitly mark a revision name as currently unused.

fix rust-lang#124714 str.to_lowercase sigma handling

Make a minimal amount of region APIs public

Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.

The starting point for this was identical comments on two different
fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`:
```
    // FIXME: investigate making this a `Option<ErrorGuaranteed>`
    recovered: bool
```
I tried that, and then found that I needed to add an `ErrorGuaranteed`
to `Recovered::Yes`. Then I ended up using `Recovered` instead of
`Option<ErrorGuaranteed>` for these two places and elsewhere, which
required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`.

This makes things more consistent, because `Recovered` is used in more
places, and there are fewer uses of `bool` and
`Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible
to set `recovered` to `Recovered::Yes` without having emitted an error.

interpret/miri: better errors on failing offset_from

chore: remove repetitive words

Make `#![feature]` suggestion MaybeIncorrect

Update Makefiles with explanatory comments

correct comments

add FIXME

Upgrade the version of Clang used in the build, move MSVC builds to Server 2022

Rename Generics::params to Generics::own_params

Add benchmarks for `impl Debug for str`

In order to inform future perf improvements and prevent regressions,
lets add some benchmarks that stress `impl Debug for str`.

Remove unused `step_trait` feature.

Also sort the features.

Remove unused `LinkSelfContainedDefault::is_linker_enabled` method.

Correct a comment.

I tried simplifying `RegionCtxt`, which led me to finding that the
fields are printed in `sccs_info`.

Fix up `DescriptionCtx::new`.

The comment mentions that `ReBound` and `ReVar` aren't expected here.
Experimentation with the full test suite indicates this is true, and
that `ReErased` also doesn't occur. So the commit introduces `bug!` for
those cases. (If any of them show up later on, at least we'll have a
test case.)

The commit also remove the first sentence in the comment.
`RePlaceholder` is now handled in the match arm above this comment and
nothing is printed for it, so that sentence is just wrong. Furthermore,
issue rust-lang#13998 was closed some time ago.

Fix out-of-date comment.

The type name has changed.

Remove `TyCtxt::try_normalize_erasing_late_bound_regions`.

It's unused.

Remove out-of-date comment.

The use of `Binder` was removed in the recent rust-lang#123900, but the comment
wasn't removed at the same time.

De-tuple two `vtable_trait_first_method_offset` args.

Thus eliminating a `FIXME` comment.

opt-dist: use xz2 instead of xz crate

xz crate consist of simple reexport of xz2 crate. Why? Idk.

analyse visitor: build proof tree in probe

update crashes

always use `GenericArgsRef`

Inline and remove unused methods.

`InferCtxt::next_{ty,const,int,float}_var_id` each have a single call
site, in `InferCtt::next_{ty,const,int,float}_var` respectively.

The only remaining method that creates a var_id is
`InferCtxt::next_ty_var_id_in_universe`, which has one use outside the
crate.

Use fewer origins when creating type variables.

`InferCtxt::next_{ty,const}_var*` all take an origin, but the
`param_def_id` is almost always `None`. This commit changes them to just
take a `Span` and build the origin within the method, and adds new
methods for the rare cases where `param_def_id` might not be `None`.
This avoids a lot of tedious origin building.

Specifically:
- next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of
  `TypeVariableOrigin`
- next_ty_var_with_origin: added

- next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin
- next_const_var_with_origin: added

- next_region_var, next_region_var_in_universe: these are unchanged,
  still take RegionVariableOrigin

The API inconsistency (ty/const vs region) seems worth it for the
large conciseness improvements.

print walltime benchmarks with subnanosecond precision

example results when benchmarking 1-4 serialized ADD instructions

```
running 4 tests
test add  ... bench:           0.24 ns/iter (+/- 0.00)
test add2 ... bench:           0.48 ns/iter (+/- 0.01)
test add3 ... bench:           0.72 ns/iter (+/- 0.01)
test add4 ... bench:           0.96 ns/iter (+/- 0.01)
```

emit fractional benchmark nanoseconds in libtest's JSON output format

bootstrap should also render fractional nanoseconds for benchmarks

from_str_radix: outline only the panic function

codegen: memmove/memset cannot be non-temporal

coverage: Separately compute the set of BCBs with counter mappings

coverage: Make the special case for async functions exit early

coverage: Don't recompute the number of test vector bitmap bytes

The code in `extract_mcdc_mappings` that allocates these bytes already knows
how many are needed in total, so there's no need to immediately recompute that
value in the calling function.

coverage: Destructure the mappings struct to make sure we don't miss any

coverage: Rename `CoverageSpans` to `ExtractedMappings`

coverage: Tidy imports in `rustc_mir_transform::coverage`

Fix parse error message for meta items

Refactor float `Primitive`s to a separate `Float` type

Migrate `run-make/rustdoc-output-path` to rmake

Make builtin_deref just return a Ty

rename some variants in FulfillmentErrorCode

Remove glob imports for ObligationCauseCode

Rename some ObligationCauseCode variants

More rename fallout

Name tweaks

Add a codegen test for transparent aggregates

Aggregating arrays can always take the place path

Make SSA aggregates without needing an alloca

Lift `Lift`

Lift `TraitRef` into `rustc_type_ir`

Also debug

Apply nits, make some bounds into supertraits on inherent traits

Add `-lmingwex` second time in `mingw_libs`

Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around.
As a result functions like `lgamma`
now depend on libraries in this order:
`libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`.

Fixes rust-lang#124221

ignore generics args in attribute paths

bootstrap: add comments for the automatic dry run

fix typo

Co-authored-by: jyn <github@jyn.dev>

reachable computation: extend explanation of what this does, and why

Make sure we consume a generic arg when checking mistyped turbofish

Update cargo

std::rand: adding solaris/illumos for getrandom support.

To help solarish support for miri https://rust-lang/miri/issues/3567

Update ena to 0.14.3

Fix typo in ManuallyDrop's documentation

Add @saethlin to some triagebot groups

Refactor Apple `target_abi`

This was bundled together with `Arch`, which complicated a few code
paths and meant we had to do more string matching than necessary.

Match ergonomics 2024: let `&` patterns eat `&mut`

Various fixes:

- Only show error when move-check would not be triggered
- Add structured suggestion

Fix spans when macros are involved

Comments and fixes

Rename `explicit_ba`

No more `Option<Option<>>`

Remove redundant comment

Move all ref pat logic into `check_pat_ref`

Add comment on `cap_to_weakly_not`

Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>

Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`

Remove feature from documentation examples
Add rustc_const_stable attribute to stabilized functions
Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions

Document proper usage of `fmt::Error` and `fmt()`'s `Result`.

Documentation of these properties previously existed in a lone paragraph
in the `fmt` module's documentation:
<https://doc.rust-lang.org/1.78.0/std/fmt/index.html#formatting-traits>
However, users looking to implement a formatting trait won't necessarily
look there. Therefore, let's add the critical information (that
formatting per se is infallible) to all the involved items.

check if `x test tests` missing any test directory

Signed-off-by: onur-ozkan <work@onurozkan.dev>

remap missing path `tests/crashes` to `tests`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

add "tidy-alphabetical" check on "tests" remap list

Signed-off-by: onur-ozkan <work@onurozkan.dev>

Handle Deref expressions in invalid_reference_casting

unix/fs: a bit of cleanup around host-specific code

solaris support start.

reduce tokio features

remove rand test

the actual target-specific things we want to test are all in getrandom,
and rand already tests miri itself

getrandom: test with and without isolation

also add some comments for why we keep certain old obscure APIs supported

avoid code duplication between realloc and malloc

Implement wcslen

organize libc tests into a proper folder, and run some of them on Windows

README: update introduction

remove problems that I do not think we have seen in a while

io::Error handling: keep around the full io::Error for longer so we can give better errors

Implement non-null pointer for malloc(0)

Allow test targets to be set via CLI args

Update CI script for the miri-script test changes

Update documentation for miri-script test changes

minor tweaks

make MIRI_TEST_TARGET entirely an internal thing

make RUSTC_BLESS entirely an internal thing

do not run symlink tests on Windows hosts

rename 'extern-so' to 'native-lib'

Preparing for merge from rustc

alloc: update comments around malloc() alignment

separate windows heap functions from C heap shims

Add windows_i686_gnullvm to the list

Pin libc back to 0.2.153

Update Cargo.lock

fix few typo in filecheck annotations

Consolidate obligation cause codes for where clauses

Clean up users of rust_dbg_call

Enable profiler for armv7-unknown-linux-gnueabihf.

Always hide private fields in aliased type

Migrate `run-make/rustdoc-shared-flags` to rmake

Relax allocator requirements on some Rc APIs.

* Remove A: Clone bound from Rc::assume_init, Rc::downcast, and Rc::downcast_unchecked.
* Make From<Rc<[T; N]>> for Rc<[T]> allocator-aware.

Internal changes:

* Made Arc::internal_into_inner_with_allocator method into Arc::into_inner_with_allocator associated fn.
* Add private Rc::into_inner_with_allocator (to match Arc), so other fns don't have to juggle ManuallyDrop.

Relax A: Clone requirement on Rc/Arc::unwrap_or_clone.

Add test for rust-lang#122775

Refactoring after the `PlaceValue` addition

I added `PlaceValue` in 123775, but kept that one line-by-line simple because it touched so many places.

This goes through to add more helpers & docs, and change some `PlaceRef` to `PlaceValue` where the type didn't need to be included.

No behaviour changes.

Make it possible to derive Lift/TypeVisitable/TypeFoldable in rustc_type_ir

Uplift `TraitPredicate`

Uplift `ExistentialTraitRef`, `ExistentialProjection`, `ProjectionPredicate`

Uplift `NormalizesTo`, `CoercePredicate`, and `SubtypePredicate`

Apply nits, uplift ExistentialPredicate too

And `ImplPolarity` too

Expand on expr_requires_semi_to_be_stmt documentation

Mark expr_requires_semi_to_be_stmt call sites

For each of these, we need to decide whether they need to be using
`expr_requires_semi_to_be_stmt`, or `expr_requires_comma_to_be_match_arm`,
which are supposed to be 2 different behaviors. Previously they were
conflated into one, causing either too much or too little
parenthesization.

Macro call with braces does not require semicolon to be statement

This commit by itself is supposed to have no effect on behavior. All of
the call sites are updated to preserve their previous behavior.

The behavior changes are in the commits that follow.

Add ExprKind::MacCall statement boundary tests

Fix pretty printer statement boundaries after braced macro call

Delete MacCall case from pretty-printing semicolon after StmtKind::Expr

I didn't figure out how to reach this condition with `expr` containing
`ExprKind::MacCall`. All the approaches I tried ended up with the macro
call ending up in the `StmtKind::MacCall` case below instead.

In any case, from visual inspection this is a bugfix. If we do end up
with a `StmtKind::Expr` containing `ExprKind::MacCall` with brace
delimiter, it would not need ";" printed after it.

Add test of unused_parens lint involving macro calls

Document the situation with unused_parens lint and braced macro calls

Add parser tests for statement boundary insertion

Mark Parser::expr_is_complete call sites

Document MacCall special case in Parser::expr_is_complete

Document MacCall special case in Parser::parse_arm

Add macro calls to else-no-if parser test

Remove MacCall special case from recovery after missing 'if' after 'else'

The change to the test is a little goofy because the compiler was
guessing "correctly" before that `falsy! {}` is the condition as opposed
to the else body. But I believe this change is fundamentally correct.
Braced macro invocations in statement position are most often item-like
(`thread_local! {...}`) as opposed to parenthesized macro invocations
which are condition-like (`cfg!(...)`).

Remove MacCall special cases from Parser::parse_full_stmt

It is impossible for expr here to be a braced macro call. Expr comes
from `parse_stmt_without_recovery`, in which macro calls are parsed by
`parse_stmt_mac`. See this part:

    let kind = if (style == MacStmtStyle::Braces
        && self.token != token::Dot
        && self.token != token::Question)
        || self.token == token::Semi
        || self.token == token::Eof
    {
        StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
    } else {
        // Since none of the above applied, this is an expression statement macro.
        let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac));
        let e = self.maybe_recover_from_bad_qpath(e)?;
        let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?;
        let e = self.parse_expr_assoc_with(
            0,
            LhsExpr::AlreadyParsed { expr: e, starts_statement: false },
        )?;
        StmtKind::Expr(e)
    };

A braced macro call at the head of a statement is always either extended
into ExprKind::Field / MethodCall / Await / Try / Binary, or else
returned as StmtKind::MacCall. We can never get a StmtKind::Expr
containing ExprKind::MacCall containing brace delimiter.

Add classify::expr_is_complete

Fix redundant parens around braced macro call in match arms

use key-value format in stage0 file

Currently, we are working on the python removal task on bootstrap. Which means
we have to extract some data from the stage0 file using shell scripts. However,
parsing values from the stage0.json file is painful because shell scripts don't
have a built-in way to parse json files.

This change simplifies the stage0 file format to key-value pairs, which makes
it easily readable from any environment.

Signed-off-by: onur-ozkan <work@onurozkan.dev>

awk stage0 file on CI

Signed-off-by: onur-ozkan <work@onurozkan.dev>

use stage0 file in `bootstrap.py`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

use shared stage0 parser from `build_helper`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

remove outdated stage0.json parts

Signed-off-by: onur-ozkan <work@onurozkan.dev>

move comments position in `src/stage0`

Signed-off-by: onur-ozkan <work@onurozkan.dev>

io::Write::write_fmt: panic if the formatter fails when the stream does not fail

std::alloc: using posix_memalign instead of memalign on solarish.

simpler code path since small alignments are already taking care of.
close rust-langGH-124787

Relax slice safety requirements

Per rust-lang#116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when rust-lang#117945 is implemented, we can revert to the old language.

References must also be non-null

Add `crate_type` method to `Rustdoc`

Add `crate_name` method to `Rustdoc` and `Rustc`

Add `python_command` and `source_path` functions

Add `extern_` method to `Rustdoc`

Migrate `rustdoc-scrape-examples-ordering` to `rmake`

Fix some minor issues from the ui-test auto-porting

solve: replace all `debug` with `trace`

structurally important functions to `debug`

fix hidden title in command-line-arguments docs

Assert that MemCategorizationVisitor actually errors when it bails ungracefully

Inline MemCategorization into ExprUseVisitor

Remove unncessary mut ref

Introduce TypeInformationCtxt to abstract over LateCtxt/FnCtxt

Make LateCtxt be a type info delegate for EUV for clippy

Try structurally resolve

Apply nits

Propagate errors rather than using return_if_err

Match ergonomics 2024: migration lint

Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion.

Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>

Add AST pretty-printer tests for let-else

Pretty-print let-else with added parenthesization when needed

rename
cuviper pushed a commit to cuviper/rust that referenced this issue May 16, 2024
cuviper pushed a commit to cuviper/rust that referenced this issue May 16, 2024
(cherry picked from commit 758e459)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. F-on_unimplemented Error messages that can be tackled with `#[rustc_on_unimplemented]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants