Skip to content

Rollup of 10 pull requests #137688

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 48 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b479199
Run CI multiple times a day
marxin Feb 6, 2025
28dfcd0
document bootstrap logging
jyn514 Feb 13, 2025
2d2849d
Merge pull request #2250 from jyn514/logging
jieyouxu Feb 13, 2025
7d999a5
add notes for perf issue
chenyukang Feb 14, 2025
a21ffd8
Fix borked link
marxin Feb 14, 2025
6714f1d
Start using latest release where -f checks all local links
marxin Feb 14, 2025
f8cc5d7
Merge pull request #2253 from marxin/fix-link2
JohnTitor Feb 14, 2025
27566ab
Merge pull request #2252 from chenyukang/fix-perf
jieyouxu Feb 14, 2025
dce2652
Fix examples to work with nightly-2025-02-13
torfsen Feb 15, 2025
fcfabc1
Fix CI schedule
marxin Feb 15, 2025
ba340ec
Merge pull request #2254 from marxin/start-using-latest-linkcheck2
camelid Feb 15, 2025
34db7ba
Merge pull request #2246 from marxin/CI-more-ofter
camelid Feb 15, 2025
f0a6af0
remove MaybeUninit::uninit_array
cyrgani Feb 15, 2025
089af67
Bump mdbook-linkcheck2 dependency version
marxin Feb 16, 2025
56f6538
Merge pull request #2257 from marxin/start-using-latest-linkcheck2-v2
tshepang Feb 16, 2025
342ced9
Merge pull request #2256 from torfsen/fix-examples-for-nightly-2025-0…
jieyouxu Feb 19, 2025
fc02cfd
Do not use CString in the examples of CStr.
hkBst Jan 28, 2025
39667c5
document how to setup RA for nvim automatically
jyn514 Feb 24, 2025
25eac11
use lua locals
jyn514 Feb 24, 2025
ed2ccea
Merge pull request #2259 from jyn514/nvim-config
dianqk Feb 24, 2025
622b4fa
fix: attr cast for espidf
SergioGasquez Feb 25, 2025
d12ecae
Teach structured errors to display short `Ty`
estebank Feb 18, 2025
693ed26
Add tests
estebank Feb 18, 2025
ae3a825
Make E0529 a structured error
estebank Feb 18, 2025
7302dc6
Make E0614 a structured error
estebank Feb 18, 2025
26f74ef
Make E0609 a structured error
estebank Feb 18, 2025
a4e89de
add doc comment detail
estebank Feb 18, 2025
c550bee
Fix rebase
estebank Feb 25, 2025
9423634
Fix posting message to Zulip
Kobzol Feb 25, 2025
5d65732
Merge pull request #2262 from Kobzol/rustc-pull-ci-fix
Kobzol Feb 25, 2025
9313580
Don't suggest constraining unstable associated types
compiler-errors Feb 25, 2025
b7a5497
fix #137508
TaKO8Ki Feb 25, 2025
46392d1
Preparing for merge from rustc
BoxyUwU Feb 25, 2025
d9683df
Merge from rustc
BoxyUwU Feb 25, 2025
69369a7
Merge pull request #2263 from BoxyUwU/rustc-pull2
BoxyUwU Feb 25, 2025
ee8ed8c
Update gcc submodule
Kobzol Feb 26, 2025
b8c7e8a
Make -Z unpretty=mir suggest -Z dump-mir as well
meithecatte Feb 26, 2025
bab71fc
revert accidental change in get_closest_merge_commit
RalfJung Feb 26, 2025
bcfff3d
Rollup merge of #134585 - cyrgani:uninit_array, r=Amanieu
fmease Feb 26, 2025
f3a445b
Rollup merge of #136187 - hkBst:patch-27, r=workingjubilee
fmease Feb 26, 2025
5da5c37
Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obk
fmease Feb 26, 2025
c5d5727
Rollup merge of #137620 - SergioGasquez:fix/espidf-maybeunit, r=Chris…
fmease Feb 26, 2025
2fc8823
Rollup merge of #137631 - TaKO8Ki:issue-137508, r=compiler-errors
fmease Feb 26, 2025
875e390
Rollup merge of #137635 - compiler-errors:constrain-unstable, r=Sparr…
fmease Feb 26, 2025
0ae0110
Rollup merge of #137642 - BoxyUwU:rdg-push, r=Kobzol
fmease Feb 26, 2025
bd9e38d
Rollup merge of #137660 - Kobzol:gcc-update, r=GuillaumeGomez
fmease Feb 26, 2025
526dd27
Rollup merge of #137670 - RalfJung:llvm-commit-logic-revert, r=Kobzol
fmease Feb 26, 2025
46eb43e
Rollup merge of #137671 - meithecatte:discoverable-dump-mir, r=Nadrieril
fmease Feb 26, 2025
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
Make E0609 a structured error
  • Loading branch information
