treat inductive cycles as ambig
We needed inductive cycles to be `NoSolution` for proper `ParamEnv` normalization. With rust-lang/rust#158643 this is no longer necessary, so lets make the stabilization of the new solver as small as possible.
r? types
librustdoc: remove stale dep on base64
This appears to have become unused in August 2025. I noticed today because of trying to consolidate versions of things in the toolchain.
Skip redundant storage-conflict updates during coroutine layout
## Summary
When computing coroutine storage conflicts, we currently record conflicts between every pair in the live set. This PR instead remembers the last live set whose conflicts were recorded; if the current set is a subset, we skip the matrix updates. For example, after recording `{a, b, c}`, observing `{a, b}` adds no new conflicts.
I used an LLM to profile this change, and saw a compiler CPU reduction in the following projects:
- Codex: 2.69%
- Ruff: 2.84%
- uv: 5.28%
- ty: 3.28%
Tiny cleanups to deferred liveness
As discussed on zulip, this is the first batch of a handful of tiny cleanups about deferred liveness:
- some renamings
- some simplifications
- some comments
r? @jackh726
Use wrapping arithmetic in `from_str_radix`
Uses wrapping arithmetic in the fast/unchecked loop of `from_str_radix`.
Originally this PR was written using unchecked arithmetic:
This generates identical assembly when compiling with `-O`: https://godbolt.org/z/Gvb7G9YEM
However, it significantly simplifies the asm of `-O -Coverflow-checks` (e.g. RfL): https://godbolt.org/z/Pah9fMfrd
More precisely, the `-O -Coverflow-checks` output becomes identical to the `-O` one: https://godbolt.org/z/WoYMThP8e
In conclusion, it makes more sense to use wrapping operations here.
macro_metavar_expr_concat: support concatenating into string literals
Usually if you want to concatenate string literals in macros you expand into some combination of concat! and stringify! invocations. However this does not work in nested MetaItems, since those are never expanded (unlike `#[path = EXPR]` attributes like `#[doc = include_str!("README.md")]`.
This PR adds support for that using `${concat_str(...)}`, similar to `${concat(...)}`. It is unstable under the same `macro_metavar_expr_concat` feature. See the tests in this PR for examples.
My motivation for adding this is that I've seen (and had myself) some cases where this would have been really useful. Thus I'd like to add this experimentally.
stabilize `Box::take`
Tracking issue: rust-lang/rust#147212
There hasn't been any activity on the tracking issue for a while, and this is a pretty small feature, so opening this to hopefully get a FCP started.
Closes: rust-lang/rust#147212
Detect missing else in let statement
Fixesrust-lang/rust#135857
I add the help message in rustc_resolve. It now will display something like this:
```rust
error: expected identifier, found keyword `return`
--> ./test.rs:8:24
|
8 | let Some(a) = bar{return;};
| --- ^^^^^^ expected identifier, found keyword
| |
| while parsing this struct
|
help: escape `return` to use it as an identifier
|
8 | let Some(a) = bar{r#return;};
| ++
error[E0574]: expected struct, variant or union type, found local variable `bar`
--> ./test.rs:8:20
|
8 | let Some(a) = bar{return;};
| ^^^ not a struct, variant or union type
|
help: try adding `else` here:
|
8 | let Some(a) = bar else {return;};
| ++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0574`.
```
r? estebank
feat(time): add `Duration::{WEEK, DAY, HOUR, MINUTE}`
- Tracking issue: rust-lang/rust#57391
This pull request adds associated constants for representing one week, one day, one hour, or one minute to `Duration`.
In the same way as rust-lang/rust#162195 and rust-lang/rust#162199, the exact number of seconds corresponding to one week, one day, one hour, and one minute are clearly specified in the documentation. Documentation tests are used to verify the correctness of these descriptions.
I initially proposed this as an ACP. However, the `duration_constants` feature is still unstable, and the ACP simply adds associated constants for units larger than the second to the feature, I determined that it could be incorporated into the feature.
By making `Duration::WEEK` and `Duration::DAY` dependent on the `duration_constructors` feature, these associated constants can be removed if `Duration::from_weeks` and `Duration::from_days` are not stabilized. Therefore, even if the `duration_constructors` feature is not stabilized, the `duration_constants` feature can be stabilized.
```rust
impl Duration {
pub const WEEK: Duration = Duration::from_weeks(1);
pub const DAY: Duration = Duration::from_days(1);
pub const HOUR: Duration = Duration::from_hours(1);
pub const MINUTE: Duration = Duration::from_mins(1);
}
```
- See also: rust-lang/libs-team#869
powerpc64-ibm-aix: fix cfg(target_abi) value
Our powerpc64-ibm-aix target currently sets `cfg_abi` to "vec-extabi", which means that programs compiled for this target *think* they use that ABI. Even our inline asm logic trusts this field. But that's a lie, we're actually using the default ABI since we are never setting `EnableAIXExtendedAltivecABI` on the LLVM side. We should fix that discrepancy.
Between changing how we generate the code, and changing the label we put into `cfg_abi`, the latter is the less risky change. So let's do that.
This has been tried before in https://github.com/rust-lang/rust/pull/153830. We then decided to wait a bit while the target maintainers investigate whether they want to change the ABI or not. I think we have waited long enough. The last comment from them that I found is [this one](https://github.com/rust-lang/rust/issues/153876#issuecomment-4101480953) which says "I'd conclude the extend vector ABI should be disabled for now"; there have been further questions but no further communication. We can always still change the ABI in the future, but for now let's fix the obvious bug where the ABI we report in `cfg_abi` does not match the actual ABI we are compiling for.
Cc @Gelbpunkt @daltenty @gilamn5tr @amy-kwan @taiki-e
constify comparison traits on sliced types
Constify comparison traits for `str`, `CStr`, `ByteStr`, and `Location`.
The slice comparison traits originally included here have since landed independently, so this update drops that already-merged commit and rebases the remaining constifications.
r? clarfonthey
Tracking issue rust-lang/rust#143800
Move `Const` from `rustc_middle` to `rustc_type_ir`
Split by commit;
- Firstly move the type and methods
- From `I::Const` -> `Const<I>`
- Import `ConstExt` in all places that require the extension trait methods in compiler
- Import `ConstExt` in all places that require the extension trait methods in clippy
r? @lcnr
Clean up diagnostic hashing
`DiagInner` impls `PartialEq` and `Hash`, as you'd expect for storing it in a hash table. But there's a couple of strange things.
- We only store the hash value of the `DiagInner` to do deduplication, not the `DiagInner` itself, which means the `PartialEq` impl is unused.
- The `Hash` impl only considers some of the fields. Some of the ignored fields are clearly deliberate (there are comments) but for some it is unclear if it is deliberate.
This commit:
- Removes the unused `PartialEq` impl.
- Inlines and removes `keys` now that it's not needed for `PartialEq`.
- Uses struct deconstruction to ensure no fields can be accidentally ignored. I have preserved existing behaviour by assuming that all the ignored fields are supposed to be ignored.
- Renames `hash` as an inherent method `dedup_hash` to indicate that it's not a typical hash function, and simplifies it to just return `Hash128` instead of being generic.
- Replaces the unnecessary `collect` on `args` with `as_slice`.
- Improves the comment on `emitted_diagnostics`.
r? @oli-obk
emit the constant pattern note for raw identifier bindings
`is_const_pat_that_looks_like_binding` matched the pattern snippet against a plain identifier so the `#` in `let r#x = 0` rejected it and the binding lost both the label pointing at `const x` and the `introduce a variable instead` suggestion. strip a leading `r#` before the check and render the const name with `to_ident_string` in the label so a keyword name prints as `r#fn`.
fixes https://github.com/rust-lang/rust/issues/162949
r? @oli-obk
remove unnecessary restriction with next-solver
We previously FCP'd to forbid uses of opaque types which only differ in their lifetime arguments during MIR borrowck in https://github.com/rust-lang/rust/pull/116935#issuecomment-1807243974. This actually did not end up being necessary after all. Will explain this a bit more in the stabilization documentation for the new solver
r? types
Check tainted_by_error in LateLint
## Context
This PR continues from https://github.com/rust-lang/rust/pull/138679#discussion_r2436522856.
In the last PR, I introduced typeck result's tainted_by_error in check_pat. But as we've discussed, I should put the check to a better place which all lints get benefit from the check.
## Change
Since visit_nested_body in late.rs is the starting point of late lint for a nested body, I moved the error check to the function.
I also rename one ui test case which I introduced in the last PR. I think the new name describes what the test wants to check more.
This PR fixesrust-lang/rust#138361 .
Note that we need to use actually_rustdoc to call typeck_body() in visit_nested_body. Otherwise rustdoc returns an error. However, as its comment describes we shouldn't use actually_rustdoc if there is an alternative solution. So far I only come up with using actually_rustdoc (this change), or checking tainted_by_error in each check_xxx functions (e.g., check on check_pat in rust-lang/rust#138679, and on check_expr for rust-lang/rust#138361).