Skip to content

Commit f7253f2

Browse files
committed
Auto merge of #118787 - GuillaumeGomez:rollup-fj5wr3q, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #117966 (add safe compilation options) - #118747 (Remove extra check cfg handled by libc directly) - #118774 (add test for inductive cycle hangs) - #118775 (chore: add test case for type with generic) - #118782 (use `&` instead of start-process in x.ps1) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8cd8d31 + dd23469 commit f7253f2

12 files changed

+152
-25
lines changed

config.example.toml

+10
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,16 @@ change-id = 117813
600600
# desired in distributions, for example.
601601
#rpath = true
602602

603+
# Indicates whether symbols should be stripped using `-Cstrip=symbols`.
604+
#strip = false
605+
606+
# Indicates whether stack protectors should be used
607+
# via the unstable option `-Zstack-protector`.
608+
#
609+
# Valid options are : `none`(default),`basic`,`strong`, or `all`.
610+
# `strong` and `basic` options may be buggy and are not recommended, see rust-lang/rust#114903.
611+
#stack-protector = "none"
612+
603613
# Prints each test name as it is executed, to help debug issues in the test harness itself.
604614
#verbose-tests = false
605615

src/bootstrap/src/core/builder.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,12 @@ impl<'a> Builder<'a> {
16671667
}
16681668
}
16691669

1670+
cargo.env(profile_var("STRIP"), self.config.rust_strip.to_string());
1671+
1672+
if let Some(stack_protector) = &self.config.rust_stack_protector {
1673+
rustflags.arg(&format!("-Zstack-protector={stack_protector}"));
1674+
}
1675+
16701676
if let Some(host_linker) = self.linker(compiler.host) {
16711677
hostflags.arg(format!("-Clinker={}", host_linker.display()));
16721678
}

