Auto merge of #134294 - matthiaskrgr:rollup-anh6io8, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #134252 (Fix `Path::is_absolute` on Hermit)
 - #134254 (Fix building `std` for Hermit after `c_char` change)
 - #134255 (Update includes in `/library/core/src/error.rs`.)
 - #134261 (Document the symbol Visibility enum)
 - #134262 (Arbitrary self types v2: adjust diagnostic.)
 - #134265 (Rename `ty_def_id` so people will stop using it by accident)
 - #134271 (Arbitrary self types v2: better feature gate test)
 - #134274 (Add check-pass test for `&raw`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors
2024-12-14 06:44:05 +00:00
28 changed files with 157 additions and 54 deletions

View File

@@ -294,10 +294,22 @@ pub enum Linkage {
Common,
}
/// Specifies the symbol visibility with regards to dynamic linking.
///
/// Visibility doesn't have any effect when linkage is internal.
///
/// DSO means dynamic shared object, that is a dynamically linked executable or dylib.
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
pub enum Visibility {
/// Export the symbol from the DSO and apply overrides of the symbol by outside DSOs to within
/// the DSO if the object file format supports this.
Default,
/// Hide the symbol outside of the defining DSO even when external linkage is used to export it
/// from the object file.
Hidden,
/// Export the symbol from the DSO, but don't apply overrides of the symbol by outside DSOs to
/// within the DSO. Equivalent to default visibility with object file formats that don't support
/// overriding exported symbols by another DSO.
Protected,
}

View File

@@ -41,7 +41,8 @@ pub trait Key: Sized {
None
}
fn ty_def_id(&self) -> Option<DefId> {
/// Used to detect when ADT def ids are used as keys in a cycle for better error reporting.
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
None
}
}
@@ -423,7 +424,7 @@ impl<'tcx> Key for Ty<'tcx> {
DUMMY_SP
}
fn ty_def_id(&self) -> Option<DefId> {
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
match *self.kind() {
ty::Adt(adt, _) => Some(adt.did()),
ty::Coroutine(def_id, ..) => Some(def_id),
@@ -471,8 +472,8 @@ impl<'tcx, T: Key> Key for ty::PseudoCanonicalInput<'tcx, T> {
self.value.default_span(tcx)
}
fn ty_def_id(&self) -> Option<DefId> {
self.value.ty_def_id()
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
self.value.def_id_for_ty_in_cycle()
}
}
@@ -593,7 +594,7 @@ impl<'tcx> Key for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>
DUMMY_SP
}
fn ty_def_id(&self) -> Option<DefId> {
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
match self.1.value.kind() {
ty::Adt(adt, _) => Some(adt.did()),
_ => None,

View File

@@ -100,7 +100,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
}
for info in &cycle_error.cycle {
if info.query.dep_kind == dep_kinds::representability_adt_ty
&& let Some(def_id) = info.query.ty_def_id
&& let Some(def_id) = info.query.def_id_for_ty_in_cycle
&& let Some(def_id) = def_id.as_local()
&& !item_and_field_ids.iter().any(|&(id, _)| id == def_id)
{
@@ -182,7 +182,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
&cycle_error.cycle,
|cycle| {
if cycle[0].query.dep_kind == dep_kinds::layout_of
&& let Some(def_id) = cycle[0].query.ty_def_id
&& let Some(def_id) = cycle[0].query.def_id_for_ty_in_cycle
&& let Some(def_id) = def_id.as_local()
&& let def_kind = tcx.def_kind(def_id)
&& matches!(def_kind, DefKind::Closure)
@@ -209,7 +209,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
if frame.query.dep_kind != dep_kinds::layout_of {
continue;
}
let Some(frame_def_id) = frame.query.ty_def_id else {
let Some(frame_def_id) = frame.query.def_id_for_ty_in_cycle else {
continue;
};
let Some(frame_coroutine_kind) = tcx.coroutine_kind(frame_def_id) else {