Skip to content

Commit b7bd7c1

Browse files
committedApr 28, 2020
Auto merge of rust-lang#71636 - Dylan-DPC:rollup-9gc24ak, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#71311 (On `FnDef` type annotation suggestion, use fn-pointer output) - rust-lang#71488 (normalize field projection ty to fix broken MIR issue) - rust-lang#71489 (Fix off by one in treat err as bug) - rust-lang#71585 (remove obsolete comment) - rust-lang#71634 (Revert rust-lang#71372 ("Fix #! (shebang) stripping account space issue").) Failed merges: r? @ghost
2 parents d7afaa7 + 6cad1e3 commit b7bd7c1

File tree

11 files changed

+36
-33
lines changed

11 files changed

+36
-33
lines changed
 

‎src/librustc_errors/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,10 @@ impl HandlerInner {
869869
}
870870

871871
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
872-
if self.treat_err_as_bug() {
872+
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
873+
// incrementing `err_count` by one, so we need to +1 the comparing.
874+
// FIXME: Would be nice to increment err_count in a more coherent way.
875+
if self.flags.treat_err_as_bug.map(|c| self.err_count() + 1 >= c).unwrap_or(false) {
873876
// FIXME: don't abort here if report_delayed_bugs is off
874877
self.span_bug(sp, msg);
875878
}

‎src/librustc_infer/infer/error_reporting/need_type_info.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
257257
None
258258
};
259259
printer.name_resolver = Some(Box::new(&getter));
260-
let _ = ty.print(printer);
260+
let _ = if let ty::FnDef(..) = ty.kind {
261+
// We don't want the regular output for `fn`s because it includes its path in
262+
// invalid pseduo-syntax, we want the `fn`-pointer output instead.
263+
ty.fn_sig(self.tcx).print(printer)
264+
} else {
265+
ty.print(printer)
266+
};
261267
s
262268
};
263269

‎src/librustc_lexer/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,12 @@ pub enum Base {
236236
/// (e.g. "#![deny(missing_docs)]").
237237
pub fn strip_shebang(input: &str) -> Option<usize> {
238238
debug_assert!(!input.is_empty());
239-
let s: &str = &remove_whitespace(input);
240-
if !s.starts_with("#!") || s.starts_with("#![") {
239+
if !input.starts_with("#!") || input.starts_with("#![") {
241240
return None;
242241
}
243242
Some(input.find('\n').unwrap_or(input.len()))
244243
}
245244

246-
fn remove_whitespace(s: &str) -> String {
247-
s.chars().filter(|c| !c.is_whitespace()).collect()
248-
}
249-
250245
/// Parses the first token from the provided input string.
251246
pub fn first_token(input: &str) -> Token {
252247
debug_assert!(!input.is_empty());

‎src/librustc_lexer/src/tests.rs

-18
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,4 @@ mod tests {
145145
}),
146146
);
147147
}
148-
149-
#[test]
150-
fn test_valid_shebang() {
151-
// https://github.com/rust-lang/rust/issues/70528
152-
let input = "#!/usr/bin/rustrun";
153-
let actual = strip_shebang(input);
154-
let expected: Option<usize> = Some(18);
155-
assert_eq!(expected, actual);
156-
}
157-
158-
#[test]
159-
fn test_invalid_shebang_valid_rust_syntax() {
160-
// https://github.com/rust-lang/rust/issues/70528
161-
let input = "#! [bad_attribute]";
162-
let actual = strip_shebang(input);
163-
let expected: Option<usize> = None;
164-
assert_eq!(expected, actual);
165-
}
166148
}

‎src/librustc_mir/borrow_check/type_check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
689689
let fty = self.sanitize_type(place, fty);
690690
match self.field_ty(place, base, field, location) {
691691
Ok(ty) => {
692+
let ty = self.cx.normalize(ty, location);
692693
if let Err(terr) = self.cx.eq_types(
693694
ty,
694695
fty,

‎src/librustc_mir/util/elaborate_drops.rs

-7
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,6 @@ where
835835
}
836836
}
837837

838-
/// Returns a basic block that drop a place using the context
839-
/// and path in `c`. If `mode` is something, also clear `c`
840-
/// according to it.
841-
///
842-
/// if FLAG(self.path)
843-
/// if let Some(mode) = mode: FLAG(self.path)[mode] = false
844-
/// drop(self.place)
845838
fn complete_drop(
846839
&mut self,
847840
drop_mode: Option<DropFlagMode>,

‎src/test/run-make-fulldeps/treat-err-as-bug/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
all:
44
$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
55
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
6+
$(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \
7+
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(rustc_attrs)]
2+
3+
#[rustc_error(delay_span_bug_from_inside_query)]
4+
fn main() {}

‎src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ fn init_hash(_: &mut [u8; HASH_LEN]) {}
77
fn foo<'a>() -> &'a () {
88
Hash([0; HASH_LEN]);
99
init_hash(&mut [0; HASH_LEN]);
10+
let (_array,) = ([0; HASH_LEN],);
1011
&()
1112
}
1213

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn f<A>() -> A { unimplemented!() }
2+
fn foo() {
3+
let _ = f; //~ ERROR type annotations needed for `fn() -> A`
4+
}
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0282]: type annotations needed for `fn() -> A`
2+
--> $DIR/fn-needing-specified-return-type-param.rs:3:13
3+
|
4+
LL | let _ = f;
5+
| - ^ cannot infer type for type parameter `A` declared on the function `f`
6+
| |
7+
| consider giving this pattern the explicit type `fn() -> A`, where the type parameter `A` is specified
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)
Please sign in to comment.