Skip to content

Rollup of 8 pull requests #91033

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 19 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7272b6f
Make char conversion functions unstably const
est31 Sep 25, 2021
7bc827b
Refactor single variant `Candidate` enum into a struct
tmiasko Nov 5, 2021
59edb9d
Remove `Candidate::source_info`
tmiasko Nov 5, 2021
afd9dfa
bootstap: create .cargo/config only if not present
aplanas Nov 11, 2021
ddc1d58
windows: Return the "Not Found" error when a path is empty
JohnTitor Nov 16, 2021
4ca4e09
Suggest removal of arguments for unit variant, not replacement
estebank Nov 16, 2021
5520737
Remove unnecessary lifetime argument from arena macros.
nnethercote Nov 15, 2021
f1aeebf
add const generics test
lcnr Nov 4, 2021
41d9abd
Move some tests to more reasonable directories
c410-f3r Nov 18, 2021
8ace192
bless nll
lcnr Nov 18, 2021
0a89598
Add some comments.
nnethercote Nov 15, 2021
7432588
Rollup merge of #89258 - est31:const_char_convert, r=oli-obk
JohnTitor Nov 19, 2021
81fd016
Rollup merge of #90578 - lcnr:add-test, r=Mark-Simulacrum
JohnTitor Nov 19, 2021
48947ea
Rollup merge of #90633 - tmiasko:candidate-struct, r=nagisa
JohnTitor Nov 19, 2021
b542224
Rollup merge of #90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum
JohnTitor Nov 19, 2021
f62984f
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
JohnTitor Nov 19, 2021
022709f
Rollup merge of #90947 - c410-f3r:testsssssss, r=petrochenkov
JohnTitor Nov 19, 2021
c74ff8b
Rollup merge of #90961 - estebank:suggest-removal-of-call, r=nagisa
JohnTitor Nov 19, 2021
1576a7c
Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk
JohnTitor Nov 19, 2021
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
12 changes: 7 additions & 5 deletions compiler/rustc_typeck/src/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::FnPtr(sig) => (sig, None),
ref t => {
let mut unit_variant = None;
let mut removal_span = call_expr.span;
if let ty::Adt(adt_def, ..) = t {
if adt_def.is_enum() {
if let hir::ExprKind::Call(expr, _) = call_expr.kind {
removal_span =
expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
unit_variant =
self.tcx.sess.source_map().span_to_snippet(expr.span).ok();
}
Expand Down Expand Up @@ -379,14 +382,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);

if let Some(ref path) = unit_variant {
err.span_suggestion(
call_expr.span,
err.span_suggestion_verbose(
removal_span,
&format!(
"`{}` is a unit variant, you need to write it \
without the parentheses",
"`{}` is a unit variant, you need to write it without the parentheses",
path
),
path.to_string(),
String::new(),
Applicability::MachineApplicable,
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/test/ui/empty/empty-struct-unit-expr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ LL | let e4 = E::Empty4();
|
help: `E::Empty4` is a unit variant, you need to write it without the parentheses
|
LL | let e4 = E::Empty4;
| ~~~~~~~~~
LL - let e4 = E::Empty4();
LL + let e4 = E::Empty4;
|

error[E0618]: expected function, found `empty_struct::XEmpty2`
--> $DIR/empty-struct-unit-expr.rs:18:15
Expand All @@ -43,8 +44,9 @@ LL | let xe4 = XE::XEmpty4();
|
help: `XE::XEmpty4` is a unit variant, you need to write it without the parentheses
|
LL | let xe4 = XE::XEmpty4;
| ~~~~~~~~~~~
LL - let xe4 = XE::XEmpty4();
LL + let xe4 = XE::XEmpty4;
|

error: aborting due to 4 previous errors

Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/error-codes/E0618.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ LL | X::Entry();
|
help: `X::Entry` is a unit variant, you need to write it without the parentheses
|
LL | X::Entry;
| ~~~~~~~~
LL - X::Entry();
LL + X::Entry;
|

error[E0618]: expected function, found `i32`
--> $DIR/E0618.rs:9:5
Expand Down
15 changes: 9 additions & 6 deletions src/test/ui/resolve/privacy-enum-ctor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ LL | let _ = Z::Unit();
|
help: `Z::Unit` is a unit variant, you need to write it without the parentheses
|
LL | let _ = Z::Unit;
| ~~~~~~~
LL - let _ = Z::Unit();
LL + let _ = Z::Unit;
|

error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:43:16
Expand Down Expand Up @@ -374,8 +375,9 @@ LL | let _: E = m::E::Unit();
|
help: `m::E::Unit` is a unit variant, you need to write it without the parentheses
|
LL | let _: E = m::E::Unit;
| ~~~~~~~~~~
LL - let _: E = m::E::Unit();
LL + let _: E = m::E::Unit;
|

error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:51:16
Expand Down Expand Up @@ -408,8 +410,9 @@ LL | let _: E = E::Unit();
|
help: `E::Unit` is a unit variant, you need to write it without the parentheses
|
LL | let _: E = E::Unit;
| ~~~~~~~
LL - let _: E = E::Unit();
LL + let _: E = E::Unit;
|

error: aborting due to 23 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ LL | Alias::Unit();
|
help: `Alias::Unit` is a unit variant, you need to write it without the parentheses
|
LL | Alias::Unit;
| ~~~~~~~~~~~
LL - Alias::Unit();
LL + Alias::Unit;
|

error[E0164]: expected tuple struct or tuple variant, found unit variant `Alias::Unit`
--> $DIR/incorrect-variant-form-through-alias-caught.rs:17:9
Expand Down