Skip to content

Rollup of 8 pull requests #63603

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

Closed
wants to merge 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c22ba27
Stop emulating cross-crate hygiene with gensyms
matthewjasper Aug 11, 2019
f3a589a
Make built-in derives opaque macros
matthewjasper Aug 9, 2019
dd9a5b8
Make fmt-internal functions private
matthewjasper Aug 11, 2019
ade2c8f
Remove gensyms from built-in derives
matthewjasper Aug 11, 2019
1b0b505
Move type parameter shadowing errors to resolve
matthewjasper Aug 11, 2019
e9e45c5
Hash the remapped sysroot instead of the original.
jgalenson Aug 12, 2019
6f00e1e
Remove SyntaxContext from {ast, hir}::{GlobalAsm, InlineAsm}
matthewjasper Aug 12, 2019
692c0bf
Do not track the sysroot.
jgalenson Aug 13, 2019
01587b1
Remove unused `SyntaxContext` serialization impls
matthewjasper Aug 13, 2019
417f9ea
Utilize -Zbinary-dep-depinfo for dependency tracking
Mark-Simulacrum Aug 11, 2019
0b713ae
typeck: extract ban_private_field_access
Centril Aug 13, 2019
5e019de
typeck: extract ban_take_value_of_method
Centril Aug 13, 2019
9805846
typeck: extract maybe_suggest_array_indexing
Centril Aug 13, 2019
039c789
typeck: extract suggest_first_deref_field
Centril Aug 13, 2019
01e96dc
typeck: extract suggest_fields_on_recordish
Centril Aug 13, 2019
0741441
typeck: restructure check_field a bit
Centril Aug 13, 2019
88398a4
typeck: on wrong <expr>.await suggest -> 2018
Centril Aug 13, 2019
9287eb6
typeck: add tests for suggesting -> 2018 on wrong <expr>.await
Centril Aug 13, 2019
4272864
Feature gate 'yield ?' pre-expansion.
Centril Aug 14, 2019
4fe201c
Simplify pre-expansion gating in general.
Centril Aug 14, 2019
1ab9e52
Update rustc-demangle to 0.1.16.
eddyb Aug 14, 2019
f54503c
libcore: more cleanups using associated_type_bounds
Centril Aug 15, 2019
5941acd
Use libunwind from llvm-project submodule for musl targets
malbarbo Jul 30, 2019
7cef357
Rollup merge of #63173 - malbarbo:musl-libunwind, r=alexcrichton
Centril Aug 15, 2019
3296a0c
Rollup merge of #63462 - matthewjasper:hygienic-builtin-derives, r=pe…
Centril Aug 15, 2019
ae88345
Rollup merge of #63470 - Mark-Simulacrum:rustc-depdep, r=alexcrichton
Centril Aug 15, 2019
27e58ee
Rollup merge of #63505 - jgalenson:sysroot-hash, r=alexcrichton
Centril Aug 15, 2019
7dfb4b3
Rollup merge of #63539 - Centril:2015.await, r=oli-obk
Centril Aug 15, 2019
cd075b8
Rollup merge of #63545 - Centril:gate-yield-preexp, r=oli-obk
Centril Aug 15, 2019
a026aaf
Rollup merge of #63548 - eddyb:unicode-demangling, r=alexcrichton
Centril Aug 15, 2019
69a3206
Rollup merge of #63584 - Centril:cleanup-core-with-more-atb, r=alexreg
Centril Aug 15, 2019
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
typeck: extract suggest_fields_on_recordish
  • Loading branch information
Centril committed Aug 13, 2019
commit 01e96dc5832b85f87acb1a651e33d12ac9b37cc5
45 changes: 27 additions & 18 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,24 +1350,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

match expr_t.sty {
ty::Adt(def, _) if !def.is_enum() => {
if let Some(suggested_field_name) =
Self::suggest_field_name(def.non_enum_variant(),
&field.as_str(), vec![]) {
err.span_suggestion(
field.span,
"a field with a similar name exists",
suggested_field_name.to_string(),
Applicability::MaybeIncorrect,
);
} else {
err.span_label(field.span, "unknown field");
let struct_variant_def = def.non_enum_variant();
let field_names = self.available_field_names(struct_variant_def);
if !field_names.is_empty() {
err.note(&format!("available fields are: {}",
self.name_series_display(field_names)));
}
};
self.suggest_fields_on_recordish(&mut err, def, field);
}
ty::Array(_, len) => {
self.maybe_suggest_array_indexing(&mut err, expr, base, field, len);
Expand Down Expand Up @@ -1444,6 +1427,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.emit();
}

fn suggest_fields_on_recordish(
&self,
err: &mut DiagnosticBuilder<'_>,
def: &'tcx ty::AdtDef,
field: ast::Ident,
) {
if let Some(suggested_field_name) =
Self::suggest_field_name(def.non_enum_variant(), &field.as_str(), vec![])
{
err.span_suggestion(
field.span,
"a field with a similar name exists",
suggested_field_name.to_string(),
Applicability::MaybeIncorrect,
);
} else {
err.span_label(field.span, "unknown field");
let struct_variant_def = def.non_enum_variant();
let field_names = self.available_field_names(struct_variant_def);
if !field_names.is_empty() {
err.note(&format!("available fields are: {}",
self.name_series_display(field_names)));
}
}
}

fn maybe_suggest_array_indexing(
&self,
err: &mut DiagnosticBuilder<'_>,
Expand Down