Skip to content

Commit 237f16d

Browse files
authored
Rollup merge of #94037 - tmiasko:verbose, r=Mark-Simulacrum
Fix inconsistent symbol mangling with -Zverbose Always skip arguments that are the defaults of their respective parameters, to avoid generating inconsistent symbols for builds with `-Zverbose` flag and without it.
2 parents 847ac55 + 3158372 commit 237f16d

File tree

6 files changed

+23
-13
lines changed

6 files changed

+23
-13
lines changed

compiler/rustc_middle/src/ty/print/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ pub trait Printer<'tcx>: Sized {
188188
own_params.start = 1;
189189
}
190190

191-
// If we're in verbose mode, then print default-equal args too
192-
if self.tcx().sess.verbose() {
193-
return &substs[own_params];
194-
}
195-
196191
// Don't print args that are the defaults of their respective parameters.
197192
own_params.end -= generics
198193
.params

src/test/ui/associated-types/substs-ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn foo<'z>() where &'z (): Sized {
2525
let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
2626
//[verbose]~^ ERROR mismatched types
2727
//[verbose]~| expected unit type `()`
28-
//[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u32>>::bar::<ReStatic, char>}`
28+
//[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
2929
//[normal]~^^^^ ERROR mismatched types
3030
//[normal]~| expected unit type `()`
3131
//[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`

src/test/ui/associated-types/substs-ppaux.verbose.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ error[E0308]: mismatched types
2020
--> $DIR/substs-ppaux.rs:25:17
2121
|
2222
LL | fn bar<'a, T>() where T: 'a {}
23-
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u32>>::bar::<ReStatic, char>} defined here
23+
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
2424
...
2525
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
2626
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
2727
| |
2828
| expected due to this
2929
|
3030
= note: expected unit type `()`
31-
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u32>>::bar::<ReStatic, char>}`
31+
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
3232
help: use parentheses to call this function
3333
|
3434
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();

src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
66
|
77
= note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [
88
i32,
9-
extern "rust-call" fn((std::boxed::Box<T, std::alloc::Global>,)) -> std::boxed::Box<(dyn Anything + '_#2r), std::alloc::Global>,
9+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>,
1010
(),
1111
]
1212
= note: number of external vids: 3
@@ -42,7 +42,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
4242
|
4343
= note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [
4444
i32,
45-
extern "rust-call" fn((std::boxed::Box<T, std::alloc::Global>,)) -> std::boxed::Box<(dyn Anything + '_#2r), std::alloc::Global>,
45+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>,
4646
(),
4747
]
4848
= note: number of external vids: 3
@@ -69,7 +69,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
6969
|
7070
= note: defining type: wrong_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
7171
i32,
72-
extern "rust-call" fn((std::boxed::Box<T, std::alloc::Global>,)) -> std::boxed::Box<(dyn Anything + '_#3r), std::alloc::Global>,
72+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>,
7373
(),
7474
]
7575
= note: number of external vids: 4
@@ -105,7 +105,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
105105
|
106106
= note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
107107
i32,
108-
extern "rust-call" fn((std::boxed::Box<T, std::alloc::Global>,)) -> std::boxed::Box<(dyn Anything + '_#3r), std::alloc::Global>,
108+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>,
109109
(),
110110
]
111111
= note: number of external vids: 4

src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | with_signature(x, |y| y)
66
|
77
= note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [
88
i32,
9-
extern "rust-call" fn((std::boxed::Box<T, std::alloc::Global>,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r), std::alloc::Global>,
9+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r)>,
1010
(),
1111
]
1212
= note: number of external vids: 3

src/test/ui/symbol-names/verbose.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for issue #57596, where -Zverbose flag unintentionally
2+
// affected produced symbols making it impossible to link between crates
3+
// with a different value of the flag (for symbols involving generic
4+
// arguments equal to defaults of their respective parameters).
5+
//
6+
// build-pass
7+
// compile-flags: -Zverbose
8+
9+
pub fn error(msg: String) -> Box<dyn std::error::Error> {
10+
msg.into()
11+
}
12+
13+
fn main() {
14+
error(String::new());
15+
}

0 commit comments

Comments
 (0)