]> git.lizzy.rs Git - rust.git/commitdiff
Fix `Sized` requirement for empty tuples in `program_clauses`
authorscalexm <alexandre@scalexm.fr>
Fri, 23 Nov 2018 20:06:55 +0000 (21:06 +0100)
committerscalexm <alexandre@scalexm.fr>
Thu, 27 Dec 2018 18:21:16 +0000 (19:21 +0100)
src/librustc_traits/chalk_context/program_clauses.rs

index b604f140762f43bed87e36baa1e556b2a80e6212..06da938ceaa4a4607d1ccb4fcaeca31c2bd6a7b9 100644 (file)
@@ -280,7 +280,10 @@ fn wf_clause_for_tuple<'tcx>(
         Some(def_id) => def_id,
         None => return ty::List::empty(),
     };
-    let sized_implemented = type_list[0..arity - 1].iter()
+
+    // If `arity == 0` (i.e. the unit type) or `arity == 1`, this list of
+    // hypotheses is actually empty.
+    let sized_implemented = type_list[0 .. std::cmp::max(arity, 1) - 1].iter()
         .map(|ty| ty::TraitRef {
             def_id: sized_trait,
             substs: tcx.mk_substs_trait(*ty, ty::List::empty()),