Skip to content

Commit bbe99cc

Browse files
committed
Introduce TyUnusedSubst
1 parent c1492ed commit bbe99cc

File tree

28 files changed

+50
-17
lines changed

28 files changed

+50
-17
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ for ty::TypeVariants<'gcx>
857857
TyChar |
858858
TyStr |
859859
TyError |
860-
TyNever => {
860+
TyNever |
861+
TyUnusedParam => {
861862
// Nothing more to hash.
862863
}
863864
TyInt(int_ty) => {

src/librustc/infer/canonical.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
634634
| ty::TyProjection(..)
635635
| ty::TyForeign(..)
636636
| ty::TyParam(..)
637+
| ty::TyUnusedParam
637638
| ty::TyAnon(..) => {
638639
if t.flags.intersects(self.needs_canonical_flags) {
639640
t.super_fold_with(self)

src/librustc/infer/freshen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
200200
ty::TyAnon(..) => {
201201
t.super_fold_with(self)
202202
}
203+
ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in TypeFreshener"),
203204
}
204205
}
205206
}

src/librustc/traits/coherence.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
480480
ty::TyClosure(..) |
481481
ty::TyGenerator(..) |
482482
ty::TyGeneratorWitness(..) |
483-
ty::TyAnon(..) => {
483+
ty::TyAnon(..) |
484+
ty::TyUnusedParam => {
484485
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
485486
}
486487
}

src/librustc/traits/error_reporting.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
263263
ty::TyGenerator(..) => Some(18),
264264
ty::TyForeign(..) => Some(19),
265265
ty::TyGeneratorWitness(..) => Some(20),
266-
ty::TyInfer(..) | ty::TyError => None
266+
ty::TyInfer(..) | ty::TyError => None,
267+
ty::TyUnusedParam => bug!("unexpected TyUnusedParam in fuzzy_match_tys"),
267268
}
268269
}
269270

src/librustc/traits/query/dropck_outlives.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,7 @@ fn trivial_dropck_outlives<'cx, 'tcx>(tcx: TyCtxt<'cx, '_, 'tcx>, ty: Ty<'tcx>)
261261
| ty::TyAnon(..)
262262
| ty::TyInfer(_)
263263
| ty::TyGenerator(..) => false,
264+
265+
ty::TyUnusedParam => bug!("trivial_dropck_outlives called with TyUnusedParam"),
264266
}
265267
}

src/librustc/traits/select.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
20392039
))
20402040
}
20412041

2042-
ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => None,
2042+
ty::TyProjection(_) | ty::TyParam(_) | ty::TyUnusedParam | ty::TyAnon(..) => None,
20432043
ty::TyInfer(ty::TyVar(_)) => Ambiguous,
20442044

20452045
ty::TyInfer(ty::CanonicalTy(_)) |
@@ -2120,6 +2120,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21202120
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
21212121
self_ty);
21222122
}
2123+
ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in copy_clone_conditions"),
21232124
}
21242125
}
21252126

@@ -2155,6 +2156,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21552156
ty::TyParam(..) |
21562157
ty::TyForeign(..) |
21572158
ty::TyProjection(..) |
2159+
ty::TyUnusedParam |
21582160
ty::TyInfer(ty::CanonicalTy(_)) |
21592161
ty::TyInfer(ty::TyVar(_)) |
21602162
ty::TyInfer(ty::FreshTy(_)) |

src/librustc/ty/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,13 +1947,15 @@ macro_rules! sty_debug_print {
19471947
region_infer: 0, ty_infer: 0, both_infer: 0,
19481948
};
19491949
$(let mut $variant = total;)*
1950+
let mut TyUnusedParam = total;
19501951

19511952

19521953
for &Interned(t) in tcx.interners.type_.borrow().iter() {
19531954
let variant = match t.sty {
19541955
ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) |
19551956
ty::TyFloat(..) | ty::TyStr | ty::TyNever => continue,
19561957
ty::TyError => /* unimportant */ continue,
1958+
ty::TyUnusedParam => &mut TyUnusedParam,
19571959
$(ty::$variant(..) => &mut $variant,)*
19581960
};
19591961
let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER);

src/librustc/ty/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
232232
"type parameter".to_string()
233233
}
234234
}
235+
ty::TyUnusedParam => "unused type parameter".to_string(),
235236
ty::TyAnon(..) => "anonymized type".to_string(),
236237
ty::TyError => "type error".to_string(),
237238
}

src/librustc/ty/fast_reject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
121121
ty::TyForeign(def_id) => {
122122
Some(ForeignSimplifiedType(def_id))
123123
}
124-
ty::TyInfer(_) | ty::TyError => None,
124+
ty::TyInfer(_) | ty::TyError | ty::TyUnusedParam => None,
125125
}
126126
}
127127

