Skip to content

Commit 80e861c

Browse files
authored
Rollup merge of #137262 - compiler-errors:ast-ir-begone, r=lcnr
Make fewer crates depend on `rustc_ast_ir` I think it simplifies the crate graph and also exposes people less to confusion if downstream crates don't interact with `rustc_ast_ir` directly and instead just use its functionality reexported through more familiar paths. r? oli-obk since you introduced ast-ir
2 parents 4f84ba1 + b78c626 commit 80e861c

File tree

25 files changed

+30
-46
lines changed

25 files changed

+30
-46
lines changed

Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -3748,7 +3748,6 @@ dependencies = [
37483748
"itertools",
37493749
"rustc_abi",
37503750
"rustc_ast",
3751-
"rustc_ast_ir",
37523751
"rustc_attr_parsing",
37533752
"rustc_data_structures",
37543753
"rustc_errors",
@@ -3813,7 +3812,6 @@ dependencies = [
38133812
name = "rustc_infer"
38143813
version = "0.0.0"
38153814
dependencies = [
3816-
"rustc_ast_ir",
38173815
"rustc_data_structures",
38183816
"rustc_errors",
38193817
"rustc_fluent_macro",
@@ -4004,7 +4002,6 @@ dependencies = [
40044002
"rustc_apfloat",
40054003
"rustc_arena",
40064004
"rustc_ast",
4007-
"rustc_ast_ir",
40084005
"rustc_attr_parsing",
40094006
"rustc_data_structures",
40104007
"rustc_error_messages",
@@ -4134,7 +4131,6 @@ name = "rustc_next_trait_solver"
41344131
version = "0.0.0"
41354132
dependencies = [
41364133
"derive-where",
4137-
"rustc_ast_ir",
41384134
"rustc_data_structures",
41394135
"rustc_index",
41404136
"rustc_macros",
@@ -4454,7 +4450,6 @@ dependencies = [
44544450
"itertools",
44554451
"rustc_abi",
44564452
"rustc_ast",
4457-
"rustc_ast_ir",
44584453
"rustc_attr_parsing",
44594454
"rustc_data_structures",
44604455
"rustc_errors",
@@ -4493,7 +4488,6 @@ version = "0.0.0"
44934488
dependencies = [
44944489
"itertools",
44954490
"rustc_abi",
4496-
"rustc_ast_ir",
44974491
"rustc_data_structures",
44984492
"rustc_hir",
44994493
"rustc_infer",
@@ -4509,7 +4503,6 @@ version = "0.0.0"
45094503
dependencies = [
45104504
"itertools",
45114505
"rustc_abi",
4512-
"rustc_ast_ir",
45134506
"rustc_data_structures",
45144507
"rustc_errors",
45154508
"rustc_fluent_macro",

compiler/rustc_ast_ir/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
//! Common utilities shared by both `rustc_ast` and `rustc_type_ir`.
2+
//!
3+
//! Don't depend on this crate directly; both of those crates should re-export
4+
//! the functionality. Additionally, if you're in scope of `rustc_middle`, then
5+
//! prefer imports via that too, to avoid needing to directly depend on (e.g.)
6+
//! `rustc_type_ir` for a single import.
7+
18
// tidy-alphabetical-start
29
#![cfg_attr(feature = "nightly", allow(internal_features))]
310
#![cfg_attr(feature = "nightly", feature(never_type))]

compiler/rustc_hir_typeck/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2021"
88
itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
1010
rustc_ast = { path = "../rustc_ast" }
11-
rustc_ast_ir = { path = "../rustc_ast_ir" }
1211
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1312
rustc_data_structures = { path = "../rustc_data_structures" }
1413
rustc_errors = { path = "../rustc_errors" }

compiler/rustc_infer/Cargo.toml

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

99
[dependencies]
1010
# tidy-alphabetical-start
11-
rustc_ast_ir = { path = "../rustc_ast_ir" }
1211
rustc_data_structures = { path = "../rustc_data_structures" }
1312
rustc_errors = { path = "../rustc_errors" }
1413
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

compiler/rustc_infer/src/traits/structural_impls.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::fmt;
22

3-
use rustc_ast_ir::try_visit;
43
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable};
5-
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor};
4+
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor, try_visit};
65
use rustc_middle::ty::{self, TyCtxt};
76

87
use crate::traits;

compiler/rustc_macros/src/type_visitable.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ pub(super) fn type_visitable_derive(
3636
s.add_bounds(synstructure::AddBounds::Generics);
3737
let body_visit = s.each(|bind| {
3838
quote! {
39-
match ::rustc_ast_ir::visit::VisitorResult::branch(
39+
match ::rustc_middle::ty::visit::VisitorResult::branch(
4040
::rustc_middle::ty::visit::TypeVisitable::visit_with(#bind, __visitor)
4141
) {
4242
::core::ops::ControlFlow::Continue(()) => {},
4343
::core::ops::ControlFlow::Break(r) => {
44-
return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
44+
return ::rustc_middle::ty::visit::VisitorResult::from_residual(r);
4545
},
4646
}
4747
}
@@ -56,7 +56,7 @@ pub(super) fn type_visitable_derive(
5656
__visitor: &mut __V
5757
) -> __V::Result {
5858
match *self { #body_visit }
59-
<__V::Result as ::rustc_ast_ir::visit::VisitorResult>::output()
59+
<__V::Result as ::rustc_middle::ty::visit::VisitorResult>::output()
6060
}
6161
},
6262
)

compiler/rustc_middle/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rustc_abi = { path = "../rustc_abi" }
1414
rustc_apfloat = "0.2.0"
1515
rustc_arena = { path = "../rustc_arena" }
1616
rustc_ast = { path = "../rustc_ast" }
17-
rustc_ast_ir = { path = "../rustc_ast_ir" }
1817
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1918
rustc_data_structures = { path = "../rustc_data_structures" }
2019
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links

compiler/rustc_middle/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ macro_rules! TrivialTypeTraversalImpls {
8383
_: &mut F)
8484
-> F::Result
8585
{
86-
<F::Result as ::rustc_ast_ir::visit::VisitorResult>::output()
86+
<F::Result as ::rustc_middle::ty::visit::VisitorResult>::output()
8787
}
8888
}
8989
)+

compiler/rustc_middle/src/mir/interpret/error.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::{convert, fmt, mem, ops};
55

66
use either::Either;
77
use rustc_abi::{Align, Size, VariantIdx, WrappingRange};
8-
use rustc_ast_ir::Mutability;
98
use rustc_data_structures::sync::Lock;
109
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
1110
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
@@ -16,7 +15,7 @@ use rustc_span::{DUMMY_SP, Span, Symbol};
1615
use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar};
1716
use crate::error;
1817
use crate::mir::{ConstAlloc, ConstValue};
19-
use crate::ty::{self, Ty, TyCtxt, ValTree, layout, tls};
18+
use crate::ty::{self, Mutability, Ty, TyCtxt, ValTree, layout, tls};
2019

2120
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
2221
pub enum ErrorHandled {

compiler/rustc_middle/src/traits/solve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use rustc_ast_ir::try_visit;
21
use rustc_data_structures::intern::Interned;
32
use rustc_macros::HashStable;
43
use rustc_type_ir as ir;
54
pub use rustc_type_ir::solve::*;
65

6+
use crate::ty::visit::try_visit;
77
use crate::ty::{
88
self, FallibleTypeFolder, TyCtxt, TypeFoldable, TypeFolder, TypeVisitable, TypeVisitor,
99
};

compiler/rustc_middle/src/ty/generic_args.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use std::mem;
66
use std::num::NonZero;
77
use std::ptr::NonNull;
88

9-
use rustc_ast_ir::visit::VisitorResult;
10-
use rustc_ast_ir::walk_visitable_list;
119
use rustc_data_structures::intern::Interned;
1210
use rustc_errors::{DiagArgValue, IntoDiagArg};
1311
use rustc_hir::def_id::DefId;
@@ -18,7 +16,7 @@ use smallvec::SmallVec;
1816

1917
use crate::ty::codec::{TyDecoder, TyEncoder};
2018
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
21-
use crate::ty::visit::{TypeVisitable, TypeVisitor};
19+
use crate::ty::visit::{TypeVisitable, TypeVisitor, VisitorResult, walk_visitable_list};
2220
use crate::ty::{
2321
self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, InlineConstArgs, Lift, List, Ty, TyCtxt,
2422
};

compiler/rustc_middle/src/ty/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub use intrinsic::IntrinsicDef;
2727
use rustc_abi::{Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, VariantIdx};
2828
use rustc_ast::expand::StrippedCfgItem;
2929
use rustc_ast::node_id::NodeMap;
30-
pub use rustc_ast_ir::{Movability, Mutability, try_visit};
3130
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
3231
use rustc_data_structures::intern::Interned;
3332
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -48,7 +47,7 @@ pub use rustc_session::lint::RegisteredTools;
4847
use rustc_span::hygiene::MacroKind;
4948
use rustc_span::{ExpnId, ExpnKind, Ident, Span, Symbol, kw, sym};
5049
pub use rustc_type_ir::relate::VarianceDiagInfo;
51-
pub use rustc_type_ir::*;
50+
pub use rustc_type_ir::{Movability, Mutability, *};
5251
use tracing::{debug, instrument};
5352
pub use vtable::*;
5453
use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};

compiler/rustc_middle/src/ty/structural_impls.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ use std::fmt::{self, Debug};
77

88
use rustc_abi::TyAndLayout;
99
use rustc_ast::InlineAsmTemplatePiece;
10-
use rustc_ast_ir::try_visit;
11-
use rustc_ast_ir::visit::VisitorResult;
1210
use rustc_hir::def::Namespace;
1311
use rustc_hir::def_id::LocalDefId;
1412
use rustc_span::Span;
1513
use rustc_span::source_map::Spanned;
1614
use rustc_type_ir::ConstKind;
15+
use rustc_type_ir::visit::{VisitorResult, try_visit};
1716

1817
use super::print::PrettyPrinter;
1918
use super::{GenericArg, GenericArgKind, Pattern, Region};

compiler/rustc_middle/src/ty/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ops::ControlFlow;
22

33
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_type_ir::fold::TypeFoldable;
5-
pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
5+
pub use rustc_type_ir::visit::*;
66

77
use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags};
88

compiler/rustc_next_trait_solver/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
derive-where = "1.2.7"
9-
rustc_ast_ir = { path = "../rustc_ast_ir", default-features = false }
109
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
1110
rustc_index = { path = "../rustc_index", default-features = false }
1211
rustc_macros = { path = "../rustc_macros", optional = true }
@@ -22,7 +21,6 @@ nightly = [
2221
"dep:rustc_data_structures",
2322
"dep:rustc_macros",
2423
"dep:rustc_serialize",
25-
"rustc_ast_ir/nightly",
2624
"rustc_index/nightly",
2725
"rustc_type_ir/nightly",
2826
]

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
//! traits, `Copy`/`Clone`.
33
44
use derive_where::derive_where;
5-
use rustc_ast_ir::{Movability, Mutability};
65
use rustc_type_ir::data_structures::HashMap;
76
use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
87
use rustc_type_ir::inherent::*;
98
use rustc_type_ir::lang_items::TraitSolverLangItem;
10-
use rustc_type_ir::{self as ty, Interner, Upcast as _, elaborate};
9+
use rustc_type_ir::{self as ty, Interner, Movability, Mutability, Upcast as _, elaborate};
1110
use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
1211
use tracing::instrument;
1312

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! Dealing with trait goals, i.e. `T: Trait<'a, U>`.
22
3-
use rustc_ast_ir::Movability;
43
use rustc_type_ir::data_structures::IndexSet;
54
use rustc_type_ir::fast_reject::DeepRejectCtxt;
65
use rustc_type_ir::inherent::*;
76
use rustc_type_ir::lang_items::TraitSolverLangItem;
87
use rustc_type_ir::solve::CanonicalResponse;
98
use rustc_type_ir::visit::TypeVisitableExt as _;
10-
use rustc_type_ir::{self as ty, Interner, TraitPredicate, TypingMode, Upcast as _, elaborate};
9+
use rustc_type_ir::{
10+
self as ty, Interner, Movability, TraitPredicate, TypingMode, Upcast as _, elaborate,
11+
};
1112
use tracing::{instrument, trace};
1213

1314
use crate::delegate::SolverDelegate;

compiler/rustc_trait_selection/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2021"
88
itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
1010
rustc_ast = { path = "../rustc_ast" }
11-
rustc_ast_ir = { path = "../rustc_ast_ir" }
1211
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1312
rustc_data_structures = { path = "../rustc_data_structures" }
1413
rustc_errors = { path = "../rustc_errors" }

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
1212
use std::assert_matches::assert_matches;
1313

14-
use rustc_ast_ir::try_visit;
15-
use rustc_ast_ir::visit::VisitorResult;
1614
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
1715
use rustc_macros::extension;
1816
use rustc_middle::traits::ObligationCause;
1917
use rustc_middle::traits::solve::{Certainty, Goal, GoalSource, NoSolution, QueryResult};
18+
use rustc_middle::ty::visit::{VisitorResult, try_visit};
2019
use rustc_middle::ty::{TyCtxt, TypeFoldable};
2120
use rustc_middle::{bug, ty};
2221
use rustc_next_trait_solver::resolve::EagerResolver;

compiler/rustc_transmute/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
rustc_abi = { path = "../rustc_abi", optional = true }
9-
rustc_ast_ir = { path = "../rustc_ast_ir", optional = true }
109
rustc_data_structures = { path = "../rustc_data_structures" }
1110
rustc_hir = { path = "../rustc_hir", optional = true }
1211
rustc_infer = { path = "../rustc_infer", optional = true }
@@ -19,7 +18,6 @@ tracing = "0.1"
1918
[features]
2019
rustc = [
2120
"dep:rustc_abi",
22-
"dep:rustc_ast_ir",
2321
"dep:rustc_hir",
2422
"dep:rustc_infer",
2523
"dep:rustc_macros",

compiler/rustc_ty_utils/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2021"
77
# tidy-alphabetical-start
88
itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
10-
rustc_ast_ir = { path = "../rustc_ast_ir" }
1110
rustc_data_structures = { path = "../rustc_data_structures" }
1211
rustc_errors = { path = "../rustc_errors" }
1312
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

compiler/rustc_ty_utils/src/sig_types.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! This module contains helpers for walking all types of
22
//! a signature, while preserving spans as much as possible
33
4-
use rustc_ast_ir::try_visit;
5-
use rustc_ast_ir::visit::VisitorResult;
64
use rustc_hir::def::DefKind;
75
use rustc_hir::def_id::LocalDefId;
86
use rustc_middle::span_bug;
7+
use rustc_middle::ty::visit::{VisitorResult, try_visit};
98
use rustc_middle::ty::{self, TyCtxt};
109
use rustc_span::Span;
1110
use rustc_type_ir::visit::TypeVisitable;

compiler/rustc_type_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub use opaque_ty::*;
7474
pub use predicate::*;
7575
pub use predicate_kind::*;
7676
pub use region_kind::*;
77+
pub use rustc_ast_ir::{Movability, Mutability, Pinnedness};
7778
pub use ty_info::*;
7879
pub use ty_kind::*;
7980
pub use upcast::*;

compiler/rustc_type_ir/src/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use std::fmt;
4545
use std::ops::ControlFlow;
4646
use std::sync::Arc;
4747

48-
use rustc_ast_ir::visit::VisitorResult;
49-
use rustc_ast_ir::{try_visit, walk_visitable_list};
48+
pub use rustc_ast_ir::visit::VisitorResult;
49+
pub use rustc_ast_ir::{try_visit, walk_visitable_list};
5050
use rustc_index::{Idx, IndexVec};
5151
use smallvec::SmallVec;
5252
use thin_vec::ThinVec;

compiler/rustc_type_ir_macros/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Tok
4545
s.add_bounds(synstructure::AddBounds::Fields);
4646
let body_visit = s.each(|bind| {
4747
quote! {
48-
match ::rustc_ast_ir::visit::VisitorResult::branch(
48+
match ::rustc_type_ir::visit::VisitorResult::branch(
4949
::rustc_type_ir::visit::TypeVisitable::visit_with(#bind, __visitor)
5050
) {
5151
::core::ops::ControlFlow::Continue(()) => {},
5252
::core::ops::ControlFlow::Break(r) => {
53-
return ::rustc_ast_ir::visit::VisitorResult::from_residual(r);
53+
return ::rustc_type_ir::visit::VisitorResult::from_residual(r);
5454
},
5555
}
5656
}
@@ -65,7 +65,7 @@ fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Tok
6565
__visitor: &mut __V
6666
) -> __V::Result {
6767
match *self { #body_visit }
68-
<__V::Result as ::rustc_ast_ir::visit::VisitorResult>::output()
68+
<__V::Result as ::rustc_type_ir::visit::VisitorResult>::output()
6969
}
7070
},
7171
)

0 commit comments

Comments
 (0)