Skip to content

Commit d0ef85e

Browse files
committed
Fix rebase issues
1 parent 0dccb7c commit d0ef85e

File tree

8 files changed

+44
-46
lines changed

8 files changed

+44
-46
lines changed

src/librustc/hir/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl GenericArg {
414414
match self {
415415
GenericArg::Lifetime(l) => l.id,
416416
GenericArg::Type(t) => t.id,
417+
GenericArg::Const(c) => c.value.id,
417418
}
418419
}
419420
}
@@ -472,6 +473,7 @@ impl GenericArgs {
472473
match arg {
473474
GenericArg::Lifetime(_) => own_counts.lifetimes += 1,
474475
GenericArg::Type(_) => own_counts.types += 1,
476+
GenericArg::Const(_) => own_counts.consts += 1,
475477
};
476478
}
477479

src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
23852385

23862386
if seen_bindings.contains_key(&ident) {
23872387
let span = seen_bindings.get(&ident).unwrap();
2388-
let err = ResolutionError::NameAlreadyUsedInTypeParameterList(
2388+
let err = ResolutionError::NameAlreadyUsedInParameterList(
23892389
ident.name,
23902390
span,
23912391
);

src/librustc_typeck/astconv.rs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
296296
GenericParamDefKind::Type { has_default, .. } => {
297297
defaults.types += has_default as usize
298298
}
299+
GenericParamDefKind::Const { .. } => {
300+
// FIXME(const_generics:defaults)
301+
}
299302
};
300303
}
301304

