Skip to content

Commit

Permalink
Auto merge of #71636 - Dylan-DPC:rollup-9gc24ak, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #71311 (On `FnDef` type annotation suggestion, use fn-pointer output)
 - #71488 (normalize field projection ty to fix broken MIR issue)
 - #71489 (Fix off by one in treat err as bug)
 - #71585 (remove obsolete comment)
 - #71634 (Revert #71372 ("Fix #! (shebang) stripping account space issue").)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Apr 28, 2020
2 parents d7afaa7 + 6cad1e3 commit b7bd7c1
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 33 deletions.
5 changes: 4 additions & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_infer/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
7 changes: 1 addition & 6 deletions src/librustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 0 additions & 18 deletions src/librustc_lexer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/librustc_mir/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
2 changes: 2 additions & 0 deletions src/test/run-make-fulldeps/treat-err-as-bug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\`'"
4 changes: 4 additions & 0 deletions src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(rustc_attrs)]

#[rustc_error(delay_span_bug_from_inside_query)]
fn main() {}
1 change: 1 addition & 0 deletions src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],);
&()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn f<A>() -> A { unimplemented!() }
fn foo() {
let _ = f; //~ ERROR type annotations needed for `fn() -> A`
}
fn main() {}
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit b7bd7c1

Please sign in to comment.