diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
| commit | 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch) | |
| tree | 552fabade603ab0d148a49ae3cf1abd3f399740a /src/test | |
| parent | 3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff) | |
| download | rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip | |
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/test')
140 files changed, 1837 insertions, 844 deletions
diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index c617c1b2d03..1cba738c564 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -14,8 +14,8 @@ pub trait i<T> { } -pub fn f<T>() -> Box<i<T>> { +pub fn f<T>() -> Box<i<T>+'static> { impl<T> i<T> for () { } - box() () as Box<i<T>> + box() () as Box<i<T>+'static> } diff --git a/src/test/auxiliary/issue-7178.rs b/src/test/auxiliary/issue-7178.rs index fe3842ef174..18b464bd924 100644 --- a/src/test/auxiliary/issue-7178.rs +++ b/src/test/auxiliary/issue-7178.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct Foo<'a, A>(&'a A); +pub struct Foo<'a, A:'a>(&'a A); impl<'a, A> Foo<'a, A> { pub fn new(a: &'a A) -> Foo<'a, A> { diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index b6283206676..0a9cfb5884f 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -40,7 +40,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } @@ -49,7 +49,7 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) // See Issue #15750 fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), Vec::from_slice(tts)); @@ -65,7 +65,7 @@ fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>) } } -fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> { +fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> { use syntax::ext::quote::rt::*; if !tts.is_empty() { diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs new file mode 100644 index 00000000000..a7429ca534b --- /dev/null +++ b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs @@ -0,0 +1,33 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that method bounds declared on traits/impls in a cross-crate +// scenario work. This is the libary portion of the test. + +pub enum MaybeOwned<'a> { + Owned(int), + Borrowed(&'a int) +} + +struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a int +} + +// I encountered a bug at some point with encoding the IntoMaybeOwned +// trait, so I'll use that as the template for this test. +pub trait IntoMaybeOwned<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a>; + fn bigger_region<'b:'a>(self, b: Inv<'b>); +} + +impl<'a> IntoMaybeOwned<'a> for Inv<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a> { fail!() } + fn bigger_region<'b:'a>(self, b: Inv<'b>) { fail!() } +} diff --git a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs index b5d13d15493..7a4339aa9f0 100644 --- a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs +++ b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs @@ -29,7 +29,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { let answer = other::the_answer(); MacExpr::new(quote_expr!(cx, $answer)) } diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index adec9d31afe..03f98686324 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -77,7 +77,7 @@ struct AminoAcid { p: f32, } -struct RepeatFasta<'a, W> { +struct RepeatFasta<'a, W:'a> { alu: &'static str, out: &'a mut W } @@ -126,7 +126,7 @@ fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] { lookup } -struct RandomFasta<'a, W> { +struct RandomFasta<'a, W:'a> { seed: u32, lookup: [AminoAcid, ..LOOKUP_SIZE], out: &'a mut W, diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 9be111f55ae..c46c44abcd4 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -69,11 +69,11 @@ impl<'a, T> Iterator<T> for Iterate<'a, T> { } // a linked list using borrowed next. -enum List<'a, T> { +enum List<'a, T:'a> { Nil, Cons(T, &'a List<'a, T>) } -struct ListIterator<'a, T> { +struct ListIterator<'a, T:'a> { cur: &'a List<'a, T> } impl<'a, T> List<'a, T> { diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index db6db02ded5..b63ecc6b66f 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo<T>() { +fn foo<T:'static>() { 1u.bar::<T>(); //~ ERROR: does not fulfill `Send` } diff --git a/src/test/compile-fail/borrowck-call-sendfn.rs b/src/test/compile-fail/borrowck-call-sendfn.rs index 57c0deb178d..eb2ea6b3de4 100644 --- a/src/test/compile-fail/borrowck-call-sendfn.rs +++ b/src/test/compile-fail/borrowck-call-sendfn.rs @@ -9,7 +9,7 @@ // except according to those terms. struct Foo { - f: proc() + f: proc():'static } fn call(x: Foo) { diff --git a/src/test/compile-fail/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck-object-lifetime.rs index c55a5a30538..bbb58e21198 100644 --- a/src/test/compile-fail/borrowck-object-lifetime.rs +++ b/src/test/compile-fail/borrowck-object-lifetime.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,17 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test that borrows that occur due to calls to object methods +// properly "claim" the object path. trait Foo { fn borrowed(&self) -> &(); + fn mut_borrowed(&mut self) -> &(); } -fn borrowed_receiver(x: &Foo) -> &() { - x.borrowed() +fn borrowed_receiver(x: &Foo) { + let _y = x.borrowed(); + let _z = x.borrowed(); } -fn owned_receiver(x: Box<Foo>) -> &'static () { - x.borrowed() //~ ERROR `*x` does not live long enough +fn mut_borrowed_receiver(x: &mut Foo) { + let _y = x.borrowed(); + let _z = x.mut_borrowed(); //~ ERROR cannot borrow } fn mut_owned_receiver(mut x: Box<Foo>) { diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs index 5ef52ab6645..29ee79b0079 100644 --- a/src/test/compile-fail/box-static-bound.rs +++ b/src/test/compile-fail/box-static-bound.rs @@ -12,7 +12,7 @@ use std::gc::{Gc, GC}; fn f<T>(x: T) -> Gc<T> { - box(GC) x //~ ERROR value may contain references + box(GC) x //~ ERROR the parameter type `T` may not live long enough } fn g<T:'static>(x: T) -> Gc<T> { diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs index 67222bdafbf..726413981a5 100644 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ b/src/test/compile-fail/builtin-superkinds-self-type.rs @@ -11,7 +11,7 @@ // Tests (negatively) the ability for the Self type in default methods // to use capabilities granted by builtin kinds as supertraits. -trait Foo : Sync { +trait Foo : Sync+'static { fn foo(self, mut chan: Sender<Self>) { chan.send(self); //~ ERROR does not fulfill `Send` } diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index 951354d964d..1ff9dc9dac4 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -13,7 +13,7 @@ struct X { } fn foo(blk: ||:'static) -> X { - return X { field: blk }; //~ ERROR expected bounds `'static+Send` + return X { field: blk }; //~ ERROR expected bounds `Send` } fn main() { diff --git a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs index 9176412cd79..c0b463535d4 100644 --- a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs +++ b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs @@ -12,8 +12,8 @@ fn bar(blk: ||:'static) { } fn foo(x: &()) { - bar(|| { //~ ERROR cannot infer an appropriate lifetime - let _ = x; + bar(|| { + let _ = x; //~ ERROR captured variable `x` does not outlive }) } diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index d69a56b76b0..5bd9f20dd83 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -9,13 +9,13 @@ // except according to those terms. -fn take_any(_: ||:) { +fn take_any(_: ||) { } fn take_const_owned(_: ||:Sync+Send) { } -fn give_any(f: ||:) { +fn give_any(f: ||) { take_any(f); } diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs index bf501ecfb70..af4c12c754b 100644 --- a/src/test/compile-fail/drop-on-non-struct.rs +++ b/src/test/compile-fail/drop-on-non-struct.rs @@ -14,7 +14,6 @@ type Foo = Vec<u8>; impl Drop for Foo { //~^ ERROR cannot provide an extension implementation -//~^^ ERROR multiple applicable methods fn drop(&mut self) { println!("kaboom"); } diff --git a/src/test/compile-fail/isuue-12470.rs b/src/test/compile-fail/issue-12470.rs index bf13b7ebbdb..aa7e3cd3739 100644 --- a/src/test/compile-fail/isuue-12470.rs +++ b/src/test/compile-fail/issue-12470.rs @@ -24,7 +24,7 @@ impl X for B { } struct A<'a> { - p: &'a X + p: &'a X+'a } fn make_a<'a>(p: &'a X) -> A<'a> { diff --git a/src/test/compile-fail/issue-14285.rs b/src/test/compile-fail/issue-14285.rs index d5e608ecae3..624ddf0c8bb 100644 --- a/src/test/compile-fail/issue-14285.rs +++ b/src/test/compile-fail/issue-14285.rs @@ -14,7 +14,7 @@ struct A; impl Foo for A {} -struct B<'a>(&'a Foo); +struct B<'a>(&'a Foo+'a); fn foo<'a>(a: &Foo) -> B<'a> { B(a) //~ ERROR cannot infer an appropriate lifetime diff --git a/src/test/compile-fail/issue-3154.rs b/src/test/compile-fail/issue-3154.rs index 141bf2b4279..5f55c550aeb 100644 --- a/src/test/compile-fail/issue-3154.rs +++ b/src/test/compile-fail/issue-3154.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct thing<'a, Q> { +struct thing<'a, Q:'a> { x: &'a Q } diff --git a/src/test/compile-fail/issue-3907-2.rs b/src/test/compile-fail/issue-3907-2.rs index ab9f7a84530..71f91050256 100644 --- a/src/test/compile-fail/issue-3907-2.rs +++ b/src/test/compile-fail/issue-3907-2.rs @@ -11,12 +11,12 @@ // aux-build:issue_3907.rs extern crate issue_3907; -type Foo = issue_3907::Foo; +type Foo = issue_3907::Foo+'static; struct S { name: int } -fn bar(_x: Foo) {} //~ ERROR variable `_x` has dynamically sized type `issue_3907::Foo` +fn bar(_x: Foo) {} //~ ERROR variable `_x` has dynamically sized type fn main() {} diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs index 4484a004251..ab2018af999 100644 --- a/src/test/compile-fail/issue-3953.rs +++ b/src/test/compile-fail/issue-3953.rs @@ -12,15 +12,9 @@ use std::cmp::PartialEq; -trait Hahaha: PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + //~ ERROR duplicate supertrait - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + PartialEq + - PartialEq {} +trait Hahaha: PartialEq + PartialEq { + //~^ ERROR trait `PartialEq` already appears in the list of bounds +} struct Lol(int); diff --git a/src/test/compile-fail/issue-4972.rs b/src/test/compile-fail/issue-4972.rs index 199bc3f5c29..bff167fa391 100644 --- a/src/test/compile-fail/issue-4972.rs +++ b/src/test/compile-fail/issue-4972.rs @@ -12,12 +12,12 @@ trait MyTrait { } pub enum TraitWrapper { - A(Box<MyTrait>), + A(Box<MyTrait+'static>), } fn get_tw_map(tw: &TraitWrapper) -> &MyTrait { match *tw { - A(box ref map) => map, //~ ERROR type `Box<MyTrait>` cannot be dereferenced + A(box ref map) => map, //~ ERROR cannot be dereferenced } } diff --git a/src/test/compile-fail/issue-5035-2.rs b/src/test/compile-fail/issue-5035-2.rs index 689b8f7c613..0251a06c5bd 100644 --- a/src/test/compile-fail/issue-5035-2.rs +++ b/src/test/compile-fail/issue-5035-2.rs @@ -9,8 +9,8 @@ // except according to those terms. trait I {} -type K = I; +type K = I+'static; -fn foo(_x: K) {} //~ ERROR: variable `_x` has dynamically sized type `I` +fn foo(_x: K) {} //~ ERROR: variable `_x` has dynamically sized type fn main() {} diff --git a/src/test/compile-fail/issue-5216.rs b/src/test/compile-fail/issue-5216.rs index ec9ec9565c4..18af9736ed9 100644 --- a/src/test/compile-fail/issue-5216.rs +++ b/src/test/compile-fail/issue-5216.rs @@ -9,12 +9,12 @@ // except according to those terms. fn f() { } -struct S(||); //~ ERROR missing lifetime specifier +struct S(||); //~ ERROR explicit lifetime bound required pub static C: S = S(f); fn g() { } -type T = ||; //~ ERROR missing lifetime specifier +type T = ||; //~ ERROR explicit lifetime bound required pub static D: T = g; fn main() {} diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index 14136d96c2d..f3bbb8051b7 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -11,14 +11,14 @@ trait A {} struct Struct { - r: A + r: A+'static } -fn new_struct(r: A) -> Struct { - //~^ ERROR variable `r` has dynamically sized type `A` +fn new_struct(r: A+'static) -> Struct { + //~^ ERROR variable `r` has dynamically sized type Struct { r: r } //~ ERROR trying to initialise a dynamically sized struct } trait Curve {} -enum E {X(Curve)} +enum E {X(Curve+'static)} fn main() {} diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index 48e1bdd671a..4cc03ee3dcd 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -28,7 +28,7 @@ fn f<T>(val: T) { fn main() { let t: S<&int> = S; let a = &t as &Gettable<&int>; - //~^ ERROR instantiating a type parameter with an incompatible type `&int` + //~^ ERROR instantiating a type parameter with an incompatible type let t: Box<S<String>> = box S; let a = t as Box<Gettable<String>>; //~^ ERROR instantiating a type parameter with an incompatible type diff --git a/src/test/compile-fail/proc-bounds.rs b/src/test/compile-fail/kindck-proc-bounds.rs index e8c6a3ba191..57c8cc3da8a 100644 --- a/src/test/compile-fail/proc-bounds.rs +++ b/src/test/compile-fail/kindck-proc-bounds.rs @@ -10,16 +10,13 @@ fn is_send<T: Send>() {} fn is_freeze<T: Sync>() {} -fn is_static<T: 'static>() {} -fn main() { +fn foo<'a>() { is_send::<proc()>(); //~^ ERROR: instantiating a type parameter with an incompatible type is_freeze::<proc()>(); //~^ ERROR: instantiating a type parameter with an incompatible type - - is_static::<proc()>(); - //~^ ERROR: instantiating a type parameter with an incompatible type } +fn main() { } diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs new file mode 100644 index 00000000000..99519263923 --- /dev/null +++ b/src/test/compile-fail/kindck-send-object.rs @@ -0,0 +1,44 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. The tests +// in this file all test the "kind" violates detected during kindck. +// See all `regions-bounded-by-send.rs` + +fn assert_send<T:Send>() { } +trait Dummy { } +trait Message : Send { } + +// careful with object types, who knows what they close over... + +fn object_ref_with_static_bound_not_ok() { + assert_send::<&'static Dummy+'static>(); //~ ERROR does not fulfill +} + +fn box_object_with_no_bound_not_ok<'a>() { + assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill +} + +fn proc_with_no_bound_not_ok<'a>() { + assert_send::<proc()>(); //~ ERROR does not fulfill +} + +fn closure_with_no_bound_not_ok<'a>() { + assert_send::<||:'static>(); //~ ERROR does not fulfill +} + +fn object_with_send_bound_ok() { + assert_send::<&'static Dummy+Send>(); + assert_send::<Box<Dummy+Send>>(); + assert_send::<proc():Send>; + assert_send::<||:Send>; +} + +fn main() { } diff --git a/src/test/compile-fail/kindck-send.rs b/src/test/compile-fail/kindck-send.rs deleted file mode 100644 index 424c7a4e430..00000000000 --- a/src/test/compile-fail/kindck-send.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2012 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered sendable. - - -fn assert_send<T:Send>() { } -trait Dummy { } - -fn test<'a,T,U:Send>(_: &'a int) { - // lifetime pointers with 'static lifetime are ok - assert_send::<&'static int>(); - assert_send::<&'static str>(); - assert_send::<&'static [int]>(); - - // whether or not they are mutable - assert_send::<&'static mut int>(); - - // otherwise lifetime pointers are not ok - assert_send::<&'a int>(); //~ ERROR does not fulfill `Send` - assert_send::<&'a str>(); //~ ERROR does not fulfill `Send` - assert_send::<&'a [int]>(); //~ ERROR does not fulfill `Send` - - // boxes are ok - assert_send::<Box<int>>(); - assert_send::<String>(); - assert_send::<Vec<int> >(); - - // but not if they own a bad thing - assert_send::<Box<&'a int>>(); //~ ERROR does not fulfill `Send` - - // careful with object types, who knows what they close over... - assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send` - assert_send::<&'a Dummy>(); //~ ERROR does not fulfill `Send` - assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill `Send` - assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill `Send` - - // ...unless they are properly bounded - assert_send::<&'static Dummy+Send>(); - assert_send::<Box<Dummy+Send>>(); - - // but closure and object types can have lifetime bounds which make - // them not ok (FIXME #5121) - // assert_send::<proc:'a()>(); // ERROR does not fulfill `Send` - // assert_send::<Box<Dummy+'a>>(); // ERROR does not fulfill `Send` - - // unsafe ptrs are ok unless they point at unsendable things - assert_send::<*const int>(); - assert_send::<*const &'a int>(); //~ ERROR does not fulfill `Send` -} - -fn main() { -} diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs new file mode 100644 index 00000000000..21bd676a225 --- /dev/null +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs @@ -0,0 +1,30 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +struct Bar<'x, 'y, 'z> { bar: &'y int, baz: int } +fn bar1<'a>(x: &Bar) -> (&'a int, &'a int, &'a int) { +//~^ NOTE: consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a int, &'a int, &'a int) + (x.bar, &x.baz, &x.baz) + //~^ ERROR: cannot infer + //~^^ ERROR: cannot infer + //~^^^ ERROR: cannot infer +} + +fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&'a int, &'a int, &'a int) { +//~^ NOTE: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'c>(x: &'a Bar<'a, 'a, 'c>) -> (&'a int, &'a int, &'a int) + (x.bar, &x.baz, &x.baz) + //~^ ERROR: cannot infer + //~^^ ERROR: cannot infer + //~^^^ ERROR: cannot infer +} + +fn main() { } diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs index 481fb3dee73..b7da4d73489 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs @@ -33,21 +33,6 @@ fn foo4<'a, 'b>(x: &'a Foo) -> (&'b int, &'a int, &'b int) { //~^ ERROR: cannot infer } -struct Bar<'x, 'y, 'z> { bar: &'y int, baz: int } -fn bar1<'a>(x: &Bar) -> (&'a int, &'a int, &'a int) { -//~^ NOTE: consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a int, &'a int, &'a int) - (x.bar, &x.baz, &x.baz) //~ ERROR: cannot infer - //~^ ERROR: cannot infer - //~^^ ERROR: cannot infer -} - -fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&'a int, &'a int, &'a int) { -//~^ NOTE: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'c>(x: &'a Bar<'a, 'a, 'c>) -> (&'a int, &'a int, &'a int) - (x.bar, &x.baz, &x.baz) //~ ERROR: cannot infer - //~^ ERROR: cannot infer - //~^^ ERROR: cannot infer -} - struct Cat<'x, T> { cat: &'x int, t: T } struct Dog<'y> { dog: &'y int } diff --git a/src/test/compile-fail/moves-sru-moved-field.rs b/src/test/compile-fail/moves-sru-moved-field.rs index 8b02740497d..74e5e6b1202 100644 --- a/src/test/compile-fail/moves-sru-moved-field.rs +++ b/src/test/compile-fail/moves-sru-moved-field.rs @@ -9,7 +9,7 @@ // except according to those terms. -type Noncopyable = proc(); +type Noncopyable = proc():'static; struct Foo { copied: int, diff --git a/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs b/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs new file mode 100644 index 00000000000..40cff3e466b --- /dev/null +++ b/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs @@ -0,0 +1,44 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test related to when a region bound is required to be specified. + +trait IsStatic : 'static { } +trait IsSend : Send { } +trait Is<'a> : 'a { } +trait Is2<'a> : 'a { } +trait SomeTrait { } + +// Bounds on object types: + +struct Foo<'a,'b,'c> { + // All of these are ok, because we can derive exactly one bound: + a: Box<IsStatic>, + b: Box<Is<'static>>, + c: Box<Is<'a>>, + d: Box<IsSend>, + e: Box<Is<'a>+Send>, // we can derive two bounds, but one is 'static, so ok + f: Box<SomeTrait>, //~ ERROR explicit lifetime bound required + g: Box<SomeTrait+'a>, + + z: Box<Is<'a>+'b+'c>, //~ ERROR only a single explicit lifetime bound is permitted +} + +fn test< + 'a, + 'b, + A:IsStatic, + B:Is<'a>+Is2<'b>, //~ ERROR ambiguous lifetime bound + C:'b+Is<'a>+Is2<'b>, + D:Is<'a>+Is2<'static>, + E:'a+'b //~ ERROR only a single explicit lifetime bound is permitted +>() { } + +fn main() { } diff --git a/src/test/compile-fail/region-object-lifetime-1.rs b/src/test/compile-fail/region-object-lifetime-1.rs new file mode 100644 index 00000000000..01daeb628ef --- /dev/null +++ b/src/test/compile-fail/region-object-lifetime-1.rs @@ -0,0 +1,49 @@ +// Copyright 2012-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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Here the receiver and return value all have the same lifetime, +// so no error results. +fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () { + x.borrowed() +} + +// Borrowed receiver but two distinct lifetimes, we get an error. +fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { + x.borrowed() //~ ERROR cannot infer +} + +// Borrowed receiver with two distinct lifetimes, but we know that +// 'b:'a, hence &'a () is permitted. +fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a Foo+'b) -> &'a () { + x.borrowed() +} + +// Here we have two distinct lifetimes, but we try to return a pointer +// with the longer lifetime when (from the signature) we only know +// that it lives as long as the shorter lifetime. Therefore, error. +fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a Foo+'b) -> &'b () { + x.borrowed() //~ ERROR cannot infer +} + +// Here, the object is bounded by an anonymous lifetime and returned +// as `&'static`, so you get an error. +fn owned_receiver(x: Box<Foo>) -> &'static () { + x.borrowed() //~ ERROR cannot infer +} + +fn main() {} + diff --git a/src/test/compile-fail/regionck-closure-lifetimes.rs b/src/test/compile-fail/regionck-closure-lifetimes.rs index 846e03d57c3..bb895a318ff 100644 --- a/src/test/compile-fail/regionck-closure-lifetimes.rs +++ b/src/test/compile-fail/regionck-closure-lifetimes.rs @@ -15,7 +15,7 @@ fn env<'a>(blk: |p: ||: 'a|) { let mut state = 0i; let statep = &mut state; - blk(|| *statep = 1i); //~ ERROR cannot infer + blk(|| *statep = 1i); //~ ERROR captured variable `statep` does not outlive } fn no_env_no_for<'a>(blk: |p: |||: 'a) { diff --git a/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs b/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs index 1c590db11e3..7520a4c125a 100644 --- a/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs +++ b/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs @@ -16,9 +16,8 @@ fn main() { let mut f; { let c = 1; - let c_ref = &c; + let c_ref = &c; //~ ERROR `c` does not live long enough f = |&mut: a: int, b: int| { a + b + *c_ref }; - //~^ ERROR cannot infer an appropriate lifetime } } diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs new file mode 100644 index 00000000000..0c9f5004f57 --- /dev/null +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -0,0 +1,57 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +#![no_std] + +struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a int +} + +pub trait Foo<'a> { + fn no_bound<'b>(self, b: Inv<'b>); + fn has_bound<'b:'a>(self, b: Inv<'b>); + fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); + fn wrong_bound2<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); +} + + +impl<'a> Foo<'a> for &'a int { + fn no_bound<'b:'a>(self, b: Inv<'b>) { + //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match + } + + fn has_bound<'b>(self, b: Inv<'b>) { + //~^ ERROR lifetime parameters or bounds on method `has_bound` do not match + } + + fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { + //~^ ERROR method `wrong_bound1` has an incompatible type for trait + // + // Note: This is a terrible error message. It is caused + // because, in the trait, 'b is early bound, and in the impl, + // 'c is early bound, so -- after substitution -- the + // lifetimes themselves look isomorphic. We fail because the + // lifetimes that appear in the types are in the wrong + // order. This should really be fixed by keeping more + // information about the lifetime declarations in the trait so + // that we can compare better to the impl, even in cross-crate + // cases. + } + + fn wrong_bound2<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { + //~^ ERROR distinct set of bounds from its counterpart + } +} + +fn main() { } diff --git a/src/test/compile-fail/regions-bounded-by-send.rs b/src/test/compile-fail/regions-bounded-by-send.rs new file mode 100644 index 00000000000..3c7ffbc8d1f --- /dev/null +++ b/src/test/compile-fail/regions-bounded-by-send.rs @@ -0,0 +1,91 @@ +// Copyright 2012 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. The tests +// in this file all test region bound and lifetime violations that are +// detected during type check. + +fn assert_send<T:Send>() { } +trait Dummy { } + +// lifetime pointers with 'static lifetime are ok + +fn static_lifime_ok<'a,T,U:Send>(_: &'a int) { + assert_send::<&'static int>(); + assert_send::<&'static str>(); + assert_send::<&'static [int]>(); + + // whether or not they are mutable + assert_send::<&'static mut int>(); +} + +// otherwise lifetime pointers are not ok + +fn param_not_ok<'a>(x: &'a int) { + assert_send::<&'a int>(); //~ ERROR does not fulfill +} + +fn param_not_ok1<'a>(_: &'a int) { + assert_send::<&'a str>(); //~ ERROR does not fulfill +} + +fn param_not_ok2<'a>(_: &'a int) { + assert_send::<&'a [int]>(); //~ ERROR does not fulfill +} + +// boxes are ok + +fn box_ok() { + assert_send::<Box<int>>(); + assert_send::<String>(); + assert_send::<Vec<int>>(); +} + +// but not if they own a bad thing + +fn box_with_region_not_ok<'a>() { + assert_send::<Box<&'a int>>(); //~ ERROR does not fulfill +} + +// objects with insufficient bounds no ok + +fn object_with_random_bound_not_ok<'a>() { + assert_send::<&'a Dummy+'a>(); //~ ERROR does not fulfill +} + +fn object_with_send_bound_not_ok<'a>() { + assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill +} + +fn proc_with_lifetime_not_ok<'a>() { + assert_send::<proc():'a>(); //~ ERROR does not fulfill +} + +fn closure_with_lifetime_not_ok<'a>() { + assert_send::<||:'a>(); //~ ERROR does not fulfill +} + +// unsafe pointers are ok unless they point at unsendable things + +fn unsafe_ok1<'a>(_: &'a int) { + assert_send::<*const int>(); + assert_send::<*mut int>(); +} + +fn unsafe_ok2<'a>(_: &'a int) { + assert_send::<*const &'a int>(); //~ ERROR does not fulfill +} + +fn unsafe_ok3<'a>(_: &'a int) { + assert_send::<*mut &'a int>(); //~ ERROR does not fulfill +} + +fn main() { +} diff --git a/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs b/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs new file mode 100644 index 00000000000..04a94b75215 --- /dev/null +++ b/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs @@ -0,0 +1,73 @@ +// Copyright 2012 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. The tests +// in this file all test region bound and lifetime violations that are +// detected during type check. + +trait Dummy : 'static { } +fn assert_send<T:'static>() { } + +// lifetime pointers with 'static lifetime are ok + +fn static_lifime_ok<'a,T,U:Send>(_: &'a int) { + assert_send::<&'static int>(); + assert_send::<&'static str>(); + assert_send::<&'static [int]>(); + + // whether or not they are mutable + assert_send::<&'static mut int>(); +} + +// otherwise lifetime pointers are not ok + +fn param_not_ok<'a>(x: &'a int) { + assert_send::<&'a int>(); //~ ERROR does not fulfill +} + +fn param_not_ok1<'a>(_: &'a int) { + assert_send::<&'a str>(); //~ ERROR does not fulfill +} + +fn param_not_ok2<'a>(_: &'a int) { + assert_send::<&'a [int]>(); //~ ERROR does not fulfill +} + +// boxes are ok + +fn box_ok() { + assert_send::<Box<int>>(); + assert_send::<String>(); + assert_send::<Vec<int>>(); +} + +// but not if they own a bad thing + +fn box_with_region_not_ok<'a>() { + assert_send::<Box<&'a int>>(); //~ ERROR does not fulfill +} + +// unsafe pointers are ok unless they point at unsendable things + +fn unsafe_ok1<'a>(_: &'a int) { + assert_send::<*const int>(); + assert_send::<*mut int>(); +} + +fn unsafe_ok2<'a>(_: &'a int) { + assert_send::<*const &'a int>(); //~ ERROR does not fulfill +} + +fn unsafe_ok3<'a>(_: &'a int) { + assert_send::<*mut &'a int>(); //~ ERROR does not fulfill +} + +fn main() { +} diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs new file mode 100644 index 00000000000..ab97bad5bc2 --- /dev/null +++ b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs @@ -0,0 +1,33 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:regions-bounded-method-type-parameters-cross-crate-lib.rs + +// Check explicit region bounds on methods in the cross crate case. + +extern crate lib = "regions-bounded-method-type-parameters-cross-crate-lib"; + +use lib::Inv; +use lib::MaybeOwned; +use lib::IntoMaybeOwned; + +fn call_into_maybe_owned<'a,F:IntoMaybeOwned<'a>>(f: F) { + // Exercise a code path I found to be buggy. We were not encoding + // the region parameters from the receiver correctly on trait + // methods. + f.into_maybe_owned(); +} + +fn call_bigger_region<'a, 'b>(a: Inv<'a>, b: Inv<'b>) { + // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. + a.bigger_region(b) //~ ERROR cannot infer +} + +fn main() { } diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs new file mode 100644 index 00000000000..e628eb3285a --- /dev/null +++ b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs @@ -0,0 +1,44 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![feature(lang_items)] + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +#[lang="sized"] +trait Sized { } + +struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a int +} + +trait Foo<'x> { + fn method<'y:'x>(self, y: Inv<'y>); +} + +fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'a, and hence 'a:'a holds. + f.method(a); +} + +fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. + f.method(b); //~ ERROR cannot infer +} + +fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'b, and hence 'b:'a holds. + f.method(b); +} + +fn main() { } diff --git a/src/test/compile-fail/proc-static-bound.rs b/src/test/compile-fail/regions-bounded-method-type-parameters.rs index f11ddc0151f..ba1993686d5 100644 --- a/src/test/compile-fail/proc-static-bound.rs +++ b/src/test/compile-fail/regions-bounded-method-type-parameters.rs @@ -8,19 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { - let mut x = Some(1); - let mut p: proc(&mut Option<int>) = proc(_) {}; - match x { - Some(ref y) => { - p = proc(z: &mut Option<int>) { - *z = None; - let _ = y; - //~^ ERROR cannot capture variable of type `&int`, which does not fulfill `'static` - }; - } - None => {} - } - p(&mut x); +#![no_std] + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +struct Foo; + +impl Foo { + fn some_method<A:'static>(self) { } +} + +fn caller<'a>(x: &int) { + Foo.some_method::<&'a int>(); + //~^ ERROR does not fulfill the required lifetime } +fn main() { } diff --git a/src/test/compile-fail/owned-ptr-static-bound.rs b/src/test/compile-fail/regions-close-object-into-object.rs index dc6e8b1d6be..a45c8e1db54 100644 --- a/src/test/compile-fail/owned-ptr-static-bound.rs +++ b/src/test/compile-fail/regions-close-object-into-object.rs @@ -10,21 +10,25 @@ trait A<T> {} -struct B<'a, T>(&'a A<T>); +struct B<'a, T>(&'a A<T>+'a); trait X {} impl<'a, T> X for B<'a, T> {} -fn f<'a, T, U>(v: Box<A<T>>) -> Box<X> { - box B(v) as Box<X> //~ ERROR value may contain references; add `'static` bound to `T` +fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> { + box B(v) as Box<X> } -fn g<'a, T, U>(v: Box<A<U>>) -> Box<X> { - box B(v) as Box<X> //~ ERROR value may contain references; add `'static` bound to `U` +fn g<'a, T: 'static>(v: Box<A<T>>) -> Box<X+'static> { + box B(v) as Box<X> //~ ERROR cannot infer } -fn h<'a, T: 'static>(v: Box<A<T>>) -> Box<X> { - box B(v) as Box<X> // ok +fn h<'a, T, U>(v: Box<A<U>+'static>) -> Box<X+'static> { + box B(v) as Box<X> +} + +fn i<'a, T, U>(v: Box<A<U>>) -> Box<X+'static> { + box B(v) as Box<X> //~ ERROR cannot infer } fn main() {} diff --git a/src/test/compile-fail/regions-bound-lists-feature-gate-2.rs b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs index 0f79716f370..037514f45c7 100644 --- a/src/test/compile-fail/regions-bound-lists-feature-gate-2.rs +++ b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs @@ -8,11 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-pretty - trait Foo { } -fn foo<'a, 'b:'a>() { //~ ERROR region bounds require `issue_5723_bootstrap` -} +impl<'a> Foo for &'a int { } -pub fn main() { } +fn main() { + let blah; + { + let ss: &int = &1; //~ ERROR borrowed value does not live long enough + blah = box ss as Box<Foo>; + } +} diff --git a/src/test/compile-fail/regions-close-over-type-parameter-1.rs b/src/test/compile-fail/regions-close-over-type-parameter-1.rs new file mode 100644 index 00000000000..5465f199f40 --- /dev/null +++ b/src/test/compile-fail/regions-close-over-type-parameter-1.rs @@ -0,0 +1,31 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for what happens when a type parameter `A` is closed over into +// an object. This should yield errors unless `A` (and the object) +// both have suitable bounds. + +trait SomeTrait { fn get(&self) -> int; } + +fn make_object1<A:SomeTrait>(v: A) -> Box<SomeTrait+'static> { + box v as Box<SomeTrait+'static> + //~^ ERROR the parameter type `A` may not live long enough +} + +fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'a> { + box v as Box<SomeTrait+'a> +} + +fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'b> { + box v as Box<SomeTrait+'b> + //~^ ERROR the parameter type `A` may not live long enough +} + +fn main() { } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/regions-close-over-type-parameter-2.rs index 50704a1afbf..0ee349aaebf 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/regions-close-over-type-parameter-2.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,25 +8,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test for what happens when a type parameter `A` is closed over into +// an object. This should yield errors unless `A` (and the object) +// both have suitable bounds. -trait Repeat<A> { fn get(&self) -> A; } +trait Foo { fn get(&self); } -impl<A:Clone> Repeat<A> for A { - fn get(&self) -> A { self.clone() } +impl<A> Foo for A { + fn get(&self) { } } -fn repeater<A:Clone>(v: A) -> Box<Repeat<A>> { - box v as Box<Repeat<A>> // No +fn repeater3<'a,A:'a>(v: A) -> Box<Foo+'a> { + box v as Box<Foo+'a> } fn main() { // Error results because the type of is inferred to be // ~Repeat<&'blk int> where blk is the lifetime of the block below. - let y = { + let _ = { let tmp0 = 3i; let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough - repeater(tmp1) + repeater3(tmp1) }; - assert!(3 == *(y.get())); } diff --git a/src/test/compile-fail/regions-early-bound-error.rs b/src/test/compile-fail/regions-early-bound-error.rs index 25016c104ad..5da281d93dd 100644 --- a/src/test/compile-fail/regions-early-bound-error.rs +++ b/src/test/compile-fail/regions-early-bound-error.rs @@ -15,7 +15,7 @@ trait GetRef<'a, T> { fn get(&self) -> &'a T; } -struct Box<'a, T> { +struct Box<'a, T:'a> { t: &'a T } diff --git a/src/test/compile-fail/regions-enum-not-wf.rs b/src/test/compile-fail/regions-enum-not-wf.rs new file mode 100644 index 00000000000..6395ee62f16 --- /dev/null +++ b/src/test/compile-fail/regions-enum-not-wf.rs @@ -0,0 +1,37 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various examples of structs whose fields are not well-formed. + +#![no_std] +#![allow(dead_code)] + +enum Ref1<'a, T> { //~ ERROR the parameter type `T` may not live long enough + Ref1Variant1(&'a T) +} + +enum Ref2<'a, T> { //~ ERROR the parameter type `T` may not live long enough + Ref2Variant1, + Ref2Variant2(int, &'a T), +} + +enum RefOk<'a, T:'a> { + RefOkVariant1(&'a T) +} + +enum RefIndirect<'a, T> { //~ ERROR the parameter type `T` may not live long enough + RefIndirectVariant1(int, RefOk<'a,T>) +} + +enum RefDouble<'a, 'b, T> { //~ ERROR reference has a longer lifetime than the data + RefDoubleVariant1(&'a &'b T) +} + +fn main() { } diff --git a/src/test/compile-fail/regions-escape-bound-fn-2.rs b/src/test/compile-fail/regions-escape-bound-fn-2.rs index d2551ec4fed..d752bc97cac 100644 --- a/src/test/compile-fail/regions-escape-bound-fn-2.rs +++ b/src/test/compile-fail/regions-escape-bound-fn-2.rs @@ -16,5 +16,6 @@ fn with_int(f: |x: &int|) { fn main() { let mut x = None; //~^ ERROR lifetime of variable does not enclose its declaration + //~^^ ERROR type of expression contains references that are not valid during the expression with_int(|y| x = Some(y)); } diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs index 980a4aed34f..adef1f901fd 100644 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs @@ -8,17 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait deref { +#![no_std] + +#![allow(dead_code)] + +trait Deref { fn get(self) -> int; } -impl<'a> deref for &'a int { +impl<'a> Deref for &'a int { fn get(self) -> int { *self } } -fn with<R:deref>(f: |x: &int| -> R) -> int { +fn with<R:Deref>(f: |x: &int| -> R) -> int { f(&3).get() } diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index 9762e5c4690..26cf3be429b 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -31,6 +31,12 @@ fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint { } fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: |&'a &'b uint|) { + // Do not infer ordering from closure argument types. + let z: Option<&'a &'b uint> = None; + //~^ ERROR reference has a longer lifetime than the data it references +} + +fn ordering5<'a, 'b>(a: &'a uint, b: &'b uint, x: Option<&'a &'b uint>) { let z: Option<&'a &'b uint> = None; } diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs index 2f8caabb7f8..55c0cf3bb26 100644 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ b/src/test/compile-fail/regions-free-region-ordering-caller.rs @@ -16,18 +16,18 @@ struct Paramd<'a> { x: &'a uint } fn call2<'a, 'b>(a: &'a uint, b: &'b uint) { let z: Option<&'b &'a uint> = None; - //~^ ERROR pointer has a longer lifetime than the data it references + //~^ ERROR reference has a longer lifetime than the data it references } fn call3<'a, 'b>(a: &'a uint, b: &'b uint) { let y: Paramd<'a> = Paramd { x: a }; let z: Option<&'b Paramd<'a>> = None; - //~^ ERROR pointer has a longer lifetime than the data it references + //~^ ERROR reference has a longer lifetime than the data it references } fn call4<'a, 'b>(a: &'a uint, b: &'b uint) { - let z: Option<|&'a &'b uint|> = None; - //~^ ERROR pointer has a longer lifetime than the data it references + let z: Option<&'a &'b uint> = None; + //~^ ERROR reference has a longer lifetime than the data it references } diff --git a/src/test/compile-fail/regions-free-region-ordering-incorrect.rs b/src/test/compile-fail/regions-free-region-ordering-incorrect.rs index 6f6b6761735..9cb61c24922 100644 --- a/src/test/compile-fail/regions-free-region-ordering-incorrect.rs +++ b/src/test/compile-fail/regions-free-region-ordering-incorrect.rs @@ -15,7 +15,7 @@ // // This test began its life as a test for issue #4325. -struct Node<'b, T> { +struct Node<'b, T:'b> { val: T, next: Option<&'b Node<'b, T>> } diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index cef3b525997..76bbe71cf75 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -12,7 +12,7 @@ fn wants_static_fn(_x: ||: 'static) {} fn main() { let i = 3i; - wants_static_fn(|| { //~ ERROR cannot infer - println!("i={}", i); + wants_static_fn(|| { + println!("i={}", i); //~ ERROR captured variable `i` does not outlive }) } diff --git a/src/test/compile-fail/regions-infer-bound-from-trait-self.rs b/src/test/compile-fail/regions-infer-bound-from-trait-self.rs new file mode 100644 index 00000000000..25fd20b6ec5 --- /dev/null +++ b/src/test/compile-fail/regions-infer-bound-from-trait-self.rs @@ -0,0 +1,61 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can derive lifetime bounds on `Self` from trait +// inheritance. + +trait Static : 'static { } + +trait Is<'a> : 'a { } + +struct Inv<'a> { + x: Option<&'a mut &'a int> +} + +fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + +// In these case, `Self` inherits `'static`. + +trait InheritsFromStatic : 'static { + fn foo1<'a>(self, x: Inv<'a>) { + check_bound(x, self) + } +} +trait InheritsFromStaticIndirectly : Static { + fn foo1<'a>(self, x: Inv<'a>) { + check_bound(x, self) + } +} + + +// In these case, `Self` inherits `'a`. + +trait InheritsFromIs<'a> : 'a { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + } +} + +trait InheritsFromIsIndirectly<'a> : Is<'a> { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + } +} + +// In this case, `Self` inherits nothing. + +trait InheritsFromNothing<'a> { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + //~^ ERROR parameter type `Self` may not live long enough + } +} + +fn main() { } diff --git a/src/test/compile-fail/regions-infer-bound-from-trait.rs b/src/test/compile-fail/regions-infer-bound-from-trait.rs new file mode 100644 index 00000000000..d1111377f1e --- /dev/null +++ b/src/test/compile-fail/regions-infer-bound-from-trait.rs @@ -0,0 +1,50 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can derive lifetime bounds on type parameters +// from trait inheritance. + +trait Static : 'static { } + +trait Is<'a> : 'a { } + +struct Inv<'a> { + x: Option<&'a mut &'a int> +} + +fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + +// In all of these cases, we can derive a bound for A that is longer +// than 'a based on the trait bound of A: + +fn foo1<'a,A:Static>(x: Inv<'a>, a: A) { + check_bound(x, a) +} + +fn foo2<'a,A:Static>(x: Inv<'static>, a: A) { + check_bound(x, a) +} + +fn foo3<'a,A:Is<'a>>(x: Inv<'a>, a: A) { + check_bound(x, a) +} + +// In these cases, there is no trait bound, so we cannot derive any +// bound for A and we get an error: + +fn bar1<'a,A>(x: Inv<'a>, a: A) { + check_bound(x, a) //~ ERROR parameter type `A` may not live long enough +} + +fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { + check_bound(x, a) //~ ERROR parameter type `A` may not live long enough +} + +fn main() { } diff --git a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs index a743ff81b30..0fa4969b54c 100644 --- a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs @@ -11,7 +11,7 @@ // check that the &int here does not cause us to think that `foo` // contains region pointers -struct foo(proc(x: &int)); +struct foo(proc(x: &int):'static); fn take_foo(x: foo<'static>) {} //~ ERROR wrong number of lifetime parameters diff --git a/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs b/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs new file mode 100644 index 00000000000..a52d2f9f9a0 --- /dev/null +++ b/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs @@ -0,0 +1,41 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] + +fn a<'a, 'b:'a>(x: &mut &'a int, y: &mut &'b int) { + // Note: this is legal because of the `'b:'a` declaration. + *x = *y; +} + +fn b<'a, 'b>(x: &mut &'a int, y: &mut &'b int) { + // Illegal now because there is no `'b:'a` declaration. + *x = *y; //~ ERROR mismatched types +} + +fn c<'a,'b>(x: &mut &'a int, y: &mut &'b int) { + // Here we try to call `foo` but do not know that `'a` and `'b` are + // related as required. + a(x, y); //~ ERROR cannot infer +} + +fn d() { + // 'a and 'b are early bound in the function `a` because they appear + // inconstraints: + let _: fn(&mut &int, &mut &int) = a; //~ ERROR mismatched types +} + +fn e() { + // 'a and 'b are late bound in the function `b` because there are + // no constraints: + let _: fn(&mut &int, &mut &int) = b; +} + +fn main() { } diff --git a/src/test/compile-fail/regions-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs new file mode 100644 index 00000000000..e32ef275256 --- /dev/null +++ b/src/test/compile-fail/regions-proc-bound-capture.rs @@ -0,0 +1,26 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn borrowed_proc<'a>(x: &'a int) -> proc():'a -> int { + // This is legal, because the region bound on `proc` + // states that it captures `x`. + proc() { + *x + } +} + +fn static_proc<'a>(x: &'a int) -> proc():'static -> int { + // This is illegal, because the region bound on `proc` is 'static. + proc() { //~ ERROR captured variable `x` outlives the `proc()` + *x + } +} + +fn main() { } diff --git a/src/test/compile-fail/regions-bound-lists-feature-gate.rs b/src/test/compile-fail/regions-proc-bounds.rs index de3b2faef86..db71bc4e15c 100644 --- a/src/test/compile-fail/regions-bound-lists-feature-gate.rs +++ b/src/test/compile-fail/regions-proc-bounds.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn is_static<T: 'static>() {} -trait Foo { } +fn foo<'a>() { + is_static::<proc():'a>(); + //~^ ERROR does not fulfill the required lifetime -fn foo<'a>(x: Box<Foo + 'a>) { //~ ERROR only the 'static lifetime is accepted here -} - -fn bar<'a, T:'a>() { //~ ERROR only the 'static lifetime is accepted here + is_static::<proc():'static>(); } fn main() { } diff --git a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs b/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs index d3e0740a0fe..50ea8b1f2ed 100644 --- a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs +++ b/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs @@ -11,7 +11,7 @@ // Issue #8624. Test for reborrowing with 3 levels, not just two. fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut int) -> &'b mut int { - &mut ***p //~ ERROR cannot infer an appropriate lifetime + &mut ***p //~ ERROR lifetime of `p` is too short to guarantee its contents } fn main() { diff --git a/src/test/compile-fail/regions-ret-borrowed-1.rs b/src/test/compile-fail/regions-ret-borrowed-1.rs index df46b2aaac0..aac81a2af6b 100644 --- a/src/test/compile-fail/regions-ret-borrowed-1.rs +++ b/src/test/compile-fail/regions-ret-borrowed-1.rs @@ -18,8 +18,9 @@ fn with<R>(f: <'a>|x: &'a int| -> R) -> R { fn return_it<'a>() -> &'a int { with(|o| o) - //~^ ERROR lifetime of return value does not outlive the function call - //~^^ ERROR cannot infer + //~^ ERROR cannot infer + //~^^ ERROR not valid during the expression + //~^^^ ERROR not valid at this point } fn main() { diff --git a/src/test/compile-fail/regions-ret-borrowed.rs b/src/test/compile-fail/regions-ret-borrowed.rs index 507a48fb741..dd9421ee2ef 100644 --- a/src/test/compile-fail/regions-ret-borrowed.rs +++ b/src/test/compile-fail/regions-ret-borrowed.rs @@ -21,8 +21,9 @@ fn with<R>(f: |x: &int| -> R) -> R { fn return_it<'a>() -> &'a int { with(|o| o) - //~^ ERROR lifetime of return value does not outlive the function call - //~^^ ERROR cannot infer + //~^ ERROR cannot infer + //~^^ ERROR not valid during the expression + //~^^^ ERROR not valid at this point } fn main() { diff --git a/src/test/compile-fail/regions-struct-not-wf.rs b/src/test/compile-fail/regions-struct-not-wf.rs new file mode 100644 index 00000000000..3de137a9efb --- /dev/null +++ b/src/test/compile-fail/regions-struct-not-wf.rs @@ -0,0 +1,32 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various examples of structs whose fields are not well-formed. + +#![no_std] +#![allow(dead_code)] + +struct Ref<'a, T> { //~ ERROR the parameter type `T` may not live long enough + field: &'a T +} + +struct RefOk<'a, T:'a> { + field: &'a T +} + +struct RefIndirect<'a, T> { //~ ERROR the parameter type `T` may not live long enough + field: RefOk<'a, T> +} + +struct DoubleRef<'a, 'b, T> { //~ ERROR reference has a longer lifetime than the data it references + field: &'a &'b T +} + +fn main() { } diff --git a/src/test/compile-fail/regions-trait-variance.rs b/src/test/compile-fail/regions-trait-variance.rs index 53cfd4e0324..3ceb4e3fef6 100644 --- a/src/test/compile-fail/regions-trait-variance.rs +++ b/src/test/compile-fail/regions-trait-variance.rs @@ -31,7 +31,7 @@ impl Drop for B { } struct A<'r> { - p: &'r X + p: &'r X+'r } fn make_a(p:&X) -> A { diff --git a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs index 5cc3f1bdc37..7dcdc9875e3 100644 --- a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs +++ b/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs @@ -31,7 +31,7 @@ fn use_<'short,'long>(c: Covariant<'long>, // contravariant with respect to its parameter 'a. let _: Covariant<'short> = c; //~ ERROR mismatched types - //~^ ERROR cannot infer an appropriate lifetime + //~^ ERROR cannot infer an appropriate lifetime } fn main() {} diff --git a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs index 0790c3f956a..d09e6babe09 100644 --- a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs +++ b/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs @@ -15,7 +15,7 @@ // variance inference works in the first place. struct Invariant<'a> { - f: &'static mut &'a int + f: &'a mut &'a int } fn use_<'short,'long>(c: Invariant<'long>, diff --git a/src/test/compile-fail/regions-variance-invariant-use-covariant.rs b/src/test/compile-fail/regions-variance-invariant-use-covariant.rs index 9cdd05f8ebe..861668ad50d 100644 --- a/src/test/compile-fail/regions-variance-invariant-use-covariant.rs +++ b/src/test/compile-fail/regions-variance-invariant-use-covariant.rs @@ -15,7 +15,7 @@ // variance inference works in the first place. struct Invariant<'a> { - f: &'static mut &'a int + f: &'a mut &'a int } fn use_<'b>(c: Invariant<'b>) { diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index 3bf547e3aff..bf7c3b261fd 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -13,7 +13,7 @@ trait add { fn plus(&self, x: Self) -> Self; } -fn do_add(x: Box<add>, y: Box<add>) -> Box<add> { +fn do_add(x: Box<add+'static>, y: Box<add+'static>) -> Box<add+'static> { x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through an object } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index c36610fc79e..2cb1f462e1d 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -16,6 +16,6 @@ fn f<T:'static>(_: T) {} fn main() { let x = box(GC) 3i; f(x); - let x = &3i; - f(x); //~ ERROR instantiating a type parameter with an incompatible type + let x = &3i; //~ ERROR borrowed value does not live long enough + f(x); } diff --git a/src/test/compile-fail/trailing-plus-in-bounds.rs b/src/test/compile-fail/trailing-plus-in-bounds.rs index e8f9ed4d2cf..b189acb685a 100644 --- a/src/test/compile-fail/trailing-plus-in-bounds.rs +++ b/src/test/compile-fail/trailing-plus-in-bounds.rs @@ -11,7 +11,7 @@ use std::fmt::Show; fn main() { - let x: Box<Show+> = box 3 as Box<Show+>; + let x: Box<Show+> = box 3i as Box<Show+>; //~^ ERROR at least one type parameter bound must be specified //~^^ ERROR at least one type parameter bound must be specified } diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index c3d608b48f3..7ed8db4fcd2 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -16,15 +16,16 @@ trait Foo {} fn a(_x: Box<Foo+Send>) { } -fn b(_x: &'static Foo) { // should be same as &'static Foo+'static +fn b(_x: &'static Foo+'static) { } fn c(x: Box<Foo+Sync>) { - a(x); //~ ERROR expected bounds `Send` + a(x); //~ ERROR mismatched types } fn d(x: &'static Foo+Sync) { - b(x); //~ ERROR expected bounds `'static` + b(x); //~ ERROR cannot infer + //~^ ERROR mismatched types } fn main() {} diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs index 0f9cfab7b8a..9694c1d9f98 100644 --- a/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs +++ b/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs @@ -11,7 +11,7 @@ // This test checks that the `_` type placeholder does not react // badly if put as a lifetime parameter. -struct Foo<'a, T> { +struct Foo<'a, T:'a> { r: &'a T } diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs index e9671b353b9..365b786cc1a 100644 --- a/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs +++ b/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs @@ -11,7 +11,7 @@ // This test checks that the `_` type placeholder does not react // badly if put as a lifetime parameter. -struct Foo<'a, T> { +struct Foo<'a, T:'a> { r: &'a T } diff --git a/src/test/compile-fail/unconstrained-ref.rs b/src/test/compile-fail/unconstrained-ref.rs index a4125f94cd2..87647cdb546 100644 --- a/src/test/compile-fail/unconstrained-ref.rs +++ b/src/test/compile-fail/unconstrained-ref.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S<'a, T> { +struct S<'a, T:'a> { o: &'a Option<T> } diff --git a/src/test/compile-fail/unsized4.rs b/src/test/compile-fail/unsized4.rs index e377c9d5f41..a66c1d85009 100644 --- a/src/test/compile-fail/unsized4.rs +++ b/src/test/compile-fail/unsized4.rs @@ -12,7 +12,7 @@ trait T {} fn f<Sized? Y: T>() { -//~^ERROR incompatible bounds on type parameter Y, bound T does not allow unsized type +//~^ERROR incompatible bounds on type parameter `Y`, bound `T` does not allow unsized type } pub fn main() { diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index 043f3a233a6..3f2f43b0c9b 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -23,10 +23,10 @@ impl fmt::Show for Number { } struct List { - list: Vec<Box<ToString>> } + list: Vec<Box<ToString+'static>> } impl List { - fn push(&mut self, n: Box<ToString>) { + fn push(&mut self, n: Box<ToString+'static>) { self.list.push(n); } } diff --git a/src/test/compile-fail/variance-regions-direct.rs b/src/test/compile-fail/variance-regions-direct.rs index da4f9846187..fa38482b21c 100644 --- a/src/test/compile-fail/variance-regions-direct.rs +++ b/src/test/compile-fail/variance-regions-direct.rs @@ -32,7 +32,7 @@ struct Test3<'a, 'b, 'c> { //~ ERROR regions=[[+, +, +];[];[]] // Mutability induces invariance: #[rustc_variance] -struct Test4<'a, 'b> { //~ ERROR regions=[[-, o];[];[]] +struct Test4<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[]] x: &'a mut &'b int, } @@ -64,7 +64,7 @@ struct Test7<'a> { //~ ERROR regions=[[*];[];[]] // Try enums too. #[rustc_variance] -enum Test8<'a, 'b, 'c> { //~ ERROR regions=[[+, -, o];[];[]] +enum Test8<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[]] Test8A(extern "Rust" fn(&'a int)), Test8B(&'b [int]), Test8C(&'b mut &'c str), diff --git a/src/test/compile-fail/variance-regions-indirect.rs b/src/test/compile-fail/variance-regions-indirect.rs index 0d20f652496..c049fbc0fed 100644 --- a/src/test/compile-fail/variance-regions-indirect.rs +++ b/src/test/compile-fail/variance-regions-indirect.rs @@ -13,29 +13,29 @@ // Try enums too. #[rustc_variance] -enum Base<'a, 'b, 'c, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] +enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] Test8A(extern "Rust" fn(&'a int)), Test8B(&'b [int]), Test8C(&'b mut &'c str), } #[rustc_variance] -struct Derived1<'w, 'x, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]] +struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]] f: Base<'z, 'y, 'x, 'w> } #[rustc_variance] // Combine - and + to yield o -struct Derived2<'a, 'b, 'c> { //~ ERROR regions=[[o, o, *];[];[]] +struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[]] f: Base<'a, 'a, 'b, 'c> } #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) -struct Derived3<'a, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]] +struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]] f: Base<'a, 'b, 'a, 'c> } #[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here) -struct Derived4<'a, 'b, 'c> { //~ ERROR regions=[[+, -, o];[];[]] +struct Derived4<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[]] f: Base<'a, 'b, 'c, 'a> } diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index 92fa8124d68..eb20a09477d 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -17,7 +17,7 @@ fn call_it(f: proc(String) -> String) { } fn call_this(f: |&str|: Send) { } -fn call_that(f: <'a>|&'a int, &'a int|: -> int) { } +fn call_that(f: <'a>|&'a int, &'a int| -> int) { } fn call_extern(f: fn() -> int) { } diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index ddf79d1d750..86e394e5408 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -48,8 +48,8 @@ pub fn bar() { as core::fmt::rt::Piece<'static>)] as [core::fmt::rt::Piece<'static>, .. 1]); let __args_vec = - (&([] as [core::fmt::Argument<'static>, .. 0]) as - &'static [core::fmt::Argument<'static>, .. 0]); + (&([] as [core::fmt::Argument<'_>, .. 0]) as + &[core::fmt::Argument<'_>, .. 0]); let __args = (unsafe { ((::std::fmt::Arguments::new as @@ -58,9 +58,9 @@ pub fn bar() { [core::fmt::rt::Piece<'static>, .. 1]), (__args_vec as - &'static [core::fmt::Argument<'static>, .. 0])) - as core::fmt::Arguments<'static>) - } as core::fmt::Arguments<'static>); + &[core::fmt::Argument<'_>, .. 0])) + as core::fmt::Arguments<'_>) + } as core::fmt::Arguments<'_>); @@ -72,9 +72,9 @@ pub fn bar() { ((::std::fmt::format as fn(&core::fmt::Arguments<'_>) -> collections::string::String)((&(__args as - core::fmt::Arguments<'static>) + core::fmt::Arguments<'_>) as - &core::fmt::Arguments<'static>)) + &core::fmt::Arguments<'_>)) as collections::string::String) } } as collections::string::String); diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 7c05e6d6065..f575fb32924 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -14,7 +14,7 @@ trait Tr { } impl Tr for int { } -fn foo(x: Box<Tr+ Sync>) -> Box<Tr+ Sync> { x } +fn foo<'a>(x: Box<Tr+ Sync + 'a>) -> Box<Tr+ Sync + 'a> { x } fn main() { let x: Box<Tr+ Sync>; diff --git a/src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot index a5239a6cc66..c5455ab90dc 100644 --- a/src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot @@ -2,8 +2,10 @@ digraph block { N0[label="entry"]; N1[label="exit"]; N2[label="expr 1i"]; - N3[label="block { 1i; }"]; + N3[label="stmt 1i;"]; + N4[label="block { 1i; }"]; N0 -> N2; N2 -> N3; - N3 -> N1; + N3 -> N4; + N4 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f02.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f02.dot-expected.dot index ada3f091808..230dcbaeb98 100644 --- a/src/test/run-make/graphviz-flowgraph/f02.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f02.dot-expected.dot @@ -2,8 +2,10 @@ digraph block { N0[label="entry"]; N1[label="exit"]; N2[label="local _x"]; - N3[label="block { let _x: int; }"]; + N3[label="stmt let _x: int;"]; + N4[label="block { let _x: int; }"]; N0 -> N2; N2 -> N3; - N3 -> N1; + N3 -> N4; + N4 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot index 43462862f6e..e60d349ad14 100644 --- a/src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot @@ -4,10 +4,12 @@ digraph block { N2[label="expr 3i"]; N3[label="expr 33i"]; N4[label="expr 3i + 33i"]; - N5[label="block { 3i + 33i; }"]; + N5[label="stmt 3i + 33i;"]; + N6[label="block { 3i + 33i; }"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; - N5 -> N1; + N5 -> N6; + N6 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot index 26c858a0828..82cdcb39fbf 100644 --- a/src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot @@ -3,9 +3,11 @@ digraph block { N1[label="exit"]; N2[label="expr 4i"]; N3[label="local _x"]; - N4[label="block { let _x = 4i; }"]; + N4[label="stmt let _x = 4i;"]; + N5[label="block { let _x = 4i; }"]; N0 -> N2; N2 -> N3; N3 -> N4; - N4 -> N1; + N4 -> N5; + N5 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot index 850d04f430f..8a27d536ffc 100644 --- a/src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot @@ -7,7 +7,8 @@ digraph block { N5[label="local _x"]; N6[label="local _y"]; N7[label="pat (_x, _y)"]; - N8[label="block { let (_x, _y) = (5i, 55i); }"]; + N8[label="stmt let (_x, _y) = (5i, 55i);"]; + N9[label="block { let (_x, _y) = (5i, 55i); }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -15,5 +16,6 @@ digraph block { N5 -> N6; N6 -> N7; N7 -> N8; - N8 -> N1; + N8 -> N9; + N9 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot index b431476f84a..54e9d89d3fb 100644 --- a/src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f06.dot-expected.dot @@ -5,11 +5,13 @@ digraph block { N3[label="expr S6{val: 6,}"]; N4[label="local _x"]; N5[label="pat S6 { val: _x }"]; - N6[label="block { let S6 { val: _x } = S6{val: 6,}; }"]; + N6[label="stmt let S6 { val: _x } = S6{val: 6,};"]; + N7[label="block { let S6 { val: _x } = S6{val: 6,}; }"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; - N6 -> N1; + N6 -> N7; + N7 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot index 2b7088fbc33..4c6383324e5 100644 --- a/src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot @@ -15,7 +15,8 @@ digraph block { N13[label="expr x"]; N14[label="expr y"]; N15[label="expr x + y"]; - N16[label="block { match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, }; }"]; + N16[label="stmt match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, };"]; + N17[label="block { match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, }; }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -31,5 +32,6 @@ digraph block { N14 -> N15; N15 -> N7; N7 -> N16; - N16 -> N1; + N16 -> N17; + N17 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot index f43beb025e3..27a240ed182 100644 --- a/src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot @@ -3,16 +3,19 @@ digraph block { N1[label="exit"]; N2[label="expr 8i"]; N3[label="local x"]; - N4[label="local _y"]; - N5[label="expr x"]; - N6[label="expr 88i"]; - N7[label="expr x > 88i"]; - N8[label="expr 888i"]; - N9[label="expr _y"]; - N10[label="expr _y = 888i"]; - N11[label="block { _y = 888i; }"]; - N12[label="expr if x > 88i { _y = 888i; }"]; - N13[label="block { let x = 8i; let _y; if x > 88i { _y = 888i; } }"]; + N4[label="stmt let x = 8i;"]; + N5[label="local _y"]; + N6[label="stmt let _y;"]; + N7[label="expr x"]; + N8[label="expr 88i"]; + N9[label="expr x > 88i"]; + N10[label="expr 888i"]; + N11[label="expr _y"]; + N12[label="expr _y = 888i"]; + N13[label="stmt _y = 888i;"]; + N14[label="block { _y = 888i; }"]; + N15[label="expr if x > 88i { _y = 888i; }"]; + N16[label="block { let x = 8i; let _y; if x > 88i { _y = 888i; } }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -23,8 +26,11 @@ digraph block { N8 -> N9; N9 -> N10; N10 -> N11; - N7 -> N12; N11 -> N12; N12 -> N13; - N13 -> N1; + N13 -> N14; + N9 -> N15; + N14 -> N15; + N15 -> N16; + N16 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot index a3576b9c36b..d2c58c6d59a 100644 --- a/src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot @@ -3,23 +3,27 @@ digraph block { N1[label="exit"]; N2[label="expr 91i"]; N3[label="local x"]; - N4[label="local _y"]; - N5[label="expr x"]; - N6[label="expr 92i"]; - N7[label="expr x > 92i"]; - N8[label="expr 93i"]; - N9[label="expr _y"]; - N10[label="expr _y = 93i"]; - N11[label="block { _y = 93i; }"]; - N12[label="expr 94i"]; - N13[label="expr 95i"]; - N14[label="expr 94i + 95i"]; - N15[label="expr _y"]; - N16[label="expr _y = 94i + 95i"]; - N17[label="block { _y = 94i + 95i; }"]; - N18[label="expr { _y = 94i + 95i; }"]; - N19[label="expr if x > 92i { _y = 93i; } else { _y = 94i + 95i; }"]; - N20[label="block { let x = 91i; let _y; if x > 92i { _y = 93i; } else { _y = 94i + 95i; } }"]; + N4[label="stmt let x = 91i;"]; + N5[label="local _y"]; + N6[label="stmt let _y;"]; + N7[label="expr x"]; + N8[label="expr 92i"]; + N9[label="expr x > 92i"]; + N10[label="expr 93i"]; + N11[label="expr _y"]; + N12[label="expr _y = 93i"]; + N13[label="stmt _y = 93i;"]; + N14[label="block { _y = 93i; }"]; + N15[label="expr 94i"]; + N16[label="expr 95i"]; + N17[label="expr 94i + 95i"]; + N18[label="expr _y"]; + N19[label="expr _y = 94i + 95i"]; + N20[label="stmt _y = 94i + 95i;"]; + N21[label="block { _y = 94i + 95i; }"]; + N22[label="expr { _y = 94i + 95i; }"]; + N23[label="expr if x > 92i { _y = 93i; } else { _y = 94i + 95i; }"]; + N24[label="block { let x = 91i; let _y; if x > 92i { _y = 93i; } else { _y = 94i + 95i; } }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -30,15 +34,19 @@ digraph block { N8 -> N9; N9 -> N10; N10 -> N11; - N7 -> N12; + N11 -> N12; N12 -> N13; N13 -> N14; - N14 -> N15; + N9 -> N15; N15 -> N16; N16 -> N17; N17 -> N18; - N11 -> N19; N18 -> N19; N19 -> N20; - N20 -> N1; + N20 -> N21; + N21 -> N22; + N14 -> N23; + N22 -> N23; + N23 -> N24; + N24 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot index 69b5bd6f58c..421a79fd136 100644 --- a/src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot @@ -3,16 +3,18 @@ digraph block { N1[label="exit"]; N2[label="expr 10i"]; N3[label="local mut x"]; - N4[label="(dummy_node)"]; - N5[label="expr x"]; - N6[label="expr 0i"]; - N7[label="expr x > 0i"]; - N8[label="expr while x > 0i { x -= 1i; }"]; - N9[label="expr 1i"]; - N10[label="expr x"]; - N11[label="expr x -= 1i"]; - N12[label="block { x -= 1i; }"]; - N13[label="block { let mut x = 10i; while x > 0i { x -= 1i; } }"]; + N4[label="stmt let mut x = 10i;"]; + N5[label="(dummy_node)"]; + N6[label="expr x"]; + N7[label="expr 0i"]; + N8[label="expr x > 0i"]; + N9[label="expr while x > 0i { x -= 1i; }"]; + N10[label="expr 1i"]; + N11[label="expr x"]; + N12[label="expr x -= 1i"]; + N13[label="stmt x -= 1i;"]; + N14[label="block { x -= 1i; }"]; + N15[label="block { let mut x = 10i; while x > 0i { x -= 1i; } }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -20,11 +22,13 @@ digraph block { N5 -> N6; N6 -> N7; N7 -> N8; - N7 -> N9; - N9 -> N10; + N8 -> N9; + N8 -> N10; N10 -> N11; N11 -> N12; - N12 -> N4; - N8 -> N13; - N13 -> N1; + N12 -> N13; + N13 -> N14; + N14 -> N5; + N9 -> N15; + N15 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot index 44024cf76f3..b928058fed9 100644 --- a/src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot @@ -3,23 +3,31 @@ digraph block { N1[label="exit"]; N2[label="expr 11i"]; N3[label="local mut _x"]; - N4[label="(dummy_node)"]; - N5[label="expr loop { _x -= 1i; }"]; - N6[label="expr 1i"]; - N7[label="expr _x"]; - N8[label="expr _x -= 1i"]; - N9[label="block { _x -= 1i; }"]; - N10[label="expr \"unreachable\""]; - N11[label="block { let mut _x = 11i; loop { _x -= 1i; } \"unreachable\"; }"]; + N4[label="stmt let mut _x = 11i;"]; + N5[label="(dummy_node)"]; + N6[label="expr loop { _x -= 1i; }"]; + N7[label="expr 1i"]; + N8[label="expr _x"]; + N9[label="expr _x -= 1i"]; + N10[label="stmt _x -= 1i;"]; + N11[label="block { _x -= 1i; }"]; + N12[label="stmt loop { _x -= 1i; }"]; + N13[label="expr \"unreachable\""]; + N14[label="stmt \"unreachable\";"]; + N15[label="block { let mut _x = 11i; loop { _x -= 1i; } \"unreachable\"; }"]; N0 -> N2; N2 -> N3; N3 -> N4; - N4 -> N6; - N6 -> N7; + N4 -> N5; + N5 -> N7; N7 -> N8; N8 -> N9; - N9 -> N4; - N5 -> N10; + N9 -> N10; N10 -> N11; - N11 -> N1; + N11 -> N5; + N6 -> N12; + N12 -> N13; + N13 -> N14; + N14 -> N15; + N15 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot index ad257c19741..d89a37308de 100644 --- a/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot @@ -3,38 +3,46 @@ digraph block { N1[label="exit"]; N2[label="expr 12i"]; N3[label="local mut x"]; - N4[label="(dummy_node)"]; - N5[label="expr loop { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; - N6[label="expr 1i"]; - N7[label="expr x"]; - N8[label="expr x -= 1i"]; - N9[label="expr x"]; - N10[label="expr 2i"]; - N11[label="expr x == 2i"]; - N12[label="expr break"]; - N13[label="(dummy_node)"]; - N14[label="expr \"unreachable\""]; - N15[label="block { break ; \"unreachable\"; }"]; - N16[label="expr if x == 2i { break ; \"unreachable\"; }"]; - N17[label="block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; - N18[label="block { let mut x = 12i; loop { x -= 1i; if x == 2i { break ; \"unreachable\"; } } }"]; + N4[label="stmt let mut x = 12i;"]; + N5[label="(dummy_node)"]; + N6[label="expr loop { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; + N7[label="expr 1i"]; + N8[label="expr x"]; + N9[label="expr x -= 1i"]; + N10[label="stmt x -= 1i;"]; + N11[label="expr x"]; + N12[label="expr 2i"]; + N13[label="expr x == 2i"]; + N14[label="expr break"]; + N15[label="(dummy_node)"]; + N16[label="stmt break ;"]; + N17[label="expr \"unreachable\""]; + N18[label="stmt \"unreachable\";"]; + N19[label="block { break ; \"unreachable\"; }"]; + N20[label="expr if x == 2i { break ; \"unreachable\"; }"]; + N21[label="block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; + N22[label="block { let mut x = 12i; loop { x -= 1i; if x == 2i { break ; \"unreachable\"; } } }"]; N0 -> N2; N2 -> N3; N3 -> N4; - N4 -> N6; - N6 -> N7; + N4 -> N5; + N5 -> N7; N7 -> N8; N8 -> N9; N9 -> N10; N10 -> N11; N11 -> N12; - N12 -> N5[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2i { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; + N12 -> N13; N13 -> N14; - N14 -> N15; - N11 -> N16; + N14 -> N6[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2i { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"]; N15 -> N16; N16 -> N17; - N17 -> N4; - N5 -> N18; - N18 -> N1; + N17 -> N18; + N18 -> N19; + N13 -> N20; + N19 -> N20; + N20 -> N21; + N21 -> N5; + N6 -> N22; + N22 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot index 5d1d1253b22..aa43ef51534 100644 --- a/src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f13.dot-expected.dot @@ -5,44 +5,48 @@ digraph block { N3[label="expr 13"]; N4[label="expr E13b(13)"]; N5[label="local x"]; - N6[label="local _y"]; - N7[label="expr x"]; - N8[label="expr match x { E13a => _y = 1, E13b(v) => _y = v + 1, }"]; - N9[label="(dummy_node)"]; - N10[label="local E13a"]; - N11[label="expr 1"]; - N12[label="expr _y"]; - N13[label="expr _y = 1"]; - N14[label="(dummy_node)"]; - N15[label="local v"]; - N16[label="pat E13b(v)"]; - N17[label="expr v"]; - N18[label="expr 1"]; - N19[label="expr v + 1"]; - N20[label="expr _y"]; - N21[label="expr _y = v + 1"]; - N22[label="block {\l let x = E13b(13);\l let _y;\l match x { E13a => _y = 1, E13b(v) => _y = v + 1, }\l}\l"]; + N6[label="stmt let x = E13b(13);"]; + N7[label="local _y"]; + N8[label="stmt let _y;"]; + N9[label="expr x"]; + N10[label="expr match x { E13a => _y = 1, E13b(v) => _y = v + 1, }"]; + N11[label="(dummy_node)"]; + N12[label="local E13a"]; + N13[label="expr 1"]; + N14[label="expr _y"]; + N15[label="expr _y = 1"]; + N16[label="(dummy_node)"]; + N17[label="local v"]; + N18[label="pat E13b(v)"]; + N19[label="expr v"]; + N20[label="expr 1"]; + N21[label="expr v + 1"]; + N22[label="expr _y"]; + N23[label="expr _y = v + 1"]; + N24[label="block {\l let x = E13b(13);\l let _y;\l match x { E13a => _y = 1, E13b(v) => _y = v + 1, }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; N6 -> N7; - N7 -> N9; - N9 -> N10; - N10 -> N11; + N7 -> N8; + N8 -> N9; + N9 -> N11; N11 -> N12; N12 -> N13; - N13 -> N8; - N9 -> N14; + N13 -> N14; N14 -> N15; - N15 -> N16; + N15 -> N10; + N11 -> N16; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; N20 -> N21; - N21 -> N8; - N8 -> N22; - N22 -> N1; + N21 -> N22; + N22 -> N23; + N23 -> N10; + N10 -> N24; + N24 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot index f8e4bd12bb0..bdb2c133bad 100644 --- a/src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot @@ -3,26 +3,32 @@ digraph block { N1[label="exit"]; N2[label="expr 14i"]; N3[label="local x"]; - N4[label="expr x"]; - N5[label="expr 1i"]; - N6[label="expr x > 1i"]; - N7[label="expr return"]; - N8[label="(dummy_node)"]; - N9[label="expr \"unreachable\""]; - N10[label="block { return; \"unreachable\"; }"]; - N11[label="expr if x > 1i { return; \"unreachable\"; }"]; - N12[label="block { let x = 14i; if x > 1i { return; \"unreachable\"; } }"]; + N4[label="stmt let x = 14i;"]; + N5[label="expr x"]; + N6[label="expr 1i"]; + N7[label="expr x > 1i"]; + N8[label="expr return"]; + N9[label="(dummy_node)"]; + N10[label="stmt return;"]; + N11[label="expr \"unreachable\""]; + N12[label="stmt \"unreachable\";"]; + N13[label="block { return; \"unreachable\"; }"]; + N14[label="expr if x > 1i { return; \"unreachable\"; }"]; + N15[label="block { let x = 14i; if x > 1i { return; \"unreachable\"; } }"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; N6 -> N7; - N7 -> N1; - N8 -> N9; + N7 -> N8; + N8 -> N1; N9 -> N10; - N6 -> N11; N10 -> N11; N11 -> N12; - N12 -> N1; + N12 -> N13; + N7 -> N14; + N13 -> N14; + N14 -> N15; + N15 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot index 77ee0df5512..4bd9fc9ec1a 100644 --- a/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot @@ -3,77 +3,101 @@ digraph block { N1[label="exit"]; N2[label="expr 15i"]; N3[label="local mut x"]; - N4[label="expr 151i"]; - N5[label="local mut y"]; - N6[label="(dummy_node)"]; - N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l }\l"]; + N4[label="stmt let mut x = 15i;"]; + N5[label="expr 151i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 151i;"]; N8[label="(dummy_node)"]; - N9[label="expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l"]; - N10[label="expr x"]; - N11[label="expr 1i"]; - N12[label="expr x == 1i"]; - N13[label="expr break \'outer"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { break \'outer ; \"unreachable\"; }"]; - N17[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"]; - N18[label="expr y"]; - N19[label="expr 2i"]; - N20[label="expr y >= 2i"]; - N21[label="expr break"]; - N22[label="(dummy_node)"]; - N23[label="expr \"unreachable\""]; - N24[label="block { break ; \"unreachable\"; }"]; - N25[label="expr if y >= 2i { break ; \"unreachable\"; }"]; - N26[label="expr 3i"]; - N27[label="expr y"]; - N28[label="expr y -= 3i"]; - N29[label="block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l"]; - N30[label="expr 4i"]; - N31[label="expr y"]; - N32[label="expr y -= 4i"]; - N33[label="expr 5i"]; - N34[label="expr x"]; - N35[label="expr x -= 5i"]; - N36[label="block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l}\l"]; - N37[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l }\l}\l"]; + N9[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l }\l"]; + N10[label="(dummy_node)"]; + N11[label="expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l"]; + N12[label="expr x"]; + N13[label="expr 1i"]; + N14[label="expr x == 1i"]; + N15[label="expr break \'outer"]; + N16[label="(dummy_node)"]; + N17[label="stmt break \'outer ;"]; + N18[label="expr \"unreachable\""]; + N19[label="stmt \"unreachable\";"]; + N20[label="block { break \'outer ; \"unreachable\"; }"]; + N21[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"]; + N22[label="stmt if x == 1i { break \'outer ; \"unreachable\"; }"]; + N23[label="expr y"]; + N24[label="expr 2i"]; + N25[label="expr y >= 2i"]; + N26[label="expr break"]; + N27[label="(dummy_node)"]; + N28[label="stmt break ;"]; + N29[label="expr \"unreachable\""]; + N30[label="stmt \"unreachable\";"]; + N31[label="block { break ; \"unreachable\"; }"]; + N32[label="expr if y >= 2i { break ; \"unreachable\"; }"]; + N33[label="stmt if y >= 2i { break ; \"unreachable\"; }"]; + N34[label="expr 3i"]; + N35[label="expr y"]; + N36[label="expr y -= 3i"]; + N37[label="stmt y -= 3i;"]; + N38[label="block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l"]; + N39[label="stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l"]; + N40[label="expr 4i"]; + N41[label="expr y"]; + N42[label="expr y -= 4i"]; + N43[label="stmt y -= 4i;"]; + N44[label="expr 5i"]; + N45[label="expr x"]; + N46[label="expr x -= 5i"]; + N47[label="stmt x -= 5i;"]; + N48[label="block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l}\l"]; + N49[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; - N6 -> N8; + N6 -> N7; + N7 -> N8; N8 -> N10; - N10 -> N11; - N11 -> N12; + N10 -> N12; N12 -> N13; - N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l}\l"]; + N13 -> N14; N14 -> N15; - N15 -> N16; - N12 -> N17; + N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l }\l y -= 4i;\l x -= 5i;\l}\l"]; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; + N14 -> N21; N20 -> N21; - N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 2i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 2i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l"]; + N21 -> N22; N22 -> N23; N23 -> N24; - N20 -> N25; N24 -> N25; N25 -> N26; - N26 -> N27; + N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 2i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 2i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { break ; \"unreachable\"; }\l y -= 3i;\l}\l"]; N27 -> N28; N28 -> N29; - N29 -> N8; - N9 -> N30; + N29 -> N30; N30 -> N31; + N25 -> N32; N31 -> N32; N32 -> N33; N33 -> N34; N34 -> N35; N35 -> N36; - N36 -> N6; - N7 -> N37; - N37 -> N1; + N36 -> N37; + N37 -> N38; + N38 -> N10; + N11 -> N39; + N39 -> N40; + N40 -> N41; + N41 -> N42; + N42 -> N43; + N43 -> N44; + N44 -> N45; + N45 -> N46; + N46 -> N47; + N47 -> N48; + N48 -> N8; + N9 -> N49; + N49 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot index b5a867e6029..16b871bd844 100644 --- a/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot @@ -3,79 +3,107 @@ digraph block { N1[label="exit"]; N2[label="expr 16i"]; N3[label="local mut x"]; - N4[label="expr 16i"]; - N5[label="local mut y"]; - N6[label="(dummy_node)"]; - N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l }\l"]; + N4[label="stmt let mut x = 16i;"]; + N5[label="expr 16i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 16i;"]; N8[label="(dummy_node)"]; - N9[label="expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l"]; - N10[label="expr x"]; - N11[label="expr 1i"]; - N12[label="expr x == 1i"]; - N13[label="expr continue \'outer"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { continue \'outer ; \"unreachable\"; }"]; - N17[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"]; - N18[label="expr y"]; - N19[label="expr 1i"]; - N20[label="expr y >= 1i"]; - N21[label="expr break"]; - N22[label="(dummy_node)"]; - N23[label="expr \"unreachable\""]; - N24[label="block { break ; \"unreachable\"; }"]; - N25[label="expr if y >= 1i { break ; \"unreachable\"; }"]; - N26[label="expr 1i"]; - N27[label="expr y"]; - N28[label="expr y -= 1i"]; - N29[label="block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l"]; - N30[label="expr 1i"]; - N31[label="expr y"]; - N32[label="expr y -= 1i"]; - N33[label="expr 1i"]; - N34[label="expr x"]; - N35[label="expr x -= 1i"]; - N36[label="block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l}\l"]; - N37[label="expr \"unreachable\""]; - N38[label="block {\l let mut x = 16i;\l let mut y = 16i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l }\l \"unreachable\";\l}\l"]; + N9[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l }\l"]; + N10[label="(dummy_node)"]; + N11[label="expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l"]; + N12[label="expr x"]; + N13[label="expr 1i"]; + N14[label="expr x == 1i"]; + N15[label="expr continue \'outer"]; + N16[label="(dummy_node)"]; + N17[label="stmt continue \'outer ;"]; + N18[label="expr \"unreachable\""]; + N19[label="stmt \"unreachable\";"]; + N20[label="block { continue \'outer ; \"unreachable\"; }"]; + N21[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"]; + N22[label="stmt if x == 1i { continue \'outer ; \"unreachable\"; }"]; + N23[label="expr y"]; + N24[label="expr 1i"]; + N25[label="expr y >= 1i"]; + N26[label="expr break"]; + N27[label="(dummy_node)"]; + N28[label="stmt break ;"]; + N29[label="expr \"unreachable\""]; + N30[label="stmt \"unreachable\";"]; + N31[label="block { break ; \"unreachable\"; }"]; + N32[label="expr if y >= 1i { break ; \"unreachable\"; }"]; + N33[label="stmt if y >= 1i { break ; \"unreachable\"; }"]; + N34[label="expr 1i"]; + N35[label="expr y"]; + N36[label="expr y -= 1i"]; + N37[label="stmt y -= 1i;"]; + N38[label="block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l"]; + N39[label="stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l"]; + N40[label="expr 1i"]; + N41[label="expr y"]; + N42[label="expr y -= 1i"]; + N43[label="stmt y -= 1i;"]; + N44[label="expr 1i"]; + N45[label="expr x"]; + N46[label="expr x -= 1i"]; + N47[label="stmt x -= 1i;"]; + N48[label="block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l}\l"]; + N49[label="stmt \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l }\l"]; + N50[label="expr \"unreachable\""]; + N51[label="stmt \"unreachable\";"]; + N52[label="block {\l let mut x = 16i;\l let mut y = 16i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l }\l \"unreachable\";\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; - N6 -> N8; + N6 -> N7; + N7 -> N8; N8 -> N10; - N10 -> N11; - N11 -> N12; + N10 -> N12; N12 -> N13; - N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l}\l"]; + N13 -> N14; N14 -> N15; - N15 -> N16; - N12 -> N17; + N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l }\l y -= 1i;\l x -= 1i;\l}\l"]; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; + N14 -> N21; N20 -> N21; - N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 1i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 1i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l"]; + N21 -> N22; N22 -> N23; N23 -> N24; - N20 -> N25; N24 -> N25; N25 -> N26; - N26 -> N27; + N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 1i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 1i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 1i { break ; \"unreachable\"; }\l y -= 1i;\l}\l"]; N27 -> N28; N28 -> N29; - N29 -> N8; - N9 -> N30; + N29 -> N30; N30 -> N31; + N25 -> N32; N31 -> N32; N32 -> N33; N33 -> N34; N34 -> N35; N35 -> N36; - N36 -> N6; - N7 -> N37; + N36 -> N37; N37 -> N38; - N38 -> N1; + N38 -> N10; + N11 -> N39; + N39 -> N40; + N40 -> N41; + N41 -> N42; + N42 -> N43; + N43 -> N44; + N44 -> N45; + N45 -> N46; + N46 -> N47; + N47 -> N48; + N48 -> N8; + N9 -> N49; + N49 -> N50; + N50 -> N51; + N51 -> N52; + N52 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot index d3e098a71f2..c78224c00df 100644 --- a/src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot @@ -6,12 +6,14 @@ digraph block { N4[label="expr 17i"]; N5[label="expr [1i, 7i, 17i]"]; N6[label="local _v"]; - N7[label="block { let _v = [1i, 7i, 17i]; }"]; + N7[label="stmt let _v = [1i, 7i, 17i];"]; + N8[label="block { let _v = [1i, 7i, 17i]; }"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; N6 -> N7; - N7 -> N1; + N7 -> N8; + N8 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot index 6345b4effaf..c4a39a519ed 100644 --- a/src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f18.dot-expected.dot @@ -1,17 +1,21 @@ digraph block { N0[label="entry"]; N1[label="exit"]; - N2[label="expr inner"]; + N2[label="stmt fn inner(x: int) -> int { x + x }"]; N3[label="expr inner"]; - N4[label="expr 18"]; - N5[label="expr inner(18)"]; - N6[label="expr inner(inner(18))"]; - N7[label="block {\l fn inner(x: int) -> int { x + x }\l inner(inner(18));\l}\l"]; + N4[label="expr inner"]; + N5[label="expr 18"]; + N6[label="expr inner(18)"]; + N7[label="expr inner(inner(18))"]; + N8[label="stmt inner(inner(18));"]; + N9[label="block {\l fn inner(x: int) -> int { x + x }\l inner(inner(18));\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; N6 -> N7; - N7 -> N1; + N7 -> N8; + N8 -> N9; + N9 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot index 5fad18536e5..8d21ef80917 100644 --- a/src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f19.dot-expected.dot @@ -1,13 +1,17 @@ digraph block { N0[label="entry"]; N1[label="exit"]; - N2[label="expr 19"]; - N3[label="expr S19{x: 19,}"]; - N4[label="local s"]; - N5[label="expr s"]; - N6[label="expr s.inner()"]; - N7[label="expr s.inner().inner()"]; - N8[label="block {\l struct S19 {\l x: int,\l }\l impl S19 {\l fn inner(self) -> S19 { S19{x: self.x + self.x,} }\l }\l let s = S19{x: 19,};\l s.inner().inner();\l}\l"]; + N2[label="stmt struct S19 {\l x: int,\l}\l"]; + N3[label="stmt impl S19 {\l fn inner(self) -> S19 { S19{x: self.x + self.x,} }\l}\l"]; + N4[label="expr 19"]; + N5[label="expr S19{x: 19,}"]; + N6[label="local s"]; + N7[label="stmt let s = S19{x: 19,};"]; + N8[label="expr s"]; + N9[label="expr s.inner()"]; + N10[label="expr s.inner().inner()"]; + N11[label="stmt s.inner().inner();"]; + N12[label="block {\l struct S19 {\l x: int,\l }\l impl S19 {\l fn inner(self) -> S19 { S19{x: self.x + self.x,} }\l }\l let s = S19{x: 19,};\l s.inner().inner();\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -15,5 +19,9 @@ digraph block { N5 -> N6; N6 -> N7; N7 -> N8; - N8 -> N1; + N8 -> N9; + N9 -> N10; + N10 -> N11; + N11 -> N12; + N12 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot index 716ec469fb0..a625a1a0026 100644 --- a/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot @@ -6,10 +6,12 @@ digraph block { N4[label="expr 20u"]; N5[label="expr [2u, 0u, 20u]"]; N6[label="local v"]; - N7[label="expr v"]; - N8[label="expr 20u"]; - N9[label="expr v[20u]"]; - N10[label="block { let v = [2u, 0u, 20u]; v[20u]; }"]; + N7[label="stmt let v = [2u, 0u, 20u];"]; + N8[label="expr v"]; + N9[label="expr 20u"]; + N10[label="expr v[20u]"]; + N11[label="stmt v[20u];"]; + N12[label="block { let v = [2u, 0u, 20u]; v[20u]; }"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -19,5 +21,7 @@ digraph block { N7 -> N8; N8 -> N9; N9 -> N10; - N10 -> N1; + N10 -> N11; + N11 -> N12; + N12 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot index 2bbc3e7e5c8..ad2ef60ce29 100644 --- a/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot @@ -3,73 +3,97 @@ digraph block { N1[label="exit"]; N2[label="expr 15i"]; N3[label="local mut x"]; - N4[label="expr 151i"]; - N5[label="local mut y"]; - N6[label="(dummy_node)"]; - N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l"]; + N4[label="stmt let mut x = 15i;"]; + N5[label="expr 151i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 151i;"]; N8[label="(dummy_node)"]; - N9[label="expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l"]; - N10[label="expr x"]; - N11[label="expr 1i"]; - N12[label="expr x == 1i"]; - N13[label="expr break \'outer"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { break \'outer ; \"unreachable\"; }"]; - N17[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"]; - N18[label="expr y"]; - N19[label="expr 2i"]; - N20[label="expr y >= 2i"]; - N21[label="expr return"]; - N22[label="(dummy_node)"]; - N23[label="expr \"unreachable\""]; - N24[label="block { return; \"unreachable\"; }"]; - N25[label="expr if y >= 2i { return; \"unreachable\"; }"]; - N26[label="expr 3i"]; - N27[label="expr y"]; - N28[label="expr y -= 3i"]; - N29[label="expr 5i"]; - N30[label="expr x"]; - N31[label="expr x -= 5i"]; - N32[label="block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l}\l"]; - N33[label="expr \"unreachable\""]; - N34[label="block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l}\l"]; - N35[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l}\l"]; + N9[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l"]; + N10[label="(dummy_node)"]; + N11[label="expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l"]; + N12[label="expr x"]; + N13[label="expr 1i"]; + N14[label="expr x == 1i"]; + N15[label="expr break \'outer"]; + N16[label="(dummy_node)"]; + N17[label="stmt break \'outer ;"]; + N18[label="expr \"unreachable\""]; + N19[label="stmt \"unreachable\";"]; + N20[label="block { break \'outer ; \"unreachable\"; }"]; + N21[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"]; + N22[label="stmt if x == 1i { break \'outer ; \"unreachable\"; }"]; + N23[label="expr y"]; + N24[label="expr 2i"]; + N25[label="expr y >= 2i"]; + N26[label="expr return"]; + N27[label="(dummy_node)"]; + N28[label="stmt return;"]; + N29[label="expr \"unreachable\""]; + N30[label="stmt \"unreachable\";"]; + N31[label="block { return; \"unreachable\"; }"]; + N32[label="expr if y >= 2i { return; \"unreachable\"; }"]; + N33[label="stmt if y >= 2i { return; \"unreachable\"; }"]; + N34[label="expr 3i"]; + N35[label="expr y"]; + N36[label="expr y -= 3i"]; + N37[label="stmt y -= 3i;"]; + N38[label="expr 5i"]; + N39[label="expr x"]; + N40[label="expr x -= 5i"]; + N41[label="stmt x -= 5i;"]; + N42[label="block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l}\l"]; + N43[label="stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l"]; + N44[label="expr \"unreachable\""]; + N45[label="stmt \"unreachable\";"]; + N46[label="block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l}\l"]; + N47[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; - N6 -> N8; + N6 -> N7; + N7 -> N8; N8 -> N10; - N10 -> N11; - N11 -> N12; + N10 -> N12; N12 -> N13; - N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l}\l"]; + N13 -> N14; N14 -> N15; - N15 -> N16; - N12 -> N17; + N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l}\l"]; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; + N14 -> N21; N20 -> N21; - N21 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l"]; + N21 -> N22; N22 -> N23; N23 -> N24; - N20 -> N25; N24 -> N25; N25 -> N26; - N26 -> N27; + N26 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { break \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l y -= 3i;\l x -= 5i;\l }\l \"unreachable\";\l }\l"]; N27 -> N28; N28 -> N29; N29 -> N30; N30 -> N31; + N25 -> N32; N31 -> N32; - N32 -> N8; - N9 -> N33; + N32 -> N33; N33 -> N34; - N34 -> N6; - N7 -> N35; - N35 -> N1; + N34 -> N35; + N35 -> N36; + N36 -> N37; + N37 -> N38; + N38 -> N39; + N39 -> N40; + N40 -> N41; + N41 -> N42; + N42 -> N10; + N11 -> N43; + N43 -> N44; + N44 -> N45; + N45 -> N46; + N46 -> N8; + N9 -> N47; + N47 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot index 8ecddba21fc..dcceb5bb937 100644 --- a/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot @@ -3,75 +3,103 @@ digraph block { N1[label="exit"]; N2[label="expr 15i"]; N3[label="local mut x"]; - N4[label="expr 151i"]; - N5[label="local mut y"]; - N6[label="(dummy_node)"]; - N7[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l"]; + N4[label="stmt let mut x = 15i;"]; + N5[label="expr 151i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 151i;"]; N8[label="(dummy_node)"]; - N9[label="expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l"]; - N10[label="expr x"]; - N11[label="expr 1i"]; - N12[label="expr x == 1i"]; - N13[label="expr continue \'outer"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { continue \'outer ; \"unreachable\"; }"]; - N17[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"]; - N18[label="expr y"]; - N19[label="expr 2i"]; - N20[label="expr y >= 2i"]; - N21[label="expr return"]; - N22[label="(dummy_node)"]; - N23[label="expr \"unreachable\""]; - N24[label="block { return; \"unreachable\"; }"]; - N25[label="expr if y >= 2i { return; \"unreachable\"; }"]; - N26[label="expr 1i"]; - N27[label="expr x"]; - N28[label="expr x -= 1i"]; - N29[label="expr 3i"]; - N30[label="expr y"]; - N31[label="expr y -= 3i"]; - N32[label="block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l}\l"]; - N33[label="expr \"unreachable\""]; - N34[label="block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l}\l"]; - N35[label="expr \"unreachable\""]; - N36[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l \"unreachable\";\l}\l"]; + N9[label="expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l"]; + N10[label="(dummy_node)"]; + N11[label="expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l"]; + N12[label="expr x"]; + N13[label="expr 1i"]; + N14[label="expr x == 1i"]; + N15[label="expr continue \'outer"]; + N16[label="(dummy_node)"]; + N17[label="stmt continue \'outer ;"]; + N18[label="expr \"unreachable\""]; + N19[label="stmt \"unreachable\";"]; + N20[label="block { continue \'outer ; \"unreachable\"; }"]; + N21[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"]; + N22[label="stmt if x == 1i { continue \'outer ; \"unreachable\"; }"]; + N23[label="expr y"]; + N24[label="expr 2i"]; + N25[label="expr y >= 2i"]; + N26[label="expr return"]; + N27[label="(dummy_node)"]; + N28[label="stmt return;"]; + N29[label="expr \"unreachable\""]; + N30[label="stmt \"unreachable\";"]; + N31[label="block { return; \"unreachable\"; }"]; + N32[label="expr if y >= 2i { return; \"unreachable\"; }"]; + N33[label="stmt if y >= 2i { return; \"unreachable\"; }"]; + N34[label="expr 1i"]; + N35[label="expr x"]; + N36[label="expr x -= 1i"]; + N37[label="stmt x -= 1i;"]; + N38[label="expr 3i"]; + N39[label="expr y"]; + N40[label="expr y -= 3i"]; + N41[label="stmt y -= 3i;"]; + N42[label="block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l}\l"]; + N43[label="stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l"]; + N44[label="expr \"unreachable\""]; + N45[label="stmt \"unreachable\";"]; + N46[label="block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l}\l"]; + N47[label="stmt \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l"]; + N48[label="expr \"unreachable\""]; + N49[label="stmt \"unreachable\";"]; + N50[label="block {\l let mut x = 15i;\l let mut y = 151i;\l \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l \"unreachable\";\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; N4 -> N5; N5 -> N6; - N6 -> N8; + N6 -> N7; + N7 -> N8; N8 -> N10; - N10 -> N11; - N11 -> N12; + N10 -> N12; N12 -> N13; - N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l}\l"]; + N13 -> N14; N14 -> N15; - N15 -> N16; - N12 -> N17; + N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l}\l"]; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; + N14 -> N21; N20 -> N21; - N21 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l"]; + N21 -> N22; N22 -> N23; N23 -> N24; - N20 -> N25; N24 -> N25; N25 -> N26; - N26 -> N27; + N26 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1i { continue \'outer ; \"unreachable\"; }\l if y >= 2i { return; \"unreachable\"; }\l x -= 1i;\l y -= 3i;\l }\l \"unreachable\";\l }\l"]; N27 -> N28; N28 -> N29; N29 -> N30; N30 -> N31; + N25 -> N32; N31 -> N32; - N32 -> N8; - N9 -> N33; + N32 -> N33; N33 -> N34; - N34 -> N6; - N7 -> N35; + N34 -> N35; N35 -> N36; - N36 -> N1; + N36 -> N37; + N37 -> N38; + N38 -> N39; + N39 -> N40; + N40 -> N41; + N41 -> N42; + N42 -> N10; + N11 -> N43; + N43 -> N44; + N44 -> N45; + N45 -> N46; + N46 -> N8; + N9 -> N47; + N47 -> N48; + N48 -> N49; + N49 -> N50; + N50 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot index 718d4687ef9..034ecfb7f20 100644 --- a/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot @@ -3,46 +3,55 @@ digraph block { N1[label="exit"]; N2[label="expr 23i"]; N3[label="local mut x"]; - N4[label="expr 23i"]; - N5[label="local mut y"]; - N6[label="expr 23i"]; - N7[label="local mut z"]; - N8[label="(dummy_node)"]; - N9[label="expr x"]; - N10[label="expr 0i"]; - N11[label="expr x > 0i"]; - N12[label="expr while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; - N13[label="expr 1i"]; - N14[label="expr x"]; - N15[label="expr x -= 1i"]; - N16[label="(dummy_node)"]; - N17[label="expr y"]; - N18[label="expr 0i"]; - N19[label="expr y > 0i"]; - N20[label="expr while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; - N21[label="expr 1i"]; - N22[label="expr y"]; - N23[label="expr y -= 1i"]; - N24[label="(dummy_node)"]; - N25[label="expr z"]; - N26[label="expr 0i"]; - N27[label="expr z > 0i"]; - N28[label="expr while z > 0i { z -= 1i; }"]; - N29[label="expr 1i"]; + N4[label="stmt let mut x = 23i;"]; + N5[label="expr 23i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 23i;"]; + N8[label="expr 23i"]; + N9[label="local mut z"]; + N10[label="stmt let mut z = 23i;"]; + N11[label="(dummy_node)"]; + N12[label="expr x"]; + N13[label="expr 0i"]; + N14[label="expr x > 0i"]; + N15[label="expr while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N16[label="expr 1i"]; + N17[label="expr x"]; + N18[label="expr x -= 1i"]; + N19[label="stmt x -= 1i;"]; + N20[label="(dummy_node)"]; + N21[label="expr y"]; + N22[label="expr 0i"]; + N23[label="expr y > 0i"]; + N24[label="expr while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; + N25[label="expr 1i"]; + N26[label="expr y"]; + N27[label="expr y -= 1i"]; + N28[label="stmt y -= 1i;"]; + N29[label="(dummy_node)"]; N30[label="expr z"]; - N31[label="expr z -= 1i"]; - N32[label="block { z -= 1i; }"]; - N33[label="expr x"]; - N34[label="expr 10i"]; - N35[label="expr x > 10i"]; - N36[label="expr return"]; - N37[label="(dummy_node)"]; - N38[label="expr \"unreachable\""]; - N39[label="block { return; \"unreachable\"; }"]; - N40[label="expr if x > 10i { return; \"unreachable\"; }"]; - N41[label="block { y -= 1i; while z > 0i { z -= 1i; } if x > 10i { return; \"unreachable\"; } }"]; - N42[label="block {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; - N43[label="block {\l let mut x = 23i;\l let mut y = 23i;\l let mut z = 23i;\l while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l }\l}\l"]; + N31[label="expr 0i"]; + N32[label="expr z > 0i"]; + N33[label="expr while z > 0i { z -= 1i; }"]; + N34[label="expr 1i"]; + N35[label="expr z"]; + N36[label="expr z -= 1i"]; + N37[label="stmt z -= 1i;"]; + N38[label="block { z -= 1i; }"]; + N39[label="stmt while z > 0i { z -= 1i; }"]; + N40[label="expr x"]; + N41[label="expr 10i"]; + N42[label="expr x > 10i"]; + N43[label="expr return"]; + N44[label="(dummy_node)"]; + N45[label="stmt return;"]; + N46[label="expr \"unreachable\""]; + N47[label="stmt \"unreachable\";"]; + N48[label="block { return; \"unreachable\"; }"]; + N49[label="expr if x > 10i { return; \"unreachable\"; }"]; + N50[label="block { y -= 1i; while z > 0i { z -= 1i; } if x > 10i { return; \"unreachable\"; } }"]; + N51[label="block {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N52[label="block {\l let mut x = 23i;\l let mut y = 23i;\l let mut z = 23i;\l while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -54,40 +63,49 @@ digraph block { N9 -> N10; N10 -> N11; N11 -> N12; - N11 -> N13; + N12 -> N13; N13 -> N14; N14 -> N15; - N15 -> N16; + N14 -> N16; N16 -> N17; N17 -> N18; N18 -> N19; N19 -> N20; - N19 -> N21; + N20 -> N21; N21 -> N22; N22 -> N23; N23 -> N24; - N24 -> N25; + N23 -> N25; N25 -> N26; N26 -> N27; N27 -> N28; - N27 -> N29; + N28 -> N29; N29 -> N30; N30 -> N31; N31 -> N32; - N32 -> N24; - N28 -> N33; - N33 -> N34; + N32 -> N33; + N32 -> N34; N34 -> N35; N35 -> N36; - N36 -> N1[label="exiting scope_0 expr while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N36 -> N37; N37 -> N38; - N38 -> N39; - N35 -> N40; + N38 -> N29; + N33 -> N39; N39 -> N40; N40 -> N41; - N41 -> N16; - N20 -> N42; - N42 -> N8; - N12 -> N43; - N43 -> N1; + N41 -> N42; + N42 -> N43; + N43 -> N1[label="exiting scope_0 expr while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0i {\l x -= 1i;\l while y > 0i {\l y -= 1i;\l while z > 0i { z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N44 -> N45; + N45 -> N46; + N46 -> N47; + N47 -> N48; + N42 -> N49; + N48 -> N49; + N49 -> N50; + N50 -> N20; + N24 -> N51; + N51 -> N11; + N15 -> N52; + N52 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot index 646d98a54a7..ddb5b865c2e 100644 --- a/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot @@ -3,61 +3,79 @@ digraph block { N1[label="exit"]; N2[label="expr 24i"]; N3[label="local mut x"]; - N4[label="expr 24i"]; - N5[label="local mut y"]; - N6[label="expr 24i"]; - N7[label="local mut z"]; - N8[label="(dummy_node)"]; - N9[label="expr loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; - N10[label="expr x"]; - N11[label="expr 0i"]; - N12[label="expr x == 0i"]; - N13[label="expr break"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { break ; \"unreachable\"; }"]; - N17[label="expr if x == 0i { break ; \"unreachable\"; }"]; - N18[label="expr 1i"]; - N19[label="expr x"]; - N20[label="expr x -= 1i"]; - N21[label="(dummy_node)"]; - N22[label="expr loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; - N23[label="expr y"]; - N24[label="expr 0i"]; - N25[label="expr y == 0i"]; - N26[label="expr break"]; - N27[label="(dummy_node)"]; - N28[label="expr \"unreachable\""]; - N29[label="block { break ; \"unreachable\"; }"]; - N30[label="expr if y == 0i { break ; \"unreachable\"; }"]; - N31[label="expr 1i"]; - N32[label="expr y"]; - N33[label="expr y -= 1i"]; + N4[label="stmt let mut x = 24i;"]; + N5[label="expr 24i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 24i;"]; + N8[label="expr 24i"]; + N9[label="local mut z"]; + N10[label="stmt let mut z = 24i;"]; + N11[label="(dummy_node)"]; + N12[label="expr loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N13[label="expr x"]; + N14[label="expr 0i"]; + N15[label="expr x == 0i"]; + N16[label="expr break"]; + N17[label="(dummy_node)"]; + N18[label="stmt break ;"]; + N19[label="expr \"unreachable\""]; + N20[label="stmt \"unreachable\";"]; + N21[label="block { break ; \"unreachable\"; }"]; + N22[label="expr if x == 0i { break ; \"unreachable\"; }"]; + N23[label="stmt if x == 0i { break ; \"unreachable\"; }"]; + N24[label="expr 1i"]; + N25[label="expr x"]; + N26[label="expr x -= 1i"]; + N27[label="stmt x -= 1i;"]; + N28[label="(dummy_node)"]; + N29[label="expr loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; + N30[label="expr y"]; + N31[label="expr 0i"]; + N32[label="expr y == 0i"]; + N33[label="expr break"]; N34[label="(dummy_node)"]; - N35[label="expr loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; - N36[label="expr z"]; - N37[label="expr 0i"]; - N38[label="expr z == 0i"]; - N39[label="expr break"]; - N40[label="(dummy_node)"]; - N41[label="expr \"unreachable\""]; - N42[label="block { break ; \"unreachable\"; }"]; - N43[label="expr if z == 0i { break ; \"unreachable\"; }"]; - N44[label="expr 1i"]; - N45[label="expr z"]; - N46[label="expr z -= 1i"]; - N47[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; - N48[label="expr x"]; - N49[label="expr 10i"]; - N50[label="expr x > 10i"]; - N51[label="expr return"]; - N52[label="(dummy_node)"]; + N35[label="stmt break ;"]; + N36[label="expr \"unreachable\""]; + N37[label="stmt \"unreachable\";"]; + N38[label="block { break ; \"unreachable\"; }"]; + N39[label="expr if y == 0i { break ; \"unreachable\"; }"]; + N40[label="stmt if y == 0i { break ; \"unreachable\"; }"]; + N41[label="expr 1i"]; + N42[label="expr y"]; + N43[label="expr y -= 1i"]; + N44[label="stmt y -= 1i;"]; + N45[label="(dummy_node)"]; + N46[label="expr loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N47[label="expr z"]; + N48[label="expr 0i"]; + N49[label="expr z == 0i"]; + N50[label="expr break"]; + N51[label="(dummy_node)"]; + N52[label="stmt break ;"]; N53[label="expr \"unreachable\""]; - N54[label="block { return; \"unreachable\"; }"]; - N55[label="expr if x > 10i { return; \"unreachable\"; }"]; - N56[label="block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; - N57[label="block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; - N58[label="block {\l let mut x = 24i;\l let mut y = 24i;\l let mut z = 24i;\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l }\l}\l"]; + N54[label="stmt \"unreachable\";"]; + N55[label="block { break ; \"unreachable\"; }"]; + N56[label="expr if z == 0i { break ; \"unreachable\"; }"]; + N57[label="stmt if z == 0i { break ; \"unreachable\"; }"]; + N58[label="expr 1i"]; + N59[label="expr z"]; + N60[label="expr z -= 1i"]; + N61[label="stmt z -= 1i;"]; + N62[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N63[label="stmt loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N64[label="expr x"]; + N65[label="expr 10i"]; + N66[label="expr x > 10i"]; + N67[label="expr return"]; + N68[label="(dummy_node)"]; + N69[label="stmt return;"]; + N70[label="expr \"unreachable\""]; + N71[label="stmt \"unreachable\";"]; + N72[label="block { return; \"unreachable\"; }"]; + N73[label="expr if x > 10i { return; \"unreachable\"; }"]; + N74[label="block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; + N75[label="block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N76[label="block {\l let mut x = 24i;\l let mut y = 24i;\l let mut z = 24i;\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -65,59 +83,77 @@ digraph block { N5 -> N6; N6 -> N7; N7 -> N8; - N8 -> N10; + N8 -> N9; + N9 -> N10; N10 -> N11; - N11 -> N12; - N12 -> N13; - N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N11 -> N13; + N13 -> N14; N14 -> N15; N15 -> N16; - N12 -> N17; - N16 -> N17; + N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; N17 -> N18; N18 -> N19; N19 -> N20; N20 -> N21; - N21 -> N23; + N15 -> N22; + N21 -> N22; + N22 -> N23; N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; + N26 -> N27; N27 -> N28; - N28 -> N29; - N25 -> N30; - N29 -> N30; + N28 -> N30; N30 -> N31; N31 -> N32; N32 -> N33; - N33 -> N34; - N34 -> N36; + N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l"]; + N34 -> N35; + N35 -> N36; N36 -> N37; N37 -> N38; + N32 -> N39; N38 -> N39; - N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N39 -> N40; N40 -> N41; N41 -> N42; - N38 -> N43; N42 -> N43; N43 -> N44; N44 -> N45; - N45 -> N46; - N46 -> N47; - N47 -> N34; - N35 -> N48; + N45 -> N47; + N47 -> N48; N48 -> N49; N49 -> N50; - N50 -> N51; - N51 -> N1[label="exiting scope_0 expr loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N51 -> N52; N52 -> N53; N53 -> N54; - N50 -> N55; N54 -> N55; + N49 -> N56; N55 -> N56; - N56 -> N21; - N22 -> N57; - N57 -> N8; - N9 -> N58; - N58 -> N1; + N56 -> N57; + N57 -> N58; + N58 -> N59; + N59 -> N60; + N60 -> N61; + N61 -> N62; + N62 -> N45; + N46 -> N63; + N63 -> N64; + N64 -> N65; + N65 -> N66; + N66 -> N67; + N67 -> N1[label="exiting scope_0 expr loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { return; \"unreachable\"; }\l }\l}\l"]; + N68 -> N69; + N69 -> N70; + N70 -> N71; + N71 -> N72; + N66 -> N73; + N72 -> N73; + N73 -> N74; + N74 -> N28; + N29 -> N75; + N75 -> N11; + N12 -> N76; + N76 -> N1; } diff --git a/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot index 11b9c7ef05e..9fd4dbfc395 100644 --- a/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot @@ -3,61 +3,79 @@ digraph block { N1[label="exit"]; N2[label="expr 25i"]; N3[label="local mut x"]; - N4[label="expr 25i"]; - N5[label="local mut y"]; - N6[label="expr 25i"]; - N7[label="local mut z"]; - N8[label="(dummy_node)"]; - N9[label="expr \'a:\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l }\l"]; - N10[label="expr x"]; - N11[label="expr 0i"]; - N12[label="expr x == 0i"]; - N13[label="expr break"]; - N14[label="(dummy_node)"]; - N15[label="expr \"unreachable\""]; - N16[label="block { break ; \"unreachable\"; }"]; - N17[label="expr if x == 0i { break ; \"unreachable\"; }"]; - N18[label="expr 1i"]; - N19[label="expr x"]; - N20[label="expr x -= 1i"]; - N21[label="(dummy_node)"]; - N22[label="expr \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l"]; - N23[label="expr y"]; - N24[label="expr 0i"]; - N25[label="expr y == 0i"]; - N26[label="expr break"]; - N27[label="(dummy_node)"]; - N28[label="expr \"unreachable\""]; - N29[label="block { break ; \"unreachable\"; }"]; - N30[label="expr if y == 0i { break ; \"unreachable\"; }"]; - N31[label="expr 1i"]; - N32[label="expr y"]; - N33[label="expr y -= 1i"]; + N4[label="stmt let mut x = 25i;"]; + N5[label="expr 25i"]; + N6[label="local mut y"]; + N7[label="stmt let mut y = 25i;"]; + N8[label="expr 25i"]; + N9[label="local mut z"]; + N10[label="stmt let mut z = 25i;"]; + N11[label="(dummy_node)"]; + N12[label="expr \'a:\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l }\l"]; + N13[label="expr x"]; + N14[label="expr 0i"]; + N15[label="expr x == 0i"]; + N16[label="expr break"]; + N17[label="(dummy_node)"]; + N18[label="stmt break ;"]; + N19[label="expr \"unreachable\""]; + N20[label="stmt \"unreachable\";"]; + N21[label="block { break ; \"unreachable\"; }"]; + N22[label="expr if x == 0i { break ; \"unreachable\"; }"]; + N23[label="stmt if x == 0i { break ; \"unreachable\"; }"]; + N24[label="expr 1i"]; + N25[label="expr x"]; + N26[label="expr x -= 1i"]; + N27[label="stmt x -= 1i;"]; + N28[label="(dummy_node)"]; + N29[label="expr \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l"]; + N30[label="expr y"]; + N31[label="expr 0i"]; + N32[label="expr y == 0i"]; + N33[label="expr break"]; N34[label="(dummy_node)"]; - N35[label="expr \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; - N36[label="expr z"]; - N37[label="expr 0i"]; - N38[label="expr z == 0i"]; - N39[label="expr break"]; - N40[label="(dummy_node)"]; - N41[label="expr \"unreachable\""]; - N42[label="block { break ; \"unreachable\"; }"]; - N43[label="expr if z == 0i { break ; \"unreachable\"; }"]; - N44[label="expr 1i"]; - N45[label="expr z"]; - N46[label="expr z -= 1i"]; - N47[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; - N48[label="expr x"]; - N49[label="expr 10i"]; - N50[label="expr x > 10i"]; - N51[label="expr continue \'a"]; - N52[label="(dummy_node)"]; + N35[label="stmt break ;"]; + N36[label="expr \"unreachable\""]; + N37[label="stmt \"unreachable\";"]; + N38[label="block { break ; \"unreachable\"; }"]; + N39[label="expr if y == 0i { break ; \"unreachable\"; }"]; + N40[label="stmt if y == 0i { break ; \"unreachable\"; }"]; + N41[label="expr 1i"]; + N42[label="expr y"]; + N43[label="expr y -= 1i"]; + N44[label="stmt y -= 1i;"]; + N45[label="(dummy_node)"]; + N46[label="expr \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N47[label="expr z"]; + N48[label="expr 0i"]; + N49[label="expr z == 0i"]; + N50[label="expr break"]; + N51[label="(dummy_node)"]; + N52[label="stmt break ;"]; N53[label="expr \"unreachable\""]; - N54[label="block { continue \'a ; \"unreachable\"; }"]; - N55[label="expr if x > 10i { continue \'a ; \"unreachable\"; }"]; - N56[label="block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; - N57[label="block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l}\l"]; - N58[label="block {\l let mut x = 25i;\l let mut y = 25i;\l let mut z = 25i;\l \'a:\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a:\l loop {\l if z == 0i { break ; \"unreachable\"; }\l z -= 1i;\l }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l }\l}\l"]; + N54[label="stmt \"unreachable\";"]; + N55[label="block { break ; \"unreachable\"; }"]; + N56[label="expr if z == 0i { break ; \"unreachable\"; }"]; + N57[label="stmt if z == 0i { break ; \"unreachable\"; }"]; + N58[label="expr 1i"]; + N59[label="expr z"]; + N60[label="expr z -= 1i"]; + N61[label="stmt z -= 1i;"]; + N62[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N63[label="stmt \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N64[label="expr x"]; + N65[label="expr 10i"]; + N66[label="expr x > 10i"]; + N67[label="expr continue \'a"]; + N68[label="(dummy_node)"]; + N69[label="stmt continue \'a ;"]; + N70[label="expr \"unreachable\""]; + N71[label="stmt \"unreachable\";"]; + N72[label="block { continue \'a ; \"unreachable\"; }"]; + N73[label="expr if x > 10i { continue \'a ; \"unreachable\"; }"]; + N74[label="block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; + N75[label="block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l}\l"]; + N76[label="block {\l let mut x = 25i;\l let mut y = 25i;\l let mut z = 25i;\l \'a:\l loop {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a:\l loop {\l if z == 0i { break ; \"unreachable\"; }\l z -= 1i;\l }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l }\l}\l"]; N0 -> N2; N2 -> N3; N3 -> N4; @@ -65,59 +83,77 @@ digraph block { N5 -> N6; N6 -> N7; N7 -> N8; - N8 -> N10; + N8 -> N9; + N9 -> N10; N10 -> N11; - N11 -> N12; - N12 -> N13; - N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l}\l"]; + N11 -> N13; + N13 -> N14; N14 -> N15; N15 -> N16; - N12 -> N17; - N16 -> N17; + N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0i { break ; \"unreachable\"; }\l x -= 1i;\l \'a:\l loop {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l }\l}\l"]; N17 -> N18; N18 -> N19; N19 -> N20; N20 -> N21; - N21 -> N23; + N15 -> N22; + N21 -> N22; + N22 -> N23; N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; + N26 -> N27; N27 -> N28; - N28 -> N29; - N25 -> N30; - N29 -> N30; + N28 -> N30; N30 -> N31; N31 -> N32; N32 -> N33; - N33 -> N34; - N34 -> N36; + N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; + N34 -> N35; + N35 -> N36; N36 -> N37; N37 -> N38; + N32 -> N39; N38 -> N39; - N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N39 -> N40; N40 -> N41; N41 -> N42; - N38 -> N43; N42 -> N43; N43 -> N44; N44 -> N45; - N45 -> N46; - N46 -> N47; - N47 -> N34; - N35 -> N48; + N45 -> N47; + N47 -> N48; N48 -> N49; N49 -> N50; - N50 -> N51; - N51 -> N21[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10i { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; + N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"]; + N51 -> N52; N52 -> N53; N53 -> N54; - N50 -> N55; N54 -> N55; + N49 -> N56; N55 -> N56; - N56 -> N21; - N22 -> N57; - N57 -> N8; - N9 -> N58; - N58 -> N1; + N56 -> N57; + N57 -> N58; + N58 -> N59; + N59 -> N60; + N60 -> N61; + N61 -> N62; + N62 -> N45; + N46 -> N63; + N63 -> N64; + N64 -> N65; + N65 -> N66; + N66 -> N67; + N67 -> N28[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10i { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l if y == 0i { break ; \"unreachable\"; }\l y -= 1i;\l \'a: loop { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"]; + N68 -> N69; + N69 -> N70; + N70 -> N71; + N71 -> N72; + N66 -> N73; + N72 -> N73; + N73 -> N74; + N74 -> N28; + N29 -> N75; + N75 -> N11; + N12 -> N76; + N76 -> N1; } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index dec53672d87..6e67b3f6add 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -29,11 +29,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>> { +fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> { box Invoker { a: a, b: b, - } as (Box<Invokable<A>>) + } as (Box<Invokable<A>+'static>) } pub fn main() { diff --git a/src/test/run-pass/borrowck-freeze-frozen-mut.rs b/src/test/run-pass/borrowck-freeze-frozen-mut.rs index 4044e9f06af..f224042bc79 100644 --- a/src/test/run-pass/borrowck-freeze-frozen-mut.rs +++ b/src/test/run-pass/borrowck-freeze-frozen-mut.rs @@ -10,7 +10,7 @@ // Test that a `&mut` inside of an `&` is freezable. -struct MutSlice<'a, T> { +struct MutSlice<'a, T:'a> { data: &'a mut [T] } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 59d532a40e7..69878d4a06b 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -33,11 +33,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>> { +fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> { box Invoker { a: a, b: b, - } as (Box<Invokable<A>>) + } as (Box<Invokable<A>+'static>) } pub fn main() { diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs index c05f2502a89..aa4d48e5ae0 100644 --- a/src/test/run-pass/closure-reform.rs +++ b/src/test/run-pass/closure-reform.rs @@ -26,7 +26,7 @@ fn call_this(f: |&str|:Send) { f("Hello!"); } -fn call_that(f: <'a>|&'a int, &'a int|: -> int) { +fn call_that(f: <'a>|&'a int, &'a int| -> int) { let (ten, forty_two) = (10, 42); println!("Your lucky number is {}", f(&ten, &forty_two)); } diff --git a/src/test/run-pass/closure-syntax.rs b/src/test/run-pass/closure-syntax.rs index 7b8d1dd7576..c2fbc2a4bf2 100644 --- a/src/test/run-pass/closure-syntax.rs +++ b/src/test/run-pass/closure-syntax.rs @@ -13,16 +13,16 @@ fn foo<T>() {} trait Bar1 {} -impl Bar1 for proc() {} +impl Bar1 for proc():'static {} trait Bar2 {} -impl Bar2 for proc(): Send {} +impl Bar2 for proc():Send {} trait Bar3 {} impl<'b> Bar3 for <'a>|&'a int|: 'b + Send -> &'a int {} trait Bar4 {} -impl Bar4 for proc<'a>(&'a int) -> &'a int {} +impl Bar4 for proc<'a>(&'a int):'static -> &'a int {} struct Foo<'a> { a: ||: 'a, @@ -30,9 +30,9 @@ struct Foo<'a> { c: <'b>||: 'a, d: ||: 'a + Sync, e: <'b>|int|: 'a + Sync -> &'b f32, - f: proc(), - g: proc(): 'static + Sync, - h: proc<'b>(int): Sync -> &'b f32, + f: proc():'static, + g: proc():'static+Sync, + h: proc<'b>(int):'static+Sync -> &'b f32, } fn f<'a>(a: &'a int, f: <'b>|&'b int| -> &'b int) -> &'a int { diff --git a/src/test/run-pass/colorful-write-macros.rs b/src/test/run-pass/colorful-write-macros.rs index 724e57bdef2..60b6d8f8be0 100644 --- a/src/test/run-pass/colorful-write-macros.rs +++ b/src/test/run-pass/colorful-write-macros.rs @@ -18,7 +18,7 @@ use std::fmt; use std::fmt::FormatWriter; struct Foo<'a> { - writer: &'a mut Writer, + writer: &'a mut Writer+'a, other: &'a str, } diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index ac2922e92d4..e95b1ed2f0e 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -13,8 +13,8 @@ * * The hash should concentrate entropy in the lower bits. */ -type HashFn<K> = proc(K) -> uint; -type EqFn<K> = proc(K, K) -> bool; +type HashFn<K> = proc(K):'static -> uint; +type EqFn<K> = proc(K, K):'static -> bool; struct LM { resize_at: uint, size: uint } diff --git a/src/test/run-pass/issue-10802.rs b/src/test/run-pass/issue-10802.rs index 4fda506ae64..7487ea81fa8 100644 --- a/src/test/run-pass/issue-10802.rs +++ b/src/test/run-pass/issue-10802.rs @@ -30,9 +30,9 @@ trait MyTrait { } impl MyTrait for Box<DroppableStruct> {} impl MyTrait for Box<DroppableEnum> {} -struct Whatever { w: Box<MyTrait> } +struct Whatever { w: Box<MyTrait+'static> } impl Whatever { - fn new(w: Box<MyTrait>) -> Whatever { + fn new(w: Box<MyTrait+'static>) -> Whatever { Whatever { w: w } } } diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index 5b52bc34d2b..c2c291c0bec 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -49,7 +49,7 @@ fn main() { foog(x, &[box 1i]); struct T<'a> { - t: [&'a Foo, ..2] + t: [&'a Foo+'a, ..2] } let _n = T { t: [&1i, &2i] @@ -64,7 +64,7 @@ fn main() { }; struct F<'b> { - t: &'b [&'b Foo] + t: &'b [&'b Foo+'b] } let _n = F { t: &[&1i, &2i] @@ -80,7 +80,7 @@ fn main() { }; struct M<'a> { - t: &'a [Box<Foo>] + t: &'a [Box<Foo+'static>] } let _n = M { t: &[box 1i, box 2i] diff --git a/src/test/run-pass/issue-11612.rs b/src/test/run-pass/issue-11612.rs index 5fb2274a446..fa25d25df05 100644 --- a/src/test/run-pass/issue-11612.rs +++ b/src/test/run-pass/issue-11612.rs @@ -14,7 +14,7 @@ trait A {} -struct B<'a, T> { +struct B<'a, T:'a> { f: &'a T } diff --git a/src/test/run-pass/issue-11677.rs b/src/test/run-pass/issue-11677.rs index 5a244250852..14c1b1b06ea 100644 --- a/src/test/run-pass/issue-11677.rs +++ b/src/test/run-pass/issue-11677.rs @@ -14,7 +14,8 @@ trait X<T> {} -struct S<T> {f: Box<X<T>>, g: Box<X<T>>} +struct S<T> {f: Box<X<T>+'static>, + g: Box<X<T>+'static>} struct F; impl X<int> for F {} diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index b53c2258736..c2bd8c5b3e5 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -14,7 +14,7 @@ trait Foo {} struct Bar; -impl<'a> std::ops::Fn<(&'a Foo,), ()> for Bar { +impl<'a> std::ops::Fn<(&'a Foo+'a,), ()> for Bar { extern "rust-call" fn call(&self, _: (&'a Foo,)) {} } diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index af0bc78094e..74b9df9b88d 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -33,8 +33,8 @@ impl Alloy { } } -impl<'a, 'b> Fn<(&'b mut Response,),()> for SendFile<'a> { - extern "rust-call" fn call(&self, (_res,): (&'b mut Response,)) {} +impl<'a, 'b> Fn<(&'b mut Response+'b,),()> for SendFile<'a> { + extern "rust-call" fn call(&self, (_res,): (&'b mut Response+'b,)) {} } impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld { diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 11ebf014bc6..9eec2d048d4 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -12,8 +12,8 @@ trait hax { } impl<A> hax for A { } -fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax> { - box x as Box<hax> +fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax+'static> { + box x as Box<hax+'static> } fn deadcode() { diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 1a5b175cffc..74b64bb87cf 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -12,8 +12,8 @@ trait hax { } impl<A> hax for A { } -fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax> { - box x as Box<hax> +fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax+'static> { + box x as Box<hax+'static> } fn deadcode() { diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index b7818ea732a..2dac64b2ec8 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -15,7 +15,7 @@ use std::path::{Path}; use std::path; use std::result; -type rsrc_loader = proc(path: &Path) -> result::Result<String, String>; +type rsrc_loader = proc(path: &Path):'static -> result::Result<String, String>; fn tester() { diff --git a/src/test/run-pass/issue-5192.rs b/src/test/run-pass/issue-5192.rs index 0dd6623a349..3b1a8c4a190 100644 --- a/src/test/run-pass/issue-5192.rs +++ b/src/test/run-pass/issue-5192.rs @@ -28,12 +28,12 @@ impl EventLoop for UvEventLoop { } pub struct Scheduler { - event_loop: Box<EventLoop>, + event_loop: Box<EventLoop+'static>, } impl Scheduler { - pub fn new(event_loop: Box<EventLoop>) -> Scheduler { + pub fn new(event_loop: Box<EventLoop+'static>) -> Scheduler { Scheduler { event_loop: event_loop, } diff --git a/src/test/run-pass/issue-5554.rs b/src/test/run-pass/issue-5554.rs index 9151fb2b764..24dcc3838c5 100644 --- a/src/test/run-pass/issue-5554.rs +++ b/src/test/run-pass/issue-5554.rs @@ -17,7 +17,10 @@ pub struct X<T> { } // reordering these bounds stops the ICE -impl<T: Default + PartialEq + Default> Default for X<T> { +// +// nmatsakis: This test used to have the bounds Default + PartialEq + +// Default, but having duplicate bounds became illegal. +impl<T: Default + PartialEq> Default for X<T> { fn default() -> X<T> { X { a: Default::default() } } diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs index 2bb320e5562..6168753b6d7 100644 --- a/src/test/run-pass/issue-5708.rs +++ b/src/test/run-pass/issue-5708.rs @@ -29,7 +29,7 @@ impl Inner for int { } struct Outer<'a> { - inner: &'a Inner + inner: &'a Inner+'a } impl<'a> Outer<'a> { @@ -51,7 +51,7 @@ pub fn main() { trait MyTrait<T> { } pub struct MyContainer<'a, T> { - foos: Vec<&'a MyTrait<T>> , + foos: Vec<&'a MyTrait<T>+'a> , } impl<'a, T> MyContainer<'a, T> { diff --git a/src/test/run-pass/issue-6318.rs b/src/test/run-pass/issue-6318.rs index 6512db3b1c5..a4576bc7c8c 100644 --- a/src/test/run-pass/issue-6318.rs +++ b/src/test/run-pass/issue-6318.rs @@ -10,7 +10,7 @@ pub enum Thing { - A(Box<Foo>) + A(Box<Foo+'static>) } pub trait Foo {} @@ -20,7 +20,7 @@ pub struct Struct; impl Foo for Struct {} pub fn main() { - match A(box Struct as Box<Foo>) { + match A(box Struct as Box<Foo+'static>) { A(_a) => 0i, }; } diff --git a/src/test/run-pass/issue-8249.rs b/src/test/run-pass/issue-8249.rs index 3ca6c806ef5..dae5db11b0a 100644 --- a/src/test/run-pass/issue-8249.rs +++ b/src/test/run-pass/issue-8249.rs @@ -13,7 +13,7 @@ struct B; impl A for B {} struct C<'a> { - foo: &'a mut A, + foo: &'a mut A+'a, } fn foo(a: &mut A) { diff --git a/src/test/run-pass/issue-9719.rs b/src/test/run-pass/issue-9719.rs index ac200e6c1ac..0f054a3083d 100644 --- a/src/test/run-pass/issue-9719.rs +++ b/src/test/run-pass/issue-9719.rs @@ -16,7 +16,7 @@ mod a { pub trait X {} impl X for int {} - pub struct Z<'a>(Enum<&'a X>); + pub struct Z<'a>(Enum<&'a X+'a>); fn foo() { let x = 42i; let z = Z(A(&x as &X)); let _ = z; } } @@ -24,7 +24,7 @@ mod b { trait X {} impl X for int {} struct Y<'a>{ - x:Option<&'a X>, + x:Option<&'a X+'a>, } fn bar() { @@ -36,7 +36,7 @@ mod b { mod c { pub trait X { fn f(&self); } impl X for int { fn f(&self) {} } - pub struct Z<'a>(Option<&'a X>); + pub struct Z<'a>(Option<&'a X+'a>); fn main() { let x = 42i; let z = Z(Some(&x as &X)); let _ = z; } } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 511629a6d7a..fbd6c92a020 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -17,9 +17,8 @@ impl<A:Clone + 'static> repeat<A> for Box<A> { } } -fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<repeat<A>> { - // Note: owned kind is not necessary as A appears in the trait type - box v as Box<repeat<A>> // No +fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<repeat<A>+'static> { + box v as Box<repeat<A>+'static> // No } pub fn main() { diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 84d49820239..f704545af33 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -11,7 +11,7 @@ // Test that the lambda kind is inferred correctly as a return // expression -fn unique() -> proc() { return proc() (); } +fn unique() -> proc():'static { return proc() (); } pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 86ad53c0228..22e51ea9a75 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -11,7 +11,7 @@ // Test that the lambda kind is inferred correctly as a return // expression -fn unique() -> proc() { proc() () } +fn unique() -> proc():'static { proc() () } pub fn main() { } diff --git a/src/test/run-pass/overloaded-autoderef-indexing.rs b/src/test/run-pass/overloaded-autoderef-indexing.rs index 37e7ee6c216..5c4befcd0c8 100644 --- a/src/test/run-pass/overloaded-autoderef-indexing.rs +++ b/src/test/run-pass/overloaded-autoderef-indexing.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct DerefArray<'a, T> { +struct DerefArray<'a, T:'a> { inner: &'a [T] } diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index 6deae8618fa..27ef90d7376 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -30,7 +30,7 @@ fn object_invoke1<'d>(x: &'d Trait<'d>) -> (int, int) { } struct Struct1<'e> { - f: &'e Trait<'e> + f: &'e Trait<'e>+'e } fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (int,int) { @@ -40,7 +40,7 @@ fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (int,int) { } struct Struct2<'h, 'i> { - f: &'h Trait<'i> + f: &'h Trait<'i>+'h } fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> int { @@ -78,8 +78,8 @@ impl<'s> Trait<'s> for (int,int) { } } -impl<'t> MakerTrait<'t> for Box<Trait<'t>> { - fn mk() -> Box<Trait<'t>> { box() (4i,5i) as Box<Trait> } +impl<'t> MakerTrait<'t> for Box<Trait<'t>+'static> { + fn mk() -> Box<Trait<'t>+'static> { box() (4i,5i) as Box<Trait> } } enum List<'l> { diff --git a/src/test/run-pass/regions-early-bound-used-in-bound.rs b/src/test/run-pass/regions-early-bound-used-in-bound.rs index c262370ac5d..58de2e0e20e 100644 --- a/src/test/run-pass/regions-early-bound-used-in-bound.rs +++ b/src/test/run-pass/regions-early-bound-used-in-bound.rs @@ -15,7 +15,7 @@ trait GetRef<'a, T> { fn get(&self) -> &'a T; } -struct Box<'a, T> { +struct Box<'a, T:'a> { t: &'a T } diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs index 1a96af43d23..f33483d31bf 100644 --- a/src/test/run-pass/swap-overlapping.rs +++ b/src/test/run-pass/swap-overlapping.rs @@ -34,8 +34,8 @@ pub enum TestName { } pub enum TestFn { - DynTestFn(proc()), - DynBenchFn(proc(&mut int)) + DynTestFn(proc():'static), + DynBenchFn(proc(&mut int):'static) } pub struct TestDesc { diff --git a/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs b/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs index 55ad22dd0bf..5b744a44132 100644 --- a/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs +++ b/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs @@ -17,7 +17,7 @@ trait A { } impl A for int { - fn foo<T: Ord + Ord>(&self) {} + fn foo<T: Ord>(&self) {} // Ord implies Eq, so this is ok. } fn main() {} diff --git a/src/test/run-pass/trait-bounds-on-structs-and-enums.rs b/src/test/run-pass/trait-bounds-on-structs-and-enums.rs index ebcaf772db4..e3234f03754 100644 --- a/src/test/run-pass/trait-bounds-on-structs-and-enums.rs +++ b/src/test/run-pass/trait-bounds-on-structs-and-enums.rs @@ -12,11 +12,11 @@ trait U {} trait T<X: U> {} trait S2<Y: U> { - fn m(x: Box<T<Y>>) {} + fn m(x: Box<T<Y>+'static>) {} } struct St<X: U> { - f: Box<T<X>>, + f: Box<T<X>+'static>, } impl<X: U> St<X> { diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index 3c5ae6b57a3..b20915763f2 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -21,7 +21,7 @@ pub struct Impl<A1, A2, A3> { * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', * src/librustc/middle/subst.rs:58 */ - t: Box<Trait2<A2>> + t: Box<Trait2<A2>+'static> } impl<A1, A2, A3> Impl<A1, A2, A3> { diff --git a/src/test/run-pass/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures-boxed.rs index c4b990abf7e..746af1b9cf5 100644 --- a/src/test/run-pass/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures-boxed.rs @@ -12,8 +12,8 @@ use std::ops::FnMut; -fn make_adder(x: int) -> Box<FnMut<(int,),int>> { - (box |&mut: y: int| -> int { x + y }) as Box<FnMut<(int,),int>> + fn make_adder(x: int) -> Box<FnMut<(int,),int>+'static> { + (box |&mut: y: int| -> int { x + y }) as Box<FnMut<(int,),int>+'static> } pub fn main() { |
