0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-24 00:58:00 +01:00
Commit Graph

271451 Commits

Author SHA1 Message Date
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
Michael Goulet
19b528b8a0 Store resolution for self and crate root module segments 2024-11-20 18:57:02 +00:00
bors
3fee0f12e4 Auto merge of #131326 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakis
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2)

r? `@nikomatsakis`

Tracked by #123739.

Related to #129864 but not replacing, yet.

Related to #130836.

This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
2024-11-20 18:51:54 +00:00
Esteban Küber
2487765b88 Detect const in pattern with typo
When writing a constant name incorrectly in a pattern, the pattern will be identified as a new binding. We look for consts in the current crate, consts that where imported in the current crate and for local `let` bindings in case someone got them confused with `const`s.

```
error: unreachable pattern
  --> $DIR/const-with-typo-in-pattern-binding.rs:30:9
   |
LL |         GOOOD => {}
   |         ----- matches any value
LL |
LL |         _ => {}
   |         ^ no value can reach this
   |
help: you might have meant to pattern match against the value of similarly named constant `GOOD` instead of introducing a new catch-all binding
   |
LL |         GOOD => {}
   |         ~~~~
```

Fix #132582.
2024-11-20 17:55:18 +00:00
Guillaume Gomez
186e282a43 Add UnordMap::clear method 2024-11-20 18:11:37 +01:00
Michael Goulet
228068bc6e Make PointerLike opt-in as a trait 2024-11-20 16:36:12 +00:00
Michael Goulet
06e66d78c3 Rip out built-in PointerLike impl 2024-11-20 16:13:57 +00:00
Earlopain
a4bd5708c6
Update LLVM to 19.1.4 2024-11-20 16:59:48 +01:00
bors
a1f2999536 Auto merge of #133251 - matthiaskrgr:rollup-gjeis3q, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #131904 (Stabilize const_pin_2)
 - #133239 (Fix LLVM target triple for `x86_64-win7-windows-msvc`)
 - #133241 (interpret: make typing_env field private)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-20 15:49:54 +00:00
Matthias Krüger
b1413e0583
Rollup merge of #133241 - RalfJung:typing-env, r=lcnr
interpret: make typing_env field private

This was made public in https://github.com/rust-lang/rust/pull/133212 but IMO it should remain private. (Specifically, this prevents it from being mutated.)

r? `@lcnr`
2024-11-20 15:48:29 +01:00
Matthias Krüger
d3326564b2
Rollup merge of #133239 - kleisauke:fix-llvm-triple-x86_64-win7-windows-msvc, r=ChrisDenton
Fix LLVM target triple for `x86_64-win7-windows-msvc`

The vendor field needs to be `pc` rather than `win7`.
2024-11-20 15:48:28 +01:00
Matthias Krüger
2595118ee2
Rollup merge of #131904 - GKFX:stabilize-const-pin-2, r=tgross35
Stabilize const_pin_2

Tracking issue #76654; review before FCP in progress.
2024-11-20 15:48:28 +01:00
daxpedda
f37d021d6c
Account for wasm32v1-none when exporting TLS symbols 2024-11-20 14:02:25 +01:00
MarcoIeni
91be81592f
ci: Disable full debuginfo-level=2 in windows alt job 2024-11-20 13:55:35 +01:00
George Bateman
5777c73438 Stabilize const_pin_2 2024-11-20 07:54:12 -05:00
Ding Xiang Fei
297b618944
reduce false positives of tail-expr-drop-order from consumed values
take 2

open up coroutines

tweak the wordings

the lint works up until 2021

We were missing one case, for ADTs, which was
causing `Result` to yield incorrect results.

only include field spans with significant types

deduplicate and eliminate field spans

switch to emit spans to impl Drops

Co-authored-by: Niko Matsakis <nikomat@amazon.com>

collect drops instead of taking liveness diff

apply some suggestions and add explantory notes

small fix on the cache

let the query recurse through coroutine