@@ -435,8 +438,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
435438
inferred_kind: I,
436439
) -> &'tcx Substs<'tcx> where
437440
A: Fn(DefId) -> (Option<&'b GenericArgs>, bool),
438-
P: Fn(&GenericParamDef, &GenericArg) -> Kind<'tcx>,
439-
I: Fn(Option<&[Kind<'tcx>]>, &GenericParamDef, bool) -> Kind<'tcx>
441+
P: Fn(&GenericParamDef<'tcx>, &GenericArg) -> Kind<'tcx>,
442+
I: Fn(Option<&[Kind<'tcx>]>, &GenericParamDef<'tcx>, bool) -> Kind<'tcx>
440443
{
441444
// Collect the segments of the path: we need to substitute arguments
442445
// for parameters throughout the entire path (wherever there are
@@ -507,24 +510,26 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
507510
(Some(&arg), Some(&param)) => {
508511
match (arg, &param.kind) {
509512
(GenericArg::Lifetime(_), GenericParamDefKind::Lifetime)
510-
| (GenericArg::Type(_), GenericParamDefKind::Type { .. }) => {
513+
| (GenericArg::Type(_), GenericParamDefKind::Type { .. })
514+
| (GenericArg::Const(_), GenericParamDefKind::Const { .. }) => {
511515
push_kind(&mut substs, provided_kind(param, arg));
512516
args.next();
513517
params.next();
514518
}
515-
(GenericArg::Lifetime(_), GenericParamDefKind::Type { .. }) => {
516-
// We expected a type argument, but got a lifetime
517-
// argument. This is an error, but we need to handle it
518-
// gracefully so we can report sensible errors. In this
519-
// case, we're simply going to infer this argument.
520-
args.next();
521-
}
522-
(GenericArg::Type(_), GenericParamDefKind::Lifetime) => {
523-
// We expected a lifetime argument, but got a type
519+
(GenericArg::Type(_), GenericParamDefKind::Lifetime)
520+
| (GenericArg::Const(_), GenericParamDefKind::Lifetime) => {
521+
// We expected a lifetime argument, but got a type or const
524522
// argument. That means we're inferring the lifetimes.
525523
push_kind(&mut substs, inferred_kind(None, param, infer_types));
526524
params.next();
527525
}
526+
(_, _) => {
527+
// We expected one kind of parameter, but the user provided
528+
// another. This is an error, but we need to handle it
529+
// gracefully so we can report sensible errors.
530+
// In this case, we're simply going to infer this argument.
531+
args.next();
532+
}
528533
}
529534
}
530535
(Some(_), None) => {
@@ -536,12 +541,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
536541
(None, Some(&param)) => {
537542
// If there are fewer arguments than parameters, it means
538543
// we're inferring the remaining arguments.
539-
match param.kind {
540-
GenericParamDefKind::Lifetime | GenericParamDefKind::Type { .. } => {
541-
let kind = inferred_kind(Some(&substs), param, infer_types);
542-
push_kind(&mut substs, kind);
543-
}
544-
}
544+
let kind = inferred_kind(Some(&substs), param, infer_types);
545+
push_kind(&mut substs, kind);
545546
args.next();
546547
params.next();
547548
}
@@ -595,7 +596,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
595596
);
596597

597598
let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
598-
let default_needs_object_self = |param: &ty::GenericParamDef| {
599+
let default_needs_object_self = |param: &ty::GenericParamDef<'tcx>| {
599600
if let GenericParamDefKind::Type { has_default, .. } = param.kind {
600601
if is_object && has_default {
601602
if tcx.at(span).type_of(param.def_id).has_self_ty() {
@@ -626,6 +627,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
626627
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
627628
self.ast_ty_to_ty(&ty).into()
628629
}
630+
(GenericParamDefKind::Const { ty }, GenericArg::Const(ct)) => {
631+
self.ast_const_to_const(&ct, ty).into()
632+
}
629633
_ => unreachable!(),
630634
}
631635
},
@@ -675,14 +679,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
675679
}
676680
}
677681
GenericParamDefKind::Const { .. } => {
678-
// FIXME(varkor)
679-
let mut i = param.index as usize - (ty_params.accepted + lt_accepted + own_self);
680-
if i < const_provided {
681-
unimplemented!() // TODO(const_generics):
682-
} else {
683-
// We've already errored above about the mismatch.
684-
tcx.types.err.into()
685-
}
682+
// FIXME(const_generics:defaults)
683+
// We've already errored above about the mismatch.
684+
tcx.types.err.into()
686685
}
687686
}
688687
},

src/librustc_typeck/check/method/confirm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
351351
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
352352
self.to_ty(ty).into()
353353
}
354-
// FIXME(varkor)
354+
(GenericParamDefKind::Const { ty }, GenericArg::Const(ct)) => {
355+
self.to_const(ct, ty).into()
356+
}
355357
_ => unreachable!(),
356358
}
357359
},

src/librustc_typeck/check/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5024,6 +5024,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50245024
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
50255025
self.to_ty(ty).into()
50265026
}
5027+
(GenericParamDefKind::Const { ty }, GenericArg::Const(ct)) => {
5028+
self.to_const(ct, ty).into()
5029+
}
50275030
_ => unreachable!(),
50285031
}
50295032
},
@@ -5052,20 +5055,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50525055
}
50535056
}
50545057
GenericParamDefKind::Const { .. } => {
5055-
// FIXME(varkor)
5056-
if let Some((_, generics)) = segment {
5057-
let own_counts = generics.own_counts();
5058-
i -= own_counts.lifetimes + own_counts.types;
5059-
}
5060-
5061-
if let Some(ct) = consts.get(i) {
5062-
// A provided const parameter.
5063-
self.to_const(ct, ty).into()
5064-
} else {
5065-
// FIXME(const_generics:defaults)
5066-
// No const parameters were provided, we can infer all.
5067-
self.var_for_def(span, param)
5068-
}
5058+
// FIXME(const_generics:defaults)
5059+
// No const parameters were provided, we have to infer them.
5060+
self.var_for_def(span, param)
50695061
}
50705062
}
50715063
},

src/librustdoc/core.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,12 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocContext<'a, 'tcx, 'rcx, 'cstore> {
218218
name: hir::LifetimeName::Param(name),
219219
}));
220220
}
221-
ty::GenericParamDefKind::Type {..} => {
221+
ty::GenericParamDefKind::Type { .. } => {
222222
args.push(hir::GenericArg::Type(self.ty_param_to_ty(param.clone())));
223223
}
224+
ty::GenericParamDefKind::Const { .. } => {
225+
unimplemented!() // TODO(const_generics)
226+
}
224227
}
225228
}
226229

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ pub struct Expr {
922922
pub id: NodeId,
923923
pub node: ExprKind,
924924
pub span: Span,
925-
pub attrs: ThinVec<Attribute>
925+
pub attrs: ThinVec<Attribute>,
926926
}
927927

928928
impl Expr {

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
410410
id: ast::DUMMY_NODE_ID,
411411
node: expr,
412412
span,
413-
attrs: ast::ThinVec::new(),
413+
attrs: ThinVec::new(),
414414
})
415415
}
416416
}

0 commit comments

Comments
 (0)