From 54b1675a4c5c2b8cbf584eb2fcdc522488f617e9 Mon Sep 17 00:00:00 2001 From: Kazuyarch Date: Sat, 21 Nov 2026 17:23:15 +0000 Subject: [PATCH 1/2] Add regression test for issue 53156 --- ...e-bound-with-lifetime-53156.current.stderr | 26 ++ ...here-bound-with-lifetime-53156.next.stderr | 26 ++ .../where-bound-with-lifetime-53156.rs | 235 ++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr create mode 100644 tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr create mode 100644 tests/ui/lifetimes/where-bound-with-lifetime-53156.rs 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() {} From 7ee3dfef93638aadd4c7affda9fe6674be127428 Mon Sep 17 00:00:00 2001 From: xonx4l Date: Tue, 24 Nov 2026 21:14:14 +0000 Subject: [PATCH 2/2] Add explanatory comment and rename alias of stdarch intrinsic-test --- src/bootstrap/src/core/build_steps/test.rs | 13 +++++++++---- .../core/builder/cli_paths/snapshots/x_test.snap | 2 +- .../cli_paths/snapshots/x_test_skip_coverage.snap | 2 +- .../snapshots/x_test_skip_coverage_map.snap | 2 +- .../snapshots/x_test_skip_coverage_run.snap | 2 +- .../cli_paths/snapshots/x_test_skip_tests.snap | 2 +- .../snapshots/x_test_skip_tests_coverage.snap | 2 +- .../cli_paths/snapshots/x_test_skip_tests_etc.snap | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 9c930c201b20d..2701e9f3b7e0c 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 1fe97ca766c81..4518b08c8b866 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 f112cdafa81b3..55a800f25e596 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 401cdc8432d2f..b5624cfaa0a72 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 01d5b362e928f..10067d8bf076f 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 b936eeefe8805..febeb867a4920 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 c7ea1c663a030..d96a35d841110 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 98b39e619fad8..13953e98f335c 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})