Skip to content

Commit b9dc4a3

Browse files
committed
Auto merge of #130919 - workingjubilee:rollup-4diycoy, r=workingjubilee
Rollup of 8 pull requests Successful merges: - #130313 ([`cfg_match`] Generalize inputs) - #130706 ([rustdoc] Remove unneeded jinja comments) - #130846 (Revert Break into the debugger on panic (129019)) - #130875 (update `compiler-builtins` to 0.1.126) - #130889 (Weekly `cargo update`: only `rustbook`) - #130892 (Partially update `library/Cargo.lock`) - #130911 (diagnostics: wrap fn cast suggestions in parens when needed) - #130912 (On implicit `Sized` bound on fn argument, point at type instead of pattern) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 58420a0 + b463bd1 commit b9dc4a3

File tree

61 files changed

+626
-603
lines changed

Some content is hidden

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

61 files changed

+626
-603
lines changed

compiler/rustc_hir_typeck/src/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub(super) fn check_fn<'a, 'tcx>(
9999
if !params_can_be_unsized {
100100
fcx.require_type_is_sized(
101101
param_ty,
102-
param.pat.span,
102+
param.ty_span,
103103
// ty.span == binding_span iff this is a closure parameter with no type ascription,
104104
// or if it's an implicit `self` parameter
105105
ObligationCauseCode::SizedArgumentType(

compiler/rustc_hir_typeck/src/gather_locals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
144144
if !self.fcx.tcx.features().unsized_fn_params {
145145
self.fcx.require_type_is_sized(
146146
var_ty,
147-
p.span,
147+
ty_span,
148148
// ty_span == ident.span iff this is a closure parameter with no type
149149
// ascription, or if it's an implicit `self` parameter
150150
ObligationCauseCode::SizedArgumentType(

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+25-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use tracing::{debug, instrument};
3333
use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
3434
use super::suggestions::get_explanation_based_on_obligation;
3535
use super::{
36-
ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate, UnsatisfiedConst,
36+
ArgKind, CandidateSimilarity, FindExprBySpan, GetSafeTransmuteErrorAndReason, ImplCandidate,
37+
UnsatisfiedConst,
3738
};
3839
use crate::error_reporting::TypeErrCtxt;
3940
use crate::error_reporting::infer::TyCategory;
@@ -378,14 +379,34 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
378379
if let (ty::FnPtr(..), ty::FnDef(..)) =
379380
(cand.self_ty().kind(), main_trait_ref.self_ty().skip_binder().kind())
380381
{
381-
err.span_suggestion(
382-
span.shrink_to_hi(),
382+
// Wrap method receivers and `&`-references in parens
383+
let suggestion = if self.tcx.sess.source_map().span_look_ahead(span, ".", Some(50)).is_some() {
384+
vec![
385+
(span.shrink_to_lo(), format!("(")),
386+
(span.shrink_to_hi(), format!(" as {})", cand.self_ty())),
387+
]
388+
} else if let Some(body) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) {
389+
let mut expr_finder = FindExprBySpan::new(span, self.tcx);
390+
expr_finder.visit_expr(body.value);
391+
if let Some(expr) = expr_finder.result &&
392+
let hir::ExprKind::AddrOf(_, _, expr) = expr.kind {
393+
vec![
394+
(expr.span.shrink_to_lo(), format!("(")),
395+
(expr.span.shrink_to_hi(), format!(" as {})", cand.self_ty())),
396+
]
397+
} else {
398+
vec![(span.shrink_to_hi(), format!(" as {}", cand.self_ty()))]
399+
}
400+
} else {
401+
vec![(span.shrink_to_hi(), format!(" as {}", cand.self_ty()))]
402+
};
403+
err.multipart_suggestion(
383404
format!(
384405
"the trait `{}` is implemented for fn pointer `{}`, try casting using `as`",
385406
cand.print_trait_sugared(),
386407
cand.self_ty(),
387408
),
388-
format!(" as {}", cand.self_ty()),
409+
suggestion,
389410
Applicability::MaybeIncorrect,
390411
);
391412
true

library/Cargo.lock

+34-34
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ dependencies = [
5858

5959
[[package]]
6060
name = "compiler_builtins"
61-
version = "0.1.125"
61+
version = "0.1.126"
6262
source = "registry+https://github.com/rust-lang/crates.io-index"
63-
checksum = "bd02a01d7bc069bed818e956600fe437ee222dd1d6ad92bfb9db87b43b71fd87"
63+
checksum = "758019257ad46e191b587d8f711022a6ac1d1fb6745d75e1d76c587fdcbca770"
6464
dependencies = [
6565
"cc",
6666
"rustc-std-workspace-core",
@@ -110,9 +110,9 @@ dependencies = [
110110

111111
[[package]]
112112
name = "gimli"
113-
version = "0.28.1"
113+
version = "0.29.0"
114114
source = "registry+https://github.com/rust-lang/crates.io-index"
115-
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
115+
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
116116
dependencies = [
117117
"compiler_builtins",
118118
"rustc-std-workspace-alloc",
@@ -121,9 +121,9 @@ dependencies = [
121121

122122
[[package]]
123123
name = "gimli"
124-
version = "0.29.0"
124+
version = "0.30.0"
125125
source = "registry+https://github.com/rust-lang/crates.io-index"
126-
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
126+
checksum = "e2e1d97fbe9722ba9bbd0c97051c2956e726562b61f86a25a4360398a40edfc9"
127127
dependencies = [
128128
"compiler_builtins",
129129
"rustc-std-workspace-alloc",
@@ -155,9 +155,9 @@ dependencies = [
155155

156156
[[package]]
157157
name = "libc"
158-
version = "0.2.158"
158+
version = "0.2.159"
159159
source = "registry+https://github.com/rust-lang/crates.io-index"
160-
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
160+
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
161161
dependencies = [
162162
"rustc-std-workspace-core",
163163
]
@@ -186,9 +186,9 @@ dependencies = [
186186

187187
[[package]]
188188
name = "object"
189-
version = "0.36.2"
189+
version = "0.36.4"
190190
source = "registry+https://github.com/rust-lang/crates.io-index"
191-
checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e"
191+
checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a"
192192
dependencies = [
193193
"compiler_builtins",
194194
"memchr",
@@ -375,9 +375,9 @@ dependencies = [
375375

376376
[[package]]
377377
name = "unicode-width"
378-
version = "0.1.13"
378+
version = "0.1.14"
379379
source = "registry+https://github.com/rust-lang/crates.io-index"
380-
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
380+
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
381381
dependencies = [
382382
"compiler_builtins",
383383
"rustc-std-workspace-core",
@@ -397,12 +397,12 @@ dependencies = [
397397

398398
[[package]]
399399
name = "unwinding"
400-
version = "0.2.1"
400+
version = "0.2.2"
401401
source = "registry+https://github.com/rust-lang/crates.io-index"
402-
checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b"
402+
checksum = "dc55842d0db6329a669d55a623c674b02d677b16bfb2d24857d4089d41eba882"
403403
dependencies = [
404404
"compiler_builtins",
405-
"gimli 0.28.1",
405+
"gimli 0.30.0",
406406
"rustc-std-workspace-core",
407407
]
408408

@@ -423,7 +423,7 @@ version = "0.52.0"
423423
source = "registry+https://github.com/rust-lang/crates.io-index"
424424
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
425425
dependencies = [
426-
"windows-targets 0.52.5",
426+
"windows-targets 0.52.6",
427427
]
428428

429429
[[package]]
@@ -432,9 +432,9 @@ version = "0.0.0"
432432

433433
[[package]]
434434
name = "windows-targets"
435-
version = "0.52.5"
435+
version = "0.52.6"
436436
source = "registry+https://github.com/rust-lang/crates.io-index"
437-
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
437+
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
438438
dependencies = [
439439
"windows_aarch64_gnullvm",
440440
"windows_aarch64_msvc",
@@ -448,48 +448,48 @@ dependencies = [
448448

449449
[[package]]
450450
name = "windows_aarch64_gnullvm"
451-
version = "0.52.5"
451+
version = "0.52.6"
452452
source = "registry+https://github.com/rust-lang/crates.io-index"
453-
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
453+
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
454454

455455
[[package]]
456456
name = "windows_aarch64_msvc"
457-
version = "0.52.5"
457+
version = "0.52.6"
458458
source = "registry+https://github.com/rust-lang/crates.io-index"
459-
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
459+
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
460460

461461
[[package]]
462462
name = "windows_i686_gnu"
463-
version = "0.52.5"
463+
version = "0.52.6"
464464
source = "registry+https://github.com/rust-lang/crates.io-index"
465-
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
465+
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
466466

467467
[[package]]
468468
name = "windows_i686_gnullvm"
469-
version = "0.52.5"
469+
version = "0.52.6"
470470
source = "registry+https://github.com/rust-lang/crates.io-index"
471-
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
471+
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
472472

473473
[[package]]
474474
name = "windows_i686_msvc"
475-
version = "0.52.5"
475+
version = "0.52.6"
476476
source = "registry+https://github.com/rust-lang/crates.io-index"
477-
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
477+
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
478478

479479
[[package]]
480480
name = "windows_x86_64_gnu"
481-
version = "0.52.5"
481+
version = "0.52.6"
482482
source = "registry+https://github.com/rust-lang/crates.io-index"
483-
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
483+
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
484484

485485
[[package]]
486486
name = "windows_x86_64_gnullvm"
487-
version = "0.52.5"
487+
version = "0.52.6"
488488
source = "registry+https://github.com/rust-lang/crates.io-index"
489-
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
489+
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
490490

491491
[[package]]
492492
name = "windows_x86_64_msvc"
493-
version = "0.52.5"
493+
version = "0.52.6"
494494
source = "registry+https://github.com/rust-lang/crates.io-index"
495-
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
495+
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

library/alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[dependencies]
1212
core = { path = "../core" }
13-
compiler_builtins = { version = "0.1.125", features = ['rustc-dep-of-std'] }
13+
compiler_builtins = { version = "0.1.126", features = ['rustc-dep-of-std'] }
1414

1515
[dev-dependencies]
1616
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

library/core/src/arch.rs

+34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#[allow(unused_imports)]
44
#[stable(feature = "simd_arch", since = "1.27.0")]
55
pub use crate::core_arch::arch::*;
6+
#[unstable(feature = "naked_functions", issue = "90957")]
7+
#[cfg(bootstrap)]
8+
pub use crate::naked_asm;
69

710
/// Inline assembly.
811
///
@@ -17,6 +20,37 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
1720
/* compiler built-in */
1821
}
1922

23+
/// Inline assembly used in combination with `#[naked]` functions.
24+
///
25+
/// Refer to [Rust By Example] for a usage guide and the [reference] for
26+
/// detailed information about the syntax and available options.
27+
///
28+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
29+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
30+
#[unstable(feature = "naked_functions", issue = "90957")]
31+
#[macro_export]
32+
#[cfg(bootstrap)]
33+
macro_rules! naked_asm {
34+
([$last:expr], [$($pushed:expr),*]) => {
35+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
36+
{
37+
core::arch::asm!($($pushed),*, options(att_syntax, noreturn))
38+
}
39+
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
40+
{
41+
core::arch::asm!($($pushed),* , $last, options(noreturn))
42+
}
43+
};
44+
45+
([$first:expr $(, $rest:expr)*], [$($pushed:expr),*]) => {
46+
naked_asm!([$($rest),*], [$($pushed,)* $first]);
47+
};
48+
49+
($($expr:expr),* $(,)?) => {
50+
naked_asm!([$($expr),*], []);
51+
};
52+
}
53+
2054
/// Inline assembly used in combination with `#[naked]` functions.
2155
///
2256
/// Refer to [Rust By Example] for a usage guide and the [reference] for

library/core/src/macros/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ pub macro assert_matches {
229229
pub macro cfg_match {
230230
// with a final wildcard
231231
(
232-
$(cfg($initial_meta:meta) => { $($initial_tokens:item)* })+
233-
_ => { $($extra_tokens:item)* }
232+
$(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+
233+
_ => { $($extra_tokens:tt)* }
234234
) => {
235235
cfg_match! {
236236
@__items ();
@@ -241,7 +241,7 @@ pub macro cfg_match {
241241

242242
// without a final wildcard
243243
(
244-
$(cfg($extra_meta:meta) => { $($extra_tokens:item)* })*
244+
$(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })*
245245
) => {
246246
cfg_match! {
247247
@__items ();
@@ -256,7 +256,7 @@ pub macro cfg_match {
256256
(@__items ($($_:meta,)*);) => {},
257257
(
258258
@__items ($($no:meta,)*);
259-
(($($yes:meta)?) ($($tokens:item)*)),
259+
(($($yes:meta)?) ($($tokens:tt)*)),
260260
$($rest:tt,)*
261261
) => {
262262
// Emit all items within one block, applying an appropriate #[cfg]. The
@@ -279,7 +279,7 @@ pub macro cfg_match {
279279

280280
// Internal macro to make __apply work out right for different match types,
281281
// because of how macros match/expand stuff.
282-
(@__identity $($tokens:item)*) => {
282+
(@__identity $($tokens:tt)*) => {
283283
$($tokens)*
284284
}
285285
}

library/core/tests/macros.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unused_must_use)]
2+
13
#[allow(dead_code)]
24
trait Trait {
35
fn blah(&self);
@@ -173,3 +175,21 @@ fn cfg_match_two_functions() {
173175
bar2();
174176
}
175177
}
178+
179+
fn _accepts_expressions() -> i32 {
180+
cfg_match! {
181+
cfg(unix) => { 1 }
182+
_ => { 2 }
183+
}
184+
}
185+
186+
// The current implementation expands to a macro call, which allows the use of expression
187+
// statements.
188+
fn _allows_stmt_expr_attributes() {
189+
let one = 1;
190+
let two = 2;
191+
cfg_match! {
192+
cfg(unix) => { one * two; }
193+
_ => { one + two; }
194+
}
195+
}

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1717
panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
20-
compiler_builtins = { version = "0.1.125" }
20+
compiler_builtins = { version = "0.1.126" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.14", default-features = false, features = [

0 commit comments

Comments
 (0)