Commit Graph

256559 Commits

Author SHA1 Message Date
Jubilee
78d9a7e107
Rollup merge of #125906 - compiler-errors:simplify-method-error-args, r=fmease
Remove a bunch of redundant args from `report_method_error`

Rebased on top of #125397 because I had originally asked there (https://github.com/rust-lang/rust/pull/125397#discussion_r1610124799) for this change to be made, but I just chose to do it myself.

r? fmease
2024-06-05 01:14:32 -07:00
Jubilee
009613802d
Rollup merge of #125903 - petrochenkov:upctxt3, r=nnethercote
rustc_span: Inline some hot functions

Found while benchmarking https://github.com/rust-lang/rust/pull/125829.
2024-06-05 01:14:31 -07:00
Jubilee
05b4674054
Rollup merge of #125815 - nnethercote:rustc_parse-top-level-cleanups, r=spastorino
`rustc_parse` top-level cleanups

A bunch of improvements in and around `compiler/rustc_parse/src/lib.rs`. Many of the changes streamline the API in that file from this (12 functions and one macro):
```
    name                              args                  return type
    ----                              ----                  -----------
    panictry_buffer!                  Result<T, Vec<Diag>>  T

pub parse_crate_from_file             path                  PResult<Crate>
pub parse_crate_attrs_from_file       path                  PResult<AttrVec>
pub parse_crate_from_source_str       name,src              PResult<Crate>
pub parse_crate_attrs_from_source_str name,src              PResult<AttrVec>

pub new_parser_from_source_str        name,src              Parser
pub maybe_new_parser_from_source_str  name,src              Result<Parser, Vec<Diag>>
pub new_parser_from_file              path,error_sp         Parser
    maybe_source_file_to_parser       srcfile               Result<Parser, Vec<Diag>>

pub parse_stream_from_source_str      name,src,override_sp  TokenStream
pub source_file_to_stream             srcfile,override_sp   TokenStream
    maybe_file_to_stream              srcfile,override_sp   Result<TokenStream, Vec<Diag>>

pub stream_to_parser                  stream,subparser_name Parser
```
to this:
```
    name                              args                  return type
    ----                              ----                  -----------
    unwrap_or_emit_fatal              Result<T, Vec<Diag>>  T

pub new_parser_from_source_str        name,src              Result<Parser, Vec<Diag>>
pub new_parser_from_file              path,error_sp         Result<Parser, Vec<Diag>>
    new_parser_from_source_file       srcfile               Result<Parser, Vec<Diag>>

pub source_str_to_stream              name,src,override_sp  Result<TokenStream, Vec<Diag>>
    source_file_to_stream             srcfile,override_sp   Result<TokenStream, Vec<Diag>>
```
I found the old API quite confusing, with lots of similar-sounding function names and no clear structure. I think the new API is much better.

r? `@spastorino`
2024-06-05 01:14:31 -07:00
Jubilee
0f2b34acdc
Rollup merge of #125683 - Oneirical:patience-testing-test, r=jieyouxu
Rewrite `suspicious-library`, `resolve-rename` and `incr-prev-body-beyond-eof` `run-make` tests in `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Some oddly specific ignore flags in `incr-prev-body-beyond-eof`:

```rs
// ignore-none
// ignore-nvptx64-nvidia-cuda
```

it could be interesting to run a try job, but it seems there is no nvidia-cuda in the CI settings (`jobs.yml`).

try-job: armhf-gnu
2024-06-05 01:14:30 -07:00
Jubilee
0f86182988
Rollup merge of #125273 - onur-ozkan:bootstrap-self-test, r=albertlarsan68
bootstrap: implement new feature `bootstrap-self-test`

Some of the bootstrap logics should be ignored during unit tests because they either make the tests take longer or cause them to fail. Therefore we need to be able to exclude them from the bootstrap when it's called by unit tests. This change introduces a new feature called `bootstrap-self-test`, which is enabled on bootstrap unit tests by default. This allows us to keep the logic separate between compiler builds and bootstrap tests without needing messy workarounds (like checking if target names match those in the unit tests).

Also, resolves https://github.com/rust-lang/rust/issues/122090 (without having to create separate modules)
2024-06-05 01:14:30 -07:00
Jubilee
9ccc7b78ec
Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude

(Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.)

Many, many projects use `size_of` to get the size of a type. However,
it's also often equally easy to hardcode a size (e.g. `8` instead of
`size_of::<u64>()`). Minimizing friction in the use of `size_of` helps
ensure that people use it and make code more self-documenting.

The name `size_of` is unambiguous: the name alone, without any prefix or
path, is self-explanatory and unmistakeable for any other functionality.
Adding it to the prelude cannot produce any name conflicts, as any local
definition will silently shadow the one from the prelude. Thus, we don't
need to wait for a new edition prelude to add it.
2024-06-05 01:14:29 -07:00
Nicholas Nethercote
2d4e7df144 rustfmt: Remove an unnecessary catch_unwind use.
The `Input::File` and `Input::Text` cases should be very similar.
However, currently the `Input::File` case uses `catch_unwind` because,
until recently (#125815) there was a fallible version of
`new_parser_from_source_str` but only an infallible version of
`new_parser_from_file`. This difference wasn't fundamental, just an
overlooked gap in the API of `rustc_parse`.

Both of those operations are now fallible, so the `Input::File` and
`Input::Text` cases can made more similar, with no need for
`catch_unwind`. This also lets us simplify an `Option<Vec<Diag>>` to
`Vec<Diag>`.
2024-06-05 10:38:03 +10:00
Nicholas Nethercote
b9037339cb Make top-level rustc_parse functions fallible.
Currently we have an awkward mix of fallible and infallible functions:
```
       new_parser_from_source_str
 maybe_new_parser_from_source_str
       new_parser_from_file
