Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
39eb148
Follow C-RW-VALUE in std::io::Cursor example
mattfbacon Jun 29, 2022
22a456a
Stabilize `nonnull_slice_from_raw_parts`
JohnTitor May 29, 2022
5e49f09
Use an IndexVec to debug fingerprints.
cjgillot Mar 12, 2023
08f3deb
fix type suggestions in match arms
Mar 25, 2023
28982a1
Fix "Directly go to item in search if there is only one result" setting
GuillaumeGomez Mar 26, 2023
bc9eec0
Add GUI test for "Directly go to item in search if there is only one …
GuillaumeGomez Mar 26, 2023
b874502
Remove unnecessary raw pointer in __rust_start_panic arg
bjorn3 Oct 6, 2022
72c917d
debuginfo: Get pointer size/align from tcx.data_layout instead of lay…
Noratrieb Mar 26, 2023
1ce4b37
Don't elaborate non-obligations into obligations
compiler-errors Mar 26, 2023
102bbbd
Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-p…
matthiaskrgr Mar 27, 2023
fe0b042
Rollup merge of #98651 - mattfbacon:master, r=ChrisDenton
matthiaskrgr Mar 27, 2023
704991c
Rollup merge of #102742 - bjorn3:cleanup_rust_start_panic, r=ChrisDenton
matthiaskrgr Mar 27, 2023
32aa4c0
Rollup merge of #109587 - cjgillot:no-hashmap-fingerprint, r=Nilstrieb
matthiaskrgr Mar 27, 2023
04b8523
Rollup merge of #109613 - lukas-code:match-str-to-char-suggestion, r=…
matthiaskrgr Mar 27, 2023
b39db70
Rollup merge of #109633 - GuillaumeGomez:fix-go-to-only-setting, r=no…
matthiaskrgr Mar 27, 2023
2b7dc94
Rollup merge of #109635 - Nilstrieb:debrrruginfo, r=compiler=errors
matthiaskrgr Mar 27, 2023
6535e66
Rollup merge of #109641 - compiler-errors:dont-elaborate-non-obl, r=o…
matthiaskrgr Mar 27, 2023
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
fix type suggestions in match arms
  • Loading branch information
Lukas Markeffsky committed Mar 25, 2023
commit 08f3deb3d5a2164d8a601d37c87f2453b2f09eed
3 changes: 2 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
escaped
}
let mut err = struct_span_err!(self.tcx.sess, span, E0308, "{}", failure_str);
if let Some((expected, found)) = trace.values.ty() {
let values = self.resolve_vars_if_possible(trace.values);
if let Some((expected, found)) = values.ty() {
match (expected.kind(), found.kind()) {
(ty::Tuple(_), ty::Tuple(_)) => {}
// If a tuple of length one was expected and the found expression has
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/inference/char-as-str-single.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ fn main() {
let _: char = '人'; //~ ERROR mismatched types
let _: char = '\''; //~ ERROR mismatched types
}

// regression test for https://github.com/rust-lang/rust/issues/109586
#[allow(dead_code)]
fn convert_c_to_str(c: char) {
match c {
'A' => {} //~ ERROR mismatched types
_ => {}
}
}
9 changes: 9 additions & 0 deletions tests/ui/inference/char-as-str-single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ fn main() {
let _: char = "人"; //~ ERROR mismatched types
let _: char = "'"; //~ ERROR mismatched types
}

// regression test for https://github.com/rust-lang/rust/issues/109586
#[allow(dead_code)]
fn convert_c_to_str(c: char) {
match c {
"A" => {} //~ ERROR mismatched types
_ => {}
}
}
15 changes: 14 additions & 1 deletion tests/ui/inference/char-as-str-single.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ help: if you meant to write a `char` literal, use single quotes
LL | let _: char = '\'';
| ~~~~

error: aborting due to 3 previous errors
error[E0308]: mismatched types
--> $DIR/char-as-str-single.rs:18:9
|
LL | match c {
| - this expression has type `char`
LL | "A" => {}
| ^^^ expected `char`, found `&str`
|
help: if you meant to write a `char` literal, use single quotes
|
LL | 'A' => {}
| ~~~

error: aborting due to 4 previous errors

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