Skip to content

Commit 62ac10f

Browse files
committed
simplify reexports in rustc::hir
1 parent 7785834 commit 62ac10f

File tree

23 files changed

+72
-78
lines changed

23 files changed

+72
-78
lines changed

src/librustc/hir.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@
33
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
44
55
pub mod check_attr;
6-
pub use rustc_hir::def;
76
pub mod exports;
8-
pub use rustc_hir::def_id;
9-
pub use rustc_hir::hir_id::*;
107
pub mod intravisit;
11-
pub use rustc_hir::itemlikevisit;
128
pub mod map;
13-
pub use rustc_hir::pat_util;
14-
pub use rustc_hir::print;
159
pub mod upvars;
1610

17-
pub use rustc_hir::BlockCheckMode::*;
18-
pub use rustc_hir::FunctionRetTy::*;
19-
pub use rustc_hir::PrimTy::*;
20-
pub use rustc_hir::UnOp::*;
21-
pub use rustc_hir::UnsafeSource::*;
2211
pub use rustc_hir::*;
2312

2413
use crate::ty::query::Providers;

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
867867
}
868868

869869
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy<'v>) {
870-
if let Return(ref output_ty) = *ret_ty {
870+
if let FunctionRetTy::Return(ref output_ty) = *ret_ty {
871871
visitor.visit_ty(output_ty)
872872
}
873873
}

src/librustc_ast_lowering/expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
207207

208208
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
209209
match u {
210-
UnOp::Deref => hir::UnDeref,
211-
UnOp::Not => hir::UnNot,
212-
UnOp::Neg => hir::UnNeg,
210+
UnOp::Deref => hir::UnOp::UnDeref,
211+
UnOp::Not => hir::UnOp::UnNot,
212+
UnOp::Neg => hir::UnOp::UnNeg,
213213
}
214214
}
215215

@@ -1374,7 +1374,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13741374
stmts: &[],
13751375
expr: Some(expr),
13761376
hir_id,
1377-
rules: hir::UnsafeBlock(hir::CompilerGenerated),
1377+
rules: hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::CompilerGenerated),
13781378
span,
13791379
targeted_by_break: false,
13801380
}),

src/librustc_ast_lowering/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,12 +2144,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21442144
} else {
21452145
match decl.output {
21462146
FunctionRetTy::Ty(ref ty) => match in_band_ty_params {
2147-
Some((def_id, _)) if impl_trait_return_allow => {
2148-
hir::Return(self.lower_ty(ty, ImplTraitContext::OpaqueTy(Some(def_id))))
2149-
}
2150-
_ => hir::Return(self.lower_ty(ty, ImplTraitContext::disallowed())),
2147+
Some((def_id, _)) if impl_trait_return_allow => hir::FunctionRetTy::Return(
2148+
self.lower_ty(ty, ImplTraitContext::OpaqueTy(Some(def_id))),
2149+
),
2150+
_ => hir::FunctionRetTy::Return(
2151+
self.lower_ty(ty, ImplTraitContext::disallowed()),
2152+
),
21512153
},
2152-
FunctionRetTy::Default(span) => hir::DefaultReturn(span),
2154+
FunctionRetTy::Default(span) => hir::FunctionRetTy::DefaultReturn(span),
21532155
}
21542156
};
21552157

@@ -2940,8 +2942,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
29402942

29412943
fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
29422944
match *b {
2943-
BlockCheckMode::Default => hir::DefaultBlock,
2944-
BlockCheckMode::Unsafe(u) => hir::UnsafeBlock(self.lower_unsafe_source(u)),
2945+
BlockCheckMode::Default => hir::BlockCheckMode::DefaultBlock,
2946+
BlockCheckMode::Unsafe(u) => {
2947+
hir::BlockCheckMode::UnsafeBlock(self.lower_unsafe_source(u))
2948+
}
29452949
}
29462950
}
29472951

@@ -2956,8 +2960,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
29562960

29572961
fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
29582962
match u {
2959-
CompilerGenerated => hir::CompilerGenerated,
2960-
UserProvided => hir::UserProvided,
2963+
CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
2964+
UserProvided => hir::UnsafeSource::UserProvided,
29612965
}
29622966
}
29632967

@@ -3004,7 +3008,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
30043008
stmts,
30053009
expr,
30063010
hir_id: self.next_id(),
3007-
rules: hir::DefaultBlock,
3011+
rules: hir::BlockCheckMode::DefaultBlock,
30083012
span,
30093013
targeted_by_break: false,
30103014
};

