parent
5f9f0b7cc3
commit
a33532b1b7
67
src/test/compile-fail/issue-22638.rs
Normal file
67
src/test/compile-fail/issue-22638.rs
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(Clone)]
|
||||
struct A (B);
|
||||
|
||||
impl A {
|
||||
pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
//~^ ERROR reached the recursion limit during monomorphization
|
||||
let &A(ref term) = self;
|
||||
term.matches(f);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
enum B {
|
||||
Variant1,
|
||||
Variant2(C),
|
||||
}
|
||||
|
||||
impl B {
|
||||
pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
match self {
|
||||
&B::Variant2(ref factor) => {
|
||||
factor.matches(&|| ())
|
||||
}
|
||||
_ => unreachable!("")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct C (D);
|
||||
|
||||
impl C {
|
||||
pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
let &C(ref base) = self;
|
||||
base.matches(&|| {
|
||||
C(base.clone()).matches(f)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct D (Box<A>);
|
||||
|
||||
impl D {
|
||||
pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
let &D(ref a) = self;
|
||||
a.matches(f)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn matches() {
|
||||
A(B::Variant1).matches(&(|| ()))
|
||||
}
|
||||
|
||||
fn main() {}
|
36
src/test/compile-fail/issue-22872.rs
Normal file
36
src/test/compile-fail/issue-22872.rs
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
trait Wrap<'b> {
|
||||
fn foo(&'b mut self);
|
||||
}
|
||||
|
||||
struct Wrapper<P>(P);
|
||||
|
||||
impl<'b, P> Wrap<'b> for Wrapper<P>
|
||||
where P: Process<'b>,
|
||||
<P as Process<'b>>::Item: Iterator {
|
||||
fn foo(&mut self) {}
|
||||
}
|
||||
|
||||
|
||||
pub trait Process<'a> {
|
||||
type Item;
|
||||
fn bar(&'a self);
|
||||
}
|
||||
|
||||
fn push_process<P>(process: P) where P: Process<'static> {
|
||||
let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
|
||||
//~^ ERROR the trait `for<'b> Process<'b>` is not implemented for the type `P` [E0277]
|
||||
//~| ERROR the trait `for<'b> core::iter::Iterator` is not implemented for the type
|
||||
//~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting
|
||||
}
|
||||
|
||||
fn main() {}
|
23
src/test/compile-fail/issue-23024.rs
Normal file
23
src/test/compile-fail/issue-23024.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
use std::any::Any;
|
||||
|
||||
fn main()
|
||||
{
|
||||
fn h(x:i32) -> i32 {3*x}
|
||||
let mut vfnfer:Vec<Box<Any>> = vec![];
|
||||
vfnfer.push(box h);
|
||||
println!("{:?}",(vfnfer[0] as Fn)(3));
|
||||
//~^ ERROR the precise format of `Fn`-family traits'
|
||||
//~| ERROR wrong number of type arguments: expected 1, found 0
|
||||
//~| ERROR the value of the associated type `Output` (from the trait `core::ops::FnOnce`)
|
||||
}
|
30
src/test/compile-fail/issue-23046.rs
Normal file
30
src/test/compile-fail/issue-23046.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
pub enum Expr<'var, VAR> {
|
||||
Let(Box<Expr<'var, VAR>>,
|
||||
Box<for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>)
|
||||
}
|
||||
|
||||
pub fn add<'var, VAR>
|
||||
(a: Expr<'var, VAR>, b: Expr<'var, VAR>) -> Expr<'var, VAR> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub fn let_<'var, VAR, F: for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>>
|
||||
(a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let ex = (|x| {
|
||||
let_(add(x,x), |y| { //~ ERROR unable to infer enough type information about `_`
|
||||
let_(add(x, x), |x|x)})});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user