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 058ab53
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 24 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
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:40: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

14 changes: 10 additions & 4 deletions tests/ui/implied-bounds/normalization-nested.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
// Test for normalization of projections that appear in the item bounds
// (versus those that appear directly in the input types).
//
// revisions: param_ty lifetime
// check-pass
// revisions: param_ty lifetime param_ty_no_compat lifetime_no_compat

//[param_ty] check-pass
//[param_ty_no_compat] check-pass
//[lifetime_no_compat] check-pass
//[param_ty_no_compat] compile-flags: -Zno-implied-bounds-compat
//[lifetime_no_compat] compile-flags: -Zno-implied-bounds-compat

pub trait Iter {
type Item;
}

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

#[cfg(lifetime)]
#[cfg(any(lifetime, lifetime_no_compat))]
impl<'x, I> Iter for I
where
I: IntoIterator<Item = &'x ()>,
Expand All @@ -33,6 +38,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.
19 changes: 12 additions & 7 deletions tests/ui/inference/issue-80409.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// 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 058ab53

Please sign in to comment.