src/bootstrap/src/core/config/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ pub struct Config {
223223
pub rust_debuginfo_level_tests: DebuginfoLevel,
224224
pub rust_split_debuginfo: SplitDebuginfo,
225225
pub rust_rpath: bool,
226+
pub rust_strip: bool,
227+
pub rust_stack_protector: Option<String>,
226228
pub rustc_parallel: bool,
227229
pub rustc_default_linker: Option<String>,
228230
pub rust_optimize_tests: bool,
@@ -1002,6 +1004,8 @@ define_config! {
10021004
description: Option<String> = "description",
10031005
musl_root: Option<String> = "musl-root",
10041006
rpath: Option<bool> = "rpath",
1007+
strip: Option<bool> = "strip",
1008+
stack_protector: Option<String> = "stack-protector",
10051009
verbose_tests: Option<bool> = "verbose-tests",
10061010
optimize_tests: Option<bool> = "optimize-tests",
10071011
codegen_tests: Option<bool> = "codegen-tests",
@@ -1071,6 +1075,7 @@ impl Config {
10711075
config.docs = true;
10721076
config.docs_minification = true;
10731077
config.rust_rpath = true;
1078+
config.rust_strip = false;
10741079
config.channel = "dev".to_string();
10751080
config.codegen_tests = true;
10761081
config.rust_dist_src = true;
@@ -1425,6 +1430,8 @@ impl Config {
14251430
set(&mut config.rust_optimize_tests, rust.optimize_tests);
14261431
set(&mut config.codegen_tests, rust.codegen_tests);
14271432
set(&mut config.rust_rpath, rust.rpath);
1433+
set(&mut config.rust_strip, rust.strip);
1434+
config.rust_stack_protector = rust.stack_protector;
14281435
set(&mut config.jemalloc, rust.jemalloc);
14291436
set(&mut config.test_compare_mode, rust.test_compare_mode);
14301437
set(&mut config.backtrace, rust.backtrace);

src/bootstrap/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
8383
(Some(Mode::Std), "no_global_oom_handling", None),
8484
(Some(Mode::Std), "no_rc", None),
8585
(Some(Mode::Std), "no_sync", None),
86-
(Some(Mode::Std), "freebsd12", None),
87-
(Some(Mode::Std), "freebsd13", None),
8886
(Some(Mode::Std), "backtrace_in_libstd", None),
8987
/* Extra values not defined in the built-in targets yet, but used in std */
9088
(Some(Mode::Std), "target_env", Some(&["libnx"])),

tests/ui/suggestions/suggest-assoc-fn-call-without-receiver.fixed

+14
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ impl A {
77
fn test(_a: Self, _b: i32) {}
88
}
99

10+
struct B<T> {
11+
_b: T
12+
}
13+
impl<T> B<T> {
14+
fn hello(_a: i32) {}
15+
fn test(_a: Self, _b: i32) {}
16+
}
17+
1018
fn main() {
1119
let _a = A {};
1220
A::hello(1);
1321
//~^ ERROR no method named `hello` found
1422
A::test(_a, 1);
1523
//~^ ERROR no method named `test` found
24+
25+
let _b = B {_b: ""};
26+
B::<&str>::hello(1);
27+
//~^ ERROR no method named `hello` found
28+
B::<&str>::test(_b, 1);
29+
//~^ ERROR no method named `test` found
1630
}

tests/ui/suggestions/suggest-assoc-fn-call-without-receiver.rs

+14
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ impl A {
77
fn test(_a: Self, _b: i32) {}
88
}
99

10+
struct B<T> {
11+
_b: T
12+
}
13+
impl<T> B<T> {
14+
fn hello(_a: i32) {}
15+
fn test(_a: Self, _b: i32) {}
16+
}
17+
1018
fn main() {
1119
let _a = A {};
1220
_a.hello(1);
1321
//~^ ERROR no method named `hello` found
1422
_a.test(1);
1523
//~^ ERROR no method named `test` found
24+
25+
let _b = B {_b: ""};
26+
_b.hello(1);
27+
//~^ ERROR no method named `hello` found
28+
_b.test(1);
29+
//~^ ERROR no method named `test` found
1630
}

tests/ui/suggestions/suggest-assoc-fn-call-without-receiver.stderr

+41-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0599]: no method named `hello` found for struct `A` in the current scope
2-
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:12:8
2+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:20:8
33
|
44
LL | struct A {}
55
| -------- method `hello` not found for this struct
@@ -18,7 +18,7 @@ LL | fn hello(_a: i32) {}
1818
| ^^^^^^^^^^^^^^^^^
1919

2020
error[E0599]: no method named `test` found for struct `A` in the current scope
21-
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:14:8
21+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:22:8
2222
|
2323
LL | struct A {}
2424
| -------- method `test` not found for this struct
@@ -36,6 +36,44 @@ note: the candidate is defined in an impl for the type `A`
3636
LL | fn test(_a: Self, _b: i32) {}
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3838

39-
error: aborting due to 2 previous errors
39+
error[E0599]: no method named `hello` found for struct `B<&str>` in the current scope
40+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:26:8
41+
|
42+
LL | struct B<T> {
43+
| ----------- method `hello` not found for this struct
44+
...
45+
LL | _b.hello(1);
46+
| ---^^^^^---
47+
| | |
48+
| | this is an associated function, not a method
49+
| help: use associated function syntax instead: `B::<&str>::hello(1)`
50+
|
51+
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
52+
note: the candidate is defined in an impl for the type `B<T>`
53+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:14:5
54+
|
55+
LL | fn hello(_a: i32) {}
56+
| ^^^^^^^^^^^^^^^^^
57+
58+
error[E0599]: no method named `test` found for struct `B<&str>` in the current scope
59+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:28:8
60+
|
61+
LL | struct B<T> {
62+
| ----------- method `test` not found for this struct
63+
...
64+
LL | _b.test(1);
65+
| ---^^^^---
66+
| | |
67+
| | this is an associated function, not a method
68+
| help: use associated function syntax instead: `B::<&str>::test(_b, 1)`
69+
|
70+
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
71+
note: the candidate is defined in an impl for the type `B<T>`
72+
--> $DIR/suggest-assoc-fn-call-without-receiver.rs:15:5
73+
|
74+
LL | fn test(_a: Self, _b: i32) {}
75+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
77+
error: aborting due to 4 previous errors
4078

4179
For more information about this error, try `rustc --explain E0599`.

tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
// Proving `W<?0>: Trait` instantiates `?0` with `(W<?1>, W<?2>)` and then
44
// proves `W<?1>: Trait` and `W<?2>: Trait`, resulting in a coinductive cycle.
55
//
6-
// Proving coinductive cycles runs until we reach a fixpoint. This fixpoint is
7-
// never reached here and each step doubles the amount of nested obligations.
6+
// Proving coinductive cycles runs until we reach a fixpoint. However, after
7+
// computing `try_evaluate_added_goals` in the second fixpoint iteration, the
8+
// self type already has a depth equal to the number of steps. This results
9+
// in enormous constraints, causing the canonicalizer to hang without ever
10+
// reaching the recursion limit. We currently avoid that by erasing the constraints
11+
// from overflow.
812
//
913
// This previously caused a hang in the trait solver, see
1014
// https://github.com/rust-lang/trait-system-refactor-initiative/issues/13.

tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error[E0275]: overflow evaluating the requirement `W<_>: Trait`
2-
--> $DIR/fixpoint-exponential-growth.rs:29:13
2+
--> $DIR/fixpoint-exponential-growth.rs:33:13
33
|
44
LL | impls::<W<_>>();
55
| ^^^^
66
|
77
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`fixpoint_exponential_growth`)
88
note: required by a bound in `impls`
9-
--> $DIR/fixpoint-exponential-growth.rs:26:13
9+
--> $DIR/fixpoint-exponential-growth.rs:30:13
1010
|
1111
LL | fn impls<T: Trait>() {}
1212
| ^^^^^ required by this bound in `impls`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// compile-flags: -Ztrait-solver=next
2+
3+
// This currently hangs if we do not erase constraints from
4+
// overflow.
5+
//
6+
// We set the provisional result of `W<?0>` to `?0 := W<_>`.
7+
// The next iteration does not simply result in a `?0 := W<W<_>` constraint as
8+
// one might expect, but instead each time we evaluate the nested `W<T>` goal we
9+
// apply the previously returned constraints: the first fixpoint iteration goes
10+
// as follows: `W<?1>: Trait` constrains `?1` to `W<?2>`, we then evaluate
11+
// `W<W<?2>>: Trait` the next time we try to prove the nested goal. This results
12+
// inn `W<W<W<?3>>>` and so on. This goes on until we reach overflow in
13+
// `try_evaluate_added_goals`. This means the provisional result after the
14+
// second fixpoint iteration is already `W<W<W<...>>>` with a size proportional
15+
// to the number of steps in `try_evaluate_added_goals`. The size then continues
16+
// to grow. The exponential blowup from having 2 nested goals per impl causes
17+
// the solver to hang without hitting the recursion limit.
18+
trait Trait {}
19+
20+
struct W<T: ?Sized>(*const T);
21+
22+
impl<T: ?Sized> Trait for W<W<T>>
23+
where
24+
W<T>: Trait,
25+
W<T>: Trait,
26+
{}
27+
28+
fn impls_trait<T: Trait>() {}
29+
30+
fn main() {
31+
impls_trait::<W<_>>();
32+
//~^ ERROR overflow evaluating the requirement
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0275]: overflow evaluating the requirement `W<_>: Trait`
2+
--> $DIR/inductive-fixpoint-hang.rs:31:19
3+
|
4+
LL | impls_trait::<W<_>>();
5+
| ^^^^
6+
|
7+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_fixpoint_hang`)
8+
note: required by a bound in `impls_trait`
9+
--> $DIR/inductive-fixpoint-hang.rs:28:19
10+
|
11+
LL | fn impls_trait<T: Trait>() {}
12+
| ^^^^^ required by this bound in `impls_trait`
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0275`.

x.ps1

+3-16
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,16 @@ $ErrorActionPreference = "Stop"
88
Get-Command -syntax ${PSCommandPath} >$null
99

1010
$xpy = Join-Path $PSScriptRoot x.py
11-
# Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?)
12-
# Double-quote all the arguments so it doesn't do that.
13-
$xpy_args = @("""$xpy""")
14-
foreach ($arg in $args) {
15-
$xpy_args += """$arg"""
16-
}
11+
$xpy_args = @($xpy) + $args
1712

1813
function Get-Application($app) {
1914
$cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1
2015
return $cmd
2116
}
2217

2318
function Invoke-Application($application, $arguments) {
24-
$process = Start-Process -NoNewWindow -PassThru $application $arguments
25-
# WORKAROUND: Caching the handle is necessary to make ExitCode work.
26-
# See https://stackoverflow.com/a/23797762
27-
$handle = $process.Handle
28-
$process.WaitForExit()
29-
if ($null -eq $process.ExitCode) {
30-
Write-Error "Unable to read the exit code"
31-
Exit 1
32-
}
33-
Exit $process.ExitCode
19+
& $application $arguments
20+
Exit $LASTEXITCODE
3421
}
3522

3623
foreach ($python in "py", "python3", "python", "python2") {

0 commit comments

Comments
 (0)