Merge remote-tracking branch 'rust-lang/master'

Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
This commit is contained in:
Brian Anderson 2015-01-24 09:15:42 -08:00
commit 63fcbcf3ce
433 changed files with 7348 additions and 12011 deletions

View file

@ -10,28 +10,55 @@
#![allow(non_snake_case)]
register_diagnostic! { E0001, r##"
register_long_diagnostics! {
E0001: r##"
This error suggests that the expression arm corresponding to the noted pattern
will never be reached as for all possible values of the expression being matched,
one of the preceeding patterns will match.
This means that perhaps some of the preceeding patterns are too general, this
one is too specific or the ordering is incorrect.
"## }
"##,
E0003: r##"
Not-a-Number (NaN) values can not be compared for equality and hence can never match
the input to a match expression. To match against NaN values, you should instead use
the `is_nan` method in a guard, as in: x if x.is_nan() => ...
"##,
E0004: r##"
This error indicates that the compiler can not guarantee a matching pattern for one
or more possible inputs to a match expression. Guaranteed matches are required in order
to assign values to match expressions, or alternatively, determine the flow of execution.
If you encounter this error you must alter your patterns so that every possible value of
the input type is matched. For types with a small number of variants (like enums) you
should probably cover all cases explicitly. Alternatively, the underscore `_` wildcard
pattern can be added after all other patterns to match "anything else".
"##,
// FIXME: Remove duplication here?
E0005: r##"
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
name will be extracted in all cases. If you encounter this error you probably need
to use a `match` or `if let` to deal with the possibility of failure.
"##,
E0006: r##"
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
name will be extracted in all cases. If you encounter this error you probably need
to use a `match` or `if let` to deal with the possibility of failure.
"##
}
register_diagnostics! {
E0002,
E0003,
E0004,
E0005,
E0006,
E0007,
E0008,
E0009,
E0010,
E0011,
E0012,
E0013,
E0014,
E0015,
E0016,
@ -49,24 +76,58 @@ register_diagnostics! {
E0137,
E0138,
E0139,
E0140,
E0152,
E0153,
E0157,
E0158,
E0161,
E0162,
E0165,
E0166,
E0167,
E0168,
E0169,
E0170,
E0171,
E0172,
E0173,
E0174,
E0177,
E0178,
E0179
E0261, // use of undeclared lifetime name
E0262, // illegal lifetime parameter name
E0263, // lifetime name declared twice in same scope
E0264, // unknown external lang item
E0265, // recursive constant
E0266, // expected item
E0267, // thing inside of a closure
E0268, // thing outside of a loop
E0269, // not all control paths return a value
E0270, // computation may converge in a function marked as diverging
E0271, // type mismatch resolving
E0272, // rustc_on_unimplemented attribute refers to non-existent type parameter
E0273, // rustc_on_unimplemented must have named format arguments
E0274, // rustc_on_unimplemented must have a value
E0275, // overflow evaluating requirement
E0276, // requirement appears on impl method but not on corresponding trait method
E0277, // trait is not implemented for type
E0278, // requirement is not satisfied
E0279, // requirement is not satisfied
E0280, // requirement is not satisfied
E0281, // type implements trait but other trait is required
E0282, // unable to infer enough type information about
E0283, // cannot resolve type
E0284, // cannot resolve type
E0285, // overflow evaluation builtin bounds
E0296, // malformed recursion limit attribute
E0297, // refutable pattern in for loop binding
E0298, // mismatched types between arms
E0299, // mismatched types between arms
E0300, // unexpanded macro
E0301, // cannot mutable borrow in a pattern guard
E0302, // cannot assign in a pattern guard
E0303, // pattern bindings are not allowed after an `@`
E0304, // expected signed integer constant
E0305, // expected constant
E0306, // expected positive integer for repeat count
E0307, // expected constant integer for repeat count
E0308,
E0309, // thing may not live long enough
E0310, // thing may not live long enough
E0311, // thing may not live long enough
E0312, // lifetime of reference outlives lifetime of borrowed content
E0313, // lifetime of borrowed pointer outlives lifetime of captured variable
E0314, // closure outlives stack frame
E0315 // cannot invoke closure outside of its lifetime
}
__build_diagnostic_array! { DIAGNOSTICS }

View file

@ -40,6 +40,7 @@
#![feature(std_misc)]
#![feature(unicode)]
#![feature(hash)]
#![cfg_attr(test, feature(test))]
extern crate arena;
extern crate flate;
@ -47,7 +48,6 @@ extern crate fmt_macros;
extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate regex;
extern crate rustc_llvm;
extern crate rustc_back;
extern crate serialize;
@ -64,7 +64,9 @@ extern crate test;
pub use rustc_llvm as llvm;
mod diagnostics;
// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
pub mod diagnostics;
pub mod back {
pub use rustc_back::abi;
@ -142,8 +144,6 @@ pub mod lib {
pub use llvm;
}
__build_diagnostic_array! { DIAGNOSTICS }
// A private module so that macro-expanded idents like
// `::rustc::lint::Lint` will also work in `rustc` itself.
//

View file

@ -1199,17 +1199,17 @@ impl LintPass for UnusedImportBraces {
lint_array!(UNUSED_IMPORT_BRACES)
}
fn check_view_item(&mut self, cx: &Context, view_item: &ast::ViewItem) {
match view_item.node {
ast::ViewItemUse(ref view_path) => {
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
match item.node {
ast::ItemUse(ref view_path) => {
match view_path.node {
ast::ViewPathList(_, ref items, _) => {
ast::ViewPathList(_, ref items) => {
if items.len() == 1 {
match items[0].node {
ast::PathListIdent {ref name, ..} => {
let m = format!("braces around {} is unnecessary",
token::get_ident(*name).get());
cx.span_lint(UNUSED_IMPORT_BRACES, view_item.span,
cx.span_lint(UNUSED_IMPORT_BRACES, item.span,
&m[]);
},
_ => ()
@ -1326,7 +1326,7 @@ impl UnusedMut {
let ident = path1.node;
if let ast::BindByValue(ast::MutMutable) = mode {
if !token::get_ident(ident).get().starts_with("_") {
match mutables.entry(ident.name.uint()) {
match mutables.entry(ident.name.usize()) {
Vacant(entry) => { entry.insert(vec![id]); },
Occupied(mut entry) => { entry.get_mut().push(id); },
}
@ -1663,11 +1663,6 @@ impl LintPass for Stability {
lint_array!(DEPRECATED)
}
fn check_view_item(&mut self, cx: &Context, item: &ast::ViewItem) {
stability::check_view_item(cx.tcx, item,
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
}
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
stability::check_item(cx.tcx, item,
&mut |id, sp, stab| self.lint(cx, id, sp, stab));

View file

@ -231,30 +231,7 @@ impl LintStore {
// We have one lint pass defined in this module.
self.register_pass(sess, false, box GatherNodeLevels as LintPassObject);
// Insert temporary renamings for a one-time deprecation (#16545)
self.register_renamed("unnecessary_typecast", "unused_typecasts");
self.register_renamed("unsigned_negate", "unsigned_negation");
self.register_renamed("type_limits", "unused_comparisons");
self.register_renamed("type_overflow", "overflowing_literals");
self.register_renamed("ctypes", "improper_ctypes");
self.register_renamed("owned_heap_memory", "box_pointers");
self.register_renamed("unused_attribute", "unused_attributes");
self.register_renamed("path_statement", "path_statements");
self.register_renamed("unused_result", "unused_results");
self.register_renamed("non_uppercase_statics", "non_upper_case_globals");
self.register_renamed("unnecessary_parens", "unused_parens");
self.register_renamed("unnecessary_import_braces", "unused_import_braces");
self.register_renamed("unsafe_block", "unsafe_blocks");
self.register_renamed("unnecessary_allocation", "unused_allocation");
self.register_renamed("missing_doc", "missing_docs");
self.register_renamed("unused_extern_crate", "unused_extern_crates");
self.register_renamed("unnecessary_qualification", "unused_qualifications");
self.register_renamed("unrecognized_lint", "unknown_lints");
self.register_renamed("unused_variable", "unused_variables");
self.register_renamed("dead_assignment", "unused_assignments");
self.register_renamed("unknown_crate_type", "unknown_crate_types");
self.register_renamed("variant_size_difference", "variant_size_differences");
self.register_renamed("transmute_fat_ptr", "fat_ptr_transmutes");
// Insert temporary renamings for a one-time deprecation
self.register_renamed("raw_pointer_deriving", "raw_pointer_derive");
self.register_renamed("unknown_features", "unused_features");
@ -595,14 +572,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
})
}
fn visit_view_item(&mut self, i: &ast::ViewItem) {
self.with_lint_attrs(&i.attrs[], |cx| {
run_lints!(cx, check_view_item, i);
cx.visit_ids(|v| v.visit_view_item(i));
visit::walk_view_item(cx, i);
})
}
fn visit_pat(&mut self, p: &ast::Pat) {
run_lints!(self, check_pat, p);
visit::walk_pat(self, p);

View file

@ -128,7 +128,6 @@ pub trait LintPass {
fn check_crate(&mut self, _: &Context, _: &ast::Crate) { }
fn check_ident(&mut self, _: &Context, _: Span, _: ast::Ident) { }
fn check_mod(&mut self, _: &Context, _: &ast::Mod, _: Span, _: ast::NodeId) { }
fn check_view_item(&mut self, _: &Context, _: &ast::ViewItem) { }
fn check_foreign_item(&mut self, _: &Context, _: &ast::ForeignItem) { }
fn check_item(&mut self, _: &Context, _: &ast::Item) { }
fn check_local(&mut self, _: &Context, _: &ast::Local) { }

View file

@ -40,10 +40,6 @@ pub struct CrateReader<'a> {
}
impl<'a, 'v> visit::Visitor<'v> for CrateReader<'a> {
fn visit_view_item(&mut self, a: &ast::ViewItem) {
self.process_view_item(a);
visit::walk_view_item(self, a);
}
fn visit_item(&mut self, a: &ast::Item) {
self.process_item(a);
visit::walk_item(self, a);
@ -64,9 +60,8 @@ fn dump_crates(cstore: &CStore) {
})
}
fn should_link(i: &ast::ViewItem) -> bool {
fn should_link(i: &ast::Item) -> bool {
!attr::contains_name(&i.attrs[], "no_link")
}
struct CrateInfo {
@ -181,29 +176,10 @@ impl<'a> CrateReader<'a> {
}
}
fn process_view_item(&mut self, i: &ast::ViewItem) {
if !should_link(i) {
return;
}
match self.extract_crate_info(i) {
Some(info) => {
let (cnum, _, _) = self.resolve_crate(&None,
&info.ident[],
&info.name[],
None,
i.span,
PathKind::Crate);
self.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
}
None => ()
}
}
fn extract_crate_info(&self, i: &ast::ViewItem) -> Option<CrateInfo> {
fn extract_crate_info(&self, i: &ast::Item) -> Option<CrateInfo> {
match i.node {
ast::ViewItemExternCrate(ident, ref path_opt, id) => {
let ident = token::get_ident(ident);
ast::ItemExternCrate(ref path_opt) => {
let ident = token::get_ident(i.ident);
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
ident, path_opt);
let name = match *path_opt {
@ -218,7 +194,7 @@ impl<'a> CrateReader<'a> {
Some(CrateInfo {
ident: ident.get().to_string(),
name: name,
id: id,
id: i.id,
should_link: should_link(i),
})
}
@ -226,8 +202,26 @@ impl<'a> CrateReader<'a> {
}
}
fn process_item(&self, i: &ast::Item) {
fn process_item(&mut self, i: &ast::Item) {
match i.node {
ast::ItemExternCrate(_) => {
if !should_link(i) {
return;
}
match self.extract_crate_info(i) {
Some(info) => {
let (cnum, _, _) = self.resolve_crate(&None,
&info.ident[],
&info.name[],
None,
i.span,
PathKind::Crate);
self.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
}
None => ()
}
}
ast::ItemForeignMod(ref fm) => {
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
return;
@ -533,7 +527,7 @@ impl<'a> CrateReader<'a> {
#[derive(Copy)]
pub enum CrateOrString<'a> {
Krate(&'a ast::ViewItem),
Krate(&'a ast::Item),
Str(&'a str)
}

View file

@ -242,7 +242,7 @@ impl MetadataBlob {
((slice[2] as u32) << 8) |
((slice[3] as u32) << 0)) as uint;
if len + 4 <= slice.len() {
slice.slice(4, len + 4)
&slice[4.. len + 4]
} else {
&[] // corrupt or old metadata
}

View file

@ -74,7 +74,7 @@ fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml:
let mut ret = None;
reader::tagged_docs(tagged_doc.doc, belt, |elt| {
let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
if eq_fn(&elt.data[(elt.start + 4) .. elt.end]) {
if eq_fn(&elt.data[elt.start + 4 .. elt.end]) {
ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
false
} else {

View file

@ -1456,8 +1456,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
rbml_w.end_tag();
}
}
ast::ItemMac(..) => {
// macros are encoded separately
ast::ItemExternCrate(_) | ast::ItemUse(_) |ast::ItemMac(..) => {
// these are encoded separately
}
}
}

View file

@ -392,11 +392,11 @@ impl<'a> Context<'a> {
};
let (hash, rlib) = if file.starts_with(&rlib_prefix[]) &&
file.ends_with(".rlib") {
(file.slice(rlib_prefix.len(), file.len() - ".rlib".len()),
(&file[(rlib_prefix.len()) .. (file.len() - ".rlib".len())],
true)
} else if file.starts_with(dylib_prefix.as_slice()) &&
file.ends_with(dypair.1.as_slice()) {
(file.slice(dylib_prefix.len(), file.len() - dypair.1.len()),
(&file[(dylib_prefix.len()) .. (file.len() - dypair.1.len())],
false)
} else {
return FileDoesntMatch

View file

@ -243,19 +243,6 @@ fn parse_size(st: &mut PState) -> Option<uint> {
}
}
fn parse_trait_store_<F>(st: &mut PState, conv: &mut F) -> ty::TraitStore where
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
{
match next(st) {
'~' => ty::UniqTraitStore,
'&' => ty::RegionTraitStore(parse_region_(st, conv), parse_mutability(st)),
c => {
st.tcx.sess.bug(&format!("parse_trait_store(): bad input '{}'",
c)[])
}
}
}
fn parse_vec_per_param_space<'a, 'tcx, T, F>(st: &mut PState<'a, 'tcx>,
mut f: F)
-> VecPerParamSpace<T> where
@ -641,14 +628,6 @@ fn parse_abi_set(st: &mut PState) -> abi::Abi {
})
}
fn parse_onceness(c: char) -> ast::Onceness {
match c {
'o' => ast::Once,
'm' => ast::Many,
_ => panic!("parse_onceness: bad onceness")
}
}
fn parse_closure_ty<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>,
mut conv: F) -> ty::ClosureTy<'tcx> where
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
@ -661,16 +640,10 @@ fn parse_closure_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>,
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
{
let unsafety = parse_unsafety(next(st));
let onceness = parse_onceness(next(st));
let store = parse_trait_store_(st, conv);
let bounds = parse_existential_bounds_(st, conv);
let sig = parse_sig_(st, conv);
let abi = parse_abi_set(st);
ty::ClosureTy {
unsafety: unsafety,
onceness: onceness,
store: store,
bounds: bounds,
sig: sig,
abi: abi,
}
@ -734,7 +707,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
}
let crate_part = &buf[0u..colon_idx];
let def_part = &buf[(colon_idx + 1u)..len];
let def_part = &buf[colon_idx + 1u..len];
let crate_num = match str::from_utf8(crate_part).ok().and_then(|s| s.parse::<uint>()) {
Some(cn) => cn as ast::CrateNum,

View file

@ -305,17 +305,6 @@ pub fn enc_trait_ref<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
enc_substs(w, cx, s.substs);
}
pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore) {
match s {
ty::UniqTraitStore => mywrite!(w, "~"),
ty::RegionTraitStore(re, m) => {
mywrite!(w, "&");
enc_region(w, cx, re);
enc_mutability(w, m);
}
}
}
fn enc_unsafety(w: &mut SeekableMemWriter, p: ast::Unsafety) {
match p {
ast::Unsafety::Normal => mywrite!(w, "n"),
@ -329,13 +318,6 @@ fn enc_abi(w: &mut SeekableMemWriter, abi: Abi) {
mywrite!(w, "]")
}
fn enc_onceness(w: &mut SeekableMemWriter, o: ast::Onceness) {
match o {
ast::Once => mywrite!(w, "o"),
ast::Many => mywrite!(w, "m")
}
}
pub fn enc_bare_fn_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
ft: &ty::BareFnTy<'tcx>) {
enc_unsafety(w, ft.unsafety);
@ -346,9 +328,6 @@ pub fn enc_bare_fn_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
ft: &ty::ClosureTy<'tcx>) {
enc_unsafety(w, ft.unsafety);
enc_onceness(w, ft.onceness);
enc_trait_store(w, cx, ft.store);
enc_existential_bounds(w, cx, &ft.bounds);
enc_fn_sig(w, cx, &ft.sig);
enc_abi(w, ft.abi);
}

View file

@ -332,8 +332,6 @@ impl Folder for NestedItemsDropper {
}
}).collect();
let blk_sans_items = P(ast::Block {
view_items: Vec::new(), // I don't know if we need the view_items
// here, but it doesn't break tests!
stmts: stmts_sans_items,
expr: expr,
id: id,
@ -515,17 +513,6 @@ impl tr for ty::BoundRegion {
}
}
impl tr for ty::TraitStore {
fn tr(&self, dcx: &DecodeContext) -> ty::TraitStore {
match *self {
ty::RegionTraitStore(r, m) => {
ty::RegionTraitStore(r.tr(dcx), m)
}
ty::UniqTraitStore => ty::UniqTraitStore
}
}
}
// ______________________________________________________________________
// Encoding and decoding of freevar information

View file

@ -424,7 +424,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
ast::ExprMethodCall(_, _, ref args) => {
self.call(expr, pred, &*args[0], args.slice_from(1).iter().map(|e| &**e))
self.call(expr, pred, &*args[0], args[1..].iter().map(|e| &**e))
}
ast::ExprIndex(ref l, ref r) |

View file

@ -73,12 +73,12 @@ impl<'a> CheckLoopVisitor<'a> {
match self.cx {
Loop => {}
Closure => {
self.sess.span_err(span,
&format!("`{}` inside of a closure", name)[]);
span_err!(self.sess, span, E0267,
"`{}` inside of a closure", name);
}
Normal => {
self.sess.span_err(span,
&format!("`{}` outside of loop", name)[]);
span_err!(self.sess, span, E0268,
"`{}` outside of loop", name);
}
}
}

View file

@ -57,7 +57,7 @@ struct Matrix<'a>(Vec<Vec<&'a Pat>>);
/// ++++++++++++++++++++++++++
/// + _ + [_, _, ..tail] +
/// ++++++++++++++++++++++++++
impl<'a> fmt::Show for Matrix<'a> {
impl<'a> fmt::Debug for Matrix<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "\n"));
@ -226,11 +226,10 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
ast::ExprForLoop(ref pat, _, _, _) => {
let mut static_inliner = StaticInliner::new(cx.tcx);
is_refutable(cx, &*static_inliner.fold_pat((*pat).clone()), |uncovered_pat| {
cx.tcx.sess.span_err(
pat.span,
&format!("refutable pattern in `for` loop binding: \
span_err!(cx.tcx.sess, pat.span, E0297,
"refutable pattern in `for` loop binding: \
`{}` not covered",
pat_to_string(uncovered_pat))[]);
pat_to_string(uncovered_pat));
});
// Check legality of move bindings.
@ -869,7 +868,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
Some(true) => Some(vec![]),
Some(false) => None,
None => {
cx.tcx.sess.span_err(pat_span, "mismatched types between arms");
span_err!(cx.tcx.sess, pat_span, E0298, "mismatched types between arms");
None
}
}
@ -882,7 +881,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
Some(true) => Some(vec![]),
Some(false) => None,
None => {
cx.tcx.sess.span_err(pat_span, "mismatched types between arms");
span_err!(cx.tcx.sess, pat_span, E0299, "mismatched types between arms");
None
}
}
@ -921,13 +920,13 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
}
ast::PatMac(_) => {
cx.tcx.sess.span_err(pat_span, "unexpanded macro");
span_err!(cx.tcx.sess, pat_span, E0300, "unexpanded macro");
None
}
};
head.map(|mut head| {
head.push_all(&r[..col]);
head.push_all(&r[(col + 1)..]);
head.push_all(&r[col + 1..]);
head
})
}
@ -1082,11 +1081,8 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
_: LoanCause) {
match kind {
MutBorrow => {
self.cx
.tcx
.sess
.span_err(span,
"cannot mutably borrow in a pattern guard")
span_err!(self.cx.tcx.sess, span, E0301,
"cannot mutably borrow in a pattern guard")
}
ImmBorrow | UniqueImmBorrow => {}
}
@ -1095,10 +1091,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
fn mutate(&mut self, _: NodeId, span: Span, _: cmt, mode: MutateMode) {
match mode {
JustWrite | WriteAndRead => {
self.cx
.tcx
.sess
.span_err(span, "cannot assign in a pattern guard")
span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
}
Init => {}
}
@ -1120,7 +1113,7 @@ struct AtBindingPatternVisitor<'a, 'b:'a, 'tcx:'b> {
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
fn visit_pat(&mut self, pat: &Pat) {
if !self.bindings_allowed && pat_is_binding(&self.cx.tcx.def_map, pat) {
self.cx.tcx.sess.span_err(pat.span,
span_err!(self.cx.tcx.sess, pat.span, E0303,
"pattern bindings are not allowed \
after an `@`");
}

View file

@ -83,7 +83,7 @@ pub fn check_item_recursion<'a>(sess: &'a Session,
impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
fn visit_item(&mut self, it: &ast::Item) {
if self.idstack.iter().any(|x| x == &(it.id)) {
self.sess.span_err(self.root_it.span, "recursive constant");
span_err!(self.sess, self.root_it.span, E0265, "recursive constant");
return;
}
self.idstack.push(it.id);
@ -103,9 +103,9 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
self.visit_item(item),
ast_map::NodeForeignItem(_) => {},
_ => {
self.sess.span_err(e.span,
&format!("expected item, found {}",
self.ast_map.node_to_string(def_id.node))[]);
span_err!(self.sess, e.span, E0266,
"expected item, found {}",
self.ast_map.node_to_string(def_id.node));
return;
},
}

View file

@ -118,17 +118,17 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
assert!(self.bits_per_id > 0);
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
let (start, end) = self.compute_id_range(cfgidx);
let on_entry = self.on_entry.slice(start, end);
let on_entry = &self.on_entry[start.. end];
let entry_str = bits_to_string(on_entry);
let gens = self.gens.slice(start, end);
let gens = &self.gens[start.. end];
let gens_str = if gens.iter().any(|&u| u != 0) {
format!(" gen: {}", bits_to_string(gens))
} else {
"".to_string()
};
let kills = self.kills.slice(start, end);
let kills = &self.kills[start .. end];
let kills_str = if kills.iter().any(|&u| u != 0) {
format!(" kill: {}", bits_to_string(kills))
} else {
@ -232,7 +232,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
let (start, end) = self.compute_id_range(cfgidx);
let gens = self.gens.slice_mut(start, end);
let gens = &mut self.gens[start.. end];
set_bit(gens, bit);
}
@ -245,7 +245,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
let (start, end) = self.compute_id_range(cfgidx);
let kills = self.kills.slice_mut(start, end);
let kills = &mut self.kills[start.. end];
set_bit(kills, bit);
}
@ -256,9 +256,9 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
assert!(self.bits_per_id > 0);
let (start, end) = self.compute_id_range(cfgidx);
let gens = self.gens.slice(start, end);
let gens = &self.gens[start.. end];
bitwise(bits, gens, &Union);
let kills = self.kills.slice(start, end);
let kills = &self.kills[start.. end];
bitwise(bits, kills, &Subtract);
debug!("{} apply_gen_kill(cfgidx={:?}, bits={}) [after]",
@ -304,7 +304,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
}
let (start, end) = self.compute_id_range(cfgidx);
let on_entry = self.on_entry.slice(start, end);
let on_entry = &self.on_entry[start.. end];
let temp_bits;
let slice = match e {
Entry => on_entry,
@ -336,7 +336,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
let (start, end) = self.compute_id_range(cfgidx);
let gens = self.gens.slice(start, end);
let gens = &self.gens[start.. end];
debug!("{} each_gen_bit(id={}, gens={})",
self.analysis_name, id, bits_to_string(gens));
self.each_bit(gens, f)
@ -396,7 +396,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
cfg.graph.each_edge(|_edge_index, edge| {
let flow_exit = edge.source();
let (start, end) = self.compute_id_range(flow_exit);
let mut orig_kills = self.kills.slice(start, end).to_vec();
let mut orig_kills = self.kills[start.. end].to_vec();
let mut changed = false;
for &node_id in edge.data.exiting_scopes.iter() {
@ -404,7 +404,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
match opt_cfg_idx {
Some(cfg_idx) => {
let (start, end) = self.compute_id_range(cfg_idx);
let kills = self.kills.slice(start, end);
let kills = &self.kills[start.. end];
if bitwise(orig_kills.as_mut_slice(), kills, &Union) {
changed = true;
}
@ -418,7 +418,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
}
if changed {
let bits = self.kills.slice_mut(start, end);
let bits = &mut self.kills[start.. end];
debug!("{} add_kills_from_flow_exits flow_exit={:?} bits={} [before]",
self.analysis_name, flow_exit, mut_bits_to_string(bits));
bits.clone_from_slice(&orig_kills[]);
@ -487,7 +487,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
let (start, end) = self.dfcx.compute_id_range(node_index);
// Initialize local bitvector with state on-entry.
in_out.clone_from_slice(self.dfcx.on_entry.slice(start, end));
in_out.clone_from_slice(&self.dfcx.on_entry[start.. end]);
// Compute state on-exit by applying transfer function to
// state on-entry.
@ -528,13 +528,13 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
let (start, end) = self.dfcx.compute_id_range(cfgidx);
let changed = {
// (scoping mutable borrow of self.dfcx.on_entry)
let on_entry = self.dfcx.on_entry.slice_mut(start, end);
let on_entry = &mut self.dfcx.on_entry[start.. end];
bitwise(on_entry, pred_bits, &self.dfcx.oper)
};
if changed {
debug!("{} changed entry set for {:?} to {}",
self.dfcx.analysis_name, cfgidx,
bits_to_string(self.dfcx.on_entry.slice(start, end)));
bits_to_string(&self.dfcx.on_entry[start.. end]));
self.changed = true;
}
}

View file

@ -32,7 +32,7 @@
#![allow(dead_code)] // still WIP
use std::fmt::{Formatter, Error, Show};
use std::fmt::{Formatter, Error, Debug};
use std::uint;
use std::collections::BitvSet;
@ -53,7 +53,7 @@ pub struct Edge<E> {
pub data: E,
}
impl<E: Show> Show for Edge<E> {
impl<E: Debug> Debug for Edge<E> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(f, "Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}",
self.next_edge[0], self.next_edge[1], self.source,
@ -353,7 +353,7 @@ impl<E> Edge<E> {
#[cfg(test)]
mod test {
use middle::graph::*;
use std::fmt::Show;
use std::fmt::Debug;
type TestNode = Node<&'static str>;
type TestEdge = Edge<&'static str>;
@ -408,7 +408,7 @@ mod test {
});
}
fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
fn test_adjacent_edges<N:PartialEq+Debug,E:PartialEq+Debug>(graph: &Graph<N,E>,
start_index: NodeIndex,
start_data: N,
expected_incoming: &[(E,N)],

View file

@ -202,39 +202,6 @@ pub trait Combine<'tcx> : Sized {
sig: sig})
}
fn closure_tys(&self, a: &ty::ClosureTy<'tcx>,
b: &ty::ClosureTy<'tcx>) -> cres<'tcx, ty::ClosureTy<'tcx>> {
let store = match (a.store, b.store) {
(ty::RegionTraitStore(a_r, a_m),
ty::RegionTraitStore(b_r, b_m)) if a_m == b_m => {
let r = try!(self.contraregions(a_r, b_r));
ty::RegionTraitStore(r, a_m)
}
_ if a.store == b.store => {
a.store
}
_ => {
return Err(ty::terr_sigil_mismatch(expected_found(self, a.store, b.store)))
}
};
let unsafety = try!(self.unsafeties(a.unsafety, b.unsafety));
let onceness = try!(self.oncenesses(a.onceness, b.onceness));
let bounds = try!(self.existential_bounds(&a.bounds, &b.bounds));
let sig = try!(self.binders(&a.sig, &b.sig));
let abi = try!(self.abi(a.abi, b.abi));
Ok(ty::ClosureTy {
unsafety: unsafety,
onceness: onceness,
store: store,
bounds: bounds,
sig: sig,
abi: abi,
})
}
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>> {
if a.variadic != b.variadic {
return Err(ty::terr_variadic_mismatch(expected_found(self, a.variadic, b.variadic)));
@ -356,31 +323,6 @@ pub trait Combine<'tcx> : Sized {
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region>;
fn trait_stores(&self,
vk: ty::terr_vstore_kind,
a: ty::TraitStore,
b: ty::TraitStore)
-> cres<'tcx, ty::TraitStore> {
debug!("{}.trait_stores(a={:?}, b={:?})", self.tag(), a, b);
match (a, b) {
(ty::RegionTraitStore(a_r, a_m),
ty::RegionTraitStore(b_r, b_m)) if a_m == b_m => {
self.contraregions(a_r, b_r).and_then(|r| {
Ok(ty::RegionTraitStore(r, a_m))
})
}
_ if a == b => {
Ok(a)
}
_ => {
Err(ty::terr_trait_stores_differ(vk, expected_found(self, a, b)))
}
}
}
fn trait_refs(&self,
a: &ty::TraitRef<'tcx>,
b: &ty::TraitRef<'tcx>)

View file

@ -371,12 +371,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
infer::EquatePredicate(_) => "equality predicate not satisfied",
};
self.tcx.sess.span_err(
trace.origin.span(),
&format!("{}: {} ({})",
span_err!(self.tcx.sess, trace.origin.span(), E0308,
"{}: {} ({})",
message_root_str,
expected_found_str,
ty::type_err_to_str(self.tcx, terr))[]);
ty::type_err_to_str(self.tcx, terr));
match trace.origin {
infer::MatchExpressionArm(_, arm_span) =>
@ -443,9 +442,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
match sub {
ty::ReFree(ty::FreeRegion {bound_region: ty::BrNamed(..), ..}) => {
// Does the required lifetime have a nice name we can print?
self.tcx.sess.span_err(
origin.span(),
&format!("{} may not live long enough", labeled_user_string)[]);
span_err!(self.tcx.sess, origin.span(), E0309,
"{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
@ -456,9 +454,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
ty::ReStatic => {
// Does the required lifetime have a nice name we can print?
self.tcx.sess.span_err(
origin.span(),
&format!("{} may not live long enough", labeled_user_string)[]);
span_err!(self.tcx.sess, origin.span(), E0310,
"{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
@ -468,11 +465,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
_ => {
// If not, be less specific.
self.tcx.sess.span_err(
origin.span(),
&format!(
span_err!(self.tcx.sess, origin.span(), E0311,
"{} may not live long enough",
labeled_user_string)[]);
labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
@ -499,8 +494,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.report_and_explain_type_error(trace, &terr);
}
infer::Reborrow(span) => {
self.tcx.sess.span_err(
span,
span_err!(self.tcx.sess, span, E0312,
"lifetime of reference outlines \
lifetime of borrowed content...");
note_and_explain_region(
@ -515,14 +509,13 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
"");
}
infer::ReborrowUpvar(span, ref upvar_id) => {
self.tcx.sess.span_err(
span,
&format!("lifetime of borrowed pointer outlives \
span_err!(self.tcx.sess, span, E0313,
"lifetime of borrowed pointer outlives \
lifetime of captured variable `{}`...",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.get()
.to_string())[]);
.to_string());
note_and_explain_region(
self.tcx,
"...the borrowed pointer is valid for ",
@ -539,8 +532,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
"");
}
infer::InfStackClosure(span) => {
self.tcx.sess.span_err(
span,
span_err!(self.tcx.sess, span, E0314,
"closure outlives stack frame");
note_and_explain_region(
self.tcx,
@ -554,8 +546,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
"");
}
infer::InvokeClosure(span) => {
self.tcx.sess.span_err(
span,
span_err!(self.tcx.sess, span, E0315,
"cannot invoke closure outside of its lifetime");
note_and_explain_region(
self.tcx,

View file

@ -609,8 +609,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
pub fn vars_created_since_snapshot(&self, mark: &RegionSnapshot)
-> Vec<RegionVid>
{
self.undo_log.borrow()
.slice_from(mark.length)
self.undo_log.borrow()[mark.length..]
.iter()
.filter_map(|&elt| match elt {
AddVar(vid) => Some(vid),
@ -637,7 +636,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
debug!("result_index={}, r={:?}", result_index, r);
for undo_entry in
self.undo_log.borrow().slice_from(mark.length).iter()
self.undo_log.borrow()[mark.length..].iter()
{
match undo_entry {
&AddConstraint(ConstrainVarSubVar(a, b)) => {

View file

@ -17,7 +17,7 @@ use middle::ty::{self, Ty};
use middle::infer::{uok, ures};
use middle::infer::InferCtxt;
use std::cell::RefCell;
use std::fmt::Show;
use std::fmt::Debug;
use syntax::ast;
use util::ppaux::Repr;
use util::snapshot_vec as sv;
@ -32,7 +32,7 @@ use util::snapshot_vec as sv;
/// (possibly not yet known) sort of integer.
///
/// Implementations of this trait are at the end of this file.
pub trait UnifyKey<'tcx, V> : Clone + Show + PartialEq + Repr<'tcx> {
pub trait UnifyKey<'tcx, V> : Clone + Debug + PartialEq + Repr<'tcx> {
fn index(&self) -> uint;
fn from_index(u: uint) -> Self;

View file

@ -320,9 +320,7 @@ lets_do_this! {
ContravariantLifetimeItem, "contravariant_lifetime", contravariant_lifetime;
InvariantLifetimeItem, "invariant_lifetime", invariant_lifetime;
NoSendItem, "no_send_bound", no_send_bound;
NoCopyItem, "no_copy_bound", no_copy_bound;
NoSyncItem, "no_sync_bound", no_sync_bound;
ManagedItem, "managed_bound", managed_bound;
NonZeroItem, "non_zero", non_zero;

View file

@ -198,13 +198,13 @@ pub fn check_crate(tcx: &ty::ctxt) {
tcx.sess.abort_if_errors();
}
impl fmt::Show for LiveNode {
impl fmt::Debug for LiveNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ln({})", self.get())
}
}
impl fmt::Show for Variable {
impl fmt::Debug for Variable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "v({})", self.get())
}
@ -1557,8 +1557,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
},
_ => false
};
self.ir.tcx.sess.span_err(
sp, "not all control paths return a value");
span_err!(self.ir.tcx.sess, sp, E0269, "not all control paths return a value");
if ends_with_stmt {
let last_stmt = body.stmts.first().unwrap();
let original_span = original_sp(self.ir.tcx.sess.codemap(),
@ -1575,7 +1574,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
ty::FnDiverging
if self.live_on_entry(entry_ln, self.s.clean_exit_var).is_some() => {
self.ir.tcx.sess.span_err(sp,
span_err!(self.ir.tcx.sess, sp, E0270,
"computation may converge in a function marked as diverging");
}

View file

@ -297,6 +297,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// These are normal, nothing reachable about these
// inherently and their children are already in the
// worklist, as determined by the privacy pass
ast::ItemExternCrate(_) | ast::ItemUse(_) |
ast::ItemTy(..) | ast::ItemStatic(_, _, _) |
ast::ItemMod(..) | ast::ItemForeignMod(..) |
ast::ItemImpl(..) | ast::ItemTrait(..) |

View file

@ -33,7 +33,7 @@ pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
}
}
sess.span_err(attr.span, "malformed recursion limit attribute, \
span_err!(sess, attr.span, E0296, "malformed recursion limit attribute, \
expected #![recursion_limit=\"N\"]");
}
}

View file

@ -22,9 +22,6 @@ use util::nodemap::{FnvHashMap, FnvHashSet, NodeMap};
use util::common::can_reach;
use std::cell::RefCell;
// NOTE(stage0) remove import after a snapshot
#[cfg(stage0)]
use std::hash::{Hash};
use syntax::codemap::Span;
use syntax::{ast, visit};
use syntax::ast::{Block, Item, FnDecl, NodeId, Arm, Pat, Stmt, Expr, Local};

View file

@ -94,6 +94,8 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
// Fn lifetimes get added in visit_fn below:
visit::walk_item(this, item);
}
ast::ItemExternCrate(_) |
ast::ItemUse(_) |
ast::ItemMod(..) |
ast::ItemMac(..) |
ast::ItemForeignMod(..) |
@ -396,10 +398,9 @@ impl<'a> LifetimeContext<'a> {
}
fn unresolved_lifetime_ref(&self, lifetime_ref: &ast::Lifetime) {
self.sess.span_err(
lifetime_ref.span,
&format!("use of undeclared lifetime name `{}`",
token::get_name(lifetime_ref.name))[]);
span_err!(self.sess, lifetime_ref.span, E0261,
"use of undeclared lifetime name `{}`",
token::get_name(lifetime_ref.name));
}
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
@ -409,11 +410,9 @@ impl<'a> LifetimeContext<'a> {
let special_idents = [special_idents::static_lifetime];
for lifetime in lifetimes.iter() {
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
self.sess.span_err(
lifetime.lifetime.span,
&format!("illegal lifetime parameter name: `{}`",
token::get_name(lifetime.lifetime.name))
[]);
span_err!(self.sess, lifetime.lifetime.span, E0262,
"illegal lifetime parameter name: `{}`",
token::get_name(lifetime.lifetime.name));
}
}
@ -422,12 +421,10 @@ impl<'a> LifetimeContext<'a> {
let lifetime_j = &lifetimes[j];
if lifetime_i.lifetime.name == lifetime_j.lifetime.name {
self.sess.span_err(
lifetime_j.lifetime.span,
&format!("lifetime name `{}` declared twice in \
span_err!(self.sess, lifetime_j.lifetime.span, E0263,
"lifetime name `{}` declared twice in \
the same scope",
token::get_name(lifetime_j.lifetime.name))
[]);
token::get_name(lifetime_j.lifetime.name));
}
}
@ -462,11 +459,11 @@ impl<'a> LifetimeContext<'a> {
format!("lifetime name `{}` shadows another \
lifetime name that is already in scope",
token::get_name(lifetime.name)).as_slice());
self.sess.span_help(
self.sess.span_note(
lifetime_def.span,
format!("shadowed lifetime `{}` declared here",
token::get_name(lifetime.name)).as_slice());
self.sess.span_help(
self.sess.span_note(
lifetime.span,
"shadowed lifetimes are deprecated \
and will become a hard error before 1.0");
@ -602,7 +599,7 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
}
}
impl<'a> fmt::Show for ScopeChain<'a> {
impl<'a> fmt::Debug for ScopeChain<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
EarlyScope(space, defs, _) => write!(fmt, "EarlyScope({:?}, {:?})", space, defs),

View file

@ -244,12 +244,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
}
impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> {
fn visit_view_item(&mut self, item: &ast::ViewItem) {
check_view_item(self.tcx, item,
&mut |id, sp, stab| self.check(id, sp, stab));
visit::walk_view_item(self, item)
}
fn visit_item(&mut self, item: &ast::Item) {
check_item(self.tcx, item,
&mut |id, sp, stab| self.check(id, sp, stab));
@ -264,22 +258,34 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> {
}
/// Helper for discovering nodes to check for stability
pub fn check_view_item(tcx: &ty::ctxt, item: &ast::ViewItem,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
// compiler-generated `extern crate` statements have a dummy span.
if item.span == DUMMY_SP { return }
pub fn check_item(tcx: &ty::ctxt, item: &ast::Item,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
match item.node {
ast::ItemExternCrate(_) => {
// compiler-generated `extern crate` items have a dummy span.
if item.span == DUMMY_SP { return }
let id = match item.node {
ast::ViewItemExternCrate(_, _, id) => id,
ast::ViewItemUse(..) => return,
};
let cnum = match tcx.sess.cstore.find_extern_mod_stmt_cnum(id) {
Some(cnum) => cnum,
None => return,
};
let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID };
maybe_do_stability_check(tcx, id, item.span, cb);
let cnum = match tcx.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
Some(cnum) => cnum,
None => return,
};
let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID };
maybe_do_stability_check(tcx, id, item.span, cb);
}
ast::ItemTrait(_, _, ref supertraits, _) => {
for t in supertraits.iter() {
if let ast::TraitTyParamBound(ref t, _) = *t {
let id = ty::trait_ref_to_def_id(tcx, &t.trait_ref);
maybe_do_stability_check(tcx, id, t.trait_ref.path.span, cb);
}
}
}
ast::ItemImpl(_, _, _, Some(ref t), _, _) => {
let id = ty::trait_ref_to_def_id(tcx, t);
maybe_do_stability_check(tcx, id, t.path.span, cb);
}
_ => (/* pass */)
}
}
/// Helper for discovering nodes to check for stability
@ -331,28 +337,6 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
maybe_do_stability_check(tcx, id, span, cb);
}
/// Helper for discovering nodes to check for stability
pub fn check_item(tcx: &ty::ctxt, item: &ast::Item,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
if is_internal(tcx, item.span) { return }
match item.node {
ast::ItemTrait(_, _, ref supertraits, _) => {
for t in supertraits.iter() {
if let ast::TraitTyParamBound(ref t, _) = *t {
let id = ty::trait_ref_to_def_id(tcx, &t.trait_ref);
maybe_do_stability_check(tcx, id, t.trait_ref.path.span, cb);
}
}
}
ast::ItemImpl(_, _, _, Some(ref t), _, _) => {
let id = ty::trait_ref_to_def_id(tcx, t);
maybe_do_stability_check(tcx, id, t.path.span, cb);
}
_ => (/* pass */)
}
}
fn maybe_do_stability_check(tcx: &ty::ctxt, id: ast::DefId, span: Span,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
if !is_staged_api(tcx, id) { return }

View file

@ -238,7 +238,7 @@ pub struct SeparateVecsPerParamSpace<T> {
pub fns: Vec<T>,
}
impl<T:fmt::Show> fmt::Show for VecPerParamSpace<T> {
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "VecPerParamSpace {{"));
for space in ParamSpace::all().iter() {
@ -373,12 +373,12 @@ impl<T> VecPerParamSpace<T> {
pub fn get_slice<'a>(&'a self, space: ParamSpace) -> &'a [T] {
let (start, limit) = self.limits(space);
self.content.slice(start, limit)
&self.content[start.. limit]
}
pub fn get_mut_slice<'a>(&'a mut self, space: ParamSpace) -> &'a mut [T] {
let (start, limit) = self.limits(space);
self.content.slice_mut(start, limit)
&mut self.content[start.. limit]
}
pub fn opt_get<'a>(&'a self,

View file

@ -55,12 +55,10 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
if !predicate.references_error() {
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0271,
"type mismatch resolving `{}`: {}",
predicate.user_string(infcx.tcx),
ty::type_err_to_str(infcx.tcx, &error.err)).as_slice());
ty::type_err_to_str(infcx.tcx, &error.err));
note_obligation_cause(infcx, obligation);
}
}
@ -97,28 +95,25 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
Position::ArgumentNamed(s) => match generic_map.get(s) {
Some(val) => Some(val.as_slice()),
None => {
infcx.tcx.sess
.span_err(err_sp,
format!("the #[rustc_on_unimplemented] \
span_err!(infcx.tcx.sess, err_sp, E0272,
"the #[rustc_on_unimplemented] \
attribute on \
trait definition for {} refers to \
non-existent type parameter {}",
trait_str, s)
.as_slice());
trait_str, s);
errored = true;
None
}
},
_ => {
infcx.tcx.sess
.span_err(err_sp,
format!("the #[rustc_on_unimplemented] \
span_err!(infcx.tcx.sess, err_sp, E0273,
"the #[rustc_on_unimplemented] \
attribute on \
trait definition for {} must have named \
format arguments, \
eg `#[rustc_on_unimplemented = \
\"foo {{T}}\"]`",
trait_str).as_slice());
trait_str);
errored = true;
None
}
@ -130,11 +125,11 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
report = Some(err);
}
} else {
infcx.tcx.sess.span_err(err_sp,
format!("the #[rustc_on_unimplemented] attribute on \
span_err!(infcx.tcx.sess, err_sp, E0274,
"the #[rustc_on_unimplemented] attribute on \
trait definition for {} must have a value, \
eg `#[rustc_on_unimplemented = \"foo\"]`",
trait_str).as_slice());
trait_str);
}
break;
}
@ -151,11 +146,9 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
// We could track the stack here more precisely if we wanted, I imagine.
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0275,
"overflow evaluating the requirement `{}`",
predicate.user_string(infcx.tcx)).as_slice());
predicate.user_string(infcx.tcx));
suggest_new_overflow_limit(infcx.tcx, obligation.cause.span);
@ -165,12 +158,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
SelectionError::Unimplemented => {
match &obligation.cause.code {
&ObligationCauseCode::CompareImplMethodObligation => {
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0276,
"the requirement `{}` appears on the impl \
method but not on the corresponding trait method",
obligation.predicate.user_string(infcx.tcx)).as_slice());
obligation.predicate.user_string(infcx.tcx));;
}
_ => {
match obligation.predicate {
@ -180,12 +171,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
if !trait_predicate.references_error() {
let trait_ref = trait_predicate.to_poly_trait_ref();
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0277,
"the trait `{}` is not implemented for the type `{}`",
trait_ref.user_string(infcx.tcx),
trait_ref.self_ty().user_string(infcx.tcx)).as_slice());
trait_ref.self_ty().user_string(infcx.tcx));
// Check if it has a custom "#[rustc_on_unimplemented]"
// error message, report with that message if it does
let custom_note = report_on_unimplemented(infcx, &*trait_ref.0,
@ -200,35 +189,29 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
ty::Predicate::Equate(ref predicate) => {
let predicate = infcx.resolve_type_vars_if_possible(predicate);
let err = infcx.equality_predicate(obligation.cause.span,
&predicate).unwrap_err();
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
&predicate).err().unwrap();
span_err!(infcx.tcx.sess, obligation.cause.span, E0278,
"the requirement `{}` is not satisfied (`{}`)",
predicate.user_string(infcx.tcx),
ty::type_err_to_str(infcx.tcx, &err)).as_slice());
ty::type_err_to_str(infcx.tcx, &err));
}
ty::Predicate::RegionOutlives(ref predicate) => {
let predicate = infcx.resolve_type_vars_if_possible(predicate);
let err = infcx.region_outlives_predicate(obligation.cause.span,
&predicate).unwrap_err();
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
&predicate).err().unwrap();
span_err!(infcx.tcx.sess, obligation.cause.span, E0279,
"the requirement `{}` is not satisfied (`{}`)",
predicate.user_string(infcx.tcx),
ty::type_err_to_str(infcx.tcx, &err)).as_slice());
ty::type_err_to_str(infcx.tcx, &err));
}
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0280,
"the requirement `{}` is not satisfied",
predicate.user_string(infcx.tcx)).as_slice());
predicate.user_string(infcx.tcx));
}
}
}
@ -239,15 +222,13 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
let expected_trait_ref = infcx.resolve_type_vars_if_possible(&*expected_trait_ref);
let actual_trait_ref = infcx.resolve_type_vars_if_possible(&*actual_trait_ref);
if !ty::type_is_error(actual_trait_ref.self_ty()) {
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0281,
"type mismatch: the type `{}` implements the trait `{}`, \
but the trait `{}` is required ({})",
expected_trait_ref.self_ty().user_string(infcx.tcx),
expected_trait_ref.user_string(infcx.tcx),
actual_trait_ref.user_string(infcx.tcx),
ty::type_err_to_str(infcx.tcx, e)).as_slice());
ty::type_err_to_str(infcx.tcx, e));
note_obligation_cause(infcx, obligation);
}
}
@ -293,18 +274,14 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
infcx.tcx.lang_items.sized_trait()
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
{
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0282,
"unable to infer enough type information about `{}`; \
type annotations required",
self_ty.user_string(infcx.tcx)).as_slice());
self_ty.user_string(infcx.tcx));
} else {
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0283,
"type annotations required: cannot resolve `{}`",
predicate.user_string(infcx.tcx)).as_slice());
predicate.user_string(infcx.tcx));;
note_obligation_cause(infcx, obligation);
}
}
@ -323,11 +300,9 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
_ => {
if !infcx.tcx.sess.has_errors() {
infcx.tcx.sess.span_err(
obligation.cause.span,
format!(
span_err!(infcx.tcx.sess, obligation.cause.span, E0284,
"type annotations required: cannot resolve `{}`",
predicate.user_string(infcx.tcx)).as_slice());
predicate.user_string(infcx.tcx));;
note_obligation_cause(infcx, obligation);
}
}

View file

@ -84,6 +84,7 @@ pub struct FulfillmentContext<'tcx> {
region_obligations: NodeMap<Vec<RegionObligation<'tcx>>>,
}
#[derive(Clone)]
pub struct RegionObligation<'tcx> {
pub sub_region: ty::Region,
pub sup_type: Ty<'tcx>,

View file

@ -379,11 +379,10 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
false
}
Err(Overflow) => {
infcx.tcx.sess.span_err(
span,
format!("overflow evaluating whether `{}` is `{}`",
ty.user_string(infcx.tcx),
bound.user_string(infcx.tcx)).as_slice());
span_err!(infcx.tcx.sess, span, E0285,
"overflow evaluating whether `{}` is `{}`",
ty.user_string(infcx.tcx),
bound.user_string(infcx.tcx));
suggest_new_overflow_limit(infcx.tcx, span);
false
}

View file

@ -1554,10 +1554,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let tcx = this.tcx();
match bound {
ty::BoundSend => {
if
Some(def_id) == tcx.lang_items.no_send_bound() ||
Some(def_id) == tcx.lang_items.managed_bound()
{
if Some(def_id) == tcx.lang_items.managed_bound() {
return Err(Unimplemented)
}
}
@ -1568,7 +1565,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundSync => {
if
Some(def_id) == tcx.lang_items.no_sync_bound() ||
Some(def_id) == tcx.lang_items.managed_bound() ||
Some(def_id) == tcx.lang_items.unsafe_type()
{

View file

@ -236,13 +236,13 @@ pub fn fresh_substs_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
infcx.fresh_substs_for_generics(span, &impl_generics)
}
impl<'tcx, N> fmt::Show for VtableImplData<'tcx, N> {
impl<'tcx, N> fmt::Debug for VtableImplData<'tcx, N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "VtableImpl({:?})", self.impl_def_id)
}
}
impl<'tcx> fmt::Show for super::VtableObjectData<'tcx> {
impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "VtableObject(...)")
}
@ -449,7 +449,7 @@ impl<'tcx> Repr<'tcx> for super::FulfillmentErrorCode<'tcx> {
}
}
impl<'tcx> fmt::Show for super::FulfillmentErrorCode<'tcx> {
impl<'tcx> fmt::Debug for super::FulfillmentErrorCode<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
super::CodeSelectionError(ref e) => write!(f, "{:?}", e),
@ -465,7 +465,7 @@ impl<'tcx> Repr<'tcx> for super::MismatchedProjectionTypes<'tcx> {
}
}
impl<'tcx> fmt::Show for super::MismatchedProjectionTypes<'tcx> {
impl<'tcx> fmt::Debug for super::MismatchedProjectionTypes<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "MismatchedProjectionTypes(..)")
}

View file

@ -17,7 +17,6 @@ pub use self::InferTy::*;
pub use self::InferRegion::*;
pub use self::ImplOrTraitItemId::*;
pub use self::UnboxedClosureKind::*;
pub use self::TraitStore::*;
pub use self::ast_ty_to_ty_cache_entry::*;
pub use self::Variance::*;
pub use self::AutoAdjustment::*;
@ -61,7 +60,7 @@ use middle::ty;
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
use middle::ty_walk::TypeWalker;
use util::ppaux::{note_and_explain_region, bound_region_ptr_to_string};
use util::ppaux::{trait_store_to_string, ty_to_string};
use util::ppaux::ty_to_string;
use util::ppaux::{Repr, UserString};
use util::common::{memoized, ErrorReported};
use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet};
@ -70,7 +69,7 @@ use util::nodemap::{FnvHashMap};
use arena::TypedArena;
use std::borrow::{BorrowFrom, Cow};
use std::cell::{Cell, RefCell};
use std::cmp::{self, Ordering};
use std::cmp;
use std::fmt::{self, Show};
use std::hash::{Hash, Writer, SipHasher, Hasher};
use std::mem;
@ -247,14 +246,6 @@ pub struct mt<'tcx> {
pub mutbl: ast::Mutability,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
pub enum TraitStore {
/// Box<Trait>
UniqTraitStore,
/// &Trait and &mut Trait
RegionTraitStore(Region, ast::Mutability),
}
#[derive(Clone, Copy, Show)]
pub struct field_ty {
pub name: Name,
@ -934,7 +925,7 @@ pub struct TyS<'tcx> {
region_depth: u32,
}
impl fmt::Show for TypeFlags {
impl fmt::Debug for TypeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.bits)
}
@ -1041,11 +1032,8 @@ pub struct BareFnTy<'tcx> {
#[derive(Clone, PartialEq, Eq, Hash, Show)]
pub struct ClosureTy<'tcx> {
pub unsafety: ast::Unsafety,
pub onceness: ast::Onceness,
pub store: TraitStore,
pub bounds: ExistentialBounds<'tcx>,
pub sig: PolyFnSig<'tcx>,
pub abi: abi::Abi,
pub sig: PolyFnSig<'tcx>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Show)]
@ -1545,7 +1533,6 @@ pub enum type_err<'tcx> {
terr_onceness_mismatch(expected_found<Onceness>),
terr_abi_mismatch(expected_found<abi::Abi>),
terr_mutability,
terr_sigil_mismatch(expected_found<TraitStore>),
terr_box_mutability,
terr_ptr_mutability,
terr_ref_mutability,
@ -1559,7 +1546,6 @@ pub enum type_err<'tcx> {
terr_regions_no_overlap(Region, Region),
terr_regions_insufficiently_polymorphic(BoundRegion, Region),
terr_regions_overly_polymorphic(BoundRegion, Region),
terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
terr_sorts(expected_found<Ty<'tcx>>),
terr_integer_as_char,
terr_int_mismatch(expected_found<IntVarValue>),
@ -1703,37 +1689,37 @@ impl cmp::PartialEq for InferRegion {
}
}
impl fmt::Show for TyVid {
impl fmt::Debug for TyVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
write!(f, "_#{}t", self.index)
}
}
impl fmt::Show for IntVid {
impl fmt::Debug for IntVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "_#{}i", self.index)
}
}
impl fmt::Show for FloatVid {
impl fmt::Debug for FloatVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "_#{}f", self.index)
}
}
impl fmt::Show for RegionVid {
impl fmt::Debug for RegionVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "'_#{}r", self.index)
}
}
impl<'tcx> fmt::Show for FnSig<'tcx> {
impl<'tcx> fmt::Debug for FnSig<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({:?}; variadic: {})->{:?}", self.inputs, self.variadic, self.output)
}
}
impl fmt::Show for InferTy {
impl fmt::Debug for InferTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
TyVar(ref v) => v.fmt(f),
@ -1745,7 +1731,7 @@ impl fmt::Show for InferTy {
}
}
impl fmt::Show for IntVarValue {
impl fmt::Debug for IntVarValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
IntType(ref v) => v.fmt(f),
@ -3319,7 +3305,7 @@ impl ops::Sub for TypeContents {
}
}
impl fmt::Show for TypeContents {
impl fmt::Debug for TypeContents {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TypeContents({:b})", self.bits)
}
@ -4194,19 +4180,6 @@ pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> ty::Binder<Vec<Ty<'tcx>>> {
ty_fn_sig(fty).inputs()
}
pub fn ty_closure_store(fty: Ty) -> TraitStore {
match fty.sty {
ty_unboxed_closure(..) => {
// Close enough for the purposes of all the callers of this
// function (which is soon to be deprecated anyhow).
UniqTraitStore
}
ref s => {
panic!("ty_closure_store() called on non-closure type: {:?}", s)
}
}
}
pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> Binder<FnOutput<'tcx>> {
match fty.sty {
ty_bare_fn(_, ref f) => f.sig.output(),
@ -4751,13 +4724,6 @@ impl<'tcx> Repr<'tcx> for ty::type_err<'tcx> {
/// afterwards to present additional details, particularly when it comes to lifetime-related
/// errors.
pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
fn tstore_to_closure(s: &TraitStore) -> String {
match s {
&UniqTraitStore => "proc".to_string(),
&RegionTraitStore(..) => "closure".to_string()
}
}
match *err {
terr_cyclic_ty => "cyclic type of infinite size".to_string(),
terr_mismatch => "types differ".to_string(),
@ -4776,11 +4742,6 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
values.expected,
values.found)
}
terr_sigil_mismatch(values) => {
format!("expected {}, found {}",
tstore_to_closure(&values.expected),
tstore_to_closure(&values.found))
}
terr_mutability => "values differ in mutability".to_string(),
terr_box_mutability => {
"boxed values differ in mutability".to_string()
@ -4828,11 +4789,6 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
found bound lifetime parameter {}",
bound_region_ptr_to_string(cx, br))
}
terr_trait_stores_differ(_, ref values) => {
format!("trait storage differs: expected `{}`, found `{}`",
trait_store_to_string(cx, (*values).expected),
trait_store_to_string(cx, (*values).found))
}
terr_sorts(values) => {
// A naive approach to making sure that we're not reporting silly errors such as:
// (expected closure, found closure).
@ -5089,25 +5045,6 @@ pub fn associated_type_parameter_index(cx: &ctxt,
cx.sess.bug("couldn't find associated type parameter index")
}
#[derive(Copy, PartialEq, Eq)]
pub struct AssociatedTypeInfo {
pub def_id: ast::DefId,
pub index: uint,
pub name: ast::Name,
}
impl PartialOrd for AssociatedTypeInfo {
fn partial_cmp(&self, other: &AssociatedTypeInfo) -> Option<Ordering> {
Some(self.index.cmp(&other.index))
}
}
impl Ord for AssociatedTypeInfo {
fn cmp(&self, other: &AssociatedTypeInfo) -> Ordering {
self.index.cmp(&other.index)
}
}
pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId)
-> Rc<Vec<ImplOrTraitItemId>> {
lookup_locally_or_in_crate_store("trait_item_def_ids",
@ -5369,15 +5306,13 @@ pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
discriminant = val as Disr
}
Ok(_) => {
cx.sess
.span_err(e.span,
span_err!(cx.sess, e.span, E0304,
"expected signed integer constant");
}
Err(ref err) => {
cx.sess
.span_err(e.span,
&format!("expected constant: {}",
*err)[]);
span_err!(cx.sess, e.span, E0305,
"expected constant: {}",
*err);
}
},
None => {}
@ -5851,9 +5786,9 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
const_eval::const_binary(_) =>
"binary array"
};
tcx.sess.span_err(count_expr.span, &format!(
span_err!(tcx.sess, count_expr.span, E0306,
"expected positive integer for repeat count, found {}",
found)[]);
found);
}
Err(_) => {
let found = match count_expr.node {
@ -5866,9 +5801,9 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
_ =>
"non-constant expression"
};
tcx.sess.span_err(count_expr.span, &format!(
span_err!(tcx.sess, count_expr.span, E0307,
"expected constant integer for repeat count, found {}",
found)[]);
found);
}
}
0
@ -7338,11 +7273,8 @@ impl ReferencesError for Region
impl<'tcx> Repr<'tcx> for ClosureTy<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
format!("ClosureTy({},{},{:?},{},{},{})",
format!("ClosureTy({},{},{})",
self.unsafety,
self.onceness,
self.store,
self.bounds.repr(tcx),
self.sig.repr(tcx),
self.abi)
}
@ -7373,5 +7305,5 @@ impl<'a, 'tcx> Repr<'tcx> for ParameterEnvironment<'a, 'tcx> {
self.free_substs.repr(tcx),
self.implicit_region_bound.repr(tcx),
self.caller_bounds.repr(tcx))
}
}
}

