]> git.lizzy.rs Git - rust.git/commitdiff
Rebasing and review comments
authorNick Cameron <ncameron@mozilla.com>
Wed, 23 Dec 2015 21:54:37 +0000 (10:54 +1300)
committerNick Cameron <ncameron@mozilla.com>
Wed, 30 Dec 2015 01:54:36 +0000 (14:54 +1300)
src/librustc_metadata/loader.rs
src/librustc_resolve/lib.rs
src/librustc_typeck/check/mod.rs
src/libsyntax/errors/emitter.rs
src/libsyntax/errors/mod.rs
src/libsyntax/parse/parser.rs

index b82b76a57c463119bb86ef1dbcd596ae941c291d..40665beaa5ac2698b08c92e6107ad139cef5ff17 100644 (file)
@@ -676,10 +676,11 @@ fn find_commandline_library(&mut self, locs: &[String]) -> Option<Library> {
                         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
             });
 
index c2dd764f224b2e45839b225f807807f485ca5504..5a17f2528c85b1aec723b921324e8c195a8ba41d 100644 (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
index ea08343bbc04c998bc3bd3895b07f58b9097f8ef..ca2db8c3deffb50727b9df1a52addf920c71f5b1 100644 (file)
@@ -3011,7 +3011,7 @@ fn suggest_field_names<'tcx>(err: &mut DiagnosticBuilder,
         // 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));
         }
     }
 
index 8b9df7aa921304d295d7822ae5d28c6368c1f628..a7bfdedf71813d0fd70ef99033069f1927598008 100644 (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 @@ fn use_color(&self) -> bool {
     }
 }
 
-// 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,
 }
index 3cee14538a905d23c11b9fbc94dd415f70681d79..a2fae975148f953e913d96b878babf75fcd01ae8 100644 (file)
@@ -98,7 +98,7 @@ fn description(&self) -> &str {
     }
 }
 
-// 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 @@ pub fn emit(&mut self) {
         // }
     }
 
-    // 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 @@ pub fn span_note(&mut self ,
         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 @@ pub fn code(&mut self, s: String) -> &mut 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>  {
@@ -235,8 +229,8 @@ fn new(emitter: &'a RefCell<Box<Emitter>>,
         }
     }
 
-    // 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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-// 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() {
index f31f24cf249f13d39b8d962bacbdeff5b310d960..efd351a632da14f73447502bca5882ee621e681f 100644 (file)
@@ -749,7 +749,7 @@ pub fn expect_gt(&mut self) -> PResult<'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();