Skip to content
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

Rollup of 13 pull requests #93738

Merged
merged 36 commits into from
Feb 7, 2022
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9d664b2
Make the pre-commit script pre-push instead
jyn514 Aug 25, 2021
9648b31
Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping…
kellerkindt Jan 22, 2022
9b8e4c6
Don't allow {} to refer to implicit captures in format_args.
m-ou-se Jan 27, 2022
fb2d530
Add test for format args capture bug.
m-ou-se Jan 27, 2022
cef9b47
Extend format-args capture test.
m-ou-se Jan 27, 2022
6562069
remove allow_fail test flag
Jan 28, 2022
0b8c9fb
add allow_fail field in TestDesc to pass check
Jan 28, 2022
4738ce4
Suggest 1-tuple parentheses, without existing parens
bobrippling Dec 4, 2021
c734c32
Replace span suggestion with multipart
bobrippling Dec 4, 2021
18cea90
Handle existing parentheses when suggesting trailing-tuple-comma
bobrippling Jan 28, 2022
91a43f0
Only suggest 1-tuple if expected and found types match
bobrippling Jan 28, 2022
72d3b45
Test 1-tuple parentheses wrapping
bobrippling Jan 28, 2022
0fb2b7a
Drop json::from_reader
Mark-Simulacrum Feb 5, 2022
a4112dc
fix linking stage1 toolchain in setup
yerke Feb 6, 2022
e27ebb5
Linkify sidebar headings for sibling items
jsha Feb 4, 2022
57b102f
Fix tracking issue for `const_fn_trait_bound`
PatchMixolydic Feb 5, 2022
afb7a50
rewrite from_bytes_with_nul to match code style in from_vec_with_nul
inteon Feb 6, 2022
344ea6e
Factor out emit_tuple_wrap_err, improve Applicability
bobrippling Feb 2, 2022
82a0122
Merge duplicate suggestion string
bobrippling Feb 2, 2022
1870db6
Use shallow clones for submodules managed by rustbuild, not just boot…
jyn514 Feb 7, 2022
b5b2150
Rerun bootstrap's build script when RUSTC changes
jyn514 Feb 7, 2022
14ff58c
Stabilize wrapping_int_assign_impl in 1.60.0.
m-ou-se Feb 7, 2022
95054de
bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG'
mfrw Feb 7, 2022
aee13fb
Rollup merge of #88313 - jyn514:pre-push, r=Mark-Simulacrum
m-ou-se Feb 7, 2022
557d300
Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelid
m-ou-se Feb 7, 2022
8219ad4
Rollup merge of #92724 - inteon:cleanup, r=Mark-Simulacrum
m-ou-se Feb 7, 2022
e3c972e
Rollup merge of #93208 - kellerkindt:wrapping_int_assign_impl, r=m-ou-se
m-ou-se Feb 7, 2022
4445a8f
Rollup merge of #93394 - m-ou-se:fix-93378, r=estebank
m-ou-se Feb 7, 2022
252ff5e
Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se
m-ou-se Feb 7, 2022
f611de0
Rollup merge of #93487 - yerke:yerke/fix-link-toolchain-in-setup, r=M…
m-ou-se Feb 7, 2022
0b6c7fb
Rollup merge of #93673 - jsha:linkify-sidebar-headings, r=GuillaumeGomez
m-ou-se Feb 7, 2022
bd245fa
Rollup merge of #93680 - Mark-Simulacrum:drop-json-reader, r=bjorn3
m-ou-se Feb 7, 2022
f4377a8
Rollup merge of #93682 - PatchMixolydic:where-in-the-world-is-const_f…
m-ou-se Feb 7, 2022
82fe6ed
Rollup merge of #93722 - jyn514:less-submodule-cloning, r=Mark-Simula…
m-ou-se Feb 7, 2022
0f9d3b4
Rollup merge of #93723 - jyn514:rerun-if-changed, r=Mark-Simulacrum
m-ou-se Feb 7, 2022
a6c4810
Rollup merge of #93737 - mfrw:mfrw/bootstrap-config, r=Mark-Simulacrum
m-ou-se Feb 7, 2022
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
Prev Previous commit
Next Next commit
Handle existing parentheses when suggesting trailing-tuple-comma
bobrippling committed Jan 28, 2022
commit 18cea90d4a01cbb3a1285f633b1058fd39931956
29 changes: 21 additions & 8 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -2045,14 +2045,27 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
// parentheses around it, perhaps the user meant to write `(expr,)` to
// build a tuple (issue #86100)
(ty::Tuple(_), _) if expected.tuple_fields().count() == 1 => {
err.multipart_suggestion(
"use a trailing comma to create a tuple with one element",
vec![
(span.shrink_to_lo(), "(".into()),
(span.shrink_to_hi(), ",)".into()),
],
Applicability::MaybeIncorrect,
);
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) {
if code.starts_with('(') && code.ends_with(')') {
let before_close = span.hi() - BytePos::from_u32(1);

err.span_suggestion(
span.with_hi(before_close).shrink_to_hi(),
"use a trailing comma to create a tuple with one element",
",".into(),
Applicability::MaybeIncorrect,
);
} else {
err.multipart_suggestion(
"use a trailing comma to create a tuple with one element",
vec![
(span.shrink_to_lo(), "(".into()),
(span.shrink_to_hi(), ",)".into()),
],
Applicability::MaybeIncorrect,
);
}
}
}
// If a character was expected and the found expression is a string literal
// containing a single character, perhaps the user meant to write `'c'` to