Skip to content

Commit 86ad69d

Browse files
committed
Auto merge of rust-lang#106786 - JohnTitor:rollup-8f4vk8m, r=JohnTitor
Rollup of 8 pull requests Successful merges: - rust-lang#105795 (Stabilize `abi_efiapi` feature) - rust-lang#106446 ([LSDA] Take ttype_index into account when taking unwind action) - rust-lang#106675 (Mark ZST as FFI-safe if all its fields are PhantomData) - rust-lang#106740 (Adding a hint on iterator type errors) - rust-lang#106741 (Fix reexport of `doc(hidden)` item) - rust-lang#106759 (Revert "Make nested RPITIT inherit the parent opaque's generics.") - rust-lang#106772 (Re-add mw to review rotation) - rust-lang#106778 (Exclude formatting commit from blame) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 61a415b + 8dc8e3c commit 86ad69d

26 files changed

+177
-177
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ a06baa56b95674fc626b3c3fd680d6a65357fe60
66
971c549ca334b7b7406e61e958efcca9c4152822
77
# refactor infcx building
88
283abbf0e7d20176f76006825b5c52e9a4234e4c
9+
# format libstd/sys
10+
c34fbfaad38cf5829ef5cfe780dc9d58480adeaa

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ declare_features! (
4848

4949
/// Allows `#[target_feature(...)]` on aarch64 platforms
5050
(accepted, aarch64_target_feature, "1.61.0", Some(44839), None),
51+
/// Allows using the `efiapi` ABI.
52+
(accepted, abi_efiapi, "CURRENT_RUSTC_VERSION", Some(65815), None),
5153
/// Allows the sysV64 ABI to be specified on all platforms
5254
/// instead of just the platforms on which it is the C ABI.
5355
(accepted, abi_sysv64, "1.24.0", Some(36167), None),

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ declare_features! (
281281
(active, abi_avr_interrupt, "1.45.0", Some(69664), None),
282282
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
283283
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
284-
/// Allows using the `efiapi` ABI.
285-
(active, abi_efiapi, "1.40.0", Some(65815), None),
286284
/// Allows `extern "msp430-interrupt" fn()`.
287285
(active, abi_msp430_interrupt, "1.16.0", Some(38487), None),
288286
/// Allows `extern "ptx-*" fn()`.

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use hir::{
44
GenericParamKind, HirId, Node,
55
};
66
use rustc_hir as hir;
7+
use rustc_hir::def::DefKind;
78
use rustc_hir::def_id::DefId;
89
use rustc_middle::ty::{self, TyCtxt};
910
use rustc_session::lint;
@@ -142,7 +143,20 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
142143
Some(tcx.typeck_root_def_id(def_id))
143144
}
144145
Node::Item(item) => match item.kind {
145-
ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
146+
ItemKind::OpaqueTy(hir::OpaqueTy {
147+
origin:
148+
hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id),
149+
in_trait,
150+
..
151+
}) => {
152+
if in_trait {
153+
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn))
154+
} else {
155+
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn))
156+
}
157+
Some(fn_def_id.to_def_id())
158+
}
159+
ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias, .. }) => {
146160
let parent_id = tcx.hir().get_parent_item(hir_id);
147161
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
148162
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);

compiler/rustc_lint/src/types.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -878,39 +878,39 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
878878
) -> FfiResult<'tcx> {
879879
use FfiResult::*;
880880