(maybe_new_parser_from_file)        // missing
      (new_parser_from_source_file) // missing
 maybe_new_parser_from_source_file
       source_str_to_stream
 maybe_source_file_to_stream
```
We could add the two missing functions, but instead this commit removes
of all the infallible ones and renames the fallible ones leaving us with
these which are all fallible:
```
new_parser_from_source_str
new_parser_from_file
new_parser_from_source_file
source_str_to_stream
source_file_to_stream
```
This requires making `unwrap_or_emit_fatal` public so callers of
formerly infallible functions can still work.

This does make some of the call sites slightly more verbose, but I think
it's worth it for the simpler API. Also, there are two `catch_unwind`
calls and one `catch_fatal_errors` call in this diff that become
removable thanks this change. (I will do that in a follow-up PR.)
2024-06-05 10:38:03 +10:00
Nicholas Nethercote
264dbe4d81 Inline and remove source_file_to_stream.
It has a single call site.
2024-06-05 10:38:03 +10:00
Nicholas Nethercote
ab192a0c97 Reorder source_str_to_stream arguments.
It's the only one of these functions where `psess` isn't the first
argument.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
25972aec67 Inline and remove parse_crate{,_attrs}_from_{file,source_str}.
All four functions are simple and have a single call site.

This requires making `Parser::parse_inner_attributes` public, which is
no big deal.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
8964106e44 Use source_str_to_stream in a test file.
It does exactly what is required.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
191b76ef31 Rename maybe_source_file_to_parser as maybe_new_parser_from_source_file.
For consistency with `new_parser_from_{file,source_str}` and
`maybe_new_parser_from_source_str`.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
29e6e2859b Remove low-value comments.
The first one is out-of-date -- there are no longer functions expr,
item, stmt. And I don't know what a "HOF" is.

The second one doesn't really tell you anything.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
af13b48927 Improve panictry_buffer!.
- Convert it from a macro to a function, which is nicer.
- Rename it as `unwrap_or_emit_fatal`, which is clearer.
- Fix the comment. In particular, `panictry!` no longer exists.
- Remove the unnecessary `use` declaration.
2024-06-05 10:38:02 +10:00
Nicholas Nethercote
3c321b9ea8 Remove stream_to_parser.
It's a zero-value wrapper of `Parser::new`.
2024-06-05 10:37:59 +10:00
Nicholas Nethercote
769ca3f661 Rename maybe_file_to_stream as maybe_source_file_to_stream.
Because it takes an `Lrc<SourceFile>`, and for consistency with
`source_file_to_stream`.
2024-06-05 10:29:16 +10:00
Nicholas Nethercote
f6576249ab Inline and remove error_malformed_cfg_attr_missing.
It has a single call site.

This also means `CFG_ATTR_{GRAMMAR_HELP,NOTE_REF}` can be moved into
`parse_cfg_attr`, now that it's the only function that uses them.
And the commit removes the line break in the URL.
2024-06-05 10:29:16 +10:00
Nicholas Nethercote
d1215da26e Don't use the word "parse" for lexing operations.
Lexing converts source text into a token stream. Parsing converts a
token stream into AST fragments. This commit renames several lexing
operations that have "parse" in the name. I think these names have been
subtly confusing me for years.

This is just a `s/parse/lex/` on function names, with one exception:
`parse_stream_from_source_str` becomes `source_str_to_stream`, to make
it consistent with the existing `source_file_to_stream`. The commit also
moves that function's location in the file to be just above
`source_file_to_stream`.

The commit also cleans up a few comments along the way.
2024-06-05 10:29:16 +10:00
Nicholas Nethercote
e1ae0fa055 UNICODE_ARRAY and ASCII_ARRAY fixes.
- Avoid unnecessary escaping of single quotes within string literals.
- Add a missing blank line between two `UNICODE_ARRAY` sections.
2024-06-05 10:29:16 +10:00
bors
a330e49593 Auto merge of #125989 - GuillaumeGomez:rollup-xu69i13, r=GuillaumeGomez
Rollup of 11 pull requests

Successful merges:

 - #106186 (Add function `core::iter::chain`)
 - #125596 (Convert `proc_macro_back_compat` lint to an unconditional error.)
 - #125696 (Explain differences between `{Once,Lazy}{Cell,Lock}` types)
 - #125917 (Create `run-make` `env_var` and `env_var_os` helpers)
 - #125927 (Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unwind targets)
 - #125930 (feat(opt-dist): new flag `--benchmark-cargo-config`)
 - #125932 (Fix typo in the docs of `HashMap::raw_entry_mut`)
 - #125933 (Update books)
 - #125944 (Update fuchsia maintainers)
 - #125946 (Include trailing commas in wrapped function declarations [RustDoc])
 - #125973 (Remove `tests/run-make-fulldeps/pretty-expanded`)

Failed merges:

 - #125815 (`rustc_parse` top-level cleanups)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-04 21:21:18 +00:00
Guillaume Gomez
f41c3e9a69
Rollup merge of #125973 - Zalathar:pretty, r=lqd
Remove `tests/run-make-fulldeps/pretty-expanded`

This was an ancient regression test for #12685, caused by `-Zunpretty=expanded` crashing on certain code produced by `#[derive(RustcEncodable)]`.

