mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00
Do not ICE on private type in field of unresolved struct
This commit is contained in:
parent
30017c36d6
commit
caadc8df35
@ -2189,9 +2189,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||
let ast::ExprKind::Struct(struct_expr) = &expr.kind else { return };
|
||||
// We don't have to handle type-relative paths because they're forbidden in ADT
|
||||
// expressions, but that would change with `#[feature(more_qualified_paths)]`.
|
||||
let Some(Res::Def(_, def_id)) =
|
||||
self.partial_res_map[&struct_expr.path.segments.iter().last().unwrap().id].full_res()
|
||||
else {
|
||||
let Some(segment) = struct_expr.path.segments.last() else { return };
|
||||
let Some(partial_res) = self.partial_res_map.get(&segment.id) else { return };
|
||||
let Some(Res::Def(_, def_id)) = partial_res.full_res() else {
|
||||
return;
|
||||
};
|
||||
let Some(default_fields) = self.field_defaults(def_id) else { return };
|
||||
|
@ -0,0 +1,8 @@
|
||||
// Regression test for https://github.com/rust-lang/rust/issues/145367
|
||||
mod m {
|
||||
struct Priv2;
|
||||
}
|
||||
fn main() {
|
||||
WithUse { one: m::Priv2 } //~ ERROR: cannot find struct, variant or union type `WithUse` in this scope
|
||||
//~^ ERROR: unit struct `Priv2` is private
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
error[E0422]: cannot find struct, variant or union type `WithUse` in this scope
|
||||
--> $DIR/non-exhaustive-ctor-not-found.rs:6:5
|
||||
|
|
||||
LL | WithUse { one: m::Priv2 }
|
||||
| ^^^^^^^ not found in this scope
|
||||
|
||||
error[E0603]: unit struct `Priv2` is private
|
||||
--> $DIR/non-exhaustive-ctor-not-found.rs:6:23
|
||||
|
|
||||
LL | WithUse { one: m::Priv2 }
|
||||
| ^^^^^ private unit struct
|
||||
|
|
||||
note: the unit struct `Priv2` is defined here
|
||||
--> $DIR/non-exhaustive-ctor-not-found.rs:3:5
|
||||
|
|
||||
LL | struct Priv2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0422, E0603.
|
||||
For more information about an error, try `rustc --explain E0422`.
|
Loading…
x
Reference in New Issue
Block a user