Skip to content

Commit 0d9269f

Browse files
Fix obligation param and bless tests
1 parent 5babe9f commit 0d9269f

File tree

10 files changed

+25
-104
lines changed

10 files changed

+25
-104
lines changed

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+18-40
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::traits::{
2828
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
2929
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause, PolyTraitObligation,
3030
PredicateObligation, Selection, SelectionError, SignatureMismatch, TraitNotObjectSafe,
31-
Unimplemented,
31+
TraitObligation, Unimplemented,
3232
};
3333

3434
use super::BuiltinImplConditions;
@@ -691,12 +691,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
691691
)
692692
.map_bound(|(trait_ref, _)| trait_ref);
693693

694-
let mut nested = self.equate_trait_refs(
695-
&obligation.cause,
696-
obligation.param_env,
697-
placeholder_predicate.trait_ref,
698-
trait_ref,
699-
)?;
694+
let mut nested =
695+
self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
700696
let cause = obligation.derived_cause(BuiltinDerivedObligation);
701697

702698
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
@@ -762,9 +758,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
762758
);
763759

764760
let nested = self.equate_trait_refs(
765-
&obligation.cause,
766-
obligation.param_env,
767-
placeholder_predicate.trait_ref,
761+
obligation.with(self.tcx(), placeholder_predicate),
768762
ty::Binder::dummy(trait_ref),
769763
)?;
770764
debug!(?trait_ref, ?nested, "coroutine candidate obligations");
@@ -794,9 +788,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
794788
);
795789

796790
let nested = self.equate_trait_refs(
797-
&obligation.cause,
798-
obligation.param_env,
799-
placeholder_predicate.trait_ref,
791+
obligation.with(self.tcx(), placeholder_predicate),
800792
ty::Binder::dummy(trait_ref),
801793
)?;
802794
debug!(?trait_ref, ?nested, "future candidate obligations");
@@ -826,9 +818,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
826818
);
827819

828820
let nested = self.equate_trait_refs(
829-
&obligation.cause,
830-
obligation.param_env,
831-
placeholder_predicate.trait_ref,
821+
obligation.with(self.tcx(), placeholder_predicate),
832822
ty::Binder::dummy(trait_ref),
833823
)?;
834824
debug!(?trait_ref, ?nested, "iterator candidate obligations");
@@ -858,9 +848,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
858848
);
859849

860850
let nested = self.equate_trait_refs(
861-
&obligation.cause,
862-
obligation.param_env,
863-
placeholder_predicate.trait_ref,
851+
obligation.with(self.tcx(), placeholder_predicate),
864852
ty::Binder::dummy(trait_ref),
865853
)?;
866854
debug!(?trait_ref, ?nested, "iterator candidate obligations");
@@ -896,12 +884,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
896884
}
897885
};
898886

899-
self.equate_trait_refs(
900-
&obligation.cause,
901-
obligation.param_env,
902-
placeholder_predicate.trait_ref,
903-
trait_ref,
904-
)
887+
self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
905888
}
906889

907890
#[instrument(skip(self), level = "debug")]
@@ -979,12 +962,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
979962
_ => bug!("expected callable type for AsyncFn candidate"),
980963
};
981964

982-
nested.extend(self.equate_trait_refs(
983-
&obligation.cause,
984-
obligation.param_env,
985-
placeholder_predicate.trait_ref,
986-
trait_ref,
987-
)?);
965+
nested.extend(
966+
self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
967+
);
988968

989969
let goal_kind =
990970
self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
@@ -1039,13 +1019,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10391019
#[instrument(skip(self), level = "trace")]
10401020
fn equate_trait_refs(
10411021
&mut self,
1042-
cause: &ObligationCause<'tcx>,
1043-
param_env: ty::ParamEnv<'tcx>,
1044-
obligation_trait_ref: ty::TraitRef<'tcx>,
1022+
obligation: TraitObligation<'tcx>,
10451023
found_trait_ref: ty::PolyTraitRef<'tcx>,
10461024
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
10471025
let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
1048-
cause.span,
1026+
obligation.cause.span,
10491027
HigherRankedType,
10501028
found_trait_ref,
10511029
);
@@ -1054,16 +1032,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10541032
ensure_sufficient_stack(|| {
10551033
normalize_with_depth(
10561034
self,
1057-
param_env,
1058-
cause.clone(),
1059-
0,
1060-
(obligation_trait_ref, found_trait_ref),
1035+
obligation.param_env,
1036+
obligation.cause.clone(),
1037+
obligation.recursion_depth + 1,
1038+
(obligation.predicate.trait_ref, found_trait_ref),
10611039
)
10621040
});
10631041