881-
if def.repr().transparent() {
881+
let transparent_safety = def.repr().transparent().then(|| {
882882
// Can assume that at most one field is not a ZST, so only check
883883
// that field's type for FFI-safety.
884884
if let Some(field) = transparent_newtype_field(self.cx.tcx, variant) {
885-
self.check_field_type_for_ffi(cache, field, substs)
885+
return self.check_field_type_for_ffi(cache, field, substs);
886886
} else {
887887
// All fields are ZSTs; this means that the type should behave
888-
// like (), which is FFI-unsafe
888+
// like (), which is FFI-unsafe... except if all fields are PhantomData,
889+
// which is tested for below
889890
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_struct_zst, help: None }
890891
}
891-
} else {
892-
// We can't completely trust repr(C) markings; make sure the fields are
893-
// actually safe.
894-
let mut all_phantom = !variant.fields.is_empty();
895-
for field in &variant.fields {
896-
match self.check_field_type_for_ffi(cache, &field, substs) {
897-
FfiSafe => {
898-
all_phantom = false;
899-
}
900-
FfiPhantom(..) if def.is_enum() => {
901-
return FfiUnsafe {
902-
ty,
903-
reason: fluent::lint_improper_ctypes_enum_phantomdata,
904-
help: None,
905-
};
906-
}
907-
FfiPhantom(..) => {}
908-
r => return r,
892+
});
893+
// We can't completely trust repr(C) markings; make sure the fields are
894+
// actually safe.
895+
let mut all_phantom = !variant.fields.is_empty();
896+
for field in &variant.fields {
897+
match self.check_field_type_for_ffi(cache, &field, substs) {
898+
FfiSafe => {
899+
all_phantom = false;
909900
}
901+
FfiPhantom(..) if !def.repr().transparent() && def.is_enum() => {
902+
return FfiUnsafe {
903+
ty,
904+
reason: fluent::lint_improper_ctypes_enum_phantomdata,
905+
help: None,
906+
};
907+
}
908+
FfiPhantom(..) => {}
909+
r => return transparent_safety.unwrap_or(r),
910910
}
911-
912-
if all_phantom { FfiPhantom(ty) } else { FfiSafe }
913911
}
912+
913+
if all_phantom { FfiPhantom(ty) } else { transparent_safety.unwrap_or(FfiSafe) }
914914
}
915915

916916
/// Checks if the given type is "ffi-safe" (has a stable, well-defined

compiler/rustc_target/src/spec/abi.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
149149
match name {
150150
// Stable
151151
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
152-
| "system" => Ok(()),
152+
| "system" | "efiapi" => Ok(()),
153153
"rust-intrinsic" => Err(AbiDisabled::Unstable {
154154
feature: sym::intrinsics,
155155
explain: "intrinsics are subject to change",
@@ -198,10 +198,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
198198
feature: sym::abi_avr_interrupt,
199199
explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
200200
}),
201-
"efiapi" => Err(AbiDisabled::Unstable {
202-
feature: sym::abi_efiapi,
203-
explain: "efiapi ABI is experimental and subject to change",
204-
}),
205201
"C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
206202
feature: sym::abi_c_cmse_nonsecure_call,
207203
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",

library/core/src/iter/traits/iterator.rs

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
5858
note = "if you want to iterate between `start` until a value `end`, use the exclusive range \
5959
syntax `start..end` or the inclusive range syntax `start..=end`"
6060
),
61+
on(
62+
_Self = "{float}",
63+
note = "if you want to iterate between `start` until a value `end`, use the exclusive range \
64+
syntax `start..end` or the inclusive range syntax `start..=end`"
65+
),
6166
label = "`{Self}` is not an iterator",
6267
message = "`{Self}` is not an iterator"
6368
)]

library/std/src/personality/dwarf/eh.rs

+22-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
8484
let cs_start = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
8585
let cs_len = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
8686
let cs_lpad = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
87-
let cs_action = reader.read_uleb128();
87+
let cs_action_entry = reader.read_uleb128();
8888
// Callsite table is sorted by cs_start, so if we've passed the ip, we
8989
// may stop searching.
9090
if ip < func_start + cs_start {
@@ -95,7 +95,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
9595
return Ok(EHAction::None);
9696
} else {
9797
let lpad = lpad_base + cs_lpad;
98-
return Ok(interpret_cs_action(cs_action, lpad));
98+
return Ok(interpret_cs_action(action_table as *mut u8, cs_action_entry, lpad));
9999
}
100100
}
101101
}
@@ -113,26 +113,39 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
113113
let mut idx = ip;
114114
loop {
115115
let cs_lpad = reader.read_uleb128();
116-
let cs_action = reader.read_uleb128();
116+
let cs_action_entry = reader.read_uleb128();
117117
idx -= 1;
118118
if idx == 0 {
119119
// Can never have null landing pad for sjlj -- that would have
120120
// been indicated by a -1 call site index.
121121
let lpad = (cs_lpad + 1) as usize;
122-
return Ok(interpret_cs_action(cs_action, lpad));
122+
return Ok(interpret_cs_action(action_table as *mut u8, cs_action_entry, lpad));
123123
}
124124
}
125125
}
126126
}
127127

