Skip to content

Commit

Permalink
use implied bounds compat mode in MIR borrowck
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jan 19, 2024
1 parent d3c9082 commit 84151c3
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
param_env.and(ty)
});

tcx.implied_outlives_bounds(canonicalized)
if tcx.sess.opts.unstable_opts.no_implied_bounds_compat {
tcx.implied_outlives_bounds(canonicalized)
} else {
tcx.implied_outlives_bounds_compat(canonicalized)
}
}

fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
) -> Result<Self::QueryResponse, NoSolution> {
compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty)
if ocx.infcx.tcx.sess.opts.unstable_opts.no_implied_bounds_compat {
compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty)
} else {
compute_implied_outlives_bounds_compat_inner(ocx, key.param_env, key.value.ty)
}
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-inherent-types/issue-111404-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ impl<'a> Foo<fn(&'a ())> {
fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
//~^ ERROR higher-ranked subtype error
//~| ERROR higher-ranked subtype error
//~| ERROR higher-ranked subtype error

fn main() {}
10 changes: 1 addition & 9 deletions tests/ui/associated-inherent-types/issue-111404-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,5 @@ LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: higher-ranked subtype error
--> $DIR/issue-111404-1.rs:10:1
|
LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

4 changes: 3 additions & 1 deletion tests/ui/implied-bounds/bevy_world_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ impl<Q: WorldQuery + 'static> SystemParam for Query<Q> {

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

fn handler<'a>(_: ParamSet<Query<&'a u8>>) {}
fn handler<'a>(x: ParamSet<Query<&'a u8>>) {
let _: ParamSet<_> = x;
}

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

Expand Down
41 changes: 41 additions & 0 deletions tests/ui/implied-bounds/normalization-nested-no-compat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Test for normalization of projections that appear in the item bounds
// (versus those that appear directly in the input types).
//
// FIXME(-Zno-implied-bounds-compat): remove this test once this flag is removed,
// duplicate of `normalization-nested.rs`.
// compile-flags: -Zno-implied-bounds-compat
// revisions: param_ty lifetime
// check-pass

pub trait Iter {
type Item;
}

#[cfg(param_ty)]
impl<X, I> Iter for I
where
I: IntoIterator<Item = X>,
{
type Item = X;
}

#[cfg(lifetime)]
impl<'x, I> Iter for I
where
I: IntoIterator<Item = &'x ()>,
{
type Item = &'x ();
}

pub struct Map<I>(I)
where
I: Iter,
I::Item: 'static;

pub fn test_wfcheck<'x>(_: Map<Vec<&'x ()>>) {}

pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
s
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/implied-bounds/normalization-nested.lifetime.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: lifetime may not live long enough
--> $DIR/normalization-nested.rs:36:5
|
LL | pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
| -- lifetime `'x` defined here
LL | s
| ^ returning this value requires that `'x` must outlive `'static`

error: aborting due to 1 previous error

4 changes: 3 additions & 1 deletion tests/ui/implied-bounds/normalization-nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// (versus those that appear directly in the input types).
//
// revisions: param_ty lifetime
// check-pass

//[param_ty] check-pass

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

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

fn main() {}
File renamed without changes.
20 changes: 13 additions & 7 deletions tests/ui/inference/issue-80409.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// This should not pass, because `usize: Fsm` does not hold. However, it currently ICEs.

// check-fail
// known-bug: #80409
// failure-status: 101
// normalize-stderr-test "note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
// rustc-env:RUST_BACKTRACE=0

// ignore-tidy-linelength

// revisions: compat no-compat
//[compat] check-pass
//[no-compat] compile-flags: -Zno-implied-bounds-compat
//[no-compat] check-fail
//[no-compat] known-bug: #80409
//[no-compat] failure-status: 101
//[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
//[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
//[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
//[no-compat] rustc-env:RUST_BACKTRACE=0

#![allow(unreachable_code, unused)]

Expand Down

0 comments on commit 84151c3

Please sign in to comment.