src/librustc/ty/flags.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl FlagComputation {
190190
&ty::TyFnPtr(f) => {
191191
self.add_fn_sig(f);
192192
}
193+
&ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in FlagComputation::for_sty"),
193194
}
194195
}
195196

src/librustc/ty/item_path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
373373
ty::TyProjection(_) |
374374
ty::TyParam(_) |
375375
ty::TyAnon(..) |
376+
ty::TyUnusedParam |
376377
ty::TyInfer(_) |
377378
ty::TyError |
378379
ty::TyGeneratorWitness(..) |

src/librustc/ty/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
17121712
ty::TyParam(_) => {
17131713
return Err(LayoutError::Unknown(ty));
17141714
}
1715-
ty::TyGeneratorWitness(..) | ty::TyInfer(_) | ty::TyError => {
1715+
ty::TyUnusedParam | ty::TyGeneratorWitness(..) | ty::TyInfer(_) | ty::TyError => {
17161716
bug!("LayoutDetails::compute: unexpected type `{}`", ty)
17171717
}
17181718
})
@@ -2287,7 +2287,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
22872287
}
22882288
}
22892289

2290-
ty::TyProjection(_) | ty::TyAnon(..) | ty::TyParam(_) |
2290+
ty::TyProjection(_) | ty::TyAnon(..) | ty::TyParam(_) | ty::TyUnusedParam |
22912291
ty::TyInfer(_) | ty::TyError => {
22922292
bug!("TyLayout::field_type: unexpected type `{}`", self.ty)
22932293
}

src/librustc/ty/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ use rustc_data_structures::sync::Lrc;
4848
use std::slice;
4949
use std::vec::IntoIter;
5050
use std::mem;
51+
use std::iter;
52+
use syntax::abi::Abi;
5153
use syntax::ast::{self, DUMMY_NODE_ID, Name, Ident, NodeId};
5254
use syntax::attr;
5355
use syntax::ext::hygiene::{Mark, SyntaxContext};
@@ -2067,7 +2069,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
20672069
}
20682070
}
20692071

2070-
TyInfer(..) => {
2072+
TyUnusedParam | TyInfer(..) => {
20712073
bug!("unexpected type `{:?}` in sized_constraint_for_ty",
20722074
ty)
20732075
}
@@ -2833,7 +2835,7 @@ pub fn ty_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
28332835
))
28342836
}
28352837
ty::TyGenerator(def_id, substs, _) => {
2836-
let sig = substs.generator_poly_sig(def_id, cx.tcx);
2838+
let sig = substs.generator_poly_sig(def_id, tcx);
28372839

28382840
let env_region = ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrEnv);
28392841
let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty);

src/librustc/ty/outlives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
167167
self.compute_components(subty, out);
168168
}
169169
}
170+
ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in compute_components"),
170171
}
171172
}
172173

src/librustc/ty/structural_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
865865
ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)),
866866
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
867867
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
868-
ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => return self
868+
ty::TyParam(..) | ty::TyUnusedParam | ty::TyNever | ty::TyForeign(..) => return self
869869
};
870870

871871
if self.sty == sty {
@@ -900,7 +900,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
900900
ty::TyAnon(_, ref substs) => substs.visit_with(visitor),
901901
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
902902
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
903-
ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => false,
903+
ty::TyParam(..) | ty::TyUnusedParam | ty::TyNever | ty::TyForeign(..) => false,
904904
}
905905
}
906906

src/librustc/ty/sty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
16361636
TyTuple(..) |
16371637
TyForeign(..) |
16381638
TyParam(_) |
1639+
TyUnusedParam |
16391640
TyInfer(_) |
16401641
TyError => {
16411642
vec![]

src/librustc/ty/util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,9 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W>
741741
TySlice(_) => {}
742742

743743
// This can be generated by collapse_interchangable_instances
744-
TyError => self.hash("<unused subst>"),
744+
TyUnusedParam => self.hash("<unused param>"),
745745

746+
TyError |
746747
TyInfer(_) => bug!("TypeIdHasher: unexpected type {}", ty)
747748
}
748749

@@ -1131,6 +1132,8 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11311132
def.variants.iter().any(
11321133
|variant| variant.fields.iter().any(
11331134
|field| needs_drop(field.ty(tcx, substs)))),
1135+
1136+
ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in needs_drop_raw"),
11341137
}
11351138
}
11361139