View file

@ -124,10 +124,6 @@ pub trait TypeFolder<'tcx> : Sized {
r
}
fn fold_trait_store(&mut self, s: ty::TraitStore) -> ty::TraitStore {
super_fold_trait_store(self, s)
}
fn fold_existential_bounds(&mut self, s: &ty::ExistentialBounds<'tcx>)
-> ty::ExistentialBounds<'tcx> {
super_fold_existential_bounds(self, s)
@ -225,12 +221,6 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TraitStore {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitStore {
folder.fold_trait_store(*self)
}
}
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Ty<'tcx> {
folder.fold_ty(*self)
@ -699,11 +689,8 @@ pub fn super_fold_closure_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-> ty::ClosureTy<'tcx>
{
ty::ClosureTy {
store: fty.store.fold_with(this),
sig: fty.sig.fold_with(this),
unsafety: fty.unsafety,
onceness: fty.onceness,
bounds: fty.bounds.fold_with(this),
abi: fty.abi,
}
}
@ -726,17 +713,6 @@ pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
mutbl: mt.mutbl}
}
pub fn super_fold_trait_store<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
trait_store: ty::TraitStore)
-> ty::TraitStore {
match trait_store {
ty::UniqTraitStore => ty::UniqTraitStore,
ty::RegionTraitStore(r, m) => {
ty::RegionTraitStore(r.fold_with(this), m)
}
}
}
pub fn super_fold_existential_bounds<'tcx, T: TypeFolder<'tcx>>(
this: &mut T,
bounds: &ty::ExistentialBounds<'tcx>)

View file

@ -99,9 +99,9 @@ impl<'a> Context<'a> {
self.items.missing.push(lang_items::$item);
}
} else)* {
self.sess.span_err(span,
format!("unknown external lang item: `{}`",
name).as_slice());
span_err!(self.sess, span, E0264,
"unknown external lang item: `{}`",
name);
}
}
}

