Skip to content

Commit 2062f2c

Browse files
committed
review
1 parent 7c97a76 commit 2062f2c

File tree

5 files changed

+37
-27
lines changed

5 files changed

+37
-27
lines changed

Diff for: compiler/rustc_trait_selection/src/solve/assembly/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
311311
goal: Goal<'tcx, G>,
312312
) -> Vec<Candidate<'tcx>> {
313313
debug_assert_eq!(goal, self.resolve_vars_if_possible(goal));
314-
if let Some(ambig) = self.self_ty_infer_ambiguity_hack(goal) {
314+
if let Some(ambig) = self.assemble_self_ty_infer_ambiguity_response(goal) {
315315
return ambig;
316316
}
317317

@@ -324,13 +324,13 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
324324
candidates
325325
}
326326

327-
/// HACK: `_: Trait` is ambiguous, because it may be satisfied via a builtin rule,
327+
/// `?0: Trait` is ambiguous, because it may be satisfied via a builtin rule,
328328
/// object bound, alias bound, etc. We are unable to determine this until we can at
329329
/// least structurally resolve the type one layer.
330330
///
331331
/// It would also require us to consider all impls of the trait, which is both pretty
332332
/// bad for perf and would also constrain the self type if there is just a single impl.
333-
fn self_ty_infer_ambiguity_hack<G: GoalKind<'tcx>>(
333+
fn assemble_self_ty_infer_ambiguity_response<G: GoalKind<'tcx>>(
334334
&mut self,
335335
goal: Goal<'tcx, G>,
336336
) -> Option<Vec<Candidate<'tcx>>> {
@@ -353,7 +353,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
353353
goal: Goal<'tcx, G>,
354354
) -> Vec<Candidate<'tcx>> {
355355
debug_assert_eq!(goal, self.resolve_vars_if_possible(goal));
356-
if let Some(ambig) = self.self_ty_infer_ambiguity_hack(goal) {
356+
if let Some(ambig) = self.assemble_self_ty_infer_ambiguity_response(goal) {
357357
return ambig;
358358
}
359359

Diff for: tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// compile-flags: -Ztrait-solver=next
2+
// check-pass
23

34
// Checks that we do not get ambiguity by considering an impl
45
// multiple times if we're able to normalize the self type.
6+
57
trait Trait<'a> {}
68

79
impl<'a, T: 'a> Trait<'a> for T {}

Diff for: tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: -Ztrait-solver=next
2+
3+
// Test that we don't incorrectly leak unconstrained inference variables
4+
// if the projection contained an error. This caused an ICE in writeback.
5+
6+
trait Mirror {
7+
type Assoc: ?Sized;
8+
}
9+
10+
struct Wrapper<T: ?Sized>(T);
11+
impl<T: ?Sized> Mirror for Wrapper<T> {
12+
type Assoc = T;
13+
}
14+
15+
fn mirror<W: Mirror>(_: W) -> Box<W::Assoc> { todo!() }
16+
17+
fn type_error() -> TypeError { todo!() }
18+
//~^ ERROR cannot find type `TypeError` in this scope
19+
20+
fn main() {
21+
let x = mirror(type_error());
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `TypeError` in this scope
2+
--> $DIR/dont-normalize-proj-with-error.rs:17:20
3+
|
4+
LL | fn type_error() -> TypeError { todo!() }
5+
| ^^^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)