10641042
// needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
10651043
self.infcx
1066-
.at(&cause, param_env)
1044+
.at(&obligation.cause, obligation.param_env)
10671045
.eq(DefineOpaqueTypes::Yes, obligation_trait_ref, found_trait_ref)
10681046
.map(|InferOk { mut obligations, .. }| {
10691047
obligations.extend(nested);

tests/ui/higher-ranked/builtin-closure-like-bounds.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ compile-flags: -Zunstable-options
33
//@ revisions: current next
44
//@[next] compile-flags: -Znext-solver
5+
//@ check-pass
56

67
#![feature(unboxed_closures, gen_blocks)]
78

@@ -48,4 +49,4 @@ fn main() {
4849

4950
fn uwu<'a>(x: &'a ()) -> impl Fn(&'a ()) { |_| {} }
5051
Closure(uwu).dispatch();
51-
}
52+
}

tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr

-19
This file was deleted.

tests/ui/higher-ranked/trait-bounds/fn-ptr.current.stderr

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: current next
22
//@ ignore-compare-mode-next-solver (explicit revisions)
33
//@[next] compile-flags: -Znext-solver
4-
//@[next] check-pass
4+
//@ check-pass
55

66
fn ice()
77
where
@@ -11,5 +11,4 @@ where
1111

1212
fn main() {
1313
ice();
14-
//[current]~^ ERROR expected a `Fn(&'w ())` closure, found `fn(&'w ())`
1514
}

tests/ui/higher-ranked/trait-bounds/future.classic.stderr

-6
This file was deleted.

tests/ui/higher-ranked/trait-bounds/future.current.stderr

-6
This file was deleted.

tests/ui/higher-ranked/trait-bounds/future.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
//@ revisions: current next
44
//@ ignore-compare-mode-next-solver (explicit revisions)
55
//@[next] compile-flags: -Znext-solver
6-
//@[next] check-pass
7-
//@[current] known-bug: #112347
8-
//@[current] build-fail
9-
//@[current] failure-status: 101
10-
//@[current] normalize-stderr-test "note: .*\n\n" -> ""
11-
//@[current] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> ""
12-
//@[current] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
13-
//@[current] rustc-env:RUST_BACKTRACE=0
6+
//@ check-pass
147

158
#![feature(unboxed_closures)]
169

tests/ui/lifetimes/issue-105675.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn main() {
44
let f = | _ , y: &u32 , z | ();
55
thing(f);
66
//~^ ERROR implementation of `FnOnce` is not general enough
7-
//~^^ ERROR implementation of `FnOnce` is not general enough
7+
//~| ERROR implementation of `FnOnce` is not general enough
88
let f = | x, y: _ , z: u32 | ();
99
thing(f);
1010
//~^ ERROR implementation of `FnOnce` is not general enough

tests/ui/lifetimes/lifetime-errors/issue_74400.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely
2-
//! recognized as E0308 mismatched types.
2+
//! recognized as "implementation of `FnOnce` is not general enough".
33
44
use std::convert::identity;
55

@@ -13,6 +13,6 @@ fn g<T>(data: &[T]) {
1313
//~^ ERROR the parameter type
1414
//~| ERROR the parameter type
1515
//~| ERROR the parameter type
16-
//~| ERROR implementation of `FnOnce` is not general
16+
//~| ERROR implementation of `FnOnce` is not general enough
1717
//~| ERROR implementation of `Fn` is not general enough
1818
}

0 commit comments

Comments
 (0)