View file

@ -73,8 +73,10 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
// We need to error on `#[macro_use] extern crate` when it isn't at the
// crate root, because `$crate` won't work properly. Identify these by
// spans, because the crate map isn't set up yet.
for vi in krate.module.view_items.iter() {
loader.span_whitelist.insert(vi.span);
for item in krate.module.items.iter() {
if let ast::ItemExternCrate(_) = item.node {
loader.span_whitelist.insert(item.span);
}
}
visit::walk_crate(&mut loader, krate);
@ -91,18 +93,21 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
// note that macros aren't expanded yet, and therefore macros can't add plugins.
impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
fn visit_view_item(&mut self, vi: &ast::ViewItem) {
fn visit_item(&mut self, item: &ast::Item) {
// We're only interested in `extern crate`.
match vi.node {
ast::ViewItemExternCrate(..) => (),
_ => return,
match item.node {
ast::ItemExternCrate(_) => {}
_ => {
visit::walk_item(self, item);
return;
}
}
// Parse the attributes relating to macro / plugin loading.
let mut plugin_attr = None;
let mut macro_selection = Some(HashSet::new()); // None => load all
let mut reexport = HashSet::new();
for attr in vi.attrs.iter() {
for attr in item.attrs.iter() {
let mut used = true;
match attr.name().get() {
"phase" => {
@ -155,7 +160,10 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
}
}
self.load_plugin(CrateOrString::Krate(vi), plugin_attr, macro_selection, Some(reexport))
self.load_plugin(CrateOrString::Krate(item),
plugin_attr,
macro_selection,
Some(reexport))
}
fn visit_mac(&mut self, _: &ast::Mac) {

View file

@ -249,7 +249,7 @@ pub enum EntryFnType {
EntryNone,
}
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash)]
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Show)]
pub enum CrateType {
CrateTypeExecutable,
CrateTypeDylib,
@ -786,7 +786,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
opt::multi("", "extern", "Specify where an external rust library is \
located",
"NAME=PATH"),
opt::opt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
opt::opt("", "sysroot", "Override the system root", "PATH"),
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
opt::opt("", "color", "Configure coloring of output:
@ -794,22 +793,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
always = always colorize output;
never = never colorize output", "auto|always|never"),
// DEPRECATED
opt::flag("", "print-crate-name", "Output the crate name and exit"),
opt::flag("", "print-file-name", "Output the file(s) that would be \
written if compilation \
continued and exit"),
opt::opt("", "debuginfo", "Emit DWARF debug info to the objects created:
0 = no debug info,
1 = line-tables only (for stacktraces and breakpoints),
2 = full debug info with variable and type information \
(same as -g)", "LEVEL"),
opt::flag("", "no-trans", "Run all passes except translation; no output"),
opt::flag("", "no-analysis", "Parse and expand the source, but run no \
analysis and produce no output"),
opt::flag("", "parse-only", "Parse only; do not compile, assemble, \
or link"),
opt::flagopt("", "pretty",
opt::flagopt_u("", "pretty",
"Pretty-print the input instead of compiling;
valid types are: `normal` (un-annotated source),
`expanded` (crates expanded),
@ -823,9 +807,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
`everybody_loops` (all function bodies replaced with `loop {}`).",
"TYPE"),
opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
opt::flagopt("", "dep-info",
"Output dependency info to <filename> after compiling, \
in a format suitable for use by Makefiles", "FILENAME"),
]);
opts
}
@ -861,27 +842,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let debugging_opts = build_debugging_options(matches);
let parse_only = if matches.opt_present("parse-only") {
// FIXME(acrichto) remove this eventually
early_warn("--parse-only is deprecated in favor of -Z parse-only");
true
} else {
debugging_opts.parse_only
};
let no_trans = if matches.opt_present("no-trans") {
// FIXME(acrichto) remove this eventually
early_warn("--no-trans is deprecated in favor of -Z no-trans");
true
} else {
debugging_opts.no_trans
};
let no_analysis = if matches.opt_present("no-analysis") {
// FIXME(acrichto) remove this eventually
early_warn("--no-analysis is deprecated in favor of -Z no-analysis");
true
} else {
debugging_opts.no_analysis
};
let parse_only = debugging_opts.parse_only;
let no_trans = debugging_opts.no_trans;
let no_analysis = debugging_opts.no_analysis;
if debugging_opts.debug_llvm {
unsafe { llvm::LLVMSetDebug(1); }
@ -921,28 +884,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
host_triple().to_string());
let opt_level = {
if matches.opt_present("O") {
if matches.opt_present("opt-level") {
early_error("-O and --opt-level both provided");
}
if cg.opt_level.is_some() {
early_error("-O and -C opt-level both provided");
}
Default
} else if matches.opt_present("opt-level") {
// FIXME(acrichto) remove this eventually
early_warn("--opt-level=N is deprecated in favor of -C opt-level=N");
match matches.opt_str("opt-level").as_ref().map(|s| s.as_slice()) {
None |
Some("0") => No,
Some("1") => Less,
Some("2") => Default,
Some("3") => Aggressive,
Some(arg) => {
early_error(&format!("optimization level needs to be \
between 0-3 (instead was `{}`)",
arg)[]);
}
}
} else {
match cg.opt_level {
None => No,
@ -960,27 +905,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
};
let gc = debugging_opts.gc;
let debuginfo = if matches.opt_present("g") {
if matches.opt_present("debuginfo") {
early_error("-g and --debuginfo both provided");
}
if cg.debuginfo.is_some() {
early_error("-g and -C debuginfo both provided");
}
FullDebugInfo
} else if matches.opt_present("debuginfo") {
// FIXME(acrichto) remove this eventually
early_warn("--debuginfo=N is deprecated in favor of -C debuginfo=N");
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
Some("0") => NoDebugInfo,
Some("1") => LimitedDebugInfo,
None |
Some("2") => FullDebugInfo,
Some(arg) => {
early_error(&format!("debug info level needs to be between \
0-2 (instead was `{}`)",
arg)[]);
}
}
} else {
match cg.debuginfo {
None | Some(0) => NoDebugInfo,
@ -1036,15 +964,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
let test = matches.opt_present("test");
let write_dependency_info = if matches.opt_present("dep-info") {
// FIXME(acrichto) remove this eventually
early_warn("--dep-info has been deprecated in favor of --emit");
(true, matches.opt_str("dep-info").map(|p| Path::new(p)))
} else {
(output_types.contains(&OutputTypeDepInfo), None)
};
let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None);
let mut prints = matches.opt_strs("print").into_iter().map(|s| {
let prints = matches.opt_strs("print").into_iter().map(|s| {
match s.as_slice() {
"crate-name" => PrintRequest::CrateName,
"file-names" => PrintRequest::FileNames,
@ -1054,18 +976,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
}
}).collect::<Vec<_>>();
if matches.opt_present("print-crate-name") {
// FIXME(acrichto) remove this eventually
early_warn("--print-crate-name has been deprecated in favor of \
--print crate-name");
prints.push(PrintRequest::CrateName);
}
if matches.opt_present("print-file-name") {
// FIXME(acrichto) remove this eventually
early_warn("--print-file-name has been deprecated in favor of \
--print file-names");
prints.push(PrintRequest::FileNames);
}
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
early_warn("-C remark will not show source locations without \
@ -1159,7 +1069,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
return Ok(crate_types);
}
impl fmt::Show for CrateType {
impl fmt::Display for CrateType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CrateTypeExecutable => "bin".fmt(f),

View file

@ -15,8 +15,6 @@ use metadata::filesearch;
use session::search_paths::PathKind;
use util::nodemap::NodeMap;
use regex::Regex;
use syntax::ast::NodeId;
use syntax::codemap::Span;
use syntax::diagnostic::{self, Emitter};
@ -69,65 +67,23 @@ impl Session {
pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
self.diagnostic().span_fatal(sp, msg)
}
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! {
self.diagnostic().span_fatal_with_code(sp, msg, code)
}
pub fn fatal(&self, msg: &str) -> ! {
self.diagnostic().handler().fatal(msg)
}
pub fn span_err(&self, sp: Span, msg: &str) {
// Conditions for enabling multi-line errors:
if !msg.contains("mismatched types") &&
!msg.contains("type mismatch resolving") &&
!msg.contains("if and else have incompatible types") &&
!msg.contains("if may be missing an else clause") &&
!msg.contains("match arms have incompatible types") &&
!msg.contains("structure constructor specifies a structure of type") {
return self.diagnostic().span_err(sp, msg);
match split_msg_into_multilines(msg) {
Some(msg) => self.diagnostic().span_err(sp, &msg[]),
None => self.diagnostic().span_err(sp, msg)
}
let first = Regex::new(r"[( ]expected").unwrap();
let second = Regex::new(r" found").unwrap();
let third = Regex::new(
r"\((values differ|lifetime|cyclic type of infinite size)").unwrap();
let mut new_msg = String::new();
let mut head = 0u;
// Insert `\n` before expected and found.
for (pos1, pos2) in first.find_iter(msg).zip(
second.find_iter(msg)) {
new_msg = new_msg +
// A `(` may be preceded by a space and it should be trimmed
msg[head..pos1.0].trim_right() + // prefix
"\n" + // insert before first
&msg[pos1.0..pos1.1] + // insert what first matched
&msg[pos1.1..pos2.0] + // between matches
"\n " + // insert before second
// 123
// `expected` is 3 char longer than `found`. To align the types, `found` gets
// 3 spaces prepended.
&msg[pos2.0..pos2.1]; // insert what second matched
head = pos2.1;
}
let mut tail = &msg[head..];
// Insert `\n` before any remaining messages which match.
for pos in third.find_iter(tail).take(1) {
// The end of the message may just be wrapped in `()` without `expected`/`found`.
// Push this also to a new line and add the final tail after.
new_msg = new_msg +
// `(` is usually preceded by a space and should be trimmed.
tail[..pos.0].trim_right() + // prefix
"\n" + // insert before paren
&tail[pos.0..]; // append the tail
tail = "";
}
new_msg.push_str(tail);
self.diagnostic().span_err(sp, &new_msg[])
}
pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) {
self.diagnostic().span_err_with_code(sp, msg, code)
match split_msg_into_multilines(msg) {
Some(msg) => self.diagnostic().span_err_with_code(sp, &msg[], code),
None => self.diagnostic().span_err_with_code(sp, msg, code)
}
}
pub fn err(&self, msg: &str) {
self.diagnostic().handler().err(msg)
@ -285,6 +241,66 @@ impl Session {
}
}
fn split_msg_into_multilines(msg: &str) -> Option<String> {
// Conditions for enabling multi-line errors:
if !msg.contains("mismatched types") &&
!msg.contains("type mismatch resolving") &&
!msg.contains("if and else have incompatible types") &&
!msg.contains("if may be missing an else clause") &&
!msg.contains("match arms have incompatible types") &&
!msg.contains("structure constructor specifies a structure of type") {
return None
}
let first = msg.match_indices("expected").filter(|s| {
s.0 > 0 && (msg.char_at_reverse(s.0) == ' ' ||
msg.char_at_reverse(s.0) == '(')
}).map(|(a, b)| (a - 1, b));
let second = msg.match_indices("found").filter(|s| {
msg.char_at_reverse(s.0) == ' '
}).map(|(a, b)| (a - 1, b));
let mut new_msg = String::new();
let mut head = 0u;
// Insert `\n` before expected and found.
for (pos1, pos2) in first.zip(second) {
new_msg = new_msg +
// A `(` may be preceded by a space and it should be trimmed
msg[head..pos1.0].trim_right() + // prefix
"\n" + // insert before first
&msg[pos1.0..pos1.1] + // insert what first matched
&msg[pos1.1..pos2.0] + // between matches
"\n " + // insert before second
// 123
// `expected` is 3 char longer than `found`. To align the types,
// `found` gets 3 spaces prepended.
&msg[pos2.0..pos2.1]; // insert what second matched
head = pos2.1;
}
let mut tail = &msg[head..];
let third = tail.find_str("(values differ")
.or(tail.find_str("(lifetime"))
.or(tail.find_str("(cyclic type of infinite size"));
// Insert `\n` before any remaining messages which match.
if let Some(pos) = third {
// The end of the message may just be wrapped in `()` without
// `expected`/`found`. Push this also to a new line and add the
// final tail after.
new_msg = new_msg +
// `(` is usually preceded by a space and should be trimmed.
tail[..pos].trim_right() + // prefix
"\n" + // insert before paren
&tail[pos..]; // append the tail
tail = "";
}
new_msg.push_str(tail);
return Some(new_msg);
}
pub fn build_session(sopts: config::Options,
local_crate_source_file: Option<Path>,
registry: diagnostics::registry::Registry)

View file

@ -36,13 +36,13 @@ impl SearchPaths {
pub fn add_path(&mut self, path: &str) {
let (kind, path) = if path.starts_with("native=") {
(PathKind::Native, path.slice_from("native=".len()))
(PathKind::Native, &path["native=".len()..])
} else if path.starts_with("crate=") {
(PathKind::Crate, path.slice_from("crate=".len()))
(PathKind::Crate, &path["crate=".len()..])
} else if path.starts_with("dependency=") {
(PathKind::Dependency, path.slice_from("dependency=".len()))
(PathKind::Dependency, &path["dependency=".len()..])
} else if path.starts_with("all=") {
(PathKind::All, path.slice_from("all=".len()))
(PathKind::All, &path["all=".len()..])
} else {
(PathKind::All, path)
};

View file

@ -12,7 +12,7 @@
use std::cell::{RefCell, Cell};
use std::collections::HashMap;
use std::fmt::Show;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::iter::repeat;
use std::time::Duration;
@ -58,7 +58,7 @@ pub fn time<T, U, F>(do_it: bool, what: &str, u: U, f: F) -> T where
}
pub fn indent<R, F>(op: F) -> R where
R: Show,
R: Debug,
F: FnOnce() -> R,
{
// Use in conjunction with the log post-processor like `src/etc/indenter`

View file

@ -164,7 +164,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
fn explain_span(cx: &ctxt, heading: &str, span: Span)
-> (String, Option<Span>) {
let lo = cx.sess.codemap().lookup_char_pos_adj(span.lo);
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_uint()),
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
Some(span))
}
}
@ -237,15 +237,6 @@ pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String {
ty_to_string(cx, m.ty))
}
pub fn trait_store_to_string(cx: &ctxt, s: ty::TraitStore) -> String {
match s {
ty::UniqTraitStore => "Box ".to_string(),
ty::RegionTraitStore(r, m) => {
format!("{}{}", region_ptr_to_string(cx, r), mutability_to_string(m))
}
}
}
pub fn vec_map_to_string<T, F>(ts: &[T], f: F) -> String where
F: FnMut(&T) -> String,
{
@ -285,7 +276,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
_ => { }
}
push_sig_to_string(cx, &mut s, '(', ')', sig, "");
push_sig_to_string(cx, &mut s, '(', ')', sig);
match opt_def_id {
Some(def_id) => {
@ -303,13 +294,6 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String {
let mut s = String::new();
match cty.store {
ty::UniqTraitStore => {}
ty::RegionTraitStore(region, _) => {
s.push_str(&region_to_string(cx, "", true, region)[]);
}
}
match cty.unsafety {
ast::Unsafety::Normal => {}
ast::Unsafety::Unsafe => {
@ -318,24 +302,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
}
};
let bounds_str = cty.bounds.user_string(cx);
match cty.store {
ty::UniqTraitStore => {
assert_eq!(cty.onceness, ast::Once);
s.push_str("proc");
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig,
&bounds_str[]);
}
ty::RegionTraitStore(..) => {
match cty.onceness {
ast::Many => {}
ast::Once => s.push_str("once ")
}
push_sig_to_string(cx, &mut s, '|', '|', &cty.sig,
&bounds_str[]);
}
}
push_sig_to_string(cx, &mut s, '|', '|', &cty.sig);
s
}
@ -344,8 +311,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
s: &mut String,
bra: char,
ket: char,
sig: &ty::PolyFnSig<'tcx>,
bounds: &str) {
sig: &ty::PolyFnSig<'tcx>) {
s.push(bra);
let strs = sig.0.inputs
.iter()
@ -357,11 +323,6 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
}
s.push(ket);
if !bounds.is_empty() {
s.push_str(":");
s.push_str(bounds);
}
match sig.0.output {
ty::FnConverging(t) => {
if !ty::type_is_nil(t) {
@ -542,7 +503,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
0
};
for t in tps[..(tps.len() - num_defaults)].iter() {
for t in tps[..tps.len() - num_defaults].iter() {
strs.push(ty_to_string(cx, *t))
}
@ -550,9 +511,9 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
format!("{}({}){}",
base,
if strs[0].starts_with("(") && strs[0].ends_with(",)") {
&strs[0][1 .. (strs[0].len() - 2)] // Remove '(' and ',)'
&strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)'
} else if strs[0].starts_with("(") && strs[0].ends_with(")") {
&strs[0][1 .. (strs[0].len() - 1)] // Remove '(' and ')'
&strs[0][1 .. strs[0].len() - 1] // Remove '(' and ')'
} else {
&strs[0][]
},
@ -1090,12 +1051,6 @@ impl<'tcx> Repr<'tcx> for ty::MethodObject<'tcx> {
}
}
impl<'tcx> Repr<'tcx> for ty::TraitStore {
fn repr(&self, tcx: &ctxt) -> String {
trait_store_to_string(tcx, *self)
}
}
impl<'tcx> Repr<'tcx> for ty::BuiltinBound {
fn repr(&self, _tcx: &ctxt) -> String {
format!("{:?}", *self)