Skip to content

Commit c751c7a

Browse files
committed
Auto merge of #60329 - Centril:rollup-wv8g1ex, r=Centril
Rollup of 5 pull requests Successful merges: - #60292 (Replace the `&'tcx List<Ty<'tcx>>` in `TyKind::Tuple` with `SubstsRef<'tcx>`) - #60307 (Make "Implementations on Foreign Types" items in sidebar link to specific impls) - #60309 (Add 1.34.1 release notes) - #60315 (bootstrap: use correct version numbers for llvm-tools and lldb) - #60316 (Use "capacity" as parameter name in with_capacity() methods) Failed merges: r? @ghost
2 parents d4a32d5 + fa66b8a commit c751c7a

File tree

49 files changed

+210
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+210
-122
lines changed

RELEASES.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
Version 1.34.1 (2019-04-25)
2+
===========================
3+
4+
* [Fix false positives for the `redundant_closure` Clippy lint][clippy/3821]
5+
* [Fix false positives for the `missing_const_for_fn` Clippy lint][clippy/3844]
6+
* [Fix Clippy panic when checking some macros][clippy/3805]
7+
8+
[clippy/3821]: https://github.com/rust-lang/rust-clippy/pull/3821
9+
[clippy/3844]: https://github.com/rust-lang/rust-clippy/pull/3844
10+
[clippy/3805]: https://github.com/rust-lang/rust-clippy/pull/3805
11+
112
Version 1.34.0 (2019-04-11)
213
==========================
314

src/bootstrap/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1049,15 +1049,15 @@ impl Build {
10491049
}
10501050

10511051
fn llvm_tools_package_vers(&self) -> String {
1052-
self.package_vers(&self.rust_version())
1052+
self.package_vers(channel::CFG_RELEASE_NUM)
10531053
}
10541054

10551055
fn llvm_tools_vers(&self) -> String {
10561056
self.rust_version()
10571057
}
10581058

10591059
fn lldb_package_vers(&self) -> String {
1060-
self.package_vers(&self.rust_version())
1060+
self.package_vers(channel::CFG_RELEASE_NUM)
10611061
}
10621062