128-
fn interpret_cs_action(cs_action: u64, lpad: usize) -> EHAction {
129-
if cs_action == 0 {
130-
// If cs_action is 0 then this is a cleanup (Drop::drop). We run these
128+
unsafe fn interpret_cs_action(
129+
action_table: *mut u8,
130+
cs_action_entry: u64,
131+
lpad: usize,
132+
) -> EHAction {
133+
if cs_action_entry == 0 {
134+
// If cs_action_entry is 0 then this is a cleanup (Drop::drop). We run these
131135
// for both Rust panics and foreign exceptions.
132136
EHAction::Cleanup(lpad)
133137
} else {
134-
// Stop unwinding Rust panics at catch_unwind.
135-
EHAction::Catch(lpad)
138+
// If lpad != 0 and cs_action_entry != 0, we have to check ttype_index.
139+
// If ttype_index == 0 under the condition, we take cleanup action.
140+
let action_record = (action_table as *mut u8).offset(cs_action_entry as isize - 1);
141+
let mut action_reader = DwarfReader::new(action_record);
142+
let ttype_index = action_reader.read_sleb128();
143+
if ttype_index == 0 {
144+
EHAction::Cleanup(lpad)
145+
} else {
146+
// Stop unwinding Rust panics at catch_unwind.
147+
EHAction::Catch(lpad)
148+
}
136149
}
137150
}
138151

src/doc/unstable-book/src/language-features/abi-efiapi.md

-23
This file was deleted.

src/librustdoc/passes/strip_priv_imports.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ pub(crate) const STRIP_PRIV_IMPORTS: Pass = Pass {
1212
};
1313

1414
pub(crate) fn strip_priv_imports(krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
15-
ImportStripper { tcx: cx.tcx }.fold_crate(krate)
15+
let is_json_output = cx.output_format.is_json() && !cx.show_coverage;
16+
ImportStripper { tcx: cx.tcx, is_json_output }.fold_crate(krate)
1617
}

src/librustdoc/passes/strip_private.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub(crate) fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) ->
2828
is_json_output,
2929
tcx: cx.tcx,
3030
};
31-
krate = ImportStripper { tcx: cx.tcx }.fold_crate(stripper.fold_crate(krate));
31+
krate =
32+
ImportStripper { tcx: cx.tcx, is_json_output }.fold_crate(stripper.fold_crate(krate));
3233
}
3334

3435
// strip all impls referencing private items

src/librustdoc/passes/stripper.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,25 @@ impl<'a> DocFolder for ImplStripper<'a, '_> {
243243
/// This stripper discards all private import statements (`use`, `extern crate`)
244244
pub(crate) struct ImportStripper<'tcx> {
245245
pub(crate) tcx: TyCtxt<'tcx>,
246+
pub(crate) is_json_output: bool,
247+
}
248+
249+
impl<'tcx> ImportStripper<'tcx> {
250+
fn import_should_be_hidden(&self, i: &Item, imp: &clean::Import) -> bool {
251+
if self.is_json_output {
252+
// FIXME: This should be handled the same way as for HTML output.
253+
imp.imported_item_is_doc_hidden(self.tcx)
254+
} else {
255+
i.attrs.lists(sym::doc).has_word(sym::hidden)
256+
}
257+
}
246258
}
247259

