Commit Graph

271479 Commits

Author SHA1 Message Date
bors
75703c1a78 Auto merge of #133287 - matthiaskrgr:rollup-ab9j3pu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130236 (unstable feature usage metrics)
 - #131544 (Make asm label blocks safe context)
 - #131586 (Support s390x z13 vector ABI)
 - #132489 (Fix closure arg extraction in `extract_callable_info`, generalize it to async closures)
 - #133078 (tests: ui/inline-consts: add issue number to a test, rename other tests)
 - #133283 (Don't exclude relnotes from `needs-triage` label)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-21 14:08:40 +00:00
Gabriel Bjørnager Jensen
7c799c3e0d Mark and implement 'each_ref' and 'each_mut' in '[T; N]' as const; 2024-11-21 12:27:18 +01:00
Matthias Krüger
df2413ce1c
Rollup merge of #133283 - jieyouxu:triage-relnotes, r=BoxyUwU
Don't exclude relnotes from `needs-triage` label

So initially we *didn't* exclude `needs-triage` label, then we did exclude them in #132825 as sometimes the `needs-triage` is redundant. However, I think they are probably worth double-checking because often some of the labels are only accurate/relevant for the *implementation* PR, but not for the purposes of the relnotes tracking issue. Furthermore, sometimes relevant team labels can be removed. So to make it less likely for relnotes to slip through, I think we should still label relnotes-tracking-issues with `needs-triage`.

cc https://rust-lang.zulipchat.com/#narrow/channel/241545-t-release/topic/Please.20CC.20lang

r? release
2024-11-21 11:58:41 +01:00
Matthias Krüger
825985981f
Rollup merge of #133078 - matthiaskrgr:uiuiui, r=davidtwco
tests: ui/inline-consts: add issue number to a test, rename other tests

rename other tests from a_b_c to a-b-c
2024-11-21 11:58:40 +01:00
Matthias Krüger
c064f6e1fc
Rollup merge of #132489 - compiler-errors:fn-sugg-tweaks, r=BoxyUwU
Fix closure arg extraction in `extract_callable_info`, generalize it to async closures

* Fix argument extraction in `extract_callable_info`
* FIx `extract_callable_info` to work for async closures
* Remove redundant `is_fn_ty` which is just a less general `extract_callable_info`
* More precisely name what is being called (i.e. call it a "closure" not a "function")

Review this without whitespace -- I ended up reformatting `extract_callable_info` because some pesky `//` comments were keeping the let-chains from being formatted.
2024-11-21 11:58:39 +01:00
Matthias Krüger
379b22123c
Rollup merge of #131586 - taiki-e:s390x-vector-abi, r=compiler-errors,uweigand
Support s390x z13 vector ABI

cc #130869

This resolves the following fixmes:
- 58420a065b/compiler/rustc_target/src/abi/call/s390x.rs (L1-L2)
- 58420a065b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs (L9-L11)