src/librustc/ty/walk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> AccIntoIter<TypeWalkerArray<'tcx>> {
8282
fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
8383
match parent_ty.sty {
8484
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
85-
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError |
86-
ty::TyForeign(..) => {
85+
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyUnusedParam | ty::TyNever |
86+
ty::TyError | ty::TyForeign(..) => {
8787
}
8888
ty::TyArray(ty, len) => {
8989
push_const(stack, len);

src/librustc/ty/wf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
261261
ty::TyGeneratorWitness(..) |
262262
ty::TyNever |
263263
ty::TyParam(_) |
264+
ty::TyUnusedParam |
264265
ty::TyForeign(..) => {
265266
// WfScalar, WfParameter, etc
266267
}

src/librustc/util/ppaux.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ty::subst::{self, Subst};
1616
use ty::{BrAnon, BrEnv, BrFresh, BrNamed};
1717
use ty::{TyBool, TyChar, TyAdt};
1818
use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr};
19-
use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple};
19+
use ty::{TyParam, TyUnusedParam, TyRawPtr, TyRef, TyNever, TyTuple};
2020
use ty::{TyClosure, TyGenerator, TyGeneratorWitness, TyForeign, TyProjection, TyAnon};
2121
use ty::{TyDynamic, TyInt, TyUint, TyInfer};
2222
use ty::{self, Ty, TyCtxt, TypeFoldable};
@@ -1044,6 +1044,7 @@ define_print! {
10441044
TyInfer(infer_ty) => write!(f, "{}", infer_ty),
10451045
TyError => write!(f, "[type error]"),
10461046
TyParam(ref param_ty) => write!(f, "{}", param_ty),
1047+
TyUnusedParam => write!(f, "[unused type param]"),
10471048
TyAdt(def, substs) => cx.parameterized(f, substs, def.did, &[]),
10481049
TyDynamic(data, r) => {
10491050
data.print(f, cx)?;

src/librustc_lint/types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
705705
ty::TyForeign(..) => FfiSafe,
706706

707707
ty::TyParam(..) |
708+
ty::TyUnusedParam |
708709
ty::TyInfer(..) |
709710
ty::TyError |
710711
ty::TyClosure(..) |
711712
ty::TyGenerator(..) |
712713
ty::TyGeneratorWitness(..) |
713714
ty::TyProjection(..) |
714715
ty::TyAnon(..) |
715-
ty::TyFnDef(..) => bug!("Unexpected type in foreign function"),
716+
ty::TyFnDef(..) => bug!("Unexpected type `{:?}` in foreign function", ty),
716717
}
717718
}
718719

src/librustc_mir/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2727
#![feature(dyn_trait)]
2828
#![feature(fs_read_write)]
2929
#![feature(macro_vis_matcher)]
30+
#![feature(macro_lifetime_matcher)]
3031
#![feature(exhaustive_patterns)]
3132
#![feature(range_contains)]
3233
#![feature(rustc_diagnostic_macros)]
@@ -75,7 +76,7 @@ pub fn provide(providers: &mut Providers) {
7576
providers.const_eval = interpret::const_eval_provider;
7677
providers.check_match = hair::pattern::check_match;
7778
providers.collapse_interchangable_instances =
78-
monomorphize::deduplicate_instances::collapse_interchangable_instances; Fix it
79+
monomorphize::deduplicate_instances::collapse_interchangable_instances;
7980
}
8081

8182
__build_diagnostic_array! { librustc_mir, DIAGNOSTICS }

src/librustc_mir/monomorphize/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
387387
ty::TyInfer(_) |
388388
ty::TyProjection(..) |
389389
ty::TyParam(_) |
390+
ty::TyUnusedParam |
390391
ty::TyGeneratorWitness(_) |
391392
ty::TyAnon(..) => {
392393
bug!("DefPathBasedNames: Trying to create type name for \

src/librustc_traits/dropck_outlives.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
238238
// be fully resolved.
239239
Err(NoSolution)
240240
}
241+
242+
ty::TyUnusedParam => bug!("dtorck_constraint_for_ty called with TyUnusedParam"),
241243
};
242244

243245
debug!("dtorck_constraint_for_ty({:?}) = {:?}", ty, result);

src/librustc_trans/debuginfo/type_names.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
171171
ty::TyGenerator(..) => {
172172
output.push_str("generator");
173173
}
174+
ty::TyUnusedParam => {
175+
output.push_str("[unused type param]");
176+
}
174177
ty::TyError |
175178
ty::TyInfer(_) |
176179
ty::TyProjection(..) |

src/librustc_typeck/check/cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
138138
span, &format!("`{:?}` should be sized but is not?", t));
139139
return Err(ErrorReported);
140140
}
141+
ty::TyUnusedParam => bug!("Unexpected TyUnusedParam in FnCtxt::pointer_kind"),
141142
})
142143
}
143144
}

src/librustc_typeck/variance/constraints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
334334
// types, where we use TyError as the Self type
335335
}
336336

337+
ty::TyUnusedParam |
337338
ty::TyGeneratorWitness(..) |
338339
ty::TyInfer(..) => {
339340
bug!("unexpected type encountered in \

0 commit comments

Comments
 (0)