Skip to content

Commit 221416d

Browse files
compiler: use rustc_abi in rustc_ast_*
1 parent eddfe8f commit 221416d

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

Diff for: Cargo.lock

+2
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,7 @@ dependencies = [
34003400
name = "rustc_ast_lowering"
34013401
version = "0.0.0"
34023402
dependencies = [
3403+
"rustc_abi",
34033404
"rustc_ast",
34043405
"rustc_ast_pretty",
34053406
"rustc_data_structures",
@@ -3422,6 +3423,7 @@ name = "rustc_ast_passes"
34223423
version = "0.0.0"
34233424
dependencies = [
34243425
"itertools",
3426+
"rustc_abi",
34253427
"rustc_ast",
34263428
"rustc_ast_pretty",
34273429
"rustc_attr_parsing",

Diff for: compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3225,7 +3225,7 @@ pub enum Extern {
32253225
///
32263226
/// E.g. `extern fn foo() {}`.
32273227
///
3228-
/// This is just `extern "C"` (see `rustc_target::spec::abi::Abi::FALLBACK`).
3228+
/// This is just `extern "C"` (see `rustc_abi::ExternAbi::FALLBACK`).
32293229
Implicit(Span),
32303230
/// An explicit extern keyword was used with an explicit ABI.
32313231
///

Diff for: compiler/rustc_ast_lowering/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ doctest = false
88

99
[dependencies]
1010
# tidy-alphabetical-start
11+
rustc_abi = { path = "../rustc_abi" }
1112
rustc_ast = { path = "../rustc_ast" }
1213
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
1314
rustc_data_structures = { path = "../rustc_data_structures" }

Diff for: compiler/rustc_ast_lowering/src/item.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_abi::ExternAbi;
12
use rustc_ast::ptr::P;
23
use rustc_ast::visit::AssocCtxt;
34
use rustc_ast::*;
@@ -11,7 +12,6 @@ use rustc_middle::span_bug;
1112
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
1213
use rustc_span::edit_distance::find_best_match_for_name;
1314
use rustc_span::{DesugaringKind, Ident, Span, Symbol, kw, sym};
14-
use rustc_target::spec::abi;
1515
use smallvec::{SmallVec, smallvec};
1616
use thin_vec::ThinVec;
1717
use tracing::instrument;
@@ -275,7 +275,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
275275
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
276276
},
277277
ItemKind::ForeignMod(fm) => hir::ItemKind::ForeignMod {
278-
abi: fm.abi.map_or(abi::Abi::FALLBACK, |abi| self.lower_abi(abi)),
278+
abi: fm.abi.map_or(ExternAbi::FALLBACK, |abi| self.lower_abi(abi)),
279279
items: self
280280
.arena
281281
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
@@ -1470,23 +1470,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
14701470
}
14711471
}
14721472

1473-
pub(super) fn lower_abi(&mut self, abi: StrLit) -> abi::Abi {
1474-
abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|err| {
1473+
pub(super) fn lower_abi(&mut self, abi: StrLit) -> ExternAbi {
1474+
rustc_abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|err| {
14751475
self.error_on_invalid_abi(abi, err);
1476-
abi::Abi::Rust
1476+
ExternAbi::Rust
14771477
})
14781478
}
14791479

1480-
pub(super) fn lower_extern(&mut self, ext: Extern) -> abi::Abi {
1480+
pub(super) fn lower_extern(&mut self, ext: Extern) -> ExternAbi {
14811481
match ext {
1482-
Extern::None => abi::Abi::Rust,
1483-
Extern::Implicit(_) => abi::Abi::FALLBACK,
1482+
Extern::None => ExternAbi::Rust,
1483+
Extern::Implicit(_) => ExternAbi::FALLBACK,
14841484
Extern::Explicit(abi, _) => self.lower_abi(abi),
14851485
}
14861486
}
14871487

1488-
fn error_on_invalid_abi(&self, abi: StrLit, err: abi::AbiUnsupported) {
1489-
let abi_names = abi::enabled_names(self.tcx.features(), abi.span)
1488+
fn error_on_invalid_abi(&self, abi: StrLit, err: rustc_abi::AbiUnsupported) {
1489+
let abi_names = rustc_abi::enabled_names(self.tcx.features(), abi.span)
14901490
.iter()
14911491
.map(|s| Symbol::intern(s))
14921492
.collect::<Vec<_>>();
@@ -1495,7 +1495,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14951495
abi: abi.symbol_unescaped,
14961496
span: abi.span,
14971497
explain: match err {
1498-
abi::AbiUnsupported::Reason { explain } => Some(InvalidAbiReason(explain)),
1498+
rustc_abi::AbiUnsupported::Reason { explain } => Some(InvalidAbiReason(explain)),
14991499
_ => None,
15001500
},
15011501
suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion {

Diff for: compiler/rustc_ast_passes/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
itertools = "0.12"
9+
rustc_abi = { path = "../rustc_abi" }
910
rustc_ast = { path = "../rustc_ast" }
1011
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
1112
rustc_attr_parsing = { path = "../rustc_attr_parsing" }

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_session::Session;
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
77
use rustc_span::source_map::Spanned;
88
use rustc_span::{Span, Symbol, sym};
9-
use rustc_target::spec::abi;
109
use thin_vec::ThinVec;
1110

1211
use crate::errors;
@@ -77,12 +76,12 @@ impl<'a> PostExpansionVisitor<'a> {
7776
fn check_abi(&self, abi: ast::StrLit) {
7877
let ast::StrLit { symbol_unescaped, span, .. } = abi;
7978

80-
match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
79+
match rustc_abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
8180
Ok(()) => (),
82-
Err(abi::AbiDisabled::Unstable { feature, explain }) => {
81+
Err(rustc_abi::AbiDisabled::Unstable { feature, explain }) => {
8382
feature_err_issue(&self.sess, feature, span, GateIssue::Language, explain).emit();
8483
}
85-
Err(abi::AbiDisabled::Unrecognized) => {
84+
Err(rustc_abi::AbiDisabled::Unrecognized) => {
8685
if self.sess.opts.pretty.is_none_or(|ppm| ppm.needs_hir()) {
8786
self.sess.dcx().span_delayed_bug(
8887
span,

0 commit comments

Comments
 (0)