Skip to content

Add one more case to avoid ICE #94355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) => {
// A reborrow has no effect before a dereference.
}
// Catch cases which have Deref(None)
// having them slip to bug! causes ICE
// see #94291 for more info
(&[Adjustment { kind: Adjust::Deref(None), .. }], _) => {
self.tcx.sess.delay_span_bug(
DUMMY_SP,
&format!("Can't compose Deref(None) expressions"),
)
}
// FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could.
_ => bug!(
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/tuple/wrong_argument_ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::collections::VecDeque;

pub struct BuildPlanBuilder {
acc: VecDeque<(String, String)>,
current_provides: String,
current_requires: String,
}

impl BuildPlanBuilder {
pub fn or(&mut self) -> &mut Self {
self.acc.push_back(self.current_provides, self.current_requires);
//~^ ERROR this function takes 1 argument but 2 arguments were supplied
self
}
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/tuple/wrong_argument_ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/wrong_argument_ice.rs:11:18
|
LL | self.acc.push_back(self.current_provides, self.current_requires);
| ^^^^^^^^^ --------------------- --------------------- supplied 2 arguments
|
note: associated function defined here
--> $SRC_DIR/alloc/src/collections/vec_deque/mod.rs:LL:COL
|
LL | pub fn push_back(&mut self, value: T) {
| ^^^^^^^^^
help: use parentheses to construct a tuple
|
LL | self.acc.push_back((self.current_provides, self.current_requires));
| + +

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.