Skip to content

Commit bbebe73

Browse files
committed
Auto merge of #74633 - davidtwco:issue-74614-disable-polymorphisation, r=wesleywiser
Disable polymorphisation Fixes #74614. This PR disables polymorphisation to fix the regression in #74614 after investigation into the issue makes it clear that the fix won't be trivial. ~~I'll file an issue shortly to replace #74614 with the findings so far.~~ #74636 has been filed to track the fix of the underlying regression. r? @eddyb
2 parents 9e92106 + 799d52e commit bbebe73

25 files changed

+66
-37
lines changed

src/librustc_mir/monomorphize/collector.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
627627
Ok(val) => collect_const_value(self.tcx, val, self.output),
628628
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {}
629629
Err(ErrorHandled::TooGeneric) => span_bug!(
630-
self.tcx.def_span(def.did),
631-
"collection encountered polymorphic constant",
630+
self.body.source_info(location).span,
631+
"collection encountered polymorphic constant: {}",
632+
substituted_constant
632633
),
633634
}
634635
}

src/librustc_session/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
949949
(default: PLT is disabled if full relro is enabled)"),
950950
polonius: bool = (false, parse_bool, [UNTRACKED],
951951
"enable polonius-based borrow-checker (default: no)"),
952-
polymorphize: bool = (true, parse_bool, [TRACKED],
952+
polymorphize: bool = (false, parse_bool, [TRACKED],
953953
"perform polymorphization analysis"),
954954
pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
955955
"a single extra argument to prepend the linker invocation (can be used several times)"),

src/test/codegen-units/item-collection/static-init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags:-Zprint-mono-items=eager
1+
// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on
22

33
#![feature(start)]
44

src/test/codegen-units/item-collection/trait-method-default-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags:-Zprint-mono-items=eager
1+
// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on
22

33
#![deny(dead_code)]
44
#![feature(start)]

src/test/codegen-units/polymorphization/unused_type_parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags:-Zprint-mono-items=lazy -Copt-level=1
1+
// compile-flags:-Zpolymorphize=on -Zprint-mono-items=lazy -Copt-level=1
22
// ignore-tidy-linelength
33

44
#![crate_type = "rlib"]

src/test/ui/issues/issue-74614.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// build-pass
2+
3+
fn test<T>() {
4+
std::mem::size_of::<T>();
5+
}
6+
7+
pub fn foo<T>(_: T) -> &'static fn() {
8+
&(test::<T> as fn())
9+
}
10+
11+
fn outer<T>() {
12+
foo(|| ());
13+
}
14+
15+
fn main() {
16+
outer::<u8>();
17+
}

src/test/ui/polymorphization/const_parameters/closures.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// build-fail
2+
// compile-flags:-Zpolymorphize=on
23
#![feature(const_generics, rustc_attrs)]
34
//~^ WARN the feature `const_generics` is incomplete
45

src/test/ui/polymorphization/const_parameters/closures.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/closures.rs:2:12
2+
--> $DIR/closures.rs:3:12
33
|
44
LL | #![feature(const_generics, rustc_attrs)]
55
| ^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | #![feature(const_generics, rustc_attrs)]
88
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
99

1010
error: item has unused generic parameters
11-
--> $DIR/closures.rs:18:19
11+
--> $DIR/closures.rs:19:19
1212
|
1313
LL | pub fn unused<const T: usize>() -> usize {
1414
| - generic parameter `T` is unused
@@ -17,13 +17,13 @@ LL | let add_one = |x: usize| x + 1;
1717
| ^^^^^^^^^^^^^^^^
1818

1919
error: item has unused generic parameters
20-
--> $DIR/closures.rs:16:8
20+
--> $DIR/closures.rs:17:8
2121
|
2222
LL | pub fn unused<const T: usize>() -> usize {
2323
| ^^^^^^ - generic parameter `T` is unused
2424

2525
error: item has unused generic parameters
26-
--> $DIR/closures.rs:27:19
26+
--> $DIR/closures.rs:28:19
2727
|
2828
LL | pub fn used_parent<const T: usize>() -> usize {
2929
| - generic parameter `T` is unused
@@ -32,7 +32,7 @@ LL | let add_one = |x: usize| x + 1;
3232
| ^^^^^^^^^^^^^^^^
3333

3434
error: item has unused generic parameters
35-
--> $DIR/closures.rs:47:13
35+
--> $DIR/closures.rs:48:13
3636
|
3737
LL | pub fn unused_upvar<const T: usize>() -> usize {
3838
| - generic parameter `T` is unused

src/test/ui/polymorphization/const_parameters/functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// build-fail
2+
// compile-flags:-Zpolymorphize=on
23
#![feature(const_generics, rustc_attrs)]
34
//~^ WARN the feature `const_generics` is incomplete
45

src/test/ui/polymorphization/const_parameters/functions.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/functions.rs:2:12
2+
--> $DIR/functions.rs:3:12
33
|
44
LL | #![feature(const_generics, rustc_attrs)]
55
| ^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | #![feature(const_generics, rustc_attrs)]
88
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
99

1010
error: item has unused generic parameters
11-
--> $DIR/functions.rs:14:8
11+
--> $DIR/functions.rs:15:8
1212
|
1313
LL | pub fn unused<const T: usize>() {
1414
| ^^^^^^ - generic parameter `T` is unused

0 commit comments

Comments
 (0)