10631063
fn lldb_vers(&self) -> String {

src/liballoc/collections/vec_deque.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<T> VecDeque<T> {
369369
VecDeque::with_capacity(INITIAL_CAPACITY)
370370
}
371371

372-
/// Creates an empty `VecDeque` with space for at least `n` elements.
372+
/// Creates an empty `VecDeque` with space for at least `capacity` elements.
373373
///
374374
/// # Examples
375375
///
@@ -379,10 +379,10 @@ impl<T> VecDeque<T> {
379379
/// let vector: VecDeque<u32> = VecDeque::with_capacity(10);
380380
/// ```
381381
#[stable(feature = "rust1", since = "1.0.0")]
382-
pub fn with_capacity(n: usize) -> VecDeque<T> {
382+
pub fn with_capacity(capacity: usize) -> VecDeque<T> {
383383
// +1 since the ringbuffer always leaves one space empty
384-
let cap = cmp::max(n + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
385-
assert!(cap > n, "capacity overflow");
384+
let cap = cmp::max(capacity + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
385+
assert!(cap > capacity, "capacity overflow");
386386

387387
VecDeque {
388388
tail: 0,

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
4747
let field_def = &variant_def.fields[f.index()];
4848
field_def.ty(tcx, substs)
4949
}
50-
ty::Tuple(ref tys) => tys[f.index()],
50+
ty::Tuple(ref tys) => tys[f.index()].expect_ty(),
5151
_ => bug!("extracting field of non-tuple non-adt: {:?}", self),
5252
};
5353
debug!("field_ty self: {:?} f: {:?} yields: {:?}", self, f, answer);

src/librustc/traits/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
875875
let expected_ty = expected_trait_ref.skip_binder().substs.type_at(1);
876876
let expected = match expected_ty.sty {
877877
ty::Tuple(ref tys) => tys.iter()
878-
.map(|t| ArgKind::from_expected_ty(t, Some(span))).collect(),
878+
.map(|t| ArgKind::from_expected_ty(t.expect_ty(), Some(span))).collect(),
879879
_ => vec![ArgKind::Arg("_".to_owned(), expected_ty.to_string())],
880880
};
881881

@@ -1247,7 +1247,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12471247
let inputs = trait_ref.substs.type_at(1);
12481248
let sig = if let ty::Tuple(inputs) = inputs.sty {
12491249
tcx.mk_fn_sig(
1250-
inputs.iter().cloned(),
1250+
inputs.iter().map(|k| k.expect_ty()),
12511251
tcx.mk_infer(ty::TyVar(ty::TyVid { index: 0 })),
12521252
false,
12531253
hir::Unsafety::Normal,

src/librustc/traits/query/dropck_outlives.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
217217

218218
// (T1..Tn) and closures have same properties as T1..Tn --
219219
// check if *any* of those are trivial.
220-
ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t)),
220+
ty::Tuple(ref tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t.expect_ty())),
221221
ty::Closure(def_id, ref substs) => substs
222222
.upvar_tys(def_id, tcx)
223223
.all(|t| trivial_dropck_outlives(tcx, t)),

src/librustc/traits/select.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24292429

24302430
ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None,
24312431

2432-
ty::Tuple(tys) => Where(ty::Binder::bind(tys.last().into_iter().cloned().collect())),
2432+
ty::Tuple(tys) => {
2433+
Where(ty::Binder::bind(tys.last().into_iter().map(|k| k.expect_ty()).collect()))
2434+
}
24332435

24342436
ty::Adt(def, substs) => {
24352437
let sized_crit = def.sized_constraint(self.tcx());
@@ -2503,7 +2505,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25032505

25042506
ty::Tuple(tys) => {
25052507
// (*) binder moved here
2506-
Where(ty::Binder::bind(tys.to_vec()))
2508+
Where(ty::Binder::bind(tys.iter().map(|k| k.expect_ty()).collect()))
25072509
}
25082510

25092511
ty::Closure(def_id, substs) => {
@@ -2590,7 +2592,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25902592

25912593
ty::Tuple(ref tys) => {
25922594
// (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
2593-
tys.to_vec()
2595+
tys.iter().map(|k| k.expect_ty()).collect()
25942596
}
25952597

25962598
ty::Closure(def_id, ref substs) => substs.upvar_tys(def_id, self.tcx()).collect(),
@@ -3495,7 +3497,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
34953497

34963498
// Check that the source tuple with the target's
34973499
// last element is equal to the target.
3498-
let new_tuple = tcx.mk_tup(a_mid.iter().cloned().chain(iter::once(b_last)));
3500+
let new_tuple = tcx.mk_tup(
3501+
a_mid.iter().map(|k| k.expect_ty()).chain(iter::once(b_last.expect_ty())),
3502+
);
34993503
let InferOk { obligations, .. } = self.infcx
35003504
.at(&obligation.cause, obligation.param_env)
35013505
.eq(target, new_tuple)
@@ -3508,7 +3512,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35083512
obligation.cause.clone(),
35093513
obligation.predicate.def_id(),
35103514
obligation.recursion_depth + 1,
3511-
a_last,
3515+
a_last.expect_ty(),
35123516
&[b_last.into()],
35133517
));
35143518
}

src/librustc/ty/context.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24312431
let converted_sig = sig.map_bound(|s| {
24322432
let params_iter = match s.inputs()[0].sty {
24332433
ty::Tuple(params) => {
2434-
params.into_iter().cloned()
2434+
params.into_iter().map(|k| k.expect_ty())
24352435
}
24362436
_ => bug!(),
24372437
};
@@ -2573,11 +2573,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25732573

25742574
#[inline]
25752575
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
2576-
self.mk_ty(Tuple(self.intern_type_list(ts)))
2576+
let kinds: Vec<_> = ts.into_iter().map(|&t| Kind::from(t)).collect();
2577+
self.mk_ty(Tuple(self.intern_substs(&kinds)))
25772578
}
25782579

25792580
pub fn mk_tup<I: InternAs<[Ty<'tcx>], Ty<'tcx>>>(self, iter: I) -> I::Output {
2580-
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts))))
2581+
iter.intern_with(|ts| {
2582+
let kinds: Vec<_> = ts.into_iter().map(|&t| Kind::from(t)).collect();
2583+
self.mk_ty(Tuple(self.intern_substs(&kinds)))
2584+
})
25812585
}
25822586

25832587
#[inline]

src/librustc/ty/flags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ impl FlagComputation {
195195
self.add_ty(ty);
196196
}
197197

198-
&ty::Tuple(ref ts) => {
199-
self.add_tys(&ts[..]);
198+
&ty::Tuple(ref substs) => {
199+
self.add_substs(substs);
200200
}
201201

202202
&ty::FnDef(_, substs) => {

src/librustc/ty/inhabitedness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
181181

182182
Tuple(ref tys) => {
183183
DefIdForest::union(tcx, tys.iter().map(|ty| {
184-
ty.uninhabited_from(tcx)
184+
ty.expect_ty().uninhabited_from(tcx)
185185
}))
186186
}
187187

src/librustc/ty/layout.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
626626
StructKind::MaybeUnsized
627627
};
628628

629-
univariant(&tys.iter().map(|ty| self.layout_of(ty)).collect::<Result<Vec<_>, _>>()?,
630-
&ReprOptions::default(), kind)?
629+
univariant(&tys.iter().map(|k| {
630+
self.layout_of(k.expect_ty())
631+
}).collect::<Result<Vec<_>, _>>()?, &ReprOptions::default(), kind)?
631632
}
632633

633634
// SIMD vector types.
@@ -1723,7 +1724,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
17231724
substs.field_tys(def_id, tcx).nth(i).unwrap()
17241725
}
17251726

