diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-28 04:51:00 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-04-28 04:51:00 +0800 |
| commit | dc6b167e224f3a782fa7b1e6f5cff21f5238f97e (patch) | |
| tree | 4b7f94bd41ed6ace04a8a31b56658fafac41e739 /src | |
| parent | e5983943fe896c564db441add38e6389c978aaef (diff) | |
| parent | d92d1935cb01cfa469a725f041e4c1d8a2ee9564 (diff) | |
| download | rust-dc6b167e224f3a782fa7b1e6f5cff21f5238f97e.tar.gz rust-dc6b167e224f3a782fa7b1e6f5cff21f5238f97e.zip | |
Rollup merge of #50257 - estebank:fix-49560, r=nikomatsakis
Don't ICE on tuple struct ctor with incorrect arg count Fix #49560.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/traits/error_reporting.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/closure-arg-count.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/closure-arg-count.stderr | 17 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 285d530a38a..047d4bb8930 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -979,6 +979,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ArgKind::Arg(format!("{}", field.name), "_".to_string()) }).collect::<Vec<_>>()) } + hir::map::NodeStructCtor(ref variant_data) => { + (self.tcx.sess.codemap().def_span(self.tcx.hir.span(variant_data.id())), + variant_data.fields() + .iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned())) + .collect()) + } _ => panic!("non-FnLike node found: {:?}", node), } } diff --git a/src/test/ui/mismatched_types/closure-arg-count.rs b/src/test/ui/mismatched_types/closure-arg-count.rs index 34232e81cbd..9eb11148a8b 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.rs +++ b/src/test/ui/mismatched_types/closure-arg-count.rs @@ -39,7 +39,13 @@ fn main() { let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); //~^ ERROR function is expected to take + + call(Foo); + //~^ ERROR function is expected to take } fn foo() {} fn qux(x: usize, y: usize) {} + +fn call<F, R>(_: F) where F: FnOnce() -> R {} +struct Foo(u8); diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 6451c0d06fa..6270e794498 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -116,6 +116,21 @@ error[E0593]: function is expected to take 1 argument, but it takes 2 arguments LL | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); | ^^^ expected function that takes 1 argument -error: aborting due to 12 previous errors +error[E0593]: function is expected to take 0 arguments, but it takes 1 argument + --> $DIR/closure-arg-count.rs:43:5 + | +LL | call(Foo); + | ^^^^ expected function that takes 0 arguments +... +LL | struct Foo(u8); + | --------------- takes 1 argument + | +note: required by `call` + --> $DIR/closure-arg-count.rs:50:1 + | +LL | fn call<F, R>(_: F) where F: FnOnce() -> R {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0593`. |
