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
});
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 {
}
}
-// 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,
}
}
}
-// 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>>,
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,
}
impl<'a> DiagnosticBuilder<'a> {
- // Emit the diagnostic.
+ /// Emit the diagnostic.
pub fn emit(&mut self) {
if self.cancelled() {
return;
// }
}
- // 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;
}
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
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> {
}
}
- // 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,
}
}
-// 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() {