248260
impl<'tcx> DocFolder for ImportStripper<'tcx> {
249261
fn fold_item(&mut self, i: Item) -> Option<Item> {
250262
match *i.kind {
251-
clean::ImportItem(imp) if imp.imported_item_is_doc_hidden(self.tcx) => None,
263+
clean::ImportItem(imp) if self.import_should_be_hidden(&i, &imp) => None,
264+
clean::ImportItem(_) if i.attrs.lists(sym::doc).has_word(sym::hidden) => None,
252265
clean::ExternCrateItem { .. } | clean::ImportItem(..)
253266
if i.visibility(self.tcx) != Some(Visibility::Public) =>
254267
{

tests/codegen/abi-efiapi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// compile-flags: -C no-prepopulate-passes
1515

1616
#![crate_type = "lib"]
17-
#![feature(no_core, lang_items, abi_efiapi)]
17+
#![feature(no_core, lang_items)]
1818
#![no_core]
1919

2020
#[lang="sized"]

tests/rustdoc/reexport-doc-hidden.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Part of <https://github.com/rust-lang/rust/issues/59368>.
2+
// This test ensures that reexporting a `doc(hidden)` item will
3+
// still show the reexport.
4+
5+
#![crate_name = "foo"]
6+
7+
#[doc(hidden)]
8+
pub type Type = u32;
9+
10+
// @has 'foo/index.html'
11+
// @has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;'
12+
pub use crate::Type as Type2;
13+
14+
// @count - '//*[@id="reexport.Type3"]' 0
15+
#[doc(hidden)]
16+
pub use crate::Type as Type3;
17+
18+
#[macro_export]
19+
#[doc(hidden)]
20+
macro_rules! foo {
21+
() => {};
22+
}
23+
24+
// This is a bug: https://github.com/rust-lang/rust/issues/59368
25+
// @!has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
26+
pub use crate::foo as Macro;

tests/ui/async-await/in-trait/nested-rpit.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// check-pass
21
// edition: 2021
2+
// known-bug: #105197
3+
// failure-status:101
4+
// dont-check-compiler-stderr
35

46
#![feature(async_fn_in_trait)]
57
#![feature(return_position_impl_trait_in_trait)]

tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(abi_efiapi)]
2-
31
fn efiapi(f: extern "efiapi" fn(usize, ...)) {
42
//~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
53
//~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable

tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
2-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14
2+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:1:14
33
|
44
LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,13 +8,13 @@ LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) {
88
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
99

1010
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
11-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14
11+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:1:14
1212
|
1313
LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) {
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
1515

1616
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
17-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12
17+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:6:12
1818
|
1919
LL | fn sysv(f: extern "sysv64" fn(usize, ...)) {
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,13 +23,13 @@ LL | fn sysv(f: extern "sysv64" fn(usize, ...)) {
2323
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
2424

2525
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
26-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12
26+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:6:12
2727
|
2828
LL | fn sysv(f: extern "sysv64" fn(usize, ...)) {
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
3030

3131
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
32-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11
32+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:11:11
3333
|
3434
LL | fn win(f: extern "win64" fn(usize, ...)) {
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL | fn win(f: extern "win64" fn(usize, ...)) {
3838
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
3939

4040
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
41-
--> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11
41+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:11:11
4242
|
4343
LL | fn win(f: extern "win64" fn(usize, ...)) {
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention

tests/ui/c-variadic/variadic-ffi-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ignore-arm stdcall isn't supported
22
#![feature(extended_varargs_abi_support)]
3-
#![feature(abi_efiapi)]
43

54
fn baz(f: extern "stdcall" fn(usize, ...)) {
65
//~^ ERROR: C-variadic function must have a compatible calling convention,

tests/ui/c-variadic/variadic-ffi-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `win64`, `sysv64` or `efiapi`
2-
--> $DIR/variadic-ffi-2.rs:5:11
2+
--> $DIR/variadic-ffi-2.rs:4:11
33
|
44
LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention

0 commit comments

Comments
 (0)