Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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})
26 changes: 26 additions & 0 deletions tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr
Original file line number Diff line number Diff line change
@@ -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<B>
| -- lifetime `'a` defined here
...
LL | pub fn to_arc_aac(&self) -> Arc<B> {
| - 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<B>) -> Arc<B>
| ++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0621`.
26 changes: 26 additions & 0 deletions tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr
Original file line number Diff line number Diff line change
@@ -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<B>
| -- lifetime `'a` defined here
...
LL | pub fn to_arc_aac(&self) -> Arc<B> {
| - 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<B>) -> Arc<B>
| ++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0621`.
235 changes: 235 additions & 0 deletions tests/ui/lifetimes/where-bound-with-lifetime-53156.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/53156>.
//! 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<B: ToOwned + ?Sized>(<B as ToOwned>::Owned);

impl<'a, B> OwnedWrap<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
// 1a-2a-3a
pub fn to_arc_aaa(&self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let b: &B = owned.borrow();
unimplemented!()
}

// 1a-2a-3b
pub fn to_arc_aab(&self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let _: &B = owned.borrow();
unimplemented!()
}

// 1a-2a-3c
pub fn to_arc_aac(&self) -> Arc<B> {
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<B> {
let OwnedWrap(ref owned) = *self;
let b: &B = owned.borrow();
unimplemented!()
}

// 1a-2b-3b
pub fn to_arc_abb(&'a self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let _: &B = owned.borrow();
unimplemented!()
}

// 1a-2b-3c
pub fn to_arc_abc(&'a self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
owned.borrow().into()
}
}

impl<'a, B> OwnedWrap<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
// 1b-2a-3a
pub fn to_arc_baa(&self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let b: &B = owned.borrow();
unimplemented!()
}

// 1b-2a-3b
pub fn to_arc_bab(&self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let _: &B = owned.borrow();
unimplemented!()
}

// 1b-2a-3c
pub fn to_arc_bac(&self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
owned.borrow().into()
}

// 1b-2b-3a
pub fn to_arc_bba(&'a self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let b: &B = owned.borrow();
unimplemented!()
}

// 1b-2b-3b
pub fn to_arc_bbb(&'a self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
let _: &B = owned.borrow();
unimplemented!()
}

// 1b-2b-3c
pub fn to_arc_bbc(&'a self) -> Arc<B> {
let OwnedWrap(ref owned) = *self;
owned.borrow().into()
}
}

// 1a-2a-3a
fn to_arc_aaa<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
let OwnedWrap(ref owned) = *wrap;
let b: &B = owned.borrow();
unimplemented!()
}

// 1a-2a-3b
fn to_arc_aab<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
let OwnedWrap(ref owned) = *wrap;
let _: &B = owned.borrow();
unimplemented!()
}

// 1a-2a-3c
fn to_arc_aac<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 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<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
let OwnedWrap(ref owned) = *wrap;
let b: &B = owned.borrow();
unimplemented!()
}

// 1a-2b-3b
fn to_arc_abb<'a, B>(wrap: &'a OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
let OwnedWrap(ref owned) = *wrap;
let _: &B = owned.borrow();
unimplemented!()
}

// 1a-2b-3c
fn to_arc_abc<'a, B>(wrap: &'a OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
&'a B: Into<Arc<B>>, // 1a
{
let OwnedWrap(ref owned) = *wrap;
owned.borrow().into()
}

// 1b-2a-3a
fn to_arc_baa<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
let b: &B = owned.borrow();
unimplemented!()
}

// 1b-2a-3b
fn to_arc_bab<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
let _: &B = owned.borrow();
unimplemented!()
}

// 1b-2a-3c
fn to_arc_bac<'a, B>(wrap: &OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
owned.borrow().into()
}

// 1b-2b-3a
fn to_arc_bba<'a, B>(wrap: &'a OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
let b: &B = owned.borrow();
unimplemented!()
}

// 1b-2b-3b
fn to_arc_bbb<'a, B>(wrap: &'a OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
let _: &B = owned.borrow();
unimplemented!()
}

// 1b-2b-3c
fn to_arc_bbc<'a, B>(wrap: &'a OwnedWrap<B>) -> Arc<B>
where
B: 'a + ToOwned + ?Sized,
for<'b> &'b B: Into<Arc<B>> // 1b
{
let OwnedWrap(ref owned) = *wrap;
owned.borrow().into()
}

fn main() {}
Loading