diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 5841fc7196773..27249a76bd952 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1071,12 +1071,17 @@ pub struct IntrinsicTest { host: TargetSelection, } +impl IntrinsicTest { + const ALIAS: &'static str = "stdarch-intrinsic-test"; +} + impl CommandLineStep for IntrinsicTest { type Output = (); const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias("intrinsic-test") + // Not using a path since we don't want this to be part of `./x test library`. + run.alias(Self::ALIAS) } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -1087,12 +1092,12 @@ impl CommandLineStep for IntrinsicTest { let target = run.target; let builder = run.builder; - let is_explicit = - builder.config.paths.iter().any(|p| p.to_string_lossy() == "intrinsic-test"); + let is_explicit = builder.config.paths.iter().any(|p| p.to_string_lossy() == Self::ALIAS); if target.contains("x86_64-unknown-linux") && builder.config.sde.is_none() && is_explicit { panic!( - "SDE is required to run intrinsic-test. Please configure `build.sde` in config.toml." + "SDE is required to run {}. Please configure `build.sde` in config.toml.", + Self::ALIAS ); } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index b01ccfcba50b5..6ce5a96dfe5b8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -228,4 +228,4 @@ expression: test - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index 0a4ccdbd86e3d..f7c447b2d6ae4 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 89f26ad80b322..e4e77171cfbe6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-map - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index b0b5ba9c3e116..30b0495b0499b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-run - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 95472f161268e..29c900f1bc258 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -168,4 +168,4 @@ expression: test --skip=tests - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 8c9faca01e50c..598e41393f740 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=tests/coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 9c276798d948e..25899cf1d214f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -148,4 +148,4 @@ expression: test --skip=tests --skip=library --skip=tidyselftest - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs new file mode 100644 index 0000000000000..10663bdb5f578 --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs @@ -0,0 +1,235 @@ +//! Regression test for . +//! Second where bound was causing incorrect rejection of acceptable lifetime. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +use std::borrow::Borrow; +use std::sync::Arc; + +struct OwnedWrap(::Owned); + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + // 1a-2a-3a + pub fn to_arc_aaa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3b + pub fn to_arc_aab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3c + pub fn to_arc_aac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + //~^ ERROR lifetime may not live long enough + } + + // 1a-2b-3a + pub fn to_arc_aba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3b + pub fn to_arc_abb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3c + pub fn to_arc_abc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + // 1b-2a-3a + pub fn to_arc_baa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3b + pub fn to_arc_bab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3c + pub fn to_arc_bac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } + + // 1b-2b-3a + pub fn to_arc_bba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3b + pub fn to_arc_bbb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3c + pub fn to_arc_bbc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +// 1a-2a-3a +fn to_arc_aaa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3b +fn to_arc_aab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3c +fn to_arc_aac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() + //~^ ERROR explicit lifetime required in the type of `wrap` +} + +// 1a-2b-3a +fn to_arc_aba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3b +fn to_arc_abb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3c +fn to_arc_abc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2a-3a +fn to_arc_baa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3b +fn to_arc_bab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3c +fn to_arc_bac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2b-3a +fn to_arc_bba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3b +fn to_arc_bbb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3c +fn to_arc_bbc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +fn main() {}