Skip to content

Commit b7e2b08

Browse files
authored
Unrolled build for rust-lang#131150
Rollup merge of rust-lang#131150 - bvanjoi:issue-128327, r=chenyukang only query `params_in_repr` if def kind is adt Fixes rust-lang#128327 `params_in_repr` was only stored in `encode_info_for_adt`, so we only query it when the def kind belongs to them. https://github.com/rust-lang/rust/blob/9e3e5174462afaf6c3b9db9b35c6d1934521848a/compiler/rustc_metadata/src/rmeta/encoder.rs#L1566-L1567
2 parents 44722bd + e9b2d09 commit b7e2b08

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

compiler/rustc_middle/src/values.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn find_item_ty_spans(
358358
match ty.kind {
359359
hir::TyKind::Path(hir::QPath::Resolved(_, path)) => {
360360
if let Res::Def(kind, def_id) = path.res
361-
&& !matches!(kind, DefKind::TyAlias)
361+
&& matches!(kind, DefKind::Enum | DefKind::Struct | DefKind::Union)
362362
{
363363
let check_params = def_id.as_local().map_or(true, |def_id| {
364364
if def_id == needle {

tests/crashes/128327.rs

-5
This file was deleted.

tests/ui/infinite/auxiliary/alias.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
pub struct W<T>(T);
22
pub type Wrapper<T> = W<T>;
3+
pub trait Trait {
4+
type T;
5+
}

tests/ui/infinite/infinite-assoc.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ aux-build: alias.rs
2+
3+
// issue#128327
4+
5+
extern crate alias;
6+
7+
use alias::Trait;
8+
struct S;
9+
impl Trait for S {
10+
type T = ();
11+
}
12+
struct A((A, <S as Trait>::T<NOT_EXIST?>));
13+
//~^ ERROR: invalid `?` in type
14+
//~| ERROR: recursive type `A` has infinite size
15+
16+
fn main() {}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: invalid `?` in type
2+
--> $DIR/infinite-assoc.rs:12:39
3+
|
4+
LL | struct A((A, <S as Trait>::T<NOT_EXIST?>));
5+
| ^ `?` is only allowed on expressions, not types
6+
|
7+
help: if you meant to express that the type might not contain a value, use the `Option` wrapper type
8+
|
9+
LL | struct A((A, <S as Trait>::T<Option<NOT_EXIST>>));
10+
| +++++++ ~
11+
12+
error[E0072]: recursive type `A` has infinite size
13+
--> $DIR/infinite-assoc.rs:12:1
14+
|
15+
LL | struct A((A, <S as Trait>::T<NOT_EXIST?>));
16+
| ^^^^^^^^ - recursive without indirection
17+
|
18+
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
19+
|
20+
LL | struct A((Box<A>, <S as Trait>::T<NOT_EXIST?>));
21+
| ++++ +
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0072`.

0 commit comments

Comments
 (0)