Regression tests for issues that led me to revise typeck.
Close #23729 Close #23827 Close #24356
This commit is contained in:
parent
32d5f742cb
commit
58dc3bb575
3 changed files with 126 additions and 0 deletions
43
src/test/compile-fail/issue-23729.rs
Normal file
43
src/test/compile-fail/issue-23729.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// 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.
|
||||
|
||||
// Regression test for #23729
|
||||
|
||||
fn main() {
|
||||
let fib = {
|
||||
struct Recurrence {
|
||||
mem: [u64; 2],
|
||||
pos: usize,
|
||||
}
|
||||
|
||||
impl Iterator for Recurrence {
|
||||
//~^ ERROR not all trait items implemented, missing: `Item` [E0046]
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<u64> {
|
||||
if self.pos < 2 {
|
||||
let next_val = self.mem[self.pos];
|
||||
self.pos += 1;
|
||||
Some(next_val)
|
||||
} else {
|
||||
let next_val = (self.mem[0] + self.mem[1]);
|
||||
self.mem[0] = self.mem[1];
|
||||
self.mem[1] = next_val;
|
||||
Some(next_val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Recurrence { mem: [0, 1], pos: 0 }
|
||||
};
|
||||
|
||||
for e in fib.take(10) {
|
||||
println!("{}", e)
|
||||
}
|
||||
}
|
||||
43
src/test/compile-fail/issue-23827.rs
Normal file
43
src/test/compile-fail/issue-23827.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// 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.
|
||||
|
||||
// Regression test for #23827
|
||||
|
||||
#![feature(core, unboxed_closures)]
|
||||
|
||||
pub struct Prototype {
|
||||
pub target: u32
|
||||
}
|
||||
|
||||
trait Component {
|
||||
fn apply(self, e: u32);
|
||||
}
|
||||
|
||||
impl<C: Component> Fn<(C,)> for Prototype {
|
||||
extern "rust-call" fn call(&self, (comp,): (C,)) -> Prototype {
|
||||
comp.apply(self.target);
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Component> FnMut<(C,)> for Prototype {
|
||||
extern "rust-call" fn call_mut(&mut self, (comp,): (C,)) -> Prototype {
|
||||
Fn::call(*&self, (comp,))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||
//~^ ERROR not all trait items implemented, missing: `Output` [E0046]
|
||||
extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
|
||||
Fn::call(&self, (comp,))
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
40
src/test/compile-fail/issue-24356.rs
Normal file
40
src/test/compile-fail/issue-24356.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// 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.
|
||||
|
||||
// Regression test for #24356
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
fn main() {
|
||||
{
|
||||
use std::ops::Deref;
|
||||
|
||||
struct Thing(i8);
|
||||
|
||||
/*
|
||||
// Correct impl
|
||||
impl Deref for Thing {
|
||||
type Target = i8;
|
||||
fn deref(&self) -> &i8 { &self.0 }
|
||||
}
|
||||
*/
|
||||
|
||||
// Causes ICE
|
||||
impl Deref for Thing {
|
||||
//~^ ERROR not all trait items implemented, missing: `Target` [E0046]
|
||||
fn deref(&self) -> i8 { self.0 }
|
||||
//~^ ERROR method `deref` has an incompatible type for trait: expected &-ptr, found i8 [E0053]
|
||||
}
|
||||
|
||||
let thing = Thing(72);
|
||||
|
||||
*thing
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue