Implement generalized object and type parameter bounds (Fixes #16462)
This commit is contained in:
parent
3ee047ae1f
commit
1b487a8906
272 changed files with 6783 additions and 3154 deletions
|
|
@ -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>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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!() }
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
f: proc()
|
||||
f: proc():'static
|
||||
}
|
||||
|
||||
fn call(x: Foo) {
|
||||
|
|
|
|||
|
|
@ -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>) {
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
44
src/test/compile-fail/kindck-send-object.rs
Normal file
44
src/test/compile-fail/kindck-send-object.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -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() {
|
||||
}
|
||||
|
|
@ -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() { }
|
||||
|
|
@ -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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
type Noncopyable = proc();
|
||||
type Noncopyable = proc():'static;
|
||||
|
||||
struct Foo {
|
||||
copied: int,
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
49
src/test/compile-fail/region-object-lifetime-1.rs
Normal file
49
src/test/compile-fail/region-object-lifetime-1.rs
Normal file
|
|
@ -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() {}
|
||||
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
57
src/test/compile-fail/regions-bound-missing-bound-in-impl.rs
Normal file
57
src/test/compile-fail/regions-bound-missing-bound-in-impl.rs
Normal file
|
|
@ -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() { }
|
||||
91
src/test/compile-fail/regions-bounded-by-send.rs
Normal file
91
src/test/compile-fail/regions-bounded-by-send.rs
Normal file
|
|
@ -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() {
|
||||
}
|
||||
|
|
@ -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() {
|
||||
}
|
||||
|
|
@ -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() { }
|
||||
|
|
@ -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() { }
|
||||
|
|
@ -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() { }
|
||||
|
|
@ -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() {}
|
||||
|
|
@ -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>;
|
||||
}
|
||||
}
|
||||
31
src/test/compile-fail/regions-close-over-type-parameter-1.rs
Normal file
31
src/test/compile-fail/regions-close-over-type-parameter-1.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -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()));
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
37
src/test/compile-fail/regions-enum-not-wf.rs
Normal file
37
src/test/compile-fail/regions-enum-not-wf.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
61
src/test/compile-fail/regions-infer-bound-from-trait-self.rs
Normal file
61
src/test/compile-fail/regions-infer-bound-from-trait-self.rs
Normal file
|
|
@ -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() { }
|
||||
50
src/test/compile-fail/regions-infer-bound-from-trait.rs
Normal file
50
src/test/compile-fail/regions-infer-bound-from-trait.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
41
src/test/compile-fail/regions-lifetime-bounds-on-fns.rs
Normal file
41
src/test/compile-fail/regions-lifetime-bounds-on-fns.rs
Normal file
|
|
@ -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() { }
|
||||
26
src/test/compile-fail/regions-proc-bound-capture.rs
Normal file
26
src/test/compile-fail/regions-proc-bound-capture.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -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() { }
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
32
src/test/compile-fail/regions-struct-not-wf.rs
Normal file
32
src/test/compile-fail/regions-struct-not-wf.rs
Normal file
|
|
@ -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() { }
|
||||
|
|
@ -31,7 +31,7 @@ impl Drop for B {
|
|||
}
|
||||
|
||||
struct A<'r> {
|
||||
p: &'r X
|
||||
p: &'r X+'r
|
||||
}
|
||||
|
||||
fn make_a(p:&X) -> A {
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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>) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) { }
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue