Rebasing and review comments

This commit is contained in:
Nick Cameron 2015-12-24 10:54:37 +13:00
parent aaa02b3ff9
commit 04d972906d
6 changed files with 30 additions and 35 deletions

View File

@ -676,10 +676,11 @@ impl<'a> Context<'a> {
return true
}
}
sess.err(&format!("extern location for {} is of an unknown type: {}",
self.crate_name, loc.display()));
sess.help(&format!("file name should be lib*.rlib or {}*.{}",
dylibname.0, dylibname.1));
sess.struct_err(&format!("extern location for {} is of an unknown type: {}",
self.crate_name, loc.display()))
.help(&format!("file name should be lib*.rlib or {}*.{}",
dylibname.0, dylibname.1))
.emit();
false
});

View File

@ -425,12 +425,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
argument is missing?")
}
ResolutionError::UnresolvedName(path, msg, context) => {
let err = struct_span_err!(resolver.session,
span,
E0425,
"unresolved name `{}`{}",
path,
msg);
let mut err = struct_span_err!(resolver.session,
span,
E0425,
"unresolved name `{}`{}",
path,
msg);
match context {
UnresolvedNameContext::Other => {} // no help available

View File

@ -3011,7 +3011,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
// only find fits with at least one matching letter
if let Some(name) = find_best_match_for_name(names, &name, Some(name.len())) {
err.span_help(field.span,
&format!("did you mean `{}`?", n));
&format!("did you mean `{}`?", name));
}
}

View File

@ -28,7 +28,7 @@ pub trait Emitter {
fn emit(&mut self, span: Option<Span>, msg: &str, code: Option<&str>, lvl: Level);
fn custom_emit(&mut self, sp: RenderSpan, msg: &str, lvl: Level);
// Emit a structured diagnostic.
/// Emit a structured diagnostic.
fn emit_struct(&mut self, db: &DiagnosticBuilder) {
self.emit(db.span, &db.message, db.code.as_ref().map(|s| &**s), db.level);
for child in &db.children {
@ -60,8 +60,8 @@ impl ColorConfig {
}
}
// A basic emitter for when we don't have access to a codemap or registry. Used
// for reporting very early errors, etc.
/// A basic emitter for when we don't have access to a codemap or registry. Used
/// for reporting very early errors, etc.
pub struct BasicEmitter {
dst: Destination,
}

View File

@ -98,7 +98,7 @@ impl error::Error for ExplicitBug {
}
}
// Used for emitting structured error messages and other diagnostic information.
/// Used for emitting structured error messages and other diagnostic information.
#[must_use]
pub struct DiagnosticBuilder<'a> {
emitter: &'a RefCell<Box<Emitter>>,
@ -109,7 +109,7 @@ pub struct DiagnosticBuilder<'a> {
children: Vec<SubDiagnostic>,
}
// For example a note attached to an error.
/// For example a note attached to an error.
struct SubDiagnostic {
level: Level,
message: String,
@ -118,7 +118,7 @@ struct SubDiagnostic {
}
impl<'a> DiagnosticBuilder<'a> {
// Emit the diagnostic.
/// Emit the diagnostic.
pub fn emit(&mut self) {
if self.cancelled() {
return;
@ -132,11 +132,11 @@ impl<'a> DiagnosticBuilder<'a> {
// }
}
// Cancel the diagnostic (a structured diagnostic must either be emitted or
// cancelled or it will panic when dropped).
// BEWARE: if this DiagnosticBuilder is an error, then creating it will
// bump the error count on the Handler and cancelling it won't undo that.
// If you want to decrement the error count you should use `Handler::cancel`.
/// Cancel the diagnostic (a structured diagnostic must either be emitted or
/// cancelled or it will panic when dropped).
/// BEWARE: if this DiagnosticBuilder is an error, then creating it will
/// bump the error count on the Handler and cancelling it won't undo that.
/// If you want to decrement the error count you should use `Handler::cancel`.
pub fn cancel(&mut self) {
self.level = Level::Cancelled;
}
@ -160,12 +160,6 @@ impl<'a> DiagnosticBuilder<'a> {
self.sub(Level::Note, msg, Some(sp), None);
self
}
pub fn note_rfc_1214(&mut self , span: Span) -> &mut DiagnosticBuilder<'a> {
self.span_note(span,
"this warning results from recent bug fixes and clarifications; \
it will become a HARD ERROR in the next release. \
See RFC 1214 for details.")
}
pub fn help(&mut self , msg: &str) -> &mut DiagnosticBuilder<'a> {
self.sub(Level::Help, msg, None, None);
self
@ -220,8 +214,8 @@ impl<'a> DiagnosticBuilder<'a> {
self
}
// Convenience function for internal use, clients should use one of the
// struct_* methods on Handler.
/// Convenience function for internal use, clients should use one of the
/// struct_* methods on Handler.
fn new(emitter: &'a RefCell<Box<Emitter>>,
level: Level,
message: &str) -> DiagnosticBuilder<'a> {
@ -235,8 +229,8 @@ impl<'a> DiagnosticBuilder<'a> {
}
}
// Convenience function for internal use, clients should use one of the
// public methods above.
/// Convenience function for internal use, clients should use one of the
/// public methods above.
fn sub(&mut self,
level: Level,
message: &str,
@ -258,8 +252,8 @@ impl<'a> fmt::Debug for DiagnosticBuilder<'a> {
}
}
// Destructor bomb - a DiagnosticBuilder must be either emitted or cancelled or
// we emit a bug.
/// Destructor bomb - a DiagnosticBuilder must be either emitted or cancelled or
/// we emit a bug.
impl<'a> Drop for DiagnosticBuilder<'a> {
fn drop(&mut self) {
if !self.cancelled() {

View File

@ -749,7 +749,7 @@ impl<'a> Parser<'a> {
pub fn parse_seq_to_before_gt_or_return<T, F>(&mut self,
sep: Option<token::Token>,
mut f: F)
-> PResult<'a, (P<[T]>, bool)> where
-> PResult<'a, (P<[T]>, bool)>
where F: FnMut(&mut Parser<'a>) -> PResult<'a, Option<T>>,
{
let mut v = Vec::new();