1726-
ty::Tuple(tys) => tys[i],
1727+
ty::Tuple(tys) => tys[i].expect_ty(),
17271728

17281729
// SIMD vector types.
17291730
ty::Adt(def, ..) if def.repr.simd() => {

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2501,7 +2501,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
25012501
Tuple(ref tys) => {
25022502
match tys.last() {
25032503
None => vec![],
2504-
Some(ty) => self.sized_constraint_for_ty(tcx, ty)
2504+
Some(ty) => self.sized_constraint_for_ty(tcx, ty.expect_ty()),
25052505
}
25062506
}
25072507

src/librustc/ty/print/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
264264
ty::Ref(_, ty, _) => characteristic_def_id_of_type(ty),
265265

266266
ty::Tuple(ref tys) => tys.iter()
267-
.filter_map(|ty| characteristic_def_id_of_type(ty))
267+
.filter_map(|ty| characteristic_def_id_of_type(ty.expect_ty()))
268268
.next(),
269269

270270
ty::FnDef(def_id, _) |

src/librustc/ty/print/pretty.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
701701
if let ty::Tuple(ref args) = principal.substs.type_at(0).sty {
702702
let mut projections = predicates.projection_bounds();
703703
if let (Some(proj), None) = (projections.next(), projections.next()) {
704-
p!(pretty_fn_sig(args, false, proj.ty));
704+
let tys: Vec<_> = args.iter().map(|k| k.expect_ty()).collect();
705+
p!(pretty_fn_sig(&tys, false, proj.ty));
705706
resugared = true;
706707
}
707708
}

src/librustc/ty/relate.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
526526
(&ty::Tuple(as_), &ty::Tuple(bs)) =>
527527
{
528528
if as_.len() == bs.len() {
529-
Ok(tcx.mk_tup(as_.iter().zip(bs).map(|(a, b)| relation.relate(a, b)))?)
529+
Ok(tcx.mk_tup(as_.iter().zip(bs).map(|(a, b)| {
530+
relation.relate(&a.expect_ty(), &b.expect_ty())
531+
}))?)
530532
} else if !(as_.is_empty() || bs.is_empty()) {
531533
Err(TypeError::TupleSize(
532534
expected_found(relation, &as_.len(), &bs.len())))

src/librustc/ty/sty.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub enum TyKind<'tcx> {
171171
Never,
172172

173173
/// A tuple type. For example, `(i32, bool)`.
174-
Tuple(&'tcx List<Ty<'tcx>>),
174+
Tuple(SubstsRef<'tcx>),
175175

176176
/// The projection of an associated type. For example,
177177
/// `<T as Trait<..>>::N`.
@@ -1651,7 +1651,9 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
16511651
})
16521652
})
16531653
}
1654-
ty::Tuple(tys) => tys.iter().any(|ty| ty.conservative_is_privately_uninhabited(tcx)),
1654+
ty::Tuple(tys) => tys.iter().any(|ty| {
1655+
ty.expect_ty().conservative_is_privately_uninhabited(tcx)
1656+
}),
16551657
ty::Array(ty, len) => {
16561658
match len.assert_usize(tcx) {
16571659
// If the array is definitely non-empty, it's uninhabited if
@@ -2087,8 +2089,9 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
20872089
ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) =>
20882090
false,
20892091

2090-
ty::Tuple(tys) =>
2091-
tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
2092+
ty::Tuple(tys) => {
2093+
tys.iter().all(|ty| ty.expect_ty().is_trivially_sized(tcx))
2094+
}
20922095

20932096
ty::Adt(def, _substs) =>
20942097
def.sized_constraint(tcx).is_empty(),

src/librustc/ty/subst.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ impl<'tcx> Kind<'tcx> {
123123
}
124124
}
125125
}
126+
127+
/// Unpack the `Kind` as a type when it is known certainly to be a type.
128+
/// This is true in cases where `Substs` is used in places where the kinds are known
129+
/// to be limited (e.g. in tuples, where the only parameters are type parameters).
130+
pub fn expect_ty(self) -> Ty<'tcx> {
131+
match self.unpack() {
132+
UnpackedKind::Type(ty) => ty,
133+
_ => bug!("expected a type, but found another kind"),
134+
}
135+
}
126136
}
127137

