Rollup merge of #114779 - MU001999:fix/114701, r=petrochenkov
Add check before suggest removing parens Fixes #114701
This commit is contained in:
commit
8f1c8116f6
@ -599,6 +599,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
= self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id)
|
||||
// Only suggest removing parens if there are no arguments
|
||||
&& arg_exprs.is_empty()
|
||||
&& call_expr.span.contains(callee_expr.span)
|
||||
{
|
||||
let descr = match kind {
|
||||
def::CtorOf::Struct => "struct",
|
||||
|
15
tests/ui/suggestions/issue-114701.rs
Normal file
15
tests/ui/suggestions/issue-114701.rs
Normal file
@ -0,0 +1,15 @@
|
||||
enum Enum<T> { SVariant { v: T }, UVariant }
|
||||
|
||||
macro_rules! is_variant {
|
||||
(TSVariant, ) => (!);
|
||||
(SVariant, ) => (!);
|
||||
(UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr));
|
||||
(@check $variant:ident, $matcher:tt, $expr:expr) => (
|
||||
assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false },
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
is_variant!(UVariant, Enum::<()>::UVariant); //~ ERROR expected function
|
||||
}
|
15
tests/ui/suggestions/issue-114701.stderr
Normal file
15
tests/ui/suggestions/issue-114701.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error[E0618]: expected function, found `Enum<()>`
|
||||
--> $DIR/issue-114701.rs:14:27
|
||||
|
|
||||
LL | enum Enum<T> { SVariant { v: T }, UVariant }
|
||||
| -------- `Enum::UVariant` defined here
|
||||
...
|
||||
LL | assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false },
|
||||
| -------- call expression requires function
|
||||
...
|
||||
LL | is_variant!(UVariant, Enum::<()>::UVariant);
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0618`.
|
Loading…
x
Reference in New Issue
Block a user