Refs: Section 1.2.3 "Parameter Passing" and section 1.2.5 "Return Values" in ELF Application Binary Interface s390x Supplement, Version 1.6.1 (lzsabi_s390x.pdf in https://github.com/IBM/s390x-abi/releases/tag/v1.6.1)

This PR extends ~~https://github.com/rust-lang/rust/pull/127731~~ https://github.com/rust-lang/rust/pull/132173 (merged) 's ABI check to handle cases where `vector` target feature is disabled.
If we do not do ABI check, we run into the ABI problems as described in https://github.com/rust-lang/rust/issues/116558 and https://github.com/rust-lang/rust/issues/130869#issuecomment-2408268044, and the problem of the compiler generating strange code (https://github.com/rust-lang/rust/pull/131586#discussion_r1799003554).

cc `@uweigand`

`@rustbot` label +O-SystemZ +A-ABI
2024-11-21 11:58:38 +01:00
Matthias Krüger
395649558a
Rollup merge of #131544 - nbdd0121:asm_goto_safe_block, r=petrochenkov
Make asm label blocks safe context

Tracking issue: https://github.com/rust-lang/rust/issues/119364

`asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out. It was suggested that a simple fix is to make asm label blocks safe: https://github.com/rust-lang/rust/issues/119364#issuecomment-2316037703.

`@rustbot` labels: +A-inline-assembly +F-asm
2024-11-21 11:58:37 +01:00
Matthias Krüger
fe5403f517
Rollup merge of #130236 - yaahc:unstable-feature-usage, r=estebank
unstable feature usage metrics

example output

```
test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat src/lib.rs
───────┬───────────────────────────────────────────────────────
       │ File: src/lib.rs
───────┼───────────────────────────────────────────────────────
   1   │ #![feature(unix_set_mark)]
   2   │ pub fn add(left: u64, right: u64) -> u64 {
   3   │     left + right
   4   │ }
   5   │
   6   │ #[cfg(test)]
   7   │ mod tests {
   8   │     use super::*;
   9   │
  10   │     #[test]
  11   │     fn it_works() {
  12   │         let result = add(2, 2);
  13   │         assert_eq!(result, 4);
  14   │     }
  15   │ }
───────┴───────────────────────────────────────────────────────

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cargo +stage1 rustc -- -Zmetrics-dir=$PWD/metrics
   Compiling test-lib v0.1.0 (/home/yaahc/tmp/test-lib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat metrics/unstable_feature_usage.json
───────┬─────────────────────────────────────────────────────────────────────
       │ File: metrics/unstable_feature_usage.json
───────┼─────────────────────────────────────────────────────────────────────
   1   │ {"lib_features":[{"symbol":"unix_set_mark"}],"lang_features":[]}
   ```

   related to https://github.com/rust-lang/rust/issues/129485
2024-11-21 11:58:36 +01:00
bors
717f5df2c3 Auto merge of #132629 - nnethercote:124141-preliminaries, r=petrochenkov
#124141 preliminaries

Preliminary changes required to start removing `Nonterminal` (https://github.com/rust-lang/rust/pull/124141).

r? `@petrochenkov`
2024-11-21 10:57:22 +00:00
Deadbeef
514ef180fd constify Add 2024-11-21 18:56:49 +08:00
Jieyou Xu
5d30436d24 Re-delay a resolve bug
For the code pattern reported in
<https://github.com/rust-lang/rust/issues/133272>,

```rs
impl Foo {
   fn fun() {
        let S { ref Self } = todo!();
   }
}
```

<https://github.com/rust-lang/rust/pull/121208> converted this to a
`span_bug` from a `span_delayed_bug` because this specific self-ctor
code pattern lacked test coverage. It turns out this can be hit but we
just lacked test coverage, so change it back to a `span_delayed_bug` and
add a target tested case.
2024-11-21 18:40:36 +08:00
Jonathan Pallant
9dfc682834
generate-copyright: Now generates a library file too.
We only run reuse once, so the output has to be filtered to find only the files that are relevant to the library tree.

Outputs build/COPYRIGHT.html and build/COPYRIGHT-library.html.
2024-11-21 10:01:21 +00:00
Jieyou Xu
61a03fa98f Don't exclude relnotes from needs-triage label 2024-11-21 17:20:37 +08:00
bors
0b1bf71a71 Auto merge of #133280 - matthiaskrgr:rollup-8keusum, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #131736 (Emscripten: link with -sWASM_BIGINT)
 - #132207 (Store resolution for self and crate root module segments)
 - #133153 (Add visits to nodes that already have flat_maps in ast::MutVisitor)
 - #133218 (Implement `~const` item bounds in RPIT)
 - #133228 (Rewrite `show_md_content_with_pager`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-21 07:41:22 +00:00
Ralf Jung
12ac750f9b
Merge pull request #4044 from RalfJung/rustup
Rustup
2024-11-21 07:25:52 +00:00
Ralf Jung
ec6fe118d9 fmt 2024-11-21 07:59:07 +01:00
Ralf Jung
f5fd967283 Merge from rustc 2024-11-21 07:58:50 +01:00
Matthias Krüger
c83b6a3d0e
Rollup merge of #133228 - nnethercote:rewrite-show_md_content_with_pager, r=tgross35
Rewrite `show_md_content_with_pager`

`show_md_content_with_pager` is complex and has a couple of bugs. This PR improves it.

r? ``@tgross35``
2024-11-21 07:56:13 +01:00
Matthias Krüger
920092531f
Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-dead
Implement `~const` item bounds in RPIT

an RPIT in a `const fn` is allowed to be conditionally const itself :)

r? fee1-dead or reroll
2024-11-21 07:56:13 +01:00
Matthias Krüger
9d70af54e4
Rollup merge of #133153 - maxcabrajac:flat_maps, r=petrochenkov
Add visits to nodes that already have flat_maps in ast::MutVisitor

This PR aims to add `visit_` methods for every node that has a `flat_map_` in MutVisitor, giving implementers free choice over overriding `flat_map` for 1-to-n conversions or `visit` for a 1-to-1.

There is one major problem: `flat_map_stmt`.
While all other default implementations of `flat_map`s are 1-to-1 conversion, as they either only call visits or a internal 1-to-many conversions are natural, `flat_map_stmt` doesn't follow this pattern.

`flat_map_stmt`'s default implementation is a 1-to-n conversion that panics if n > 1 (effectively being a 1-to-[0;1]). This means that it cannot be used as is for a default `visit_stmt`, which would be required to be a 1-to-1.

Implementing `visit_stmt` without runtime checks would require it to reach over a potential `flat_map_item` or `filter_map_expr` overrides and call for their `visit` counterparts directly.
Other than that, if we want to keep the behavior of `flat_map_stmt` it cannot call `visit_stmt` internally.

To me, it seems reasonable to make all default implementations 1-to-1 conversions and let implementers handle `visit_stmt` if they need it, but I don't know if calling `visit` directly when a 1-to-1 is required is ok or not.

related to #128974 & #127615

r? ``@petrochenkov``
2024-11-21 07:56:12 +01:00
Matthias Krüger
b1008d1370
Rollup merge of #132207 - compiler-errors:tweak-res-mod-segment, r=petrochenkov
Store resolution for self and crate root module segments

Let's make sure to record the segment resolution for `self::`, `crate::` and `$crate::`.

I'm actually somewhat surprised that the only diagnostic that uses this is the one that errors on invalid generics on a module segment... but seems strictly more correct regardless, and there may be other diagnostics using these segments resolutions that just haven't been tested for `self`. Also includes a drive-by on `report_prohibit_generics_error`.
2024-11-21 07:56:12 +01:00
Matthias Krüger
61878ec254
Rollup merge of #131736 - hoodmane:emscripten-wasm-bigint, r=workingjubilee
Emscripten: link with -sWASM_BIGINT

When linking an executable without dynamic linking, this is a pure improvement. It significantly reduces code size and avoids a lot of buggy behaviors. It is supported in all browsers for many years and in all maintained versions of Node.

It does change the ABI, so people who are dynamically linking with a library or executable that uses the old ABI may need to turn it off. It can be disabled if needed by passing `-Clink-arg -sWASM_BIGINT=0` to `rustc`. But few people will want to turn it off.

Note this includes a libc bump to 0.2.162!
2024-11-21 07:56:11 +01:00
Ralf Jung
09ef8ece28 Preparing for merge from rustc 2024-11-21 07:45:20 +01:00
bors
318f96a8cf Auto merge of #133254 - Earlopain:llvm-19.1.4, r=DianQK
Update LLVM to 19.1.4

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

r? `@DianQK`
2024-11-21 04:34:11 +00:00
Michael Goulet
0465f71d60 Stop being so bail-y in candidate assembly 2024-11-21 01:35:34 +00:00
bors
2d0ea7956c Auto merge of #133261 - matthiaskrgr:rollup-ekui4we, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #129838 (uefi: process: Add args support)
 - #130800 (Mark `get_mut` and `set_position` in `std::io::Cursor` as const.)
 - #132708 (Point at `const` definition when used instead of a binding in a `let` statement)
 - #133226 (Make `PointerLike` opt-in instead of built-in)
 - #133244 (Account for `wasm32v1-none` when exporting TLS symbols)
 - #133257 (Add `UnordMap::clear` method)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-20 21:58:38 +00:00
Ralf Jung
7e6c8d21c6
Merge pull request #4042 from RalfJung/trophy
trophy case: add RwLock::downgrade bug
2024-11-20 21:56:57 +00:00
Nicholas Nethercote
525e1919f7 Rewrite show_md_content_with_pager.
I think the control flow in this function is complicated and confusing,
largely due to the use of two booleans `print_formatted` and
`fallback_to_println` that are set in multiple places and then used to
guide proceedings.

As well as hurting readability, this leads to at least one bug: if the
`write_termcolor_buf` call fails and the pager also fails, the function
will try to print color output to stdout, but that output will be empty
because `write_termcolor_buf` failed. I.e. the `if fallback_to_println`
body fails to check `print_formatted`.

This commit rewrites the function to be neater and more Rust-y, e.g. by
putting the result of `write_termcolor_buf` into an `Option` so it can
only be used on success, and by using `?` more. It also changes
terminology a little, using "pretty" to mean "formatted and colorized".
The result is a little shorter, more readable, and less buggy.
2024-11-21 08:42:01 +11:00
Ralf Jung
9e720acc34 trophy case: add RwLock::downgrade bug 2024-11-20 22:28:48 +01:00
Nicholas Nethercote
03159d4bff Remove ErrorGuaranteed retval from error_unexpected_after_dot.
It was added in #130349, but it's not used meaningfully, and causes
difficulties for Nonterminal removal in #124141.
2024-11-21 08:22:17 +11:00
Nicholas Nethercote
cee88f7a3f Prepare for invisible delimiters.
Current places where `Interpolated` is used are going to change to
instead use invisible delimiters. This prepares for that.
- It adds invisible delimiter cases to the `can_begin_*`/`may_be_*`
  methods and the `failed_to_match_macro` that are equivalent to the
  existing `Interpolated` cases.
- It adds panics/asserts in some places where invisible delimiters
  should never occur.
- In `Parser::parse_struct_fields` it excludes an ident + invisible
  delimiter from special consideration in an error message, because
  that's quite different to an ident + paren/brace/bracket.
2024-11-21 08:22:11 +11:00
Nicholas Nethercote
91164957ec Remove redundant is_terminal check.
It's not necessary because `show_md_content_with_pager` is only ever
called if `is_terminal` is true.
2024-11-21 08:21:01 +11:00
Nicholas Nethercote
15528b2d6c Fix catbat pager typo.
`bat` is known as `batcat` on Ubuntu and Debian, not `catbat`.
2024-11-21 08:21:01 +11:00
Nicholas Nethercote
cfafa9380b Add metavariables to TokenDescription.
Pasted metavariables are wrapped in invisible delimiters, which
pretty-print as empty strings, and changing that can break some proc
macros. But error messages saying "expected identifer, found ``" are
bad. So this commit adds support for metavariables in `TokenDescription`
so they print as "metavariable" in error messages, instead of "``".

It's not used meaningfully yet, but will be needed to get rid of
interpolated tokens.
2024-11-21 08:16:55 +11:00
Nicholas Nethercote
afe238f66f Introduce InvisibleOrigin on invisible delimiters.
It's not used meaningfully yet, but will be needed to get rid of
interpolated tokens.
2024-11-21 08:16:54 +11:00
binarycat
7e79f91390 implement OsString::truncate 2024-11-20 15:16:05 -06:00
Jane Losare-Lusby
0a14f712d7
Update tests/run-make/unstable-feature-usage-metrics/rmake.rs
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2024-11-20 12:11:40 -08:00
maxcabrajac
01b26e6198 Use visit_item instead of flat_map_item in test_harness.rs 2024-11-20 16:47:00 -03:00
maxcabrajac
1dc12367b9 Items 2024-11-20 16:42:18 -03:00
Ralf Jung
666bcbdb2e aarch64 softfloat target: always pass floats in int registers 2024-11-20 20:41:28 +01:00
Ralf Jung
e6946883ec
Merge pull request #4026 from eduardosm/soft-sqrt
miri: implement square root without relying on host floats
2024-11-20 19:34:47 +00:00
Jane Losare-Lusby
dc97db105a unstable feature usage metrics 2024-11-20 11:31:40 -08:00
Matthias Krüger
71d07dd030
Rollup merge of #133257 - GuillaumeGomez:unordmap-clear, r=lcnr
Add `UnordMap::clear` method

I need it for something I'm working on and I was surprised to see this method was not implemented.
2024-11-20 20:10:15 +01:00
Matthias Krüger
1099bc8e73
Rollup merge of #133244 - daxpedda:wasm32v1-none-atomic, r=alexcrichton
Account for `wasm32v1-none` when exporting TLS symbols

Exporting TLS related symbols was limited to `wasm32-unknown-unknown` because WASI and Emscripten (?) have their own infrastructure to deal with TLS. However, the introduction of `wasm32v1-none` is in the same boat as `wasm32-unknown-unknown`.

This PR adjust the mechanism to account for `wasm32v1-none` as well.

See https://github.com/rust-lang/rust/pull/102385 and https://github.com/rust-lang/rust/pull/102440.

r? ``@alexcrichton``
2024-11-20 20:10:14 +01:00
Matthias Krüger
fbed195b4d
Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr
Make `PointerLike` opt-in instead of built-in

The `PointerLike` trait currently is a built-in trait that computes the layout of the type. This is a bit problematic, because types implement this trait automatically. Since this can be broken due to semver-compatible changes to a type's layout, this is undesirable. Also, calling `layout_of` in the trait system also causes cycles.

This PR makes the trait implemented via regular impls, and adds additional validation on top to make sure that those impls are valid. This could eventually be `derive()`d for custom smart pointers, and we can trust *that* as a semver promise rather than risking library authors accidentally breaking it.

On the other hand, we may never expose `PointerLike`, but at least now the implementation doesn't invoke `layout_of` which could cause ICEs or cause cycles.

Right now for a `PointerLike` impl to be valid, it must be an ADT that is `repr(transparent)` and the non-1zst field needs to implement `PointerLike`. There are also some primitive impls for `&T`/ `&mut T`/`*const T`/`*mut T`/`Box<T>`.
2024-11-20 20:10:13 +01:00
Matthias Krüger
7fc2b33722
Rollup merge of #132708 - estebank:const-as-binding, r=Nadrieril
Point at `const` definition when used instead of a binding in a `let` statement

Modify `PatKind::InlineConstant` to be `ExpandedConstant` standing in not only for inline `const` blocks but also for `const` items. This allows us to track named `const`s used in patterns when the pattern is a single binding. When we detect that there is a refutable pattern involving a `const` that could have been a binding instead, we point at the `const` item, and suggest renaming. We do this for both `let` bindings and `match` expressions missing a catch-all arm if there's at least one single binding pattern referenced.

After:

```
error[E0005]: refutable pattern in local binding
  --> $DIR/bad-pattern.rs:19:13
   |
LL |     const PAT: u32 = 0;
   |     -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable
...
LL |         let PAT = v1;
   |             ^^^ pattern `1_u32..=u32::MAX` not covered
   |
   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
   = note: the matched value is of type `u32`
help: introduce a variable instead
   |
LL |         let PAT_var = v1;
   |             ~~~~~~~
```

Before:

```
error[E0005]: refutable pattern in local binding
  --> $DIR/bad-pattern.rs:19:13
   |
LL |         let PAT = v1;
   |             ^^^
   |             |
   |             pattern `1_u32..=u32::MAX` not covered
   |             missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable
   |             help: introduce a variable instead: `PAT_var`
   |
   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
   = note: the matched value is of type `u32`
```

CC #132582.
2024-11-20 20:10:12 +01:00
Matthias Krüger
71d3c7790f
Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplett
Mark `get_mut` and `set_position` in `std::io::Cursor` as const.

Relevant tracking issue: #130801

The methods `get_mut` and `set_position` can trivially be marked as const due to #57349 being stabilised.
2024-11-20 20:10:12 +01:00
Matthias Krüger
0576cc987b
Rollup merge of #129838 - Ayush1325:uefi-process-args, r=joboet
uefi: process: Add args support

- Wrap all args with quotes.
- Escape ^ and " inside quotes using ^.
- Doing reverse of arg parsing: d571ae851d/library/std/src/sys/pal/uefi/args.rs (L81)

 r​? joboet
2024-11-20 20:10:11 +01:00
Eduardo Sánchez Muñoz
8a5c187948 miri: implement square root without relying on host floats 2024-11-20 20:01:57 +01:00
Michael Goulet
b33a0d3292 we should not be reporting generic error if there is not a segment to deny 2024-11-20 18:57:02 +00:00