auto merge of #8030 : thestinger/rust/iterator, r=huonw
This commit is contained in:
commit
0012b5008b
7 changed files with 8 additions and 46 deletions
|
@ -108,12 +108,14 @@ impl Iterator<int> for ZeroStream {
|
||||||
## Container iterators
|
## Container iterators
|
||||||
|
|
||||||
Containers implement iteration over the contained elements by returning an
|
Containers implement iteration over the contained elements by returning an
|
||||||
iterator object. For example, vector slices have four iterators available:
|
iterator object. For example, vector slices several iterators available:
|
||||||
|
|
||||||
* `vector.iter()`, for immutable references to the elements
|
* `iter()` and `rev_iter()`, for immutable references to the elements
|
||||||
* `vector.mut_iter()`, for mutable references to the elements
|
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
|
||||||
* `vector.rev_iter()`, for immutable references to the elements in reverse order
|
* `consume_iter()` and `consume_rev_iter`, to move the elements out by-value
|
||||||
* `vector.mut_rev_iter()`, for mutable references to the elements in reverse order
|
|
||||||
|
A typical mutable container will implement at least `iter()`, `mut_iter()` and
|
||||||
|
`consume_iter()` along with the reverse variants if it maintains an order.
|
||||||
|
|
||||||
### Freezing
|
### Freezing
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ pub enum lint {
|
||||||
non_camel_case_types,
|
non_camel_case_types,
|
||||||
non_uppercase_statics,
|
non_uppercase_statics,
|
||||||
type_limits,
|
type_limits,
|
||||||
default_methods,
|
|
||||||
unused_unsafe,
|
unused_unsafe,
|
||||||
|
|
||||||
managed_heap_memory,
|
managed_heap_memory,
|
||||||
|
@ -222,13 +221,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
|
||||||
default: warn
|
default: warn
|
||||||
}),
|
}),
|
||||||
|
|
||||||
("default_methods",
|
|
||||||
LintSpec {
|
|
||||||
lint: default_methods,
|
|
||||||
desc: "allow default methods",
|
|
||||||
default: allow
|
|
||||||
}),
|
|
||||||
|
|
||||||
("unused_unsafe",
|
("unused_unsafe",
|
||||||
LintSpec {
|
LintSpec {
|
||||||
lint: unused_unsafe,
|
lint: unused_unsafe,
|
||||||
|
@ -690,23 +682,6 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_item_default_methods(cx: &Context, item: &ast::item) {
|
|
||||||
match item.node {
|
|
||||||
ast::item_trait(_, _, ref methods) => {
|
|
||||||
for methods.iter().advance |method| {
|
|
||||||
match *method {
|
|
||||||
ast::required(*) => {}
|
|
||||||
ast::provided(*) => {
|
|
||||||
cx.span_lint(default_methods, item.span,
|
|
||||||
"default methods are experimental");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_item_ctypes(cx: &Context, it: &ast::item) {
|
fn check_item_ctypes(cx: &Context, it: &ast::item) {
|
||||||
fn check_ty(cx: &Context, ty: &ast::Ty) {
|
fn check_ty(cx: &Context, ty: &ast::Ty) {
|
||||||
match ty.node {
|
match ty.node {
|
||||||
|
@ -1143,7 +1118,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::Crate) {
|
||||||
check_item_ctypes(cx, it);
|
check_item_ctypes(cx, it);
|
||||||
check_item_non_camel_case_types(cx, it);
|
check_item_non_camel_case_types(cx, it);
|
||||||
check_item_non_uppercase_statics(cx, it);
|
check_item_non_uppercase_statics(cx, it);
|
||||||
check_item_default_methods(cx, it);
|
|
||||||
check_item_heap(cx, it);
|
check_item_heap(cx, it);
|
||||||
|
|
||||||
cx.process(Item(it));
|
cx.process(Item(it));
|
||||||
|
|
|
@ -21,7 +21,6 @@ and `Eq` to overload the `==` and `!=` operators.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[allow(missing_doc)];
|
#[allow(missing_doc)];
|
||||||
#[allow(default_methods)]; // NOTE: Remove when allowed in stage0
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait for values that can be compared for equality and inequality.
|
* Trait for values that can be compared for equality and inequality.
|
||||||
|
|
|
@ -17,8 +17,6 @@ implementing the `Iterator` trait.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[allow(default_methods)]; // still off by default in stage0
|
|
||||||
|
|
||||||
use cmp;
|
use cmp;
|
||||||
use iter::Times;
|
use iter::Times;
|
||||||
use num::{Zero, One};
|
use num::{Zero, One};
|
||||||
|
|
|
@ -152,8 +152,6 @@ cleanup_task(cleanup_args *args) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL void upcall_exchange_free(void *ptr);
|
|
||||||
|
|
||||||
// This runs on the Rust stack
|
// This runs on the Rust stack
|
||||||
void task_start_wrapper(spawn_args *a)
|
void task_start_wrapper(spawn_args *a)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#[forbid(default_methods)];
|
|
||||||
|
|
||||||
trait Foo { //~ ERROR default methods are experimental
|
|
||||||
fn bar(&self) { println("hi"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
// compile-flags:-Z debug-info
|
// compile-flags:-Z debug-info
|
||||||
|
|
||||||
#[allow(default_methods)];
|
|
||||||
|
|
||||||
pub trait TraitWithDefaultMethod {
|
pub trait TraitWithDefaultMethod {
|
||||||
pub fn method(self) {
|
pub fn method(self) {
|
||||||
()
|
()
|
||||||
|
@ -24,4 +22,4 @@ impl TraitWithDefaultMethod for MyStruct { }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
MyStruct.method();
|
MyStruct.method();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue