Skip to content

Commit 48b325f

Browse files
authored
Merge branch 'master' into km/optimize-slice-index/v3
2 parents a61fde0 + ffb9d94 commit 48b325f

File tree

1,163 files changed

+18059
-14444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,163 files changed

+18059
-14444
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
568568

569569
[[package]]
570570
name = "clippy"
571-
version = "0.1.90"
571+
version = "0.1.91"
572572
dependencies = [
573573
"anstream",
574574
"askama",
@@ -595,7 +595,7 @@ dependencies = [
595595

596596
[[package]]
597597
name = "clippy_config"
598-
version = "0.1.90"
598+
version = "0.1.91"
599599
dependencies = [
600600
"clippy_utils",
601601
"itertools",
@@ -618,7 +618,7 @@ dependencies = [
618618

619619
[[package]]
620620
name = "clippy_lints"
621-
version = "0.1.90"
621+
version = "0.1.91"
622622
dependencies = [
623623
"arrayvec",
624624
"cargo_metadata 0.18.1",
@@ -649,7 +649,7 @@ dependencies = [
649649

650650
[[package]]
651651
name = "clippy_utils"
652-
version = "0.1.90"
652+
version = "0.1.91"
653653
dependencies = [
654654
"arrayvec",
655655
"itertools",
@@ -1051,7 +1051,7 @@ dependencies = [
10511051

10521052
[[package]]
10531053
name = "declare_clippy_lint"
1054-
version = "0.1.90"
1054+
version = "0.1.91"
10551055

10561056
[[package]]
10571057
name = "derive-where"

RELEASES.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,140 @@
1+
Version 1.89.0 (2025-08-07)
2+
==========================
3+
4+
<a id="1.89.0-Language"></a>
5+
6+
Language
7+
--------
8+
- [Stabilize explicitly inferred const arguments (`feature(generic_arg_infer)`)](https://github.com/rust-lang/rust/pull/141610)
9+
- [Add a warn-by-default `mismatched_lifetime_syntaxes` lint.](https://github.com/rust-lang/rust/pull/138677)
10+
This lint detects when the same lifetime is referred to by different syntax categories between function arguments and return values, which can be confusing to read, especially in unsafe code.
11+
This lint supersedes the warn-by-default `elided_named_lifetimes` lint.
12+
- [Expand `unpredictable_function_pointer_comparisons` to also lint on function pointer comparisons in external macros](https://github.com/rust-lang/rust/pull/134536)
13+
- [Make the `dangerous_implicit_autorefs` lint deny-by-default](https://github.com/rust-lang/rust/pull/141661)
14+
- [Stabilize the avx512 target features](https://github.com/rust-lang/rust/pull/138940)
15+
- [Stabilize `kl` and `widekl` target features for x86](https://github.com/rust-lang/rust/pull/140766)
16+
- [Stabilize `sha512`, `sm3` and `sm4` target features for x86](https://github.com/rust-lang/rust/pull/140767)
17+
- [Stabilize LoongArch target features `f`, `d`, `frecipe`, `lasx`, `lbt`, `lsx`, and `lvz`](https://github.com/rust-lang/rust/pull/135015)
18+
- [Remove `i128` and `u128` from `improper_ctypes_definitions`](https://github.com/rust-lang/rust/pull/137306)
19+
- [Stabilize `repr128` (`#[repr(u128)]`, `#[repr(i128)]`)](https://github.com/rust-lang/rust/pull/138285)
20+
- [Allow `#![doc(test(attr(..)))]` everywhere](https://github.com/rust-lang/rust/pull/140560)
21+
- [Extend temporary lifetime extension to also go through tuple struct and tuple variant constructors](https://github.com/rust-lang/rust/pull/140593)
22+
- [`extern "C"` functions on the `wasm32-unknown-unknown` target now have a standards compliant ABI](https://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm32-unknown-unknown/)
23+
24+
<a id="1.89.0-Compiler"></a>
25+
26+
Compiler
27+
--------
28+
- [Default to non-leaf frame pointers on aarch64-linux](https://github.com/rust-lang/rust/pull/140832)
29+
- [Enable non-leaf frame pointers for Arm64EC Windows](https://github.com/rust-lang/rust/pull/140862)
30+
- [Set Apple frame pointers by architecture](https://github.com/rust-lang/rust/pull/141797)
31+
32+
33+
<a id="1.89.0-Platform-Support"></a>
34+
35+
Platform Support
36+
----------------
37+
- [Add new Tier-3 targets `loongarch32-unknown-none` and `loongarch32-unknown-none-softfloat`](https://github.com/rust-lang/rust/pull/142053)
38+
- [`x86_64-apple-darwin` is in the process of being demoted to Tier 2 with host tools](https://github.com/rust-lang/rfcs/pull/3841)
39+
40+
Refer to Rust's [platform support page][platform-support-doc]
41+
for more information on Rust's tiered platform support.
42+
43+
[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html
44+
45+
<a id="1.89.0-Libraries"></a>
46+
47+
Libraries
48+
---------
49+
- [Specify the base path for `file!`](https://github.com/rust-lang/rust/pull/134442)
50+
- [Allow storing `format_args!()` in a variable](https://github.com/rust-lang/rust/pull/140748)
51+
- [Add `#[must_use]` to `[T; N]::map`](https://github.com/rust-lang/rust/pull/140957)
52+
- [Implement `DerefMut` for `Lazy{Cell,Lock}`](https://github.com/rust-lang/rust/pull/129334)
53+
- [Implement `Default` for `array::IntoIter`](https://github.com/rust-lang/rust/pull/141574)
54+
- [Implement `Clone` for `slice::ChunkBy`](https://github.com/rust-lang/rust/pull/138016)
55+
- [Implement `io::Seek` for `io::Take`](https://github.com/rust-lang/rust/pull/138023)
56+
57+
58+
<a id="1.89.0-Stabilized-APIs"></a>
59+
60+
Stabilized APIs
61+
---------------
62+
63+
- [`NonZero<char>`](https://doc.rust-lang.org/stable/std/num/struct.NonZero.html)
64+
- Many intrinsics for x86, not enumerated here
65+
- [AVX512 intrinsics](https://github.com/rust-lang/rust/issues/111137)
66+
- [`SHA512`, `SM3` and `SM4` intrinsics](https://github.com/rust-lang/rust/issues/126624)
67+
- [`File::lock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.lock)
68+
- [`File::lock_shared`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.lock_shared)
69+
- [`File::try_lock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.try_lock)
70+
- [`File::try_lock_shared`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.try_lock_shared)
71+
- [`File::unlock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.unlock)
72+
- [`NonNull::from_ref`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.from_ref)
73+
- [`NonNull::from_mut`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.from_mut)
74+
- [`NonNull::without_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.without_provenance)
75+
- [`NonNull::with_exposed_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.with_exposed_provenance)
76+
- [`NonNull::expose_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.expose_provenance)
77+
- [`OsString::leak`](https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.leak)
78+
- [`PathBuf::leak`](https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#method.leak)
79+
- [`Result::flatten`](https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.flatten)
80+
- [`std::os::linux::net::TcpStreamExt::quickack`](https://doc.rust-lang.org/stable/std/os/linux/net/trait.TcpStreamExt.html#tymethod.quickack)
81+
- [`std::os::linux::net::TcpStreamExt::set_quickack`](https://doc.rust-lang.org/stable/std/os/linux/net/trait.TcpStreamExt.html#tymethod.set_quickack)
82+
83+
These previously stable APIs are now stable in const contexts:
84+
85+
- [`<[T; N]>::as_mut_slice`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.as_mut_slice)
86+
- [`<[u8]>::eq_ignore_ascii_case`](https://doc.rust-lang.org/stable/std/primitive.slice.html#impl-%5Bu8%5D/method.eq_ignore_ascii_case)
87+
- [`str::eq_ignore_ascii_case`](https://doc.rust-lang.org/stable/std/primitive.str.html#impl-str/method.eq_ignore_ascii_case)
88+
89+
90+
<a id="1.89.0-Cargo"></a>
91+
92+
Cargo
93+
-----
94+
- [`cargo fix` and `cargo clippy --fix` now default to the same Cargo target selection as other build commands.](https://github.com/rust-lang/cargo/pull/15192/) Previously it would apply to all targets (like binaries, examples, tests, etc.). The `--edition` flag still applies to all targets.
95+
- [Stabilize doctest-xcompile.](https://github.com/rust-lang/cargo/pull/15462/) Doctests are now tested when cross-compiling. Just like other tests, it will use the [`runner` setting](https://doc.rust-lang.org/cargo/reference/config.html#targettriplerunner) to run the tests. If you need to disable tests for a target, you can use the [ignore doctest attribute](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#ignoring-targets) to specify the targets to ignore.
96+
97+
98+
<a id="1.89.0-Rustdoc"></a>
99+
100+
Rustdoc
101+
-----
102+
- [On mobile, make the sidebar full width and linewrap](https://github.com/rust-lang/rust/pull/139831). This makes long section and item names much easier to deal with on mobile.
103+
104+
105+
<a id="1.89.0-Compatibility-Notes"></a>
106+
107+
Compatibility Notes
108+
-------------------
109+
- [Make `missing_fragment_specifier` an unconditional error](https://github.com/rust-lang/rust/pull/128425)
110+
- [Enabling the `neon` target feature on `aarch64-unknown-none-softfloat` causes a warning](https://github.com/rust-lang/rust/pull/135160) because mixing code with and without that target feature is not properly supported by LLVM
111+
- [Sized Hierarchy: Part I](https://github.com/rust-lang/rust/pull/137944)
112+
- Introduces a small breaking change affecting `?Sized` bounds on impls on recursive types which contain associated type projections. It is not expected to affect any existing published crates. Can be fixed by refactoring the involved types or opting into the `sized_hierarchy` unstable feature. See the [FCP report](https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485) for a code example.
113+
- The warn-by-default `elided_named_lifetimes` lint is [superseded by the warn-by-default `mismatched_lifetime_syntaxes` lint.](https://github.com/rust-lang/rust/pull/138677)
114+
- [Error on recursive opaque types earlier in the type checker](https://github.com/rust-lang/rust/pull/139419)
115+
- [Type inference side effects from requiring element types of array repeat expressions are `Copy` are now only available at the end of type checking](https://github.com/rust-lang/rust/pull/139635)
116+
- [The deprecated accidentally-stable `std::intrinsics::{copy,copy_nonoverlapping,write_bytes}` are now proper intrinsics](https://github.com/rust-lang/rust/pull/139916). There are no debug assertions guarding against UB, and they cannot be coerced to function pointers.
117+
- [Remove long-deprecated `std::intrinsics::drop_in_place`](https://github.com/rust-lang/rust/pull/140151)
118+
- [Make well-formedness predicates no longer coinductive](https://github.com/rust-lang/rust/pull/140208)
119+
- [Remove hack when checking impl method compatibility](https://github.com/rust-lang/rust/pull/140557)
120+
- [Remove unnecessary type inference due to built-in trait object impls](https://github.com/rust-lang/rust/pull/141352)
121+
- [Lint against "stdcall", "fastcall", and "cdecl" on non-x86-32 targets](https://github.com/rust-lang/rust/pull/141435)
122+
- [Future incompatibility warnings relating to the never type (`!`) are now reported in dependencies](https://github.com/rust-lang/rust/pull/141937)
123+
- [Ensure `std::ptr::copy_*` intrinsics also perform the static self-init checks](https://github.com/rust-lang/rust/pull/142575)
124+
- [`extern "C"` functions on the `wasm32-unknown-unknown` target now have a standards compliant ABI](https://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm32-unknown-unknown/)
125+
126+
<a id="1.89.0-Internal-Changes"></a>
127+
128+
Internal Changes
129+
----------------
130+
131+
These changes do not affect any public interfaces of Rust, but they represent
132+
significant improvements to the performance or internals of rustc and related
133+
tools.
134+
135+
- [Correctly un-remap compiler sources paths with the `rustc-dev` component](https://github.com/rust-lang/rust/pull/142377)
136+
137+
1138
Version 1.88.0 (2025-06-26)
2139
==========================
3140

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
9898
}
9999

100100
let expr_hir_id = self.lower_node_id(e.id);
101-
self.lower_attrs(expr_hir_id, &e.attrs, e.span);
101+
let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span);
102102

103103
let kind = match &e.kind {
104104
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
@@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
232232
*fn_arg_span,
233233
),
234234
None => self.lower_expr_closure(
235+
attrs,
235236
binder,
236237
*capture_clause,
237238
e.id,
238-
expr_hir_id,
239239
*constness,
240240
*movability,
241241
fn_decl,
@@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
10521052

10531053
fn lower_expr_closure(
10541054
&mut self,
1055+
attrs: &[rustc_hir::Attribute],
10551056
binder: &ClosureBinder,
10561057
capture_clause: CaptureBy,
10571058
closure_id: NodeId,
1058-
closure_hir_id: hir::HirId,
10591059
constness: Const,
10601060
movability: Movability,
10611061
decl: &FnDecl,
@@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
10671067
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
10681068

10691069
let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
1070-
let mut coroutine_kind = if this
1071-
.attrs
1072-
.get(&closure_hir_id.local_id)
1073-
.is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
1074-
{
1075-
Some(hir::CoroutineKind::Coroutine(Movability::Movable))
1076-
} else {
1077-
None
1078-
};
1070+
1071+
let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
1072+
10791073
// FIXME(contracts): Support contracts on closures?
10801074
let body_id = this.lower_fn_body(decl, None, |this| {
10811075
this.coroutine_kind = coroutine_kind;

compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ast_passes_auto_generic = auto traits cannot have generic parameters
4040
4141
ast_passes_auto_items = auto traits cannot have associated items
4242
.label = {ast_passes_auto_items}
43-
.suggestion = remove these associated items
43+
.suggestion = remove the associated items
4444
4545
ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetime bounds
4646
.label = {ast_passes_auto_super_lifetime}

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,19 +699,23 @@ impl<'a> AstValidator<'a> {
699699
}
700700
}
701701

702-
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
702+
fn deny_super_traits(&self, bounds: &GenericBounds, ident: Span) {
703703
if let [.., last] = &bounds[..] {
704-
let span = ident_span.shrink_to_hi().to(last.span());
705-
self.dcx().emit_err(errors::AutoTraitBounds { span, ident: ident_span });
704+
let span = bounds.iter().map(|b| b.span()).collect();
705+
let removal = ident.shrink_to_hi().to(last.span());
706+
self.dcx().emit_err(errors::AutoTraitBounds { span, removal, ident });
706707
}
707708
}
708709

709-
fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) {
710+
fn deny_where_clause(&self, where_clause: &WhereClause, ident: Span) {
710711
if !where_clause.predicates.is_empty() {
711712
// FIXME: The current diagnostic is misleading since it only talks about
712713
// super trait and lifetime bounds while we should just say “bounds”.
713-
self.dcx()
714-
.emit_err(errors::AutoTraitBounds { span: where_clause.span, ident: ident_span });
714+
self.dcx().emit_err(errors::AutoTraitBounds {
715+
span: vec![where_clause.span],
716+
removal: where_clause.span,
717+
ident,
718+
});
715719
}
716720
}
717721

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub(crate) struct ModuleNonAscii {
344344
#[diag(ast_passes_auto_generic, code = E0567)]
345345
pub(crate) struct AutoTraitGeneric {
346346
#[primary_span]
347-
#[suggestion(code = "", applicability = "machine-applicable")]
347+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
348348
pub span: Span,
349349
#[label]
350350
pub ident: Span,
@@ -354,8 +354,9 @@ pub(crate) struct AutoTraitGeneric {
354354
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
355355
pub(crate) struct AutoTraitBounds {
356356
#[primary_span]
357-
#[suggestion(code = "", applicability = "machine-applicable")]
358-
pub span: Span,
357+
pub span: Vec<Span>,
358+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
359+
pub removal: Span,
359360
#[label]
360361
pub ident: Span,
361362
}
@@ -365,7 +366,7 @@ pub(crate) struct AutoTraitBounds {
365366
pub(crate) struct AutoTraitItems {
366367
#[primary_span]
367368
pub spans: Vec<Span>,
368-
#[suggestion(code = "", applicability = "machine-applicable")]
369+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
369370
pub total: Span,
370371
#[label]
371372
pub ident: Span,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Attributes that can be found in function body.
2+
3+
use rustc_hir::attrs::AttributeKind;
4+
use rustc_span::{Symbol, sym};
5+
6+
use super::{NoArgsAttributeParser, OnDuplicate};
7+
use crate::context::Stage;
8+
9+
pub(crate) struct CoroutineParser;
10+
11+
impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
12+
const PATH: &[Symbol] = &[sym::coroutine];
13+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
14+
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);
15+
}

compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,11 @@ impl<S: Stage> AttributeParser<S> for MacroUseParser {
113113
Some(AttributeKind::MacroUse { span: self.first_span?, arguments: self.state })
114114
}
115115
}
116+
117+
pub(crate) struct AllowInternalUnsafeParser;
118+
119+
impl<S: Stage> NoArgsAttributeParser<S> for AllowInternalUnsafeParser {
120+
const PATH: &[Symbol] = &[sym::allow_internal_unsafe];
121+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
122+
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::AllowInternalUnsafe(span);
123+
}

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::parser::ArgParser;
2626
use crate::session_diagnostics::UnusedMultiple;
2727

2828
pub(crate) mod allow_unstable;
29+
pub(crate) mod body;
2930
pub(crate) mod cfg;
3031
pub(crate) mod cfg_old;
3132
pub(crate) mod codegen_attrs;

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,55 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
4444
})
4545
}
4646
}
47+
48+
pub(crate) struct ShouldPanicParser;
49+
50+
impl<S: Stage> SingleAttributeParser<S> for ShouldPanicParser {
51+
const PATH: &[Symbol] = &[sym::should_panic];
52+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
53+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
54+
const TEMPLATE: AttributeTemplate =
55+
template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason");
56+
57+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
58+
Some(AttributeKind::ShouldPanic {
59+
span: cx.attr_span,
60+
reason: match args {
61+
ArgParser::NoArgs => None,
62+
ArgParser::NameValue(name_value) => {
63+
let Some(str_value) = name_value.value_as_str() else {
64+
cx.expected_string_literal(
65+
name_value.value_span,
66+
Some(name_value.value_as_lit()),
67+
);
68+
return None;
69+
};
70+
Some(str_value)
71+
}
72+
ArgParser::List(list) => {
73+
let Some(single) = list.single() else {
74+
cx.expected_single_argument(list.span);
75+
return None;
76+
};
77+
let Some(single) = single.meta_item() else {
78+
cx.expected_name_value(single.span(), Some(sym::expected));
79+
return None;
80+
};
81+
if !single.path().word_is(sym::expected) {
82+
cx.expected_specific_argument_strings(list.span, vec!["expected"]);
83+
return None;
84+
}
85+
let Some(nv) = single.args().name_value() else {
86+
cx.expected_name_value(single.span(), Some(sym::expected));
87+
return None;
88+
};
89+
let Some(expected) = nv.value_as_str() else {
90+
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
91+
return None;
92+
};
93+
Some(expected)
94+
}
95+
},
96+
})
97+
}
98+
}

0 commit comments

Comments
 (0)