mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
rustc: "iface" -> "trait" in comments, error messages, and identifiers.
(Also "interface" -> "trait" in error messages.)
This commit is contained in:
parent
dbd39f868b
commit
f78776e9d8
@ -421,7 +421,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
|
||||
}
|
||||
_ {
|
||||
// Must be a re-export, then!
|
||||
// ...or an iface ref
|
||||
// ...or a trait ref
|
||||
ebml_w.wr_str(def_to_str(did));
|
||||
}
|
||||
};
|
||||
|
@ -466,7 +466,7 @@ fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
|
||||
}
|
||||
|
||||
/// This is rather subtle. When we are casting a value to a
|
||||
/// instantiated iface like `a as iface/&r`, regionck already ensures
|
||||
/// instantiated trait like `a as trait/&r`, regionck already ensures
|
||||
/// that any borrowed pointers that appear in the type of `a` are
|
||||
/// bounded by `&r`. However, it is possible that there are *type
|
||||
/// parameters* in the type of `a`, and those *type parameters* may
|
||||
@ -475,14 +475,14 @@ fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
|
||||
///
|
||||
/// Therefore, we ensure that one of three conditions holds:
|
||||
///
|
||||
/// (1) The iface instance cannot escape the current fn. This is
|
||||
/// (1) The trait instance cannot escape the current fn. This is
|
||||
/// guaranteed if the region bound `&r` is some scope within the fn
|
||||
/// itself. This case is safe because whatever borrowed pointers are
|
||||
/// found within the type parameter, they must enclose the fn body
|
||||
/// itself.
|
||||
///
|
||||
/// (2) The type parameter appears in the type of the iface. For
|
||||
/// example, if the type parameter is `T` and the iface type is
|
||||
/// (2) The type parameter appears in the type of the trait. For
|
||||
/// example, if the type parameter is `T` and the trait type is
|
||||
/// `deque<T>`, then whatever borrowed ptrs may appear in `T` also
|
||||
/// appear in `deque<T>`.
|
||||
///
|
||||
@ -493,7 +493,7 @@ fn check_cast_for_escaping_regions(
|
||||
source: @expr,
|
||||
target: @expr) {
|
||||
|
||||
// Determine what type we are casting to; if it is not an iface, then no
|
||||
// Determine what type we are casting to; if it is not an trait, then no
|
||||
// worries.
|
||||
let target_ty = ty::expr_ty(cx.tcx, target);
|
||||
let target_substs = alt ty::get(target_ty).struct {
|
||||
@ -501,7 +501,7 @@ fn check_cast_for_escaping_regions(
|
||||
_ => { ret; /* not a cast to a trait */ }
|
||||
};
|
||||
|
||||
// Check, based on the region associated with the iface, whether it can
|
||||
// Check, based on the region associated with the trait, whether it can
|
||||
// possibly escape the enclosing fn item (note that all type parameters
|
||||
// must have been declared on the enclosing fn item):
|
||||
alt target_substs.self_r {
|
||||
@ -514,8 +514,8 @@ fn check_cast_for_escaping_regions(
|
||||
}
|
||||
}
|
||||
|
||||
// Assuming the iface instance can escape, then ensure that each parameter
|
||||
// either appears in the iface type or is owned:
|
||||
// Assuming the trait instance can escape, then ensure that each parameter
|
||||
// either appears in the trait type or is owned:
|
||||
let target_params = ty::param_tys_in_type(target_ty);
|
||||
let source_ty = ty::expr_ty(cx.tcx, source);
|
||||
do ty::walk_ty(source_ty) |ty| {
|
||||
|
@ -3365,7 +3365,7 @@ class Resolver {
|
||||
none {
|
||||
self.session.span_err(interface.path.span,
|
||||
~"attempt to implement a \
|
||||
nonexistent interface");
|
||||
nonexistent trait");
|
||||
}
|
||||
some(def) {
|
||||
// Write a mapping from the interface ID to the
|
||||
|
@ -1611,7 +1611,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
remove_send(mutable_type_kind(cx, tm) | kind_safe_for_default_mode())
|
||||
}
|
||||
|
||||
// Iface instances are (for now) like shared boxes, basically
|
||||
// Trait instances are (for now) like shared boxes, basically
|
||||
ty_trait(_, _) { kind_safe_for_default_mode() | kind_owned() }
|
||||
|
||||
// Region pointers are copyable but NOT owned nor sendable
|
||||
@ -1711,7 +1711,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
param_bounds_to_kind(cx.ty_param_bounds.get(p.def_id.node))
|
||||
}
|
||||
|
||||
// self is a special type parameter that can only appear in ifaces; it
|
||||
// self is a special type parameter that can only appear in traits; it
|
||||
// is never bounded in any way, hence it has the bottom kind.
|
||||
ty_self { kind_noncopyable() }
|
||||
|
||||
|
@ -258,7 +258,7 @@ class lookup {
|
||||
self.tcx().sess.span_err(
|
||||
self.expr.span,
|
||||
~"can not call a method that contains a \
|
||||
self type through a boxed iface");
|
||||
self type through a boxed trait");
|
||||
}
|
||||
|
||||
if (*m.tps).len() > 0u {
|
||||
|
@ -137,9 +137,9 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
}
|
||||
|
||||
ast::expr_cast(source, _) {
|
||||
// Determine if we are casting `source` to an iface instance.
|
||||
// Determine if we are casting `source` to an trait instance.
|
||||
// If so, we have to be sure that the type of the source obeys
|
||||
// the iface's region bound.
|
||||
// the trait's region bound.
|
||||
//
|
||||
// Note: there is a subtle point here concerning type
|
||||
// parameters. It is possible that the type of `source`
|
||||
@ -155,12 +155,12 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
result::ok(target_ty) => {
|
||||
alt ty::get(target_ty).struct {
|
||||
ty::ty_trait(_, substs) {
|
||||
let iface_region = alt substs.self_r {
|
||||
let trait_region = alt substs.self_r {
|
||||
some(r) => {r}
|
||||
none => {ty::re_static}
|
||||
};
|
||||
let source_ty = rcx.fcx.expr_ty(source);
|
||||
constrain_regions_in_type(rcx, iface_region,
|
||||
constrain_regions_in_type(rcx, trait_region,
|
||||
e.span, source_ty);
|
||||
}
|
||||
_ { }
|
||||
|
@ -100,11 +100,11 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
||||
for vec::each(*ty::trait_methods(tcx, did)) |m| {
|
||||
if ty::type_has_self(ty::mk_fn(tcx, m.fty)) {
|
||||
tcx.sess.span_err(
|
||||
sp, ~"a boxed iface with self types may not be \
|
||||
sp, ~"a boxed trait with self types may not be \
|
||||
passed as a bounded type");
|
||||
} else if (*m.tps).len() > 0u {
|
||||
tcx.sess.span_err(
|
||||
sp, ~"a boxed iface with generic methods may not \
|
||||
sp, ~"a boxed trait with generic methods may not \
|
||||
be passed as a bounded type");
|
||||
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
|
||||
|
||||
if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) {
|
||||
tcx.sess.span_err(sp,#fmt["method `%s` has %u parameters \
|
||||
but the iface has %u",
|
||||
but the trait has %u",
|
||||
*if_m.ident,
|
||||
vec::len(impl_m.fty.inputs),
|
||||
vec::len(if_m.fty.inputs)]);
|
||||
@ -398,7 +398,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
||||
let cms = convert_methods(ccx, methods, rp, bounds, selfty);
|
||||
for traits.each |trt| {
|
||||
check_methods_against_trait(ccx, tps, rp, selfty, trt, cms);
|
||||
// trt.impl_id represents (class, iface) pair
|
||||
// trt.impl_id represents (class, trait) pair
|
||||
write_ty_to_tcx(tcx, trt.impl_id, tpt.ty);
|
||||
tcx.tcache.insert(local_def(trt.impl_id), tpt);
|
||||
}
|
||||
@ -455,7 +455,7 @@ fn ty_of_ty_method(self: @crate_ctxt,
|
||||
fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool)
|
||||
-> (ast::def_id, ty_param_substs_and_ty) {
|
||||
|
||||
let sp = t.path.span, err = ~"can only implement interface types",
|
||||
let sp = t.path.span, err = ~"can only implement trait types",
|
||||
sess = ccx.tcx.sess;
|
||||
|
||||
let rscope = type_rscope(rp);
|
||||
|
@ -1,4 +1,4 @@
|
||||
class cat : int { //~ ERROR interface
|
||||
class cat : int { //~ ERROR trait
|
||||
let meows: uint;
|
||||
new(in_x : uint) { self.meows = in_x; }
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ iface foo {
|
||||
}
|
||||
impl of foo for int {
|
||||
fn bar() -> int {
|
||||
//~^ ERROR method `bar` has 0 parameters but the iface has 1
|
||||
//~^ ERROR method `bar` has 0 parameters but the trait has 1
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ iface channel<T> {
|
||||
fn send(v: T);
|
||||
}
|
||||
|
||||
// `chan` is not an iface, it's an enum
|
||||
impl of chan for int { //~ ERROR can only implement interface types
|
||||
// `chan` is not a trait, it's an enum
|
||||
impl of chan for int { //~ ERROR can only implement trait types
|
||||
fn send(v: int) { fail }
|
||||
}
|
||||
|
||||
|
@ -11,5 +11,5 @@ fn do_add<A:add>(x: A, y: A) -> A { x.plus(y) }
|
||||
fn main() {
|
||||
let x = 3 as add;
|
||||
let y = 4 as add;
|
||||
do_add(x, y); //~ ERROR a boxed iface with self types may not be passed as a bounded type
|
||||
do_add(x, y); //~ ERROR a boxed trait with self types may not be passed as a bounded type
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ iface add {
|
||||
}
|
||||
|
||||
fn do_add(x: add, y: add) -> add {
|
||||
x.plus(y) //~ ERROR can not call a method that contains a self type through a boxed iface
|
||||
x.plus(y) //~ ERROR can not call a method that contains a self type through a boxed trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user