The test began passing in `nightly-2025-10-16`. Probably by c50aebba78
because it fixed two "does not live long enough" errors. The test fails
to compile with `nightly-2025-10-15` with such an error:
$ rustc +nightly-2025-10-15 --edition 2018 tests/ui/async-await/gat-is-send-across-await.rs
error: `impl G` does not live long enough
--> tests/ui/async-await/gat-is-send-across-await.rs:16:24
|
16 | let _: &dyn Send = &async move {
| ________________________^
17 | | let _gat = g.as_gat();
18 | | async{}.await
19 | | };
| |_____^
Fix typos and markdown errors
This PR fixes some typos and markdown errors I found while writing rust-lang/rust#153697.
I've split it out to reduce the size of that PR.
ty-aware delayed AST -> HIR lowering
This PR implements a prototype of ty-aware delayed AST -> HIR lowering. Part of rust-lang/rust#118212.
r? @petrochenkov
# Motivation
When lowering delegation in perfect scenario we would like to access the ty-level information, in particular, queries like `generics_of`, `type_of`, `fn_sig` for proper HIR generation with less hacks. For example, we do not want to generate more lifetimes than needed, because without ty-level queries we do not know which delegee's lifetimes are late-bound. Next, consider recursive delegations, for their proper support without ty we would have to either duplicate generics inheritance code in AST -> HIR lowering or create stubs for parts of the HIR and materialize them later. We already use those queries when interacting with external crates, however when dealing with compilation of a local crate we should use resolver for similar purposes. Finally, access to ty-level queries is expected to help supporting delegation to inherent impls, as we can not resolve such calls during AST -> HIR stage.
# Benefits
We eliminate almost all code that uses resolver in delegation lowering:
- Attributes inheritance is done without copying attributes from AST at resolve stage
- Fn signatures are obtained from `tcx.fn_sig`
- Param counts are also obtained from `tcx.fn_sig`
- `is_method` function now uses `tcx.associated_item` instead of resolver
- Generics are now inherited through `get_external_generics` that uses `tcx.generics_of`. Generics for recursive delegations should also work
- `DelegationIds` that stored paths for recursive delegations is removed, we now use only `delegee_id`
- Structs that were used for storing delegation-related information in resolver are almost fully removed
- `ast_index` is no more used
# Next steps
- Remove creating generic params through AST cloning, proper const types propagation
- Inherent impls
# High level design overview
## Queries
We store ids of delayed items to lower in `Crate` struct. During first stage of lowering, owners that correspond to delayed items are filled with `MaybeOwner::Phantom`.
Next, we define two new queries: `lower_delayed_owner`, `delayed_owner` and a function `force_delayed_owners_lowering`.
The first query is used when lowering known (which is in `delayed_ids`) delayed owner.
The second is fed with children that were obtained during lowering of a delayed owner (note that the result of lowering of a single `LocalDefId` is not a single `MaybeOwner`, its a list of `(LocalDefId, MaybeOwner)` where the first `MaybeOwner` corresponds to delayed `LocalDefId` and others to children that were obtained during lowering (i.e. generic params)). By default `delayed_owner` returns `MaybeOwner::Phantom`. As we do not want to predict the whole list of children which will be obtained after lowering of a single delayed item, we need to store those children somewhere. There are several options:
- Make the return type of `lower_delayed_owner` to be `FxIndexMap<LocalDefId, MaybeOwner>` and search children here. Search will be either linear or we can introduce a map somewhere which will track parent-child relations between a single delayed `LocalDefId` and its children.
- Try to make query that will lower all delayed items in a loop and return a complete map of all delayed `LocalDefIds` and their children. In this case there will be problems with delayed items that require information about other delayed items.
By using proposed queries we handle the second concern, and in case of acyclic dependencies between delayed ids it automatically works, moreover we use queries as cache for delayed `MaybeOwners`. The only invariant here is that queries which are invoked during delayed AST -> HIR lowering of some `LocalDefId` should not in any way access children of other, yet unlowered, delayed `LocalDefId`, they should firstly materialize it.
The `force_delayed_owners_lowering` forces lowering of all delayed items and now integrated in `hir_crate_items` query.
## Resolver for lowering
> ~Currently the `resolver_for_lowering` is stolen in `lower_to_hir` function, however we want to prolong its life until all delayed `LocalDefIds` are materialized. For this purpose we borrow `resolver_for_lowering` in `lower_to_hir` and drop it after forcing materialization of all delayed `LocalDefId` in `rustc_interface::run_required_analyses`.~
We split resolver for lowering into two parts: the first part is a readonly part that came to us from resolve, the second part is a mutable part that can be used to add or overwrite values in the readonly part. Such splitted resolver is used during delayed lowering, as we can't steal it.
## AST index
Lowering uses an AST index. It is created in `lower_to_hir` function and it references parts of AST. We want to avoid reindexing AST on every delayed `LocalDefId` lowering, however now it is not clear how to properly do it. As delayed HIR lowering is used only for delegation unstable feature it should not affect other use-cases of the compiler. But it will be reworked sooner or later.
tests: Add regression test for async closures involving HRTBs
I suspect the original code from rust-lang/rust#59337 had several problems. The last problem fixed that made the code compile entered `nightly-2024-02-11`. The code fails to build with `nightly-2024-02-10`:
$ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
--> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
|
31 | foo(async move | f: &u8 | { *f });
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
| |
| required by a bound introduced by this call
|
(Note that you must add `#![feature(async_closure)]` to test with such old nightlies, since they are from before stabilization of async closures.)
So one of the following commits made the code build:
<details>
<summary>git log d44e3b95cb9d4..6cc4843512d613f --no-merges --oneline</summary>
4def37386c manually bless an aarch64 test
04bc624ea0 rebless after rebase
77f8c3caea detect consts that reference extern statics
9c0623fe8f validation: descend from consts into statics
4e77e368eb unstably allow constants to refer to statics and read from immutable statics
a2479a4ae7 Remove unnecessary `min_specialization` after bootstrap
7b73e4fd44 Allow restricted trait impls in macros with `min_specialization`
e6f5af9671 Remove unused fn
fde695a2d1 Add a helpful suggestion
d7263d7aad Change wording
973bbfbd23 No more associated type bounds in dyn trait
cf1096eb72 Remove unnecessary `#![feature(min_specialization)]`
3d4a9f5047 Turn the "no saved object file in work product" ICE into a translatable fatal error
bb60ded24b Loosen an assertion to account for stashed errors.
69a5264a52 Move some tests
4ef1790b4e tidy
e59d9b171e Avoid a collection and iteration on empty passes
8b6b9c5efc ast_lowering: Fix regression in `use ::{}` imports.
83f3bc4271 Update jobserver-rs to 0.1.28
14e0dab96b Unify item relative path computation in one function
f3c24833c5 Add regression test for non local items link generation
f0d002b890 Correctly generate path for non-local items in source code pages
c94bbb24db Clarify that atomic and regular integers can differ in alignment
7057188c54 make it recursive
7a63d3f16a Add tests for untested capabilities
548929dc5e Don't unnecessarily lower associated type bounds to impl trait
22d582a38d For a rigid projection, recursively look at the self type's item bounds
540be28f6c sort suggestions for object diagnostic
9322882ade Add a couple more tests
3bb384aad6 Prefer AsyncFn* over Fn* for coroutine-closures
aa6f45eb79 Use `ensure` when the result of the query is not needed beyond its `Result`ness
8ff1994ec0 Fix whitespace issues that tidy caught
f0c6f5a7fe Add documentation on `str::starts_with`
63cc3c7b8f test `llvm_out` behaviour
7fb4512ee8 fix `llvm_out` to use the correct LLVM root
b8c93f1223 Coroutine closures implement regular Fn traits, when possible
08af64e96b Regular closures now built-in impls for AsyncFn*
0dd40786b5 Harmonize blanket implementations for AsyncFn* traits
f3d32f2f0c Flatten confirmation logic
9a819ab8f7 static mut: allow reference to arbitrary types, not just slices and arrays
</details>
This was probably fixed by 3bb384aad6 (https://github.com/rust-lang/rust/pull/120712). That PR does not have a big tests diff, so I assume the test we add does not exist elsewhere. It's hard to know for sure.
Closesrust-lang/rust#59337 since we add the test from that issue. In that issue there is a [proposal](https://github.com/rust-lang/rust/issues/59337#issuecomment-826441716) for two minimized versions, but they both fail to compile with `nightly-2024-02-11`, so those reproducers are for different problem(s).
### Tracking Issue
- https://github.com/rust-lang/rust/issues/62290
Fix whitespace after fragment specifiers in macro pretty printing
When a macro-generating-macro captures fragment specifier tokens (like `$x:ident`) as `tt` metavariables and replays them before a keyword (like `where`), the pretty printer concatenates them into an invalid fragment specifier (e.g. `$x:identwhere` instead of `$x:ident where`).
This happens because `tt` captures preserve the original token spacing. When the fragment specifier name (e.g. `ident`) was originally the last token before a closing delimiter, it retains `JointHidden` spacing. The `print_tts` function only checks `space_between` for `Spacing::Alone` tokens, so `JointHidden` tokens skip the space check entirely, causing adjacent identifier-like tokens to merge.
The fix adds a check in `print_tts` to insert a space between adjacent identifier-like tokens (identifiers and keywords) regardless of the original spacing, preventing them from being concatenated into invalid tokens.
This is similar to the existing `space_between` mechanism that prevents token merging for `Spacing::Alone` tokens, extended to also handle `Joint`/`JointHidden` cases where two identifier-like tokens would merge.
## Example
**before** (`rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)`):
```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pretty-mode:expanded
//@ pp-exact:macro-fragment-specifier-whitespace.pp
// Test that fragment specifier names in macro definitions are properly
// separated from the following keyword/identifier token when pretty-printed.
// This is a regression test for a bug where `$x:ident` followed by `where`
// was pretty-printed as `$x:identwhere` (an invalid fragment specifier).
macro_rules! outer {
($d:tt $($params:tt)*) =>
{
#[macro_export] macro_rules! inner
{ ($($params)* where $d($rest:tt)*) => {}; }
};
}
#[macro_export]
macro_rules! inner { ($x:identwhere $ ($rest : tt)*) => {}; }
fn main() {}
```
**after** (this branch):
```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pretty-mode:expanded
//@ pp-exact:macro-fragment-specifier-whitespace.pp
// Test that fragment specifier names in macro definitions are properly
// separated from the following keyword/identifier token when pretty-printed.
// This is a regression test for a bug where `$x:ident` followed by `where`
// was pretty-printed as `$x:identwhere` (an invalid fragment specifier).
macro_rules! outer {
($d:tt $($params:tt)*) =>
{
#[macro_export] macro_rules! inner
{ ($($params)* where $d($rest:tt)*) => {}; }
};
}
#[macro_export]
macro_rules! inner { ($x:ident where $ ($rest : tt)*) => {}; }
fn main() {}
```
Notice the `$x:identwhere` in the before — an invalid fragment specifier that causes a hard parse error. The after correctly separates it as `$x:ident where`.
Insert space after float literal ending with `.` in pretty printer
The pretty printer was collapsing unsuffixed float literals (like `0.`) with adjacent dot tokens, producing ambiguous or invalid output:
- `0. ..45.` (range) became `0...45.`
- `0. ..=360.` (inclusive range) became `0...=360.`
- `0. .to_string()` (method call) became `0..to_string()`
The fix inserts a space after an unsuffixed float literal ending with `.` when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following `.`, `..`, or `..=` token. This is skipped when the expression is already parenthesized, since the closing `)` naturally provides separation.
## Example
**before** (`rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)`):
```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pp-exact
fn main() {
let _ = 0...45.;
let _ = 0...=360.;
let _ = 0...;
let _ = 0..to_string();
}
```
**after** (this branch):
```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pp-exact
fn main() {
let _ = 0. ..45.;
let _ = 0. ..=360.;
let _ = 0. ..;
let _ = 0. .to_string();
}
```
Notice `0...45.` (ambiguous — looks like deprecated `...` inclusive range) becomes `0. ..45.` (clear: float `0.` followed by range `..`). Similarly `0..to_string()` (parsed as range) becomes `0. .to_string()` (method call on float).
Preserve braces around `self` in use tree pretty printing
The AST pretty printer strips braces from single-item `use` sub-groups, simplifying `use foo::{Bar}` to `use foo::Bar`. However, when the single item is `self`, this produces `use foo::self` which is not valid Rust (E0429) — the grammar requires `use foo::{self}`.
This affects both `stringify!` and `rustc -Zunpretty=expanded`, causing `cargo expand` output to be unparseable when a crate uses `use path::{self}` imports (a common pattern in the ecosystem).
The fix checks whether the single nested item's path starts with `self` before stripping braces. If so, the braces are preserved.
## Example
**before** (`rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)`):
```rust
#![feature(prelude_import)]
//@ pp-exact
//@ edition:2021
#![allow(unused_imports)]
extern crate std;
#[prelude_import]
use std::prelude::rust_2021::*;
// Braces around `self` must be preserved, because `use foo::self` is not valid Rust.
use std::io::self;
use std::fmt::{self, Debug};
fn main() {}
```
**after** (this branch):
```rust
#![feature(prelude_import)]
//@ pp-exact
//@ edition:2021
#![allow(unused_imports)]
extern crate std;
#[prelude_import]
use std::prelude::rust_2021::*;
// Braces around `self` must be preserved, because `use foo::self` is not valid Rust.
use std::io::{self};
use std::fmt::{self, Debug};
fn main() {}
```
Notice the `use std::io::self` (invalid, E0429) in the before becomes `use std::io::{self}` in the after.
tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`
After bisect it turns out that the test passes in `nightly-2023-09-24` but fails in `nightly-2023-09-23`:
$ rustc +nightly-2023-09-23 --edition 2018 tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs
error: `MutexGuard` held across a suspend point, but should not be
--> tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs:13:9
|
13 | let lock = foo.lock().unwrap();
| ^^^^
...
18 | bar().await;
| ----- the value is held across this suspend point
|
That leaves us with
<details>
<summary>git log e4133ba9b1a150..13e6f24b9adda67 --no-merges --oneline </summary>
bffb3467e1 Make test more robust to opts.
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR.
855a75b6d6 Remove useless wrapper.
baa64b0e77 Remove dead error code.
6aa1268900 Bless clippy.
d989e14cf2 Bless mir-opt
211d2ed07b Bless tests.
286502c9ed Enable drop_tracking_mir by default.
a626caaad9 Revert duplication of tests.
ff03204365 Fold lifetimes before substitution.
9450b75986 Do not construct def_path_str for MustNotSuspend.
58ef3a0ec9 diagnostics: simpler 83556 handling by bailing out
79d685325c Check types live across yields in generators too
c21867f9f6 Check that closure's by-value captures are sized
d3dea30cb4 Point at cause of expectation of `break` value when possible
4ed4913e67 Merge `ExternProviders` into the general `Providers` struct
2ba911c832 Have a single struct for queries and hook
9090ed8119 Fix test on targets with crt-static default
5db9a5ee38 Update cargo
9defc971f1 Add tracing instrumentation, just like queries automatically add it
2157f31731 Add a way to decouple the implementation and the declaration of a TyCtxt method.
d5ec9af09d Add test to guard against VecDeque optimization regression
3799af3337 diagnostics: avoid mismatch between variance index and hir generic
34c248d31f compiletest: load supports-xray from target spec
64e27cb4d9 compiletest: load supported sanitizers from target spec
bc7bb3c8e7 compiletest: use builder pattern to construct Config in tests
</details>
of which 286502c9ed (https://github.com/rust-lang/rust/pull/107421) seems most likely. I can't find an existing test except the "inactive" one, so let's simply activate it.
Closesrust-lang/rust#89562 which is where the activated test comes from. The test was originally added in rust-lang/rust#89826.
Tracking issue:
- rust-lang/rust#83310
Introduce #[diagnostic::on_move(message)]
cc rust-lang/rust#149862
This is a first proposal. I have deliberately kept it simpler than `diagnostic::on_unimplemented`.
Few questions/remarks:
- Do I need to move the OnMoveDirective logic into a dedicated module perhaps ? let's say into compiler/rustc_borrowck/src/diagnostics/on_move.rs
- No problems to depend on crates like `rustc_ast` from the borrowck ?
- Notes are not supported yet. While message and label are very static , in the sense that they are emitted in the same way from the same place in the borrowck, it is not the case for the notes. It would make the code more complex. But, I can add support for notes if it does make sense.
Suggestions are welcomed !
Don't emit rustdoc `missing_doc_code_examples` lint on impl items
@lolbinarycat realized in [this comment](https://github.com/rust-lang/rust/pull/153964#discussion_r2953956702) that we weren't testing some cases for the `missing_doc_code_examples` lint. Turns out that it was not handling this case well. =D
So in short: `missing_doc_code_examples` lint should not be emitted on impl items and this PR fixes that.
r? @lolbinarycat
`impl` restriction lowering
This PR is linked to a [GSoC proposal](https://github.com/rust-lang/google-summer-of-code?tab=readme-ov-file#implementing-impl-and-mut-restrictions) and is part of the progress toward implementing `impl` restrictions proposed in [RFC 3323](https://rust-lang.github.io/rfcs/3323-restrictions.html).
This PR implements path resolution for `impl` restrictions. The resolution is performed in `rustc_resolve/src/late.rs` using `smart_resolve_path`.
This PR also checks whether the restricted module or crate is an ancestor. If it is not, it emits a restriction-specific counterpart to visibility’s `AncestorOnly` error.
r? @Urgau
cc @jhpratt
sess: `-Zbranch-protection` is a target modifier
`-Zbranch-protection` only makes sense if the entire crate graph has the option set, otherwise the security properties that branch protection provides won't be effective - hence a target modifier. This flag is unstable so I don't think this warrants an MCP.
I suspect the original code had several issues. The last one that made
the code compile entered `nightly-2024-02-11`. The code fails to build
with `nightly-2024-02-10`:
$ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
--> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
|
31 | foo(async move | f: &u8 | { *f });
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
| |
| required by a bound introduced by this call
|
(Note that you must add `#![feature(async_closure)]` to test with such
old nightlies, since they are from before stabilization of async
closures.)
This was probably fixed by 3bb384aad6.
merge `regions-outlives-nominal-type-*` tests into one file
This is easily done since each of the individual files was already wrapped in a `mod`. Also, this removes the unneeded `rustc_attrs` usage from the tests.
simplify and remove `tests/ui/kindck` and related tests
kindck does not exist anymore since a long time now. This PR merges and deletes several redundant tests in that directory, reformats the rest and moves it to `ui/traits`.
Point at return type when it is the source of the type expectation
When calling an fn that returns a return type as a returned expression, point at the return type to explain that it affects the expected type.
```
error[E0308]: mismatched types
--> f56.rs:5:15
|
3 | fn main() {
| - the call expression's return type is influenced by this return type
4 | let a = 0;
5 | ptr::read(&a)
| --------- ^^ expected `*const ()`, found `&{integer}`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const ()`
found reference `&{integer}`
note: function defined here
--> library/core/src/ptr/mod.rs:1681:21
|
1681 | pub const unsafe fn read<T>(src: *const T) -> T {
| ^^^^
```
Fixrust-lang/rust#43608.
fix inference variables leaking into HIR const literal lowering logic
Inference variables could leak into further const lowering logic
It ICEs when query system tries to cache `lit_to_const()` after its execution and panics, because inference variables are not hashable for some reason
Fixesrust-lang/rust#153524Fixesrust-lang/rust#153525
Add hygiene annotations for tokens in `macro_rules!` bodies
`-Zunpretty=expanded,hygiene` was not printing syntax context annotations for identifiers and lifetimes inside `macro_rules!` bodies. These tokens are printed via `print_tt()` → `token_to_string_ext()`, which converts tokens to strings without calling `ann_post()`. This meant that macro-generated `macro_rules!` definitions with hygienic metavar parameters (e.g. multiple `$marg` distinguished only by hygiene) were printed with no way to tell them apart.
This was fixed by adding a match on `token.kind` in `print_tt()` to call `ann_post()` for `Ident`, `NtIdent`, `Lifetime`, and `NtLifetime` tokens, matching how `print_ident()` and `print_lifetime()` already handle AST-level identifiers and lifetimes.
The pretty printer was collapsing unsuffixed float literals (like `0.`)
with adjacent dot tokens, producing ambiguous or invalid output:
- `0. ..45.` (range) became `0...45.`
- `0. ..=360.` (inclusive range) became `0...=360.`
- `0. .to_string()` (method call) became `0..to_string()`
The fix inserts a space after an unsuffixed float literal ending with
`.` when it appears as the start expression of a range operator or the
receiver of a method call or field access, preventing the trailing dot
from merging with the following `.`, `..`, or `..=` token. This is
skipped when the expression is already parenthesized, since the closing
`)` naturally provides separation.
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
When a macro-generating-macro captures fragment specifier tokens (like
`$x:ident`) as `tt` metavariables and replays them before a keyword
(like `where`), the pretty printer concatenates them into an invalid
fragment specifier (e.g. `$x:identwhere` instead of `$x:ident where`).
This happens because `tt` captures preserve the original token spacing.
When the fragment specifier name (e.g. `ident`) was originally the last
token before a closing delimiter, it retains `JointHidden` spacing. The
`print_tts` function only checks `space_between` for `Spacing::Alone`
tokens, so `JointHidden` tokens skip the space check entirely, causing
adjacent identifier-like tokens to merge.
The fix adds a check in `print_tts` to insert a space between adjacent
identifier-like tokens (identifiers and keywords) regardless of the
original spacing, preventing them from being concatenated into invalid
tokens.
This is similar to the existing `space_between` mechanism that prevents
token merging for `Spacing::Alone` tokens, extended to also handle
`Joint`/`JointHidden` cases where two identifier-like tokens would merge.
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
The AST pretty printer strips braces from single-item `use` sub-groups,
simplifying `use foo::{Bar}` to `use foo::Bar`. However, when the single
item is `self`, this produces `use foo::self` which is not valid Rust
(E0429) — the grammar requires `use foo::{self}`.
This affects both `stringify!` and `rustc -Zunpretty=expanded`, causing
`cargo expand` output to be unparseable when a crate uses `use
path::{self}` imports (a common pattern in the ecosystem).
The fix checks whether the single nested item's path starts with `self`
before stripping braces. If so, the braces are preserved.
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
When calling an fn that returns a return type as a returned expression, point at the return type to explain that it affects the expected type.
```
error[E0308]: mismatched types
--> f56.rs:5:15
|
3 | fn main() {
| - the call expression's return type is influenced by this return type
4 | let a = 0;
5 | ptr::read(&a)
| --------- ^^ expected `*const ()`, found `&{integer}`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const ()`
found reference `&{integer}`
note: function defined here
--> library/core/src/ptr/mod.rs:1681:21
|
1681 | pub const unsafe fn read<T>(src: *const T) -> T {
| ^^^^
```
The test pass in `nightly-2023-09-24` but fail in `nightly-2023-09-23`:
$ rustc +nightly-2023-09-23 --edition 2018 tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs
error: `MutexGuard` held across a suspend point, but should not be
--> tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs:13:9
|
13 | let lock = foo.lock().unwrap();
| ^^^^
...
18 | bar().await;
| ----- the value is held across this suspend point
|
When encountering an inference error where a return type must be known, like when calling `Iterator::sum::<T>()` without specifying `T`, look for all `T` that would satisfy `Sum<S>`. If only one, suggest it.
```
error[E0283]: type annotations needed
--> $DIR/cannot-infer-iterator-sum-return-type.rs:4:9
|
LL | let sum = v
| ^^^
...
LL | .sum(); // `sum::<T>` needs `T` to be specified
| --- type must be known at this point
|
= note: cannot satisfy `_: Sum<i32>`
help: the trait `Sum` is implemented for `i32`
--> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
::: $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
|
= note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
= note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
|
LL | let sum: i32 = v
| +++++
```
Rollup of 3 pull requests
Successful merges:
- rust-lang/rust#153580 (Handle statics and TLS in raw-dylib for ELF)
- rust-lang/rust#154020 (Moved tests/ui/issues/issue-23891.rs to tests/ui/macros/)
- rust-lang/rust#154028 (Rename trait `IntoQueryParam` to `IntoQueryKey`)
Remove string content from panics
String content can be useful for debugging panics, particularly when you are working on a small codebase where you can infer more about the path taken through your program based on the content of the string.
In production deployments that upload crashes for centralized debugging, string content poses a risk to user privacy. The string can accidentally contain information that the user is not expecting to share with the development team.
On balance it seems like the risks outweigh the benefits. It is easy to add a `dbg!()` statement to gather more information in development; but comparatively tricky to ensure panics are sanitized by every rust app that monitors their production deployments.
Ref https://internals.rust-lang.org/t/stop-including-string-content-in-index-panics/24067
r? @scottmcm
Couple of driver interface improvements
* Pass Session to `make_codegen_backend` callback. This simplifies some code in miri.
* Move env/file_depinfo from ParseSess to Session. There is no reason it has to be in ParseSess rather than Session.
* Rename hash_untracked_state to track_state to indicate that it isn't just used for hashing state, but also for adding env vars and files to be tracked through the dep info file.