about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_errors/lib.rs5
-rw-r--r--src/librustc_infer/infer/error_reporting/need_type_info.rs8
-rw-r--r--src/librustc_lexer/src/lib.rs7
-rw-r--r--src/librustc_lexer/src/tests.rs18
-rw-r--r--src/librustc_mir/borrow_check/type_check/mod.rs1
-rw-r--r--src/librustc_mir/util/elaborate_drops.rs7
-rw-r--r--src/test/run-make-fulldeps/treat-err-as-bug/Makefile2
-rw-r--r--src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs4
-rw-r--r--src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs1
-rw-r--r--src/test/ui/suggestions/fn-needing-specified-return-type-param.rs5
-rw-r--r--src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr11
11 files changed, 36 insertions, 33 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 151241fdb0b..e4a560e434a 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -869,7 +869,10 @@ impl HandlerInner {
     }
 
     fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
-        if self.treat_err_as_bug() {
+        // This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
+        // incrementing `err_count` by one, so we need to +1 the comparing.
+        // FIXME: Would be nice to increment err_count in a more coherent way.
+        if self.flags.treat_err_as_bug.map(|c| self.err_count() + 1 >= c).unwrap_or(false) {
             // FIXME: don't abort here if report_delayed_bugs is off
             self.span_bug(sp, msg);
         }
diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs
index 1986838e401..93c8e505697 100644
--- a/src/librustc_infer/infer/error_reporting/need_type_info.rs
+++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs
@@ -257,7 +257,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                 None
             };
             printer.name_resolver = Some(Box::new(&getter));
-            let _ = ty.print(printer);
+            let _ = if let ty::FnDef(..) = ty.kind {
+                // We don't want the regular output for `fn`s because it includes its path in
+                // invalid pseduo-syntax, we want the `fn`-pointer output instead.
+                ty.fn_sig(self.tcx).print(printer)
+            } else {
+                ty.print(printer)
+            };
             s
         };
 
diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs
index be85a34bd39..5ccfc1b276b 100644
--- a/src/librustc_lexer/src/lib.rs
+++ b/src/librustc_lexer/src/lib.rs
@@ -236,17 +236,12 @@ pub enum Base {
 /// (e.g. "#![deny(missing_docs)]").
 pub fn strip_shebang(input: &str) -> Option<usize> {
     debug_assert!(!input.is_empty());
-    let s: &str = &remove_whitespace(input);
-    if !s.starts_with("#!") || s.starts_with("#![") {
+    if !input.starts_with("#!") || input.starts_with("#![") {
         return None;
     }
     Some(input.find('\n').unwrap_or(input.len()))
 }
 
-fn remove_whitespace(s: &str) -> String {
-    s.chars().filter(|c| !c.is_whitespace()).collect()
-}
-
 /// Parses the first token from the provided input string.
 pub fn first_token(input: &str) -> Token {
     debug_assert!(!input.is_empty());
diff --git a/src/librustc_lexer/src/tests.rs b/src/librustc_lexer/src/tests.rs
index 065e8f3f646..06fc159fe25 100644
--- a/src/librustc_lexer/src/tests.rs
+++ b/src/librustc_lexer/src/tests.rs
@@ -145,22 +145,4 @@ mod tests {
             }),
         );
     }
-
-    #[test]
-    fn test_valid_shebang() {
-        // https://github.com/rust-lang/rust/issues/70528
-        let input = "#!/usr/bin/rustrun";
-        let actual = strip_shebang(input);
-        let expected: Option<usize> = Some(18);
-        assert_eq!(expected, actual);
-    }
-
-    #[test]
-    fn test_invalid_shebang_valid_rust_syntax() {
-        // https://github.com/rust-lang/rust/issues/70528
-        let input = "#!    [bad_attribute]";
-        let actual = strip_shebang(input);
-        let expected: Option<usize> = None;
-        assert_eq!(expected, actual);
-    }
 }
diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs
index d60ab2b81fd..7f554742777 100644
--- a/src/librustc_mir/borrow_check/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/type_check/mod.rs
@@ -689,6 +689,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
                 let fty = self.sanitize_type(place, fty);
                 match self.field_ty(place, base, field, location) {
                     Ok(ty) => {
+                        let ty = self.cx.normalize(ty, location);
                         if let Err(terr) = self.cx.eq_types(
                             ty,
                             fty,
diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs
index 8286793b532..43fa7b9922d 100644
--- a/src/librustc_mir/util/elaborate_drops.rs
+++ b/src/librustc_mir/util/elaborate_drops.rs
@@ -835,13 +835,6 @@ where
         }
     }
 
-    /// Returns a basic block that drop a place using the context
-    /// and path in `c`. If `mode` is something, also clear `c`
-    /// according to it.
-    ///
-    /// if FLAG(self.path)
-    ///     if let Some(mode) = mode: FLAG(self.path)[mode] = false
-    ///     drop(self.place)
     fn complete_drop(
         &mut self,
         drop_mode: Option<DropFlagMode>,
diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile
index 9b3bcef2faf..57cac76aec2 100644
--- a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile
+++ b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile
@@ -3,3 +3,5 @@
 all:
 	$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
 	    | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
+	$(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \
+	    | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs b/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs
new file mode 100644
index 00000000000..dad33e498b5
--- /dev/null
+++ b/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs
@@ -0,0 +1,4 @@
+#![feature(rustc_attrs)]
+
+#[rustc_error(delay_span_bug_from_inside_query)]
+fn main() {}
diff --git a/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs
index 07af8310424..9d44aa1361c 100644
--- a/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs
+++ b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs
@@ -7,6 +7,7 @@ fn init_hash(_: &mut [u8; HASH_LEN]) {}
 fn foo<'a>() -> &'a () {
     Hash([0; HASH_LEN]);
     init_hash(&mut [0; HASH_LEN]);
+    let (_array,) = ([0; HASH_LEN],);
     &()
 }
 
diff --git a/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs b/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs
new file mode 100644
index 00000000000..2f140f823af
--- /dev/null
+++ b/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs
@@ -0,0 +1,5 @@
+fn f<A>() -> A { unimplemented!() }
+fn foo() {
+    let _ = f; //~ ERROR type annotations needed for `fn() -> A`
+}
+fn main() {}
diff --git a/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr
new file mode 100644
index 00000000000..b59a3818e70
--- /dev/null
+++ b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr
@@ -0,0 +1,11 @@
+error[E0282]: type annotations needed for `fn() -> A`
+  --> $DIR/fn-needing-specified-return-type-param.rs:3:13
+   |
+LL |     let _ = f;
+   |         -   ^ cannot infer type for type parameter `A` declared on the function `f`
+   |         |
+   |         consider giving this pattern the explicit type `fn() -> A`, where the type parameter `A` is specified
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.