Skip to content

Commit

Permalink
rustdoc: Directly use rustc_abi instead of reexports
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
workingjubilee committed Nov 1, 2024
1 parent a8e1186 commit a8d4d23
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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()),
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/type_layout.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#![allow(rustc::default_hash_types)]

use rustc_abi::ExternAbi;
use rustc_ast::ast;
use rustc_attr::DeprecatedSince;
use rustc_hir::def::{CtorKind, DefKind};
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;
Expand Down Expand Up @@ -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()),
}
}
Expand Down

0 comments on commit a8d4d23

Please sign in to comment.