Auto merge of #71636 - Dylan-DPC:rollup-9gc24ak, r=Dylan-DPC
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
This commit is contained in:
commit
b7bd7c1024
11 changed files with 36 additions and 33 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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\`'"
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error(delay_span_bug_from_inside_query)]
|
||||
fn main() {}
|
|
@ -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],);
|
||||
&()
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
fn f<A>() -> A { unimplemented!() }
|
||||
fn foo() {
|
||||
let _ = f; //~ ERROR type annotations needed for `fn() -> A`
|
||||
}
|
||||
fn main() {}
|
|
@ -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`.
|
Loading…
Add table
Reference in a new issue