Rollup merge of #132444 - workingjubilee:rustdoc-my-abi, r=GuillaumeGomez

rustdoc: Directly use rustc_abi instead of reexports

rustc_target reexports a lot of things that are in rustc_abi, but that will be over soon and now is probably a good time to switch. Uses of rustc_target remain where they inquire about the target tuple.
This commit is contained in:
Guillaume Gomez 2024-11-02 03:08:53 +08:00 committed by GitHub
commit 93fb6ef84e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 20 deletions

View file

@ -5,6 +5,7 @@ use std::sync::{Arc, OnceLock as OnceCell};
use std::{fmt, iter};
use arrayvec::ArrayVec;
use rustc_abi::{ExternAbi, VariantIdx};
use rustc_ast::MetaItemInner;
use rustc_ast_pretty::pprust;
use rustc_attr::{ConstStability, Deprecation, Stability, StableSince};
@ -26,8 +27,6 @@ use rustc_session::Session;
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, FileName, Loc};
use rustc_target::abi::VariantIdx;
use rustc_target::spec::abi::Abi;
use thin_vec::ThinVec;
use tracing::{debug, trace};
use {rustc_ast as ast, rustc_hir as hir};
@ -656,7 +655,7 @@ impl Item {
let def_id = self.def_id().unwrap();
let abi = tcx.fn_sig(def_id).skip_binder().abi();
hir::FnHeader {
safety: if abi == Abi::RustIntrinsic {
safety: if abi == ExternAbi::RustIntrinsic {
intrinsic_operation_unsafety(tcx, def_id.expect_local())
} else {
safety
@ -2342,7 +2341,7 @@ pub(crate) struct BareFunctionDecl {
pub(crate) safety: hir::Safety,
pub(crate) generic_params: Vec<GenericParamDef>,
pub(crate) decl: FnDecl,
pub(crate) abi: Abi,
pub(crate) abi: ExternAbi,
}
#[derive(Clone, Debug)]

View file

@ -13,6 +13,7 @@ use std::fmt::{self, Display, Write};
use std::iter::{self, once};
use itertools::Itertools;
use rustc_abi::ExternAbi;
use rustc_attr::{ConstStability, StabilityLevel, StableSince};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
@ -23,7 +24,6 @@ use rustc_metadata::creader::{CStore, LoadedMacro};
use rustc_middle::ty::{self, TyCtxt, TypingMode};
use rustc_span::symbol::kw;
use rustc_span::{Symbol, sym};
use rustc_target::spec::abi::Abi;
use tracing::{debug, trace};
use super::url_parts_builder::{UrlPartsBuilder, estimate_item_path_byte_length};
@ -1787,11 +1787,11 @@ impl clean::AssocItemConstraint {
}
}
pub(crate) fn print_abi_with_space(abi: Abi) -> impl Display {
pub(crate) fn print_abi_with_space(abi: ExternAbi) -> impl Display {
display_fn(move |f| {
let quot = if f.alternate() { "\"" } else { "&quot;" };
match abi {
Abi::Rust => Ok(()),
ExternAbi::Rust => Ok(()),
abi => write!(f, "extern {0}{1}{0} ", quot, abi.name()),
}
})

View file

@ -5,6 +5,7 @@ use std::rc::Rc;
use itertools::Itertools;
use rinja::Template;
use rustc_abi::VariantIdx;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_hir as hir;
@ -14,7 +15,6 @@ use rustc_index::IndexVec;
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{Symbol, kw, sym};
use rustc_target::abi::VariantIdx;
use tracing::{debug, info};
use super::type_layout::document_type_layout;

View file

@ -1,13 +1,13 @@
use std::fmt;
use rinja::Template;
use rustc_abi::{Primitive, TagEncoding, Variants};
use rustc_data_structures::captures::Captures;
use rustc_hir::def_id::DefId;
use rustc_middle::span_bug;
use rustc_middle::ty::layout::LayoutError;
use rustc_middle::ty::{self};
use rustc_span::symbol::Symbol;
use rustc_target::abi::{Primitive, TagEncoding, Variants};
use crate::html::format::display_fn;
use crate::html::render::Context;

View file

@ -4,6 +4,7 @@
#![allow(rustc::default_hash_types)]
use rustc_abi::ExternAbi;
use rustc_ast::ast;
use rustc_attr::DeprecatedSince;
use rustc_hir::def::{CtorKind, DefKind};
@ -11,7 +12,6 @@ use rustc_hir::def_id::DefId;
use rustc_metadata::rendered_const;
use rustc_middle::{bug, ty};
use rustc_span::{Pos, Symbol, sym};
use rustc_target::spec::abi::Abi as RustcAbi;
use rustdoc_json_types::*;
use super::FullItemId;
@ -421,17 +421,17 @@ pub(crate) fn from_fn_header(header: &rustc_hir::FnHeader) -> FunctionHeader {
}
}
fn convert_abi(a: RustcAbi) -> Abi {
fn convert_abi(a: ExternAbi) -> Abi {
match a {
RustcAbi::Rust => Abi::Rust,
RustcAbi::C { unwind } => Abi::C { unwind },
RustcAbi::Cdecl { unwind } => Abi::Cdecl { unwind },
RustcAbi::Stdcall { unwind } => Abi::Stdcall { unwind },
RustcAbi::Fastcall { unwind } => Abi::Fastcall { unwind },
RustcAbi::Aapcs { unwind } => Abi::Aapcs { unwind },
RustcAbi::Win64 { unwind } => Abi::Win64 { unwind },
RustcAbi::SysV64 { unwind } => Abi::SysV64 { unwind },
RustcAbi::System { unwind } => Abi::System { unwind },
ExternAbi::Rust => Abi::Rust,
ExternAbi::C { unwind } => Abi::C { unwind },
ExternAbi::Cdecl { unwind } => Abi::Cdecl { unwind },
ExternAbi::Stdcall { unwind } => Abi::Stdcall { unwind },
ExternAbi::Fastcall { unwind } => Abi::Fastcall { unwind },
ExternAbi::Aapcs { unwind } => Abi::Aapcs { unwind },
ExternAbi::Win64 { unwind } => Abi::Win64 { unwind },
ExternAbi::SysV64 { unwind } => Abi::SysV64 { unwind },
ExternAbi::System { unwind } => Abi::System { unwind },
_ => Abi::Other(a.to_string()),
}
}