128138
impl<'a, 'tcx> Lift<'tcx> for Kind<'a> {
@@ -174,8 +184,7 @@ pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>;
174184

175185
impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
176186
/// Creates a `InternalSubsts` that maps each generic parameter to itself.
177-
pub fn identity_for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId)
178-
-> SubstsRef<'tcx> {
187+
pub fn identity_for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> {
179188
Self::for_item(tcx, def_id, |param, _| {
180189
tcx.mk_param_from_def(param)
181190
})

src/librustc/ty/util.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
278278

279279
ty::Tuple(tys) => {
280280
if let Some((&last_ty, _)) = tys.split_last() {
281-
ty = last_ty;
281+
ty = last_ty.expect_ty();
282282
} else {
283283
break;
284284
}
@@ -316,8 +316,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
316316
(&Tuple(a_tys), &Tuple(b_tys))
317317
if a_tys.len() == b_tys.len() => {
318318
if let Some(a_last) = a_tys.last() {
319-
a = a_last;
320-
b = b_tys.last().unwrap();
319+
a = a_last.expect_ty();
320+
b = b_tys.last().unwrap().expect_ty();
321321
} else {
322322
break;
323323
}
@@ -795,7 +795,13 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
795795
Tuple(ref ts) => {
796796
// Find non representable
797797
fold_repr(ts.iter().map(|ty| {
798-
is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty)
798+
is_type_structurally_recursive(
799+
tcx,
800+
sp,
801+
seen,
802+
representable_cache,
803+
ty.expect_ty(),
804+
)
799805
}))
800806
}
801807
// Fixed-length vectors.
@@ -1048,7 +1054,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10481054
// state transformation pass
10491055
ty::Generator(..) => true,
10501056

1051-
ty::Tuple(ref tys) => tys.iter().cloned().any(needs_drop),
1057+
ty::Tuple(ref tys) => tys.iter().map(|k| k.expect_ty()).any(needs_drop),
10521058

10531059
// unions don't have destructors because of the child types,
10541060
// only if they manually implement `Drop` (handled above).

src/librustc/ty/walk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
120120
stack.extend(ts.skip_binder().iter().cloned().rev());
121121
}
122122
ty::Tuple(ts) => {
123-
stack.extend(ts.iter().cloned().rev());
123+
stack.extend(ts.iter().map(|k| k.expect_ty()).rev());
124124
}
125125
ty::FnDef(_, substs) => {
126126
stack.extend(substs.types().rev());

src/librustc/ty/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
265265
ty::Tuple(ref tys) => {
266266
if let Some((_last, rest)) = tys.split_last() {
267267
for elem in rest {
268-
self.require_sized(elem, traits::TupleElem);
268+
self.require_sized(elem.expect_ty(), traits::TupleElem);
269269
}
270270
}
271271
}

src/librustc_codegen_llvm/abi.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
426426
assert!(!sig.c_variadic && extra_args.is_empty());
427427

428428
match sig.inputs().last().unwrap().sty {
429-
ty::Tuple(ref tupled_arguments) => {
429+
ty::Tuple(tupled_arguments) => {
430430
inputs = &sig.inputs()[0..sig.inputs().len() - 1];
431-
tupled_arguments
431+
tupled_arguments.iter().map(|k| k.expect_ty()).collect()
432432
}
433433
_ => {
434434
bug!("argument to function with \"rust-call\" ABI \
@@ -437,7 +437,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
437437
}
438438
} else {
439439
assert!(sig.c_variadic || extra_args.is_empty());
440-
extra_args
440+
extra_args.to_vec()
441441
};
442442

443443
let target = &cx.sess().target.target;
@@ -587,7 +587,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
587587

588588
let mut fn_ty = FnType {
589589
ret: arg_of(sig.output(), None),
590-
args: inputs.iter().chain(extra_args).enumerate().map(|(i, ty)| {
590+
args: inputs.iter().cloned().chain(extra_args).enumerate().map(|(i, ty)| {
591591
arg_of(ty, Some(i))
592592
}).collect(),
593593
c_variadic: sig.c_variadic,

0 commit comments

Comments
 (0)