Given that this test predates `//@ pretty-expanded` tests, and was tied to ancient implementation details of the pretty-printer and `#[derive(RustcEncodable)]` (which the test no longer even uses), I think we can safely delete it.

---

Spotted via #125948.
2024-06-04 21:41:38 +02:00
Guillaume Gomez
532aa9a81d
Rollup merge of #125946 - Sergi-Ferrez:master, r=notriddle,fmease
Include trailing commas in wrapped function declarations [RustDoc]

Fixes #125901.
2024-06-04 21:41:38 +02:00
Guillaume Gomez
47265df3f0
Rollup merge of #125944 - P1n3appl3:fuchsia, r=lqd
Update fuchsia maintainers

This makes the maintainers list in the docs line up with the current [fuchsia team](https://github.com/rust-lang/team/blob/master/teams/fuchsia.toml).
2024-06-04 21:41:37 +02:00
Guillaume Gomez
1f1b644f25
Rollup merge of #125933 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

6 commits in 85442a608426d3667f1c9458ad457b241a36b569..5228bfac8267ad24659a81b92ec5417976b5edbc
2024-05-29 20:55:49 UTC to 2024-05-27 17:22:03 UTC

- Fix typo in ch10-03 (rust-lang/book#3539)
- Backport changes to ch 9 and 10 (rust-lang/book#3946)
- infra: correctly support preprocessors for nostarch (rust-lang/book#3944)
- Use `<kbd>` instead of `<span class="keystroke">` (rust-lang/book#3945)
- infra: Fix clippy warning in remove_markup (rust-lang/book#3943)
- fix: ch10-03 - misleading use of expect on .split (rust-lang/book#3939)

## rust-lang/edition-guide

2 commits in 0c68e90acaae5a611f8f5098a3c2980de9845ab2..bbaabbe088e21a81a0d9ae6757705020d5d7b416
2024-05-24 19:07:18 UTC to 2024-05-21 22:40:52 UTC

- 2024: Document reserving `gen` keyword (rust-lang/edition-guide#300)
- 2024: Document cargo changes (rust-lang/edition-guide#301)

## rust-embedded/book

1 commits in dd962bb82865a5284f2404e5234f1e3222b9c022..b10c6acaf0f43481f6600e95d4b5013446e29f7a
2024-05-31 08:51:50 UTC to 2024-05-31 08:51:50 UTC

- Add some explanations as to why exception re-entrancy may still be an issue in a multicore-environment. (rust-embedded/book#367)

## rust-lang/reference

6 commits in e356977fceaa8591c762312d8d446769166d4b3e..6019b76f5b28938565b251bbba0bf5cc5c43d863
2024-06-03 15:58:57 UTC to 2024-05-25 18:35:54 UTC

- Add Apple `target_abi` values to the example values (rust-lang/reference#1507)
- this needs a space (rust-lang/reference#1506)
- Mention Variadics With No Fixed Parameter (rust-lang/reference#1494)
- Add "scopes" chapter. (rust-lang/reference#1040)
- update patterns.md for const pattern RFC (rust-lang/reference#1456)
- document guarantee about evaluation of associated consts and const blocks (rust-lang/reference#1497)

## rust-lang/rust-by-example

3 commits in 20482893d1a502df72f76762c97aed88854cdf81..4840dca06cadf48b305d3ce0aeafde7f80933f80
2024-05-28 13:56:12 UTC to 2024-05-27 11:51:10 UTC

- Update mdbook-i18n-helpers to 0.3.3 (rust-lang/rust-by-example#1857)
- Fix CI failure (rust-lang/rust-by-example#1856)
- Add precision on From/Into asymmetry to from_into.md (rust-lang/rust-by-example#1855)

## rust-lang/rustc-dev-guide

4 commits in b6d4a4940bab85cc91eec70cc2e3096dd48da62d..6a7374bd87cbac0f8be4fd4877d8186d9c313985
2024-05-31 00:27:28 UTC to 2024-05-21 09:56:12 UTC

- Flesh out the "representing types" chapter (rust-lang/rustc-dev-guide#1985)
- sync the stage0 filename (rust-lang/rustc-dev-guide#1979)
- Add Rust for Linux notification group entry (rust-lang/rustc-dev-guide#1984)
- fix some typos (rust-lang/rustc-dev-guide#1983)
2024-06-04 21:41:37 +02:00
Guillaume Gomez
b6b1a46631
Rollup merge of #125932 - schvv31n:patch-1, r=lqd
Fix typo in the docs of `HashMap::raw_entry_mut`

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-04 21:41:36 +02:00
Guillaume Gomez
610592b5fe
Rollup merge of #125930 - weihanglo:opt-dist-respect-cargo-config, r=Kobzol
feat(opt-dist): new flag `--benchmark-cargo-config`

This should be the last piece toward self-contained `opt-dist` (I believe).

The flag propagates cargo configs to `rustc-perf --cargo-config`,
which is particularly useful when the environment is air-gapped,
and you want to use the default set of training crates vendored
in the rustc-src tarball.

It fixes the issue described in #125465

> * The current pinned rustc-perf uses `tempfile::Tempdir` as the working
  directory when collecting profiles from some of these packages.
  This "tmp" working directory usage make it impossible for Cargo to pick
  up the correct vendor sources setting in `.cargo/config.toml` bundled
  in the rustc-src tarball. [^1]
> [^1]: 4f313add60/collector/src/compile/benchmark/mod.rs (L164-L173)

See also

* <https://github.com/rust-lang/rustc-perf/pull/1913>
* <https://github.com/rust-lang/rust/pull/125465>
* https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/tempfile.20in.20rustc-perf.20make.20it.20hard.20to.20configure.20vendor

r​? Kobzol
2024-06-04 21:41:35 +02:00
Guillaume Gomez
d9e149d9d8
Rollup merge of #125927 - ferrocene:lw-alloc-unwind-test, r=pietroalbini
Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unwind targets

https://github.com/rust-lang/rust/pull/123803 added this test which requires unwinding to succeed. This conditionally ignores the test on non-unwind targets (as is the case with other tests using `catch_unwind`).
2024-06-04 21:41:35 +02:00
Guillaume Gomez
5364a14370
Rollup merge of #125917 - GuillaumeGomez:env-var-helpers, r=jieyouxu
Create `run-make` `env_var` and `env_var_os` helpers

As mentioned in https://github.com/rust-lang/rust/pull/125886. It's quite useful to know which environment variable failed, so better provide a helper helping with that.

r? `@jieyouxu`
2024-06-04 21:41:34 +02:00
Guillaume Gomez
ee04e0f35e
Rollup merge of #125696 - workingjubilee:please-dont-say-you-are-lazy, r=Nilstrieb
Explain differences between `{Once,Lazy}{Cell,Lock}` types

The question of "which once-ish cell-ish type should I use?" has been raised multiple times, and is especially important now that we have stabilized the `LazyCell` and `LazyLock` types. The answer for the `Lazy*` types is that you would be better off using them if you want to use what is by far the most common pattern: initialize it with a single nullary function that you would call at every `get_or_init` site. For everything else there's the `Once*` types.

"For everything else" is a somewhat weak motivation, as it only describes by negation. While contrasting them is inevitable, I feel positive motivations are more understandable. For this, I now offer a distinct example that helps explain why `OnceLock` can be useful, despite `LazyLock` existing: you can do some cool stuff with it that `LazyLock` simply can't support due to its mere definition.

The pair of `std::sync::*Lock`s are usable inside a `static`, and can serve roles in async or multithreaded (or asynchronously multithreaded) programs that `*Cell`s cannot. Because of this, they received most of my attention.

Fixes #124696
Fixes #125615
2024-06-04 21:41:34 +02:00
Guillaume Gomez
fa96e2cb4f
Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebank
Convert `proc_macro_back_compat` lint to an unconditional error.

We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour.

The original "hack" implementing alternative behaviour was added in #73345.

The lint was added in #83127.

The tracking issue is #83125.

The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work.

r? ``@estebank``
2024-06-04 21:41:33 +02:00
Guillaume Gomez
190f221dba
Rollup merge of #106186 - rossmacarthur:ft/iter-chain, r=Amanieu
Add function `core::iter::chain`

The addition of `core::iter::zip` (#82917) set a precedent for adding plain functions for iterator adaptors. Adding `chain` makes it a little easier to `chain` two iterators.

```rust
for (x, y) in chain(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().chain(ys) {}
```

There is prior art for the utility of this in [`itertools::chain`](https://docs.rs/itertools/latest/itertools/fn.chain.html).

Approved ACP https://github.com/rust-lang/libs-team/issues/154
2024-06-04 21:41:33 +02:00
Oneirical
59e2074c79 rewrite suspicious-library in rmake 2024-06-04 15:27:13 -04:00
bors
23e040adec Auto merge of #125426 - jieyouxu:rmake-support-env-reset, r=saethlin
Update `compiler-builtins` test to not clear essential env vars

Noticed in https://github.com/rust-lang/rust/pull/122580#issuecomment-2125755689, the `compiler-builtins` test failed on Windows for a `cargo` invocation because necessary env vars `TMP` and `TEMP` were cleared by `Command::env_clear`, causing temp dir eventually used by codegen to fallback to the Windows directory, which will trigger permission errors.

This PR removes the `env_clear` on the cargo invocation.

r? `@saethlin` (feel free to reroll, since you authored the test)

try-job: x86_64-msvc
try-job: test-various
2024-06-04 19:14:28 +00:00
Guillaume Gomez
7e993b24d5 Create run-make env_var and env_var_os helpers 2024-06-04 21:07:48 +02:00
bors
44701e070c Auto merge of #123536 - compiler-errors:simplify-int-float, r=lcnr
Simplify `IntVarValue`/`FloatVarValue`

r? `@ghost`
2024-06-04 17:07:13 +00:00
Zalathar
c7491a9885 Remove tests/run-make-fulldeps/pretty-expanded
This was an ancient regression test for #12685, caused by `-Zunpretty=expanded`
crashing on certain code produced by `#[derive(RustcEncodable)]`.
2024-06-05 00:51:09 +10:00
bors
30ea1a2693 Auto merge of #125976 - compiler-errors:rollup-xt3le7w, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #125667 (Silence follow-up errors directly based on error types and regions)
 - #125717 (Refactor `#[diagnostic::do_not_recommend]` support)
 - #125795 (Improve renaming suggestion for names with leading underscores)
 - #125865 (Fix ICE caused by ignoring EffectVars in type inference)
 - #125953 (Streamline `nested` calls.)
 - #125959 (Reduce `pub` exposure in `rustc_mir_build`)
 - #125967 (Split smir `Const` into `TyConst` and `MirConst`)
 - #125968 (Store the types of `ty::Expr` arguments in the `ty::Expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-04 14:49:54 +00:00
Sergi-Ferrez
744dc8c503 Use checked_sub 2024-06-04 16:05:51 +02:00
Michael Goulet
a5dc684eee
Rollup merge of #125968 - BoxyUwU:shrink_ty_expr, r=oli-obk
Store the types of `ty::Expr` arguments in the `ty::Expr`

Part of #125958

In attempting to remove the `ty` field on `Const` it will become necessary to store the `Ty<'tcx>` inside of `Expr<'tcx>`. In order to do this without blowing up the size of `ConstKind`, we start storing the type/const args as `GenericArgs`

r? `@oli-obk`
2024-06-04 08:52:15 -04:00
Michael Goulet
288727ef42
Rollup merge of #125967 - BoxyUwU:split_smir_const, r=oli-obk
Split smir `Const` into `TyConst` and `MirConst`

Part of #125958

Building a `smir::Const` currently requires accessing the `Ty<'tcx>` of a `ty::Const`. This will stop being possible in the future. Replicate the split in rustc of having a representation of type level constants and mir constants with the latter being able to store the former. Ideally we wouldnt have `MirConst::Ty` but 🤷‍♀️

r? `@oli-obk`
2024-06-04 08:52:15 -04:00
Michael Goulet
8272c6d8cc
Rollup merge of #125959 - nnethercote:rustc_mir_build-cleanups, r=compiler-errors
Reduce `pub` exposure in `rustc_mir_build`

r? compiler
2024-06-04 08:52:14 -04:00
Michael Goulet
23f39a21db
Rollup merge of #125953 - nnethercote:streamline-nested-calls, r=lqd
Streamline `nested` calls.

`TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We can call that impl, which then calls the one on `intravisit::Map`, instead of calling the one on `intravisit::Map` directly, avoiding a cast and extra references.

r? `@lqd`
2024-06-04 08:52:14 -04:00
Michael Goulet
7699da4858
Rollup merge of #125865 - ajwock:ice_not_fully_resolved, r=fee1-dead
Fix ICE caused by ignoring EffectVars in type inference

Fixes #119830
​r? ```@matthiaskrgr```
2024-06-04 08:52:13 -04:00
Michael Goulet
7e5528fa55
Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, r=compiler-errors
Improve renaming suggestion for names with leading underscores

Fixes #125650

Before:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
2 |     let _ = p;
  |             ^
  |
help: a local variable with a similar name exists, consider renaming `_p` into `p`
  |
1 | fn a(p: i32) {
  |      ~
```

After:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
1 | fn a(_p: i32) {
  |      -- `_p` defined here
2 |     let _ = p;
  |             ^
  |
help: the leading underscore in `_p` marks it as unused, consider renaming it to `p`
  |
1 | fn a(p: i32) {
  |      ~
```

This change doesn't exactly conform to what was proposed in the issue:

1. I've kept the suggested code instead of solely replacing it with the label
2. I've removed the "...similar name exists..." message instead of relocating to the usage span
3. You could argue that it still isn't completely clear that the change is referring to the definition (not the usage), but I'm not sure how to do this without playing down the fact that the error was caused by the usage of an undefined name.
2024-06-04 08:52:13 -04:00
Michael Goulet
46a033958a
Rollup merge of #125717 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors
Refactor `#[diagnostic::do_not_recommend]` support

This commit refactors the `#[do_not_recommend]` support in the old parser to also apply to projection errors and not only to selection errors. This allows the attribute to be used more widely.

Part of #51992

r? `@compiler-errors`

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-04 08:52:12 -04:00
Michael Goulet
5019bb608a
Rollup merge of #125667 - oli-obk:taintify, r=TaKO8Ki
Silence follow-up errors directly based on error types and regions

During type_of, we used to just return an error type if there were any errors encountered. This is problematic, because it means a struct declared as `struct Foo<'static>` will end up not finding any inherent or trait impls because those impl blocks' `Self` type will be `{type error}` instead of `Foo<'re_error>`. Now it's the latter, silencing nonsensical follow-up errors about `Foo` not having any methods.

Unfortunately that now allows for new follow-up errors, because borrowck treats `'re_error` as `'static`, causing nonsensical errors about non-error lifetimes not outliving `'static`. So what I also did was to just strip all outlives bounds that borrowck found, thus never letting it check them. There are probably more nuanced ways to do this, but I worried there would be other nonsensical errors if some outlives bounds were missing. Also from the test changes, it looked like an improvement everywhere.
2024-06-04 08:52:12 -04:00
bors
bc33782c23 Auto merge of #125948 - nnethercote:rustfmt-more-tests, r=lqd
rustfmt more tests

This finishes the formatting of tests begun in #125759 and continued in #125912.

r? `@lqd`
2024-06-04 11:51:35 +00:00
Sergi-Ferrez
617e64c9e7 Update code format and tests 2024-06-04 13:49:39 +02:00
Oli Scherer
67a73f265f bless privacy tests (only diagnostic duplication) 2024-06-04 11:27:54 +00:00