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

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4174600
place explicit lifetime bound after generic param
bvanjoi May 8, 2024
48d3425
Remove some msys2 utils
ChrisDenton Jun 12, 2024
c81ffab
std::unix::fs::link using direct linkat call for Solaris and macOs.
devnexen Jun 12, 2024
1243213
Remove some unnecessary crate dependencies.
nnethercote Jun 13, 2024
2733b8a
Avoid follow-up errors on erroneous patterns
oli-obk Jun 11, 2024
a621701
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
ece3e3e
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
e8d6170
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
7566307
Replace a `bool` with a `Result<(), ErrorGuaranteed>`
oli-obk Jun 12, 2024
b28221e
Use diagnostic method for diagnostics
oli-obk Apr 15, 2024
c75f728
Add some tests
oli-obk Apr 15, 2024
9cf60ee
Method resolution constrains hidden types instead of rejecting method…
oli-obk Apr 15, 2024
9314831
Implement `CompletedProcess::assert_stdout_contains` and improve erro…
GuillaumeGomez Jun 13, 2024
96f9fe5
Migrate `run-make/allow-non-lint-warnings-cmdline` to `rmake.rs`
GuillaumeGomez Jun 13, 2024
eca8d20
Make `run-make/allow-non-lint-warnings-cmdline` into a ui test
GuillaumeGomez Jun 13, 2024
9bff230
Allow to bless diff tests
GuillaumeGomez Jun 11, 2024
be7b587
Migrate `run-make/const_fn_mir` to `rmake.rs`
GuillaumeGomez Jun 11, 2024
5f4111f
Update run-make-support/diff to new `fs_wrapper` API
GuillaumeGomez Jun 13, 2024
14014ab
Update fuchsia commit, and SDK to 21.20240610.2.1
erickt Jun 10, 2024
efbfcdd
Fill out missing Windows support information
ChrisDenton Jun 14, 2024
160b200
Rollup merge of #123962 - oli-obk:define_opaque_types5, r=lcnr
matthiaskrgr Jun 14, 2024
130c1a8
Rollup merge of #124884 - bvanjoi:fix-124785, r=estebank
matthiaskrgr Jun 14, 2024
158d2c1
Rollup merge of #126244 - erickt:bump, r=Kobzol
matthiaskrgr Jun 14, 2024
44e618d
Rollup merge of #126270 - GuillaumeGomez:migrate-run-make-const_fn_mi…
matthiaskrgr Jun 14, 2024
5725958
Rollup merge of #126320 - oli-obk:pat_ice, r=lcnr
matthiaskrgr Jun 14, 2024
db08f37
Rollup merge of #126343 - ChrisDenton:remove-utils, r=Kobzol
matthiaskrgr Jun 14, 2024
e435692
Rollup merge of #126351 - devnexen:to_sol11_upd, r=ChrisDenton
matthiaskrgr Jun 14, 2024
2e70bd2
Rollup merge of #126368 - nnethercote:rm-more-unused-crate-deps, r=ja…
matthiaskrgr Jun 14, 2024
8dc46d8
Rollup merge of #126386 - GuillaumeGomez:migrate-run-make-allow-non-l…
matthiaskrgr Jun 14, 2024
03068ec
Rollup merge of #126449 - ChrisDenton:windows-std-support, r=workingj…
matthiaskrgr Jun 14, 2024
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
Replace some Option<Diag> with Result<(), Diag>
  • Loading branch information
oli-obk committed Jun 13, 2024
commit ece3e3e4c146a94996b4c0f6141caf0a0a877084
42 changes: 17 additions & 25 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let _ = self.demand_eqtype_pat(pat.span, expected, pat_ty, pat_info.top_info);

// Type-check subpatterns.
if self.check_struct_pat_fields(pat_ty, pat, variant, fields, has_rest_pat, pat_info) {
pat_ty
} else {
Ty::new_misc_error(self.tcx)
match self.check_struct_pat_fields(pat_ty, pat, variant, fields, has_rest_pat, pat_info) {
Ok(()) => pat_ty,
Err(guar) => Ty::new_error(self.tcx, guar),
}
}

Expand Down Expand Up @@ -1469,7 +1468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fields: &'tcx [hir::PatField<'tcx>],
has_rest_pat: bool,
pat_info: PatInfo<'tcx, '_>,
) -> bool {
) -> Result<(), ErrorGuaranteed> {
let tcx = self.tcx;

let ty::Adt(adt, args) = adt_ty.kind() else {
Expand All @@ -1485,7 +1484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Keep track of which fields have already appeared in the pattern.
let mut used_fields = FxHashMap::default();
let mut no_field_errors = true;
let mut result = Ok(());

let mut inexistent_fields = vec![];
// Typecheck each field.
Expand All @@ -1494,8 +1493,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let ident = tcx.adjust_ident(field.ident, variant.def_id);
let field_ty = match used_fields.entry(ident) {
Occupied(occupied) => {
no_field_errors = false;
let guar = self.error_field_already_bound(span, field.ident, *occupied.get());
result = Err(guar);
Ty::new_error(tcx, guar)
}
Vacant(vacant) => {
Expand All @@ -1510,7 +1509,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
.unwrap_or_else(|| {
inexistent_fields.push(field);
no_field_errors = false;
Ty::new_misc_error(tcx)
})
}
Expand Down Expand Up @@ -1589,40 +1587,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// `Foo { a, b }` when it should have been `Foo(a, b)`.
i.delay_as_bug();
u.delay_as_bug();
e.emit();
Err(e.emit())
} else {
i.emit();
u.emit();
Err(u.emit())
}
}
(None, Some(u)) => {
if let Some(e) = self.error_tuple_variant_as_struct_pat(pat, fields, variant) {
u.delay_as_bug();
e.emit();
Err(e.emit())
} else {
u.emit();
Err(u.emit())
}
}
(Some(err), None) => {
err.emit();
(Some(err), None) => Err(err.emit()),
(None, None) => {
self.error_tuple_variant_index_shorthand(variant, pat, fields)?;
result
}
(None, None)
if let Some(err) =
self.error_tuple_variant_index_shorthand(variant, pat, fields) =>
{
err.emit();
}
(None, None) => {}
}
no_field_errors
}

fn error_tuple_variant_index_shorthand(
&self,
variant: &VariantDef,
pat: &'_ Pat<'_>,
fields: &[hir::PatField<'_>],
) -> Option<Diag<'_>> {
) -> Result<(), ErrorGuaranteed> {
// if this is a tuple struct, then all field names will be numbers
// so if any fields in a struct pattern use shorthand syntax, they will
// be invalid identifiers (for example, Foo { 0, 1 }).
Expand All @@ -1644,10 +1636,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("({})", self.get_suggested_tuple_struct_pattern(fields, variant)),
Applicability::MaybeIncorrect,
);
return Some(err);
return Err(err.emit());
}
}
None
Ok(())
}

fn error_foreign_non_exhaustive_spat(&self, pat: &Pat<'_>, descr: &str, no_fields: bool) {
Expand Down