new suggestion format with extracted variable name

fine-tune the drop span and messages

bugfix on runtime borrows

tweak message wording

filter out ecosystem types earlier

apply suggestions

clippy

check lint level at session level

further restrict applicability of the lint

translate bid into nop for stable mir

detect cycle in type structure
2024-11-20 20:53:11 +08:00
bors
bfe809d93c Auto merge of #133227 - weihanglo:update-cargo, r=weihanglo
Update cargo

5 commits in 69e595908e2c420e7f0d1be34e6c5b984c8cfb84..66221abdeca2002d318fde6efff516aab091df0e
2024-11-16 01:26:11 +0000 to 2024-11-19 21:30:02 +0000
- Docs for optional registry JSON fields (rust-lang/cargo#14839)
- Allow registries to omit empty/default fields in JSON (rust-lang/cargo#14838)
- docs(unstable): Link to -Zwarnings issue, tracking issue (rust-lang/cargo#14836)
- fix(): error context for git_fetch refspec not found (rust-lang/cargo#14806)
- you we distinction (rust-lang/cargo#14829)
2024-11-20 12:32:55 +00:00
WANG Rui
37224817d7 re-export is_loongarch_feature_detected 2024-11-20 18:38:22 +08:00
Ralf Jung
d04088fa36 interpret: make typing_env field private 2024-11-20 11:05:53 +01:00
Kleis Auke Wolthuizen
57ed8e8436 Fix LLVM target triple for x86_64-win7-windows-msvc
The vendor field needs to be `pc` rather than `win7`.
2024-11-20 10:47:28 +01:00
bors
fda6892747 Auto merge of #133234 - jhpratt:rollup-42dmg4p, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #132732 (Use attributes for `dangling_pointers_from_temporaries` lint)
 - #133108 (lints_that_dont_need_to_run: never skip future-compat-reported lints)
 - #133190 (CI: use free runner in dist-aarch64-msvc)
 - #133196 (Make rustc --explain compatible with BusyBox less)
 - #133216 (Implement `~const Fn` trait goal in the new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-20 09:27:56 +00:00
Deadbeef
030ddeecab don't require const stability for const impls 2024-11-20 17:04:05 +08:00
Ralf Jung
8d3d694349
Merge pull request #4041 from rust-lang/rustup-2024-11-20
Automatic Rustup
2024-11-20 07:16:55 +00:00
Jacob Pratt
b9cd5eb190
Rollup merge of #133216 - compiler-errors:const-fn, r=lcnr
Implement `~const Fn` trait goal in the new solver

Split out from https://github.com/rust-lang/rust/pull/132329 since this should be easier to review on its own.

r? lcnr
2024-11-20 01:54:27 -05:00
Jacob Pratt
cd36973a13
Rollup merge of #133196 - omnivagant:correct-less-r-flag, r=tgross35
Make rustc --explain compatible with BusyBox less

busybox less does not support the -r flag and less(1) says:

  USE OF THE -r OPTION IS NOT RECOMMENDED.
2024-11-20 01:54:26 -05:00
Jacob Pratt
c364ff7058
Rollup merge of #133190 - MarcoIeni:dist-aarch64-msvc-free, r=Kobzol
CI: use free runner in dist-aarch64-msvc

try-job: dist-aarch64-msvc
2024-11-20 01:54:26 -05:00
Jacob Pratt
a175db1424
Rollup merge of #133108 - RalfJung:future-compat-needs-to-run, r=lcnr
lints_that_dont_need_to_run: never skip future-compat-reported lints

Follow-up to https://github.com/rust-lang/rust/pull/125116: future-compat lints show up with `--json=future-incompat` even if they are otherwise allowed in the crate. So let's ensure we do not skip those as part of the `lints_that_dont_need_to_run` logic.

I could not find a current future compat lint that is emitted by a lint pass, so there's no clear way to add a test for this.

Cc `@blyxyas` `@cjgillot`
2024-11-20 01:54:25 -05:00