Skip to content

Commit 0ff608a

Browse files
committed
Auto merge of #159920 - JonathanBrouwer:rollup-qmClLNO, r=JonathanBrouwer
Rollup of 25 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159785 (Share _Unwind_Exception definition between native and wasm) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
2 parents 008fa22 + 1265202 commit 0ff608a

180 files changed

Lines changed: 3965 additions & 1409 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,6 +4509,7 @@ dependencies = [
45094509
"rustc_middle",
45104510
"rustc_session",
45114511
"rustc_span",
4512+
"rustc_symbol_mangling",
45124513
"rustc_target",
45134514
"serde",
45144515
"serde_json",
@@ -6336,9 +6337,9 @@ dependencies = [
63366337

63376338
[[package]]
63386339
name = "wasm-component-ld"
6339-
version = "0.5.26"
6340+
version = "0.5.27"
63406341
source = "registry+https://github.com/rust-lang/crates.io-index"
6341-
checksum = "51a12709376d4ce64f472699500db3b0e5902cc2bef16fb6ca3098bfdac032fa"
6342+
checksum = "5fd1ba338b2c06654988a76b13f38cad9a1c738e3275bf71ecf70eeac5d98eb4"
63426343
dependencies = [
63436344
"anyhow",
63446345
"clap",
@@ -6347,12 +6348,12 @@ dependencies = [
63476348
"libc",
63486349
"tempfile",
63496350
"wasi-preview1-component-adapter-provider",
6350-
"wasmparser 0.253.0",
6351+
"wasmparser 0.254.0",
63516352
"wat",
63526353
"windows-sys 0.61.2",
63536354
"winsplit",
6354-
"wit-component 0.253.0",
6355-
"wit-parser 0.253.0",
6355+
"wit-component 0.254.0",
6356+
"wit-parser 0.254.0",
63566357
]
63576358

63586359
[[package]]
@@ -6384,12 +6385,12 @@ dependencies = [
63846385

63856386
[[package]]
63866387
name = "wasm-encoder"
6387-
version = "0.253.0"
6388+
version = "0.254.0"
63886389
source = "registry+https://github.com/rust-lang/crates.io-index"
6389-
checksum = "59972d6cd272259de647b7c1f1912e45e289c75ffd4be04e10695507cd7e1b59"
6390+
checksum = "09480d646178e5fdd12bb06e812d0af9a3a191dbc9cd697fdc86687beade7393"
63906391
dependencies = [
63916392
"leb128fmt",
6392-
"wasmparser 0.253.0",
6393+
"wasmparser 0.254.0",
63936394
]
63946395

63956396
[[package]]
@@ -6406,14 +6407,14 @@ dependencies = [
64066407

64076408
[[package]]
64086409
name = "wasm-metadata"
6409-
version = "0.253.0"
6410+
version = "0.254.0"
64106411
source = "registry+https://github.com/rust-lang/crates.io-index"
6411-
checksum = "b3f45816ef616806f48498bcd831377de578c4fa51db0c83ab8ceb78cc13523b"
6412+
checksum = "b01df5f3b4ca7881e843f3bc0fb8a3905d79c68692250dcb8e33e698705ccdb6"
64126413
dependencies = [
64136414
"anyhow",
64146415
"indexmap",
6415-
"wasm-encoder 0.253.0",
6416-
"wasmparser 0.253.0",
6416+
"wasm-encoder 0.254.0",
6417+
"wasmparser 0.254.0",
64176418
]
64186419

64196420
[[package]]
@@ -6450,9 +6451,9 @@ dependencies = [
64506451

64516452
[[package]]
64526453
name = "wasmparser"
6453-
version = "0.253.0"
6454+
version = "0.254.0"
64546455
source = "registry+https://github.com/rust-lang/crates.io-index"
6455-
checksum = "19db11f87d2486580e1e8b6f494c54df7e0566b87d0b599db843c24019667339"
6456+
checksum = "d5769a29f799fbab136aaf65b4fe5384cd7d93fe6fc9ba0dcb6c8382a1f16e27"
64566457
dependencies = [
64576458
"bitflags",
64586459
"hashbrown 0.17.0",
@@ -6463,22 +6464,22 @@ dependencies = [
64636464

64646465
[[package]]
64656466
name = "wast"
6466-
version = "253.0.0"
6467+
version = "254.0.0"
64676468
source = "registry+https://github.com/rust-lang/crates.io-index"
6468-
checksum = "d3264542f8965c5d84fb1085d924bfba9a6314bb228eff13a2de14d7627664d0"
6469+
checksum = "e7ed4dfc8f6b9fc38b231065e2cdfbf7359af5ab945990abf09658dcc63c3e32"
64696470
dependencies = [
64706471
"bumpalo",
64716472
"leb128fmt",
64726473
"memchr",
64736474
"unicode-width 0.2.2",
6474-
"wasm-encoder 0.253.0",
6475+
"wasm-encoder 0.254.0",
64756476
]
64766477

64776478
[[package]]
64786479
name = "wat"
6479-
version = "1.253.0"
6480+
version = "1.254.0"
64806481
source = "registry+https://github.com/rust-lang/crates.io-index"
6481-
checksum = "4bfc5ce906144200c972ec617470aa35bd847472e170b26dde3e80541c674055"
6482+
checksum = "7127f7f9b8f127c879991cecd35f494e4628bae1b0874c681414d8d8831e952c"
64826483
dependencies = [
64836484
"wast",
64846485
]
@@ -6926,9 +6927,9 @@ dependencies = [
69266927

69276928
[[package]]
69286929
name = "wit-component"
6929-
version = "0.253.0"
6930+
version = "0.254.0"
69306931
source = "registry+https://github.com/rust-lang/crates.io-index"
6931-
checksum = "dbbd2500ac3488489ee8c6e59b79d7e47e6da5bfb019efd35d5dca57b78af624"
6932+
checksum = "b0e65bb94c369b3c4741ce3d1d2704b1fec93db7c540df0e521a097e7ceeb5be"
69326933
dependencies = [
69336934
"anyhow",
69346935
"bitflags",
@@ -6937,10 +6938,10 @@ dependencies = [
69376938
"serde",
69386939
"serde_derive",
69396940
"serde_json",
6940-
"wasm-encoder 0.253.0",
6941-
"wasm-metadata 0.253.0",
6942-
"wasmparser 0.253.0",
6943-
"wit-parser 0.253.0",
6941+
"wasm-encoder 0.254.0",
6942+
"wasm-metadata 0.254.0",
6943+
"wasmparser 0.254.0",
6944+
"wit-parser 0.254.0",
69446945
]
69456946

69466947
[[package]]
@@ -6963,9 +6964,9 @@ dependencies = [
69636964

69646965
[[package]]
69656966
name = "wit-parser"
6966-
version = "0.253.0"
6967+
version = "0.254.0"
69676968
source = "registry+https://github.com/rust-lang/crates.io-index"
6968-
checksum = "4d997b8e5920fcbeec742b58e583325d6419a6aca617ae8075c406a61c65ba8a"
6969+
checksum = "1655131e4f7d3f0cb141f6eca71315ca40eff0f3d4de7cff0a82bacedd8c89b4"
69696970
dependencies = [
69706971
"anyhow",
69716972
"hashbrown 0.17.0",
@@ -6977,7 +6978,7 @@ dependencies = [
69776978
"serde_derive",
69786979
"serde_json",
69796980
"unicode-ident",
6980-
"wasmparser 0.253.0",
6981+
"wasmparser 0.254.0",
69816982
]
69826983

69836984
[[package]]

compiler/rustc_ast/src/ast.rs

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,27 +2339,7 @@ pub struct FnSig {
23392339
impl FnSig {
23402340
/// Return a span encompassing the header, or where to insert it if empty.
23412341
pub fn header_span(&self) -> Span {
2342-
match self.header.ext {
2343-
Extern::Implicit(span) | Extern::Explicit(_, span) => {
2344-
return self.span.with_hi(span.hi());
2345-
}
2346-
Extern::None => {}
2347-
}
2348-
2349-
match self.header.safety {
2350-
Safety::Unsafe(span) | Safety::Safe(span) => return self.span.with_hi(span.hi()),
2351-
Safety::Default => {}
2352-
};
2353-
2354-
if let Some(coroutine_kind) = self.header.coroutine_kind {
2355-
return self.span.with_hi(coroutine_kind.span().hi());
2356-
}
2357-
2358-
if let Const::Yes(span) = self.header.constness {
2359-
return self.span.with_hi(span.hi());
2360-
}
2361-
2362-
self.span.shrink_to_lo()
2342+
self.header.span().unwrap_or(self.span.shrink_to_lo())
23632343
}
23642344

23652345
/// The span of the header's safety, or where to insert it if empty.
@@ -2382,6 +2362,19 @@ impl FnSig {
23822362
pub fn extern_span(&self) -> Span {
23832363
self.header.ext.span().unwrap_or(self.safety_span().shrink_to_hi())
23842364
}
2365+
2366+
pub fn as_borrowed(&self) -> BorrowedFnSig<'_> {
2367+
BorrowedFnSig { header: self.header, decl: &self.decl, span: self.span }
2368+
}
2369+
}
2370+
2371+
/// A borrowed version of `FnSig`, used to share logic between function declarations and function
2372+
/// pointer types.
2373+
#[derive(Clone, Debug)]
2374+
pub struct BorrowedFnSig<'a> {
2375+
pub header: FnHeader,
2376+
pub decl: &'a FnDecl,
2377+
pub span: Span,
23852378
}
23862379

23872380
/// A constraint on an associated item.
@@ -2487,6 +2480,16 @@ pub struct FnPtrTy {
24872480
pub decl_span: Span,
24882481
}
24892482

2483+
impl FnPtrTy {
2484+
pub fn header(&self) -> FnHeader {
2485+
FnHeader { constness: Const::No, coroutine_kind: None, safety: self.safety, ext: self.ext }
2486+
}
2487+
2488+
pub fn as_borrowed_fn_sig<'a>(&'a self) -> BorrowedFnSig<'a> {
2489+
BorrowedFnSig { header: self.header(), decl: &self.decl, span: self.decl_span }
2490+
}
2491+
}
2492+
24902493
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
24912494
pub struct UnsafeBinderTy {
24922495
pub generic_params: ThinVec<GenericParam>,
@@ -3402,6 +3405,15 @@ pub enum AttrStyle {
34023405
Inner,
34033406
}
34043407

3408+
impl AttrStyle {
3409+
pub fn line_doc_comment_prefix(self) -> &'static str {
3410+
match self {
3411+
AttrStyle::Outer => "///",
3412+
AttrStyle::Inner => "//!",
3413+
}
3414+
}
3415+
}
3416+
34053417
/// A list of attributes.
34063418
pub type AttrVec = ThinVec<Attribute>;
34073419

@@ -3836,6 +3848,30 @@ impl FnHeader {
38363848
|| matches!(constness, Const::Yes(_))
38373849
|| !matches!(ext, Extern::None)
38383850
}
3851+
3852+
pub fn span(&self) -> Option<Span> {
3853+
let mut spans = smallvec::SmallVec::<[Span; 4]>::new();
3854+
3855+
match self.ext {
3856+
Extern::Implicit(span) | Extern::Explicit(_, span) => spans.push(span),
3857+
Extern::None => {}
3858+
}
3859+
3860+
match self.safety {
3861+
Safety::Unsafe(span) | Safety::Safe(span) => spans.push(span),
3862+
Safety::Default => {}
3863+
};
3864+
3865+
if let Some(coroutine_kind) = self.coroutine_kind {
3866+
spans.push(coroutine_kind.span());
3867+
}
3868+
3869+
if let Const::Yes(span) = self.constness {
3870+
spans.push(span)
3871+
}
3872+
3873+
spans.into_iter().reduce(Span::to)
3874+
}
38393875
}
38403876

38413877
impl Default for FnHeader {

0 commit comments

Comments
 (0)