Skip to content

Commit 84151c3

Browse files
committed
use implied bounds compat mode in MIR borrowck
1 parent d3c9082 commit 84151c3

File tree

9 files changed

+81
-21
lines changed

9 files changed

+81
-21
lines changed

compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
4848
param_env.and(ty)
4949
});
5050

51-
tcx.implied_outlives_bounds(canonicalized)
51+
if tcx.sess.opts.unstable_opts.no_implied_bounds_compat {
52+
tcx.implied_outlives_bounds(canonicalized)
53+
} else {
54+
tcx.implied_outlives_bounds_compat(canonicalized)
55+
}
5256
}
5357

5458
fn perform_locally_with_next_solver(
5559
ocx: &ObligationCtxt<'_, 'tcx>,
5660
key: ParamEnvAnd<'tcx, Self>,
5761
) -> Result<Self::QueryResponse, NoSolution> {
58-
compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty)
62+
if ocx.infcx.tcx.sess.opts.unstable_opts.no_implied_bounds_compat {
63+
compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty)
64+
} else {
65+
compute_implied_outlives_bounds_compat_inner(ocx, key.param_env, key.value.ty)
66+
}
5967
}
6068
}
6169

tests/ui/associated-inherent-types/issue-111404-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ impl<'a> Foo<fn(&'a ())> {
1010
fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
1111
//~^ ERROR higher-ranked subtype error
1212
//~| ERROR higher-ranked subtype error
13-
//~| ERROR higher-ranked subtype error
1413

1514
fn main() {}

tests/ui/associated-inherent-types/issue-111404-1.stderr

+1-9
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,5 @@ LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
1212
|
1313
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1414

15-
error: higher-ranked subtype error
16-
--> $DIR/issue-111404-1.rs:10:1
17-
|
18-
LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20-
|
21-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
22-
23-
error: aborting due to 3 previous errors
15+
error: aborting due to 2 previous errors
2416

tests/ui/implied-bounds/bevy_world_query.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ impl<Q: WorldQuery + 'static> SystemParam for Query<Q> {
1919

2020
pub struct ParamSet<T: SystemParam>(T) where T::State: Sized;
2121

22-
fn handler<'a>(_: ParamSet<Query<&'a u8>>) {}
22+
fn handler<'a>(x: ParamSet<Query<&'a u8>>) {
23+
let _: ParamSet<_> = x;
24+
}
2325

2426
fn ref_handler<'a>(_: &ParamSet<Query<&'a u8>>) {}
2527

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Test for normalization of projections that appear in the item bounds
2+
// (versus those that appear directly in the input types).
3+
//
4+
// FIXME(-Zno-implied-bounds-compat): remove this test once this flag is removed,
5+
// duplicate of `normalization-nested.rs`.
6+
// compile-flags: -Zno-implied-bounds-compat
7+
// revisions: param_ty lifetime
8+
// check-pass
9+
10+
pub trait Iter {
11+
type Item;
12+
}
13+
14+
#[cfg(param_ty)]
15+
impl<X, I> Iter for I
16+
where
17+
I: IntoIterator<Item = X>,
18+
{
19+
type Item = X;
20+
}
21+
22+
#[cfg(lifetime)]
23+
impl<'x, I> Iter for I
24+
where
25+
I: IntoIterator<Item = &'x ()>,
26+
{
27+
type Item = &'x ();
28+
}
29+
30+
pub struct Map<I>(I)
31+
where
32+
I: Iter,
33+
I::Item: 'static;
34+
35+
pub fn test_wfcheck<'x>(_: Map<Vec<&'x ()>>) {}
36+
37+
pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
38+
s
39+
}
40+
41+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/normalization-nested.rs:36:5
3+
|
4+
LL | pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
5+
| -- lifetime `'x` defined here
6+
LL | s
7+
| ^ returning this value requires that `'x` must outlive `'static`
8+
9+
error: aborting due to 1 previous error
10+

tests/ui/implied-bounds/normalization-nested.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// (versus those that appear directly in the input types).
33
//
44
// revisions: param_ty lifetime
5-
// check-pass
5+
6+
//[param_ty] check-pass
67

78
pub trait Iter {
89
type Item;
@@ -33,6 +34,7 @@ pub fn test_wfcheck<'x>(_: Map<Vec<&'x ()>>) {}
3334

3435
pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
3536
s
37+
//[lifetime]~^ ERROR lifetime may not live long enough
3638
}
3739

3840
fn main() {}

tests/ui/inference/issue-80409.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
// This should not pass, because `usize: Fsm` does not hold. However, it currently ICEs.
22

3-
// check-fail
4-
// known-bug: #80409
5-
// failure-status: 101
6-
// normalize-stderr-test "note: .*\n\n" -> ""
7-
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
8-
// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
9-
// rustc-env:RUST_BACKTRACE=0
3+
4+
// ignore-tidy-linelength
5+
6+
// revisions: compat no-compat
7+
//[compat] check-pass
8+
//[no-compat] compile-flags: -Zno-implied-bounds-compat
9+
//[no-compat] check-fail
10+
//[no-compat] known-bug: #80409
11+
//[no-compat] failure-status: 101
12+
//[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
13+
//[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
14+
//[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
15+
//[no-compat] rustc-env:RUST_BACKTRACE=0
1016

1117
#![allow(unreachable_code, unused)]
1218

0 commit comments

Comments
 (0)