estebank committed Feb 25, 2025
commit 26f74ef586d2d8849e93e9a1a6c6e803a0d21065
6 changes: 6 additions & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {
*[other] {" "}in the current scope
}

hir_typeck_no_field_on_type = no field `{$field}` on type `{$ty}`

hir_typeck_no_field_on_variant = no field named `{$field}` on enum variant `{$container}::{$ident}`
hir_typeck_no_field_on_variant_enum = this enum variant...
hir_typeck_no_field_on_variant_field = ...does not have this field

hir_typeck_note_caller_chooses_ty_for_ty_param = the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`

hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,29 @@ impl HelpUseLatestEdition {
}
}

#[derive(Diagnostic)]
#[diag(hir_typeck_no_field_on_type, code = E0609)]
pub(crate) struct NoFieldOnType<'tcx> {
#[primary_span]
pub(crate) span: Span,
pub(crate) ty: Ty<'tcx>,
pub(crate) field: Ident,
}

#[derive(Diagnostic)]
#[diag(hir_typeck_no_field_on_variant, code = E0609)]
pub(crate) struct NoFieldOnVariant<'tcx> {
#[primary_span]
pub(crate) span: Span,
pub(crate) container: Ty<'tcx>,
pub(crate) ident: Ident,
pub(crate) field: Ident,
#[label(hir_typeck_no_field_on_variant_enum)]
pub(crate) enum_span: Span,
#[label(hir_typeck_no_field_on_variant_field)]
pub(crate) field_span: Span,
}

#[derive(Diagnostic)]
#[diag(hir_typeck_cant_dereference, code = E0614)]
pub(crate) struct CantDereference<'tcx> {
Expand Down
36 changes: 17 additions & 19 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ use crate::errors::{
AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr,
BaseExpressionDoubleDotEnableDefaultFieldValues, BaseExpressionDoubleDotRemove,
CantDereference, FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct,
HelpUseLatestEdition, ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody,
StructExprNonExhaustive, TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
HelpUseLatestEdition, NoFieldOnType, NoFieldOnVariant, ReturnLikeStatementKind,
ReturnStmtOutsideOfFnBody, StructExprNonExhaustive, TypeMismatchFruTypo,
YieldExprOutsideOfCoroutine,
};
use crate::{
BreakableCtxt, CoroutineTypes, Diverges, FnCtxt, Needs, cast, fatally_break_rust,
Expand Down Expand Up @@ -3282,13 +3283,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let span = field.span;
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t);

let mut err = type_error_struct!(
self.dcx(),
span,
expr_t,
E0609,
"no field `{field}` on type `{expr_t}`",
);
let mut err = self.dcx().create_err(NoFieldOnType { span, ty: expr_t, field });
if expr_t.references_error() {
err.downgrade_to_delayed_bug();
}

// try to add a suggestion in case the field is a nested field of a field of the Adt
let mod_id = self.tcx.parent_module(id).to_def_id();
Expand Down Expand Up @@ -3862,16 +3860,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.iter_enumerated()
.find(|(_, f)| f.ident(self.tcx).normalize_to_macros_2_0() == subident)
else {
type_error_struct!(
self.dcx(),
ident.span,
container,
E0609,
"no field named `{subfield}` on enum variant `{container}::{ident}`",
)
.with_span_label(field.span, "this enum variant...")
.with_span_label(subident.span, "...does not have this field")
.emit();
self.dcx()
.create_err(NoFieldOnVariant {
span: ident.span,
container,
ident,
field: subfield,
enum_span: field.span,
field_span: subident.span,
})
.emit_unless(container.references_error());
break;
};

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/long-E0609.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type C = (B, B, B, B);
type D = (C, C, C, C);

fn foo(x: D) {
x.field; //~ ERROR no field `field` on type `(
x.field; //~ ERROR no field `field` on type `(...
}

fn main() {}
5 changes: 4 additions & 1 deletion tests/ui/diagnostic-width/long-E0609.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
error[E0609]: no field `field` on type `((((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))))`
error[E0609]: no field `field` on type `(..., ..., ..., ...)`
--> $DIR/long-E0609.rs:10:7
|
LL | x.field;
| ^^^^^ unknown field
|
= note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console

error: aborting due to 1 previous error

Expand Down