File tree 8 files changed +177
-0
lines changed
8 files changed +177
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ trait Trait {
12
+ type A ;
13
+ type B ;
14
+ }
15
+
16
+ fn foo < T : Trait < A = T :: B > > ( ) { }
17
+ //~^ ERROR: unsupported cyclic reference between types/traits detected
18
+
19
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ fn foo < U > ( t : U ) {
12
+ let y = t ( ) ;
13
+ //~^ ERROR: expected function, found `U`
14
+ }
15
+
16
+ struct Bar ;
17
+
18
+ pub fn some_func ( ) {
19
+ let f = Bar ( ) ;
20
+ //~^ ERROR: expected function, found `Bar`
21
+ }
22
+
23
+ fn main ( ) {
24
+ foo ( || { 1 } ) ;
25
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ trait A {
12
+ type Output ;
13
+ fn a ( & self ) -> <Self as A >:: X ;
14
+ //~^ ERROR: use of undeclared associated type `A::X`
15
+ }
16
+
17
+ impl A for u32 {
18
+ type Output = u32 ;
19
+ fn a ( & self ) -> u32 {
20
+ 0
21
+ }
22
+ }
23
+
24
+ fn main ( ) {
25
+ let a: u32 = 0 ;
26
+ let b: u32 = a. a ( ) ;
27
+ }
Original file line number Diff line number Diff line change
1
+ -include ../tools.mk
2
+
3
+ # Test output to be four
4
+ # The original error only occurred when printing, not when comparing using assert!
5
+
6
+ all :
7
+ $(RUSTC ) foo.rs -O
8
+ [ ` $( call RUN,foo) ` = " 4" ]
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ fn identity ( a : & u32 ) -> & u32 { a }
12
+
13
+ fn print_foo ( f : & fn ( & u32 ) -> & u32 , x : & u32 ) {
14
+ print ! ( "{}" , ( * f) ( x) ) ;
15
+ }
16
+
17
+ fn main ( ) {
18
+ let x = & 4 ;
19
+ let f: fn ( & u32 ) -> & u32 = identity;
20
+
21
+ // Didn't print 4 on optimized builds
22
+ print_foo ( & f, x) ;
23
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ feature( core) ]
12
+
13
+ extern crate core;
14
+ use core:: marker:: Sync ;
15
+
16
+ static SARRAY : [ i32 ; 1 ] = [ 11 ] ;
17
+
18
+ struct MyStruct {
19
+ pub arr : * const [ i32 ] ,
20
+ }
21
+ unsafe impl Sync for MyStruct { }
22
+
23
+ static mystruct: MyStruct = MyStruct {
24
+ arr : & SARRAY
25
+ } ;
26
+
27
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ use std:: ops:: Add ;
12
+
13
+ fn f < T : Add > ( a : T , b : T ) -> <T as Add >:: Output {
14
+ a + b
15
+ }
16
+
17
+ fn main ( ) {
18
+ println ! ( "a + b is {}" , f:: <f32 >( 100f32 , 200f32 ) ) ;
19
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ macro_rules! items {
12
+ ( ) => {
13
+ type A = ( ) ;
14
+ fn a( ) { }
15
+ }
16
+ }
17
+
18
+ trait Foo {
19
+ type A ;
20
+ fn a ( ) ;
21
+ }
22
+
23
+ impl Foo for ( ) {
24
+ items ! ( ) ;
25
+ }
26
+
27
+ fn main ( ) {
28
+
29
+ }
You can’t perform that action at this time.
0 commit comments