-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow for a missing adt_def
in NamePrivacyVisitor
.
#121482
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -988,7 +988,10 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> { | |
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { | ||
if let hir::ExprKind::Struct(qpath, fields, ref base) = expr.kind { | ||
let res = self.typeck_results().qpath_res(qpath, expr.hir_id); | ||
let adt = self.typeck_results().expr_ty(expr).ty_adt_def().unwrap(); | ||
let Some(adt) = self.typeck_results().expr_ty(expr).ty_adt_def() else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this error case only reachable for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked, and yes, the result of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for |
||
self.tcx.dcx().span_delayed_bug(expr.span, "no adt_def for expression"); | ||
return; | ||
}; | ||
let variant = adt.variant_of_res(res); | ||
if let Some(base) = *base { | ||
// If the expression uses FRU we need to make sure all the unmentioned fields | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn test(s: &Self::Id) { | ||
//~^ ERROR failed to resolve: `Self` is only available in impls, traits, and type definitions | ||
match &s[0..3] {} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions | ||
--> $DIR/unreachable-issue-121455.rs:1:13 | ||
| | ||
LL | fn test(s: &Self::Id) { | ||
| ^^^^ `Self` is only available in impls, traits, and type definitions | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0433`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we ge an exprkind struct in the example you gave?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range somehow becomes a struct. Here's partial output with
-Zunpretty=hir-tree
: