Auto merge of #28332 - apasel422:tests, r=alexcrichton
Closes #22638. Closes #22872. Closes #23024. Closes #23046.
This commit is contained in:
commit
250679e20d
4 changed files with 156 additions and 0 deletions
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…
Reference in a new issue