src/librustc_lint/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn lint_literal<'a, 'tcx>(
376376
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
377377
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr<'tcx>) {
378378
match e.kind {
379-
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
379+
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
380380
// propagate negation, if the negation itself isn't negated
381381
if self.negated_expr_id != e.hir_id {
382382
self.negated_expr_id = expr.hir_id;
@@ -969,7 +969,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
969969
self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty, false);
970970
}
971971

972-
if let hir::Return(ref ret_hir) = decl.output {
972+
if let hir::FunctionRetTy::Return(ref ret_hir) = decl.output {
973973
let ret_ty = sig.output();
974974
if !ret_ty.is_unit() {
975975
self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty, false);

src/librustc_mir/hair/pattern/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
814814
}
815815
}
816816
hir::ExprKind::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind,
817-
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
817+
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
818818
let ty = self.tables.expr_ty(expr);
819819
let lit = match expr.kind {
820820
hir::ExprKind::Lit(ref lit) => lit,

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
482482
fn visit_block(&mut self, block: &'tcx hir::Block<'tcx>) {
483483
hir::intravisit::walk_block(self, block);
484484

485-
if let hir::UnsafeBlock(hir::UserProvided) = block.rules {
485+
if let hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::UserProvided) = block.rules {
486486
self.unsafe_blocks.push((block.hir_id, self.used_unsafe.contains(&block.hir_id)));
487487
}
488488
}

src/librustc_passes/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn resolve_local<'tcx>(
651651

652652
match expr.kind {
653653
hir::ExprKind::AddrOf(_, _, ref subexpr)
654-
| hir::ExprKind::Unary(hir::UnDeref, ref subexpr)
654+
| hir::ExprKind::Unary(hir::UnOp::UnDeref, ref subexpr)
655655
| hir::ExprKind::Field(ref subexpr, _)
656656
| hir::ExprKind::Index(ref subexpr, _) => {
657657
expr = &subexpr;

src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc::hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, Partial
2626
use rustc::hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
2727
use rustc::hir::exports::ExportMap;
2828
use rustc::hir::map::Definitions;
29-
use rustc::hir::{Bool, Char, Float, Int, PrimTy, Str, Uint};
29+
use rustc::hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint};
3030
use rustc::hir::{GlobMap, TraitMap};
3131
use rustc::lint;
3232
use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};

src/librustc_resolve/lifetimes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
846846

847847
fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) {
848848
let output = match fd.output {
849-
hir::DefaultReturn(_) => None,
850-
hir::Return(ref ty) => Some(&**ty),
849+
hir::FunctionRetTy::DefaultReturn(_) => None,
850+
hir::FunctionRetTy::Return(ref ty) => Some(&**ty),
851851
};
852852
self.visit_fn_like_elision(&fd.inputs, output);
853853
}

src/librustc_typeck/astconv.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,12 +2554,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25542554
assert_eq!(opt_self_ty, None);
25552555
self.prohibit_generics(path.segments);
25562556
match prim_ty {
2557-
hir::Bool => tcx.types.bool,
2558-
hir::Char => tcx.types.char,
2559-
hir::Int(it) => tcx.mk_mach_int(it),
2560-
hir::Uint(uit) => tcx.mk_mach_uint(uit),
2561-
hir::Float(ft) => tcx.mk_mach_float(ft),
2562-
hir::Str => tcx.mk_str(),
2557+
hir::PrimTy::Bool => tcx.types.bool,
2558+
hir::PrimTy::Char => tcx.types.char,
2559+
hir::PrimTy::Int(it) => tcx.mk_mach_int(it),
2560+
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(uit),
2561+
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ft),
2562+
hir::PrimTy::Str => tcx.mk_str(),
25632563
}
25642564
}
25652565
Res::Err => {
@@ -2773,11 +2773,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27732773
}
27742774
let input_tys = decl.inputs.iter().map(|a| self.ty_of_arg(a, None));
27752775
let output_ty = match decl.output {
2776-
hir::Return(ref output) => {
2776+
hir::FunctionRetTy::Return(ref output) => {
27772777
visitor.visit_ty(output);
27782778
self.ast_ty_to_ty(output)
27792779
}
2780-
hir::DefaultReturn(..) => tcx.mk_unit(),
2780+
hir::FunctionRetTy::DefaultReturn(..) => tcx.mk_unit(),
27812781
};
27822782

27832783
debug!("ty_of_fn: output_ty={:?}", output_ty);

src/librustc_typeck/check/closure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
548548
// First, convert the types that the user supplied (if any).
549549
let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a));
550550
let supplied_return = match decl.output {
551-
hir::Return(ref output) => astconv.ast_ty_to_ty(&output),
552-
hir::DefaultReturn(_) => match body.generator_kind {
551+
hir::FunctionRetTy::Return(ref output) => astconv.ast_ty_to_ty(&output),
552+
hir::FunctionRetTy::DefaultReturn(_) => match body.generator_kind {
553553
// In the case of the async block that we create for a function body,
554554
// we expect the return type of the block to match that of the enclosing
555555
// function.
@@ -696,7 +696,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
696696
self.tcx.types.err
697697
});
698698

699-
if let hir::Return(ref output) = decl.output {
699+
if let hir::FunctionRetTy::Return(ref output) = decl.output {
700700
astconv.ast_ty_to_ty(&output);
701701
}
702702

src/librustc_typeck/check/expr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
306306
) -> Ty<'tcx> {
307307
let tcx = self.tcx;
308308
let expected_inner = match unop {
309-
hir::UnNot | hir::UnNeg => expected,
310-
hir::UnDeref => NoExpectation,
309+
hir::UnOp::UnNot | hir::UnOp::UnNeg => expected,
310+
hir::UnOp::UnDeref => NoExpectation,
311311
};
312312
let needs = match unop {
313-
hir::UnDeref => needs,
313+
hir::UnOp::UnDeref => needs,
314314
_ => Needs::None,
315315
};
316316
let mut oprnd_t = self.check_expr_with_expectation_and_needs(&oprnd, expected_inner, needs);
317317

318318
if !oprnd_t.references_error() {
319319
oprnd_t = self.structurally_resolved_type(expr.span, oprnd_t);
320320
match unop {
321-
hir::UnDeref => {
321+
hir::UnOp::UnDeref => {
322322
if let Some(mt) = oprnd_t.builtin_deref(true) {
323323
oprnd_t = mt.ty;
324324
} else if let Some(ok) = self.try_overloaded_deref(expr.span, oprnd_t, needs) {
@@ -362,14 +362,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
362362
oprnd_t = tcx.types.err;
363363
}
364364
}
365-
hir::UnNot => {
365+
hir::UnOp::UnNot => {
366366
let result = self.check_user_unop(expr, oprnd_t, unop);
367367
// If it's builtin, we can reuse the type, this helps inference.
368368
if !(oprnd_t.is_integral() || oprnd_t.kind == ty::Bool) {
369369
oprnd_t = result;
370370
}
371371
}
372-
hir::UnNeg => {
372+
hir::UnOp::UnNeg => {
373373
let result = self.check_user_unop(expr, oprnd_t, unop);
374374
// If it's builtin, we can reuse the type, this helps inference.
375375
if !oprnd_t.is_numeric() {

src/librustc_typeck/check/method/confirm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
425425
match exprs.last().unwrap().kind {
426426
hir::ExprKind::Field(ref expr, _)
427427
| hir::ExprKind::Index(ref expr, _)
428-
| hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&expr),
428+
| hir::ExprKind::Unary(hir::UnOp::UnDeref, ref expr) => exprs.push(&expr),
429429
_ => break,
430430
}
431431
}
@@ -471,7 +471,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
471471
&[index_expr_ty],
472472
);
473473
}
474-
hir::ExprKind::Unary(hir::UnDeref, ref base_expr) => {
474+
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base_expr) => {
475475
self.convert_place_op_to_mutable(PlaceOp::Deref, expr, base_expr, &[]);
476476
}
477477
_ => {}

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ impl UnsafetyState {
390390
}
391391

392392
pub fn recurse(&mut self, blk: &hir::Block<'_>) -> UnsafetyState {
393+
use hir::BlockCheckMode;
393394
match self.unsafety {
394395
// If this unsafe, then if the outer function was already marked as
395396
// unsafe we shouldn't attribute the unsafe'ness to the block. This
@@ -399,16 +400,16 @@ impl UnsafetyState {
399400

400401
unsafety => {
401402
let (unsafety, def, count) = match blk.rules {
402-
hir::PushUnsafeBlock(..) => {
403+
BlockCheckMode::PushUnsafeBlock(..) => {
403404
(unsafety, blk.hir_id, self.unsafe_push_count.checked_add(1).unwrap())
404405
}
405-
hir::PopUnsafeBlock(..) => {
406+
BlockCheckMode::PopUnsafeBlock(..) => {
406407
(unsafety, blk.hir_id, self.unsafe_push_count.checked_sub(1).unwrap())
407408
}
408-
hir::UnsafeBlock(..) => {
409+
BlockCheckMode::UnsafeBlock(..) => {
409410
(hir::Unsafety::Unsafe, blk.hir_id, self.unsafe_push_count)
410411
}
411-
hir::DefaultBlock => (unsafety, self.def, self.unsafe_push_count),
412+
BlockCheckMode::DefaultBlock => (unsafety, self.def, self.unsafe_push_count),
412413
};
413414
UnsafetyState { def, unsafety, unsafe_push_count: count, from_fn: false }
414415
}

src/librustc_typeck/check/op.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
689689
),
690690
);
691691
match actual.kind {
692-
Uint(_) if op == hir::UnNeg => {
692+
Uint(_) if op == hir::UnOp::UnNeg => {
693693
err.note("unsigned values cannot be negated");
694694
}
695695
Str | Never | Char | Tuple(_) | Array(_, _) => {}
696696
Ref(_, ref lty, _) if lty.kind == Str => {}
697697
_ => {
698698
let missing_trait = match op {
699-
hir::UnNeg => "std::ops::Neg",
700-
hir::UnNot => "std::ops::Not",
701-
hir::UnDeref => "std::ops::UnDerf",
699+
hir::UnOp::UnNeg => "std::ops::Neg",
700+
hir::UnOp::UnNot => "std::ops::Not",
701+
hir::UnOp::UnDeref => "std::ops::UnDerf",
702702
};
703703
err.note(&format!(
704704
"an implementation of `{}` might \
@@ -771,9 +771,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
771771
span_bug!(span, "&& and || are not overloadable")
772772
}
773773
}
774-
} else if let Op::Unary(hir::UnNot, _) = op {
774+
} else if let Op::Unary(hir::UnOp::UnNot, _) = op {
775775
("not", lang.not_trait())
776-
} else if let Op::Unary(hir::UnNeg, _) = op {
776+
} else if let Op::Unary(hir::UnOp::UnNeg, _) = op {
777777
("neg", lang.neg_trait())
778778
} else {
779779
bug!("lookup_op_method: op not supported: {:?}", op)

src/librustc_typeck/check/regionck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
492492
if is_method_call {
493493
let origin = match expr.kind {
494494
hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall,
495-
hir::ExprKind::Unary(op, _) if op == hir::UnDeref => {
495+
hir::ExprKind::Unary(op, _) if op == hir::UnOp::UnDeref => {
496496
infer::ParameterOrigin::OverloadedDeref
497497
}
498498
_ => infer::ParameterOrigin::OverloadedOperator,
@@ -577,7 +577,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
577577
intravisit::walk_expr(self, expr);
578578
}
579579

580-
hir::ExprKind::Unary(hir::UnDeref, ref base) => {
580+
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base) => {
581581
// For *a, the lifetime of a must enclose the deref
582582
if is_method_call {
583583
self.constrain_call(expr, Some(base), None::<hir::Expr<'_>>.iter());

src/librustc_typeck/check/writeback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
133133
// operating on scalars, we clear the overload.
134134
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr<'_>) {
135135
match e.kind {
136-
hir::ExprKind::Unary(hir::UnNeg, ref inner)
137-
| hir::ExprKind::Unary(hir::UnNot, ref inner) => {
136+
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref inner)
137+
| hir::ExprKind::Unary(hir::UnOp::UnNot, ref inner) => {
138138
let inner_ty = self.fcx.node_ty(inner.hir_id);
139139
let inner_ty = self.fcx.resolve_vars_if_possible(&inner_ty);
140140

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2499,7 +2499,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
24992499
for (input, ty) in decl.inputs.iter().zip(*fty.inputs().skip_binder()) {
25002500
check(&input, ty)
25012501
}
2502-
if let hir::Return(ref ty) = decl.output {
2502+
if let hir::FunctionRetTy::Return(ref ty) = decl.output {
25032503
check(&ty, *fty.output().skip_binder())
25042504
}
25052505
}

src/librustc_typeck/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
192192

193193
hir::ExprKind::Type(ref subexpr, _) => self.walk_expr(subexpr),
194194

195-
hir::ExprKind::Unary(hir::UnDeref, ref base) => {
195+
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base) => {
196196
// *base
197197
self.select_from_expr(base);
198198
}

0 commit comments

Comments
 (0)