Skip to content

Commit d937332

Browse files
committed
Be more conservative with Def::ConstParam in general
1 parent 82e82b8 commit d937332

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

src/librustc/middle/dead.rs

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

7676
fn handle_definition(&mut self, def: Def) {
7777
match def {
78-
Def::ConstParam(_) | Def::Const(_) |
78+
Def::Const(_) |
7979
Def::AssociatedConst(..) | Def::TyAlias(_) => {
8080
self.check_def_id(def.def_id());
8181
}

src/librustc/middle/reachable.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
126126
// If this path leads to a constant, then we need to
127127
// recurse into the constant to continue finding
128128
// items that are reachable.
129-
Def::Const(..) | Def::ConstParam(..) | Def::AssociatedConst(..) => {
129+
Def::Const(..) | Def::AssociatedConst(..) => {
130130
self.worklist.push(node_id);
131131
}
132132

@@ -321,8 +321,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
321321
hir_map::NodeTy(_) |
322322
hir_map::NodeMacroDef(_) => {}
323323
_ => {
324-
bug!("found unexpected thingy in worklist: {}",
325-
self.tcx.hir.node_to_string(search_item))
324+
bug!("found unexpected thingy in worklist: {} ({:?})",
325+
self.tcx.hir.node_to_string(search_item),
326+
node);
326327
}
327328
}
328329
}

src/librustc_mir/hair/pattern/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,13 +681,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
681681
-> Pattern<'tcx> {
682682
let ty = self.tables.node_id_to_type(id);
683683
let def = self.tables.qpath_def(qpath, id);
684-
let (is_associated_const, is_const_param) = match def {
685-
Def::AssociatedConst(_) => (true, false),
686-
Def::ConstParam(_) => (false, true),
687-
_ => (false, false),
688-
};
684+
let is_associated_const = if let Def::AssociatedConst(_) = def { true } else { false };
689685
let kind = match def {
690-
Def::ConstParam(def_id) | Def::Const(def_id) | Def::AssociatedConst(def_id) => {
686+
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
691687
let substs = self.tables.node_substs(id);
692688
match ty::Instance::resolve(
693689
self.tcx,
@@ -716,8 +712,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
716712
None => {
717713
self.errors.push(if is_associated_const {
718714
PatternError::AssociatedConstInPattern(span)
719-
} else if is_const_param {
720-
PatternError::ConstParamInPattern(span)
721715
} else {
722716
PatternError::StaticInPattern(span)
723717
});

src/librustc_mir/interpret/eval_context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
569569
// Now mark those locals as dead that we do not want to initialize
570570
match self.tcx.describe_def(instance.def_id()) {
571571
// statics and constants don't have `Storage*` statements, no need to look for them
572-
Some(Def::Static(..)) | Some(Def::ConstParam(..)) |
573-
Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {},
572+
Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {}
574573
_ => {
575574
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
576575
for block in mir.basic_blocks() {

src/librustc_typeck/check/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
6060
PatKind::Path(ref qpath) => {
6161
let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
6262
match def {
63-
Def::ConstParam(..) | Def::Const(..) | Def::AssociatedConst(..) => false,
63+
Def::Const(..) | Def::AssociatedConst(..) => false,
6464
_ => true,
6565
}
6666
}

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2526,7 +2526,8 @@ impl Clean<Type> for hir::Ty {
25262526
indices.types += 1;
25272527
}
25282528
hir::GenericParamKind::Const { .. } => {
2529-
let const_param_def = Def::ConstParam(cx.tcx.hir.local_def_id(param.id));
2529+
let const_param_def =
2530+
Def::ConstParam(cx.tcx.hir.local_def_id(param.id));
25302531
let mut j = 0;
25312532
let const_ = generic_args.args.iter().find_map(|arg| {
25322533
match arg {

0 commit comments

Comments
 (0)