From 7237f150757c85ef41906b5c1c6497aabd48f1de Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 3 Mar 2022 20:39:50 -0800 Subject: [PATCH] delay bug instead of skipping check_expr --- .../rustc_typeck/src/check/fn_ctxt/_impl.rs | 13 ++++++++----- src/test/ui/tuple/wrong_argument_ice-3.rs | 17 +++++++++++++++++ src/test/ui/tuple/wrong_argument_ice-3.stderr | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/tuple/wrong_argument_ice-3.rs create mode 100644 src/test/ui/tuple/wrong_argument_ice-3.stderr diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 96bbc2800d50a..2bdc3af90d68f 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -315,11 +315,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // FIXME: currently we never try to compose autoderefs // and ReifyFnPointer/UnsafeFnPointer, but we could. - _ => bug!( - "while adjusting {:?}, can't compose {:?} and {:?}", - expr, - entry.get(), - adj + _ => self.tcx.sess.delay_span_bug( + expr.span, + &format!( + "while adjusting {:?}, can't compose {:?} and {:?}", + expr, + entry.get(), + adj + ), ), }; *entry.get_mut() = adj; diff --git a/src/test/ui/tuple/wrong_argument_ice-3.rs b/src/test/ui/tuple/wrong_argument_ice-3.rs new file mode 100644 index 0000000000000..951687c37596a --- /dev/null +++ b/src/test/ui/tuple/wrong_argument_ice-3.rs @@ -0,0 +1,17 @@ +struct Process; + +pub type Group = (Vec, Vec); + +fn test(process: &Process, groups: Vec) -> Vec { + let new_group = vec![String::new()]; + + if groups.capacity() == 0 { + groups.push(new_group, vec![process]); + //~^ ERROR this function takes 1 argument but 2 arguments were supplied + return groups; + } + + todo!() +} + +fn main() {} diff --git a/src/test/ui/tuple/wrong_argument_ice-3.stderr b/src/test/ui/tuple/wrong_argument_ice-3.stderr new file mode 100644 index 0000000000000..f0d64d2a4e18d --- /dev/null +++ b/src/test/ui/tuple/wrong_argument_ice-3.stderr @@ -0,0 +1,17 @@ +error[E0061]: this function takes 1 argument but 2 arguments were supplied + --> $DIR/wrong_argument_ice-3.rs:9:16 + | +LL | groups.push(new_group, vec![process]); + | ^^^^ --------- ------------- supplied 2 arguments + | | + | expected 1 argument + | +note: associated function defined here + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + | +LL | pub fn push(&mut self, value: T) { + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`.