-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression tests for issues that led me to revise typeck.
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
} |