From 0723d6c6edbca3cc7bd8ef2a988594756c9c0b36 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 11 Jan 2016 15:56:21 -0500 Subject: [PATCH] Pacify tidy. --- src/librustc/middle/traits/error_reporting.rs | 3 +- .../obligation_forest/node_index.rs | 10 ++ .../obligation_forest/test.rs | 132 ++++++++++-------- src/librustc_typeck/check/mod.rs | 3 +- 4 files changed, 89 insertions(+), 59 deletions(-) diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index ef97c4c8a12..d09bbc37fe4 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -286,7 +286,8 @@ pub fn try_report_overflow_error_type_of_infinite_size<'a, 'tcx>( struct_enum_tys.iter() .enumerate() .filter_map(|(index, ty)| match ty.sty { - ty::TyEnum(adt_def, _) | ty::TyStruct(adt_def, _) if adt_def.did.is_local() => + ty::TyEnum(adt_def, _) | ty::TyStruct(adt_def, _) + if adt_def.did.is_local() => Some((index, adt_def.did)), _ => None, diff --git a/src/librustc_data_structures/obligation_forest/node_index.rs b/src/librustc_data_structures/obligation_forest/node_index.rs index ecfecd4e628..465cee0b60c 100644 --- a/src/librustc_data_structures/obligation_forest/node_index.rs +++ b/src/librustc_data_structures/obligation_forest/node_index.rs @@ -1,3 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + use core::nonzero::NonZero; use std::u32; diff --git a/src/librustc_data_structures/obligation_forest/test.rs b/src/librustc_data_structures/obligation_forest/test.rs index 039b683717f..628d3f94bdb 100644 --- a/src/librustc_data_structures/obligation_forest/test.rs +++ b/src/librustc_data_structures/obligation_forest/test.rs @@ -1,3 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + use super::{ObligationForest, Outcome, Error}; #[test] @@ -86,42 +96,46 @@ fn success_in_grandchildren() { let mut forest = ObligationForest::new(); forest.push_root("A"); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, _| { - match *obligation { - "A" => Ok(Some(vec!["A.1", "A.2", "A.3"])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, _| { + match *obligation { + "A" => Ok(Some(vec!["A.1", "A.2", "A.3"])), + _ => unreachable!(), + } + }); assert!(ok.is_empty()); assert!(err.is_empty()); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, _| { - match *obligation { - "A.1" => Ok(Some(vec![])), - "A.2" => Ok(Some(vec!["A.2.i", "A.2.ii"])), - "A.3" => Ok(Some(vec![])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, _| { + match *obligation { + "A.1" => Ok(Some(vec![])), + "A.2" => Ok(Some(vec!["A.2.i", "A.2.ii"])), + "A.3" => Ok(Some(vec![])), + _ => unreachable!(), + } + }); assert_eq!(ok, vec!["A.3", "A.1"]); assert!(err.is_empty()); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, _| { - match *obligation { - "A.2.i" => Ok(Some(vec!["A.2.i.a"])), - "A.2.ii" => Ok(Some(vec![])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, _| { + match *obligation { + "A.2.i" => Ok(Some(vec!["A.2.i.a"])), + "A.2.ii" => Ok(Some(vec![])), + _ => unreachable!(), + } + }); assert_eq!(ok, vec!["A.2.ii"]); assert!(err.is_empty()); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, _| { - match *obligation { - "A.2.i.a" => Ok(Some(vec![])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, _| { + match *obligation { + "A.2.i.a" => Ok(Some(vec![])), + _ => unreachable!(), + } + }); assert_eq!(ok, vec!["A.2.i.a", "A.2.i", "A.2", "A"]); assert!(err.is_empty()); @@ -137,12 +151,13 @@ fn to_errors_no_throw() { // only yields one of them (and does not panic, in particular). let mut forest = ObligationForest::new(); forest.push_root("A"); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, _| { - match *obligation { - "A" => Ok(Some(vec!["A.1", "A.2", "A.3"])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, _| { + match *obligation { + "A" => Ok(Some(vec!["A.1", "A.2", "A.3"])), + _ => unreachable!(), + } + }); assert_eq!(ok.len(), 0); assert_eq!(err.len(), 0); let errors = forest.to_errors(()); @@ -155,34 +170,37 @@ fn backtrace() { // only yields one of them (and does not panic, in particular). let mut forest: ObligationForest<&'static str> = ObligationForest::new(); forest.push_root("A"); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, mut backtrace| { - assert!(backtrace.next().is_none()); - match *obligation { - "A" => Ok(Some(vec!["A.1"])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, mut backtrace| { + assert!(backtrace.next().is_none()); + match *obligation { + "A" => Ok(Some(vec!["A.1"])), + _ => unreachable!(), + } + }); assert!(ok.is_empty()); assert!(err.is_empty()); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, mut backtrace| { - assert!(backtrace.next().unwrap() == &"A"); - assert!(backtrace.next().is_none()); - match *obligation { - "A.1" => Ok(Some(vec!["A.1.i"])), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, mut backtrace| { + assert!(backtrace.next().unwrap() == &"A"); + assert!(backtrace.next().is_none()); + match *obligation { + "A.1" => Ok(Some(vec!["A.1.i"])), + _ => unreachable!(), + } + }); assert!(ok.is_empty()); assert!(err.is_empty()); - let Outcome { successful: ok, errors: err, .. } = forest.process_obligations::<(),_>(|obligation, mut backtrace| { - assert!(backtrace.next().unwrap() == &"A.1"); - assert!(backtrace.next().unwrap() == &"A"); - assert!(backtrace.next().is_none()); - match *obligation { - "A.1.i" => Ok(None), - _ => unreachable!(), - } - }); + let Outcome { successful: ok, errors: err, .. } = + forest.process_obligations::<(),_>(|obligation, mut backtrace| { + assert!(backtrace.next().unwrap() == &"A.1"); + assert!(backtrace.next().unwrap() == &"A"); + assert!(backtrace.next().is_none()); + match *obligation { + "A.1.i" => Ok(None), + _ => unreachable!(), + } + }); assert_eq!(ok.len(), 0); assert!(err.is_empty()); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index eafa1e4304d..4ada6c36f8f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4142,7 +4142,8 @@ pub fn check_representable(tcx: &ty::ctxt, // caught by case 1. match rty.is_representable(tcx, sp) { Representability::SelfRecursive => { - traits::recursive_type_with_infinite_size_error(tcx, tcx.map.local_def_id(item_id)).emit(); + let item_def_id = tcx.map.local_def_id(item_id); + traits::recursive_type_with_infinite_size_error(tcx, item_def_id).emit(); return false } Representability::Representable | Representability::ContainsRecursive => (),