Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4100,6 +4100,9 @@ pub enum TestBinderConstraint {
Or {
items: ThinVec<TestBinderConstraint>,
},
Ambiguity {
span: Span,
},
Lifetime {
#[visitable(extra = LifetimeCtxt::Bound)]
lhs: Lifetime,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
items.iter().map(|item| self.lower_test_binder_constraint(item)),
),
},
TestBinderConstraint::Ambiguity { span } => {
hir::TestBinderConstraint::Ambiguity { span: self.lower_span(*span) }
}
TestBinderConstraint::Lifetime { lhs, rhs } => {
let lhs = self.lower_lifetime(lhs, LifetimeSource::Other, lhs.ident.into());
let rhs = self.lower_lifetime(rhs, LifetimeSource::OutlivesBound, rhs.ident.into());
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4556,6 +4556,7 @@ pub struct TestBinderExists<'hir> {
pub enum TestBinderConstraint<'hir> {
And { items: &'hir [TestBinderConstraint<'hir>] },
Or { items: &'hir [TestBinderConstraint<'hir>] },
Ambiguity { span: Span },
Lifetime { lhs: &'hir Lifetime, rhs: &'hir Lifetime },
PlaceholderOutlives { lhs: &'hir Ty<'hir>, rhs: &'hir Lifetime },
AliasOutlives { bound_type_constraint: &'hir TestBinderBoundTypeConstraint<'hir> },
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@ pub fn walk_test_binder_constraint<'v, V: Visitor<'v>>(
TestBinderConstraint::Or { items } => {
walk_list!(visitor, visit_test_binder_constraint, *items)
}
TestBinderConstraint::Ambiguity { span: _ } => {}
TestBinderConstraint::Lifetime { lhs, rhs } => {
try_visit!(visitor.visit_lifetime(lhs));
try_visit!(visitor.visit_lifetime(rhs));
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ impl<'tcx> ItemCtxt<'tcx> {
.map(|item| self.lower_test_binder_constraint(item))
.reduce(SolverRegionConstraint::build_or)
.unwrap_or(SolverRegionConstraint::new_false()),
rustc_hir::TestBinderConstraint::Ambiguity { span } => {
SolverRegionConstraint::new_ambig(*span)
}
hir::TestBinderConstraint::Lifetime { lhs, rhs } => {
let span = lhs.ident.span.to(rhs.ident.span);
let lhs = self.lowerer().lower_lifetime(lhs, RegionInferReason::RegionPredicate);
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2791,6 +2791,11 @@ impl<'a> Parser<'a> {
.0;
Ok(TestBinderConstraint::Or { items })
}
Some((Ident { name: sym::ambiguity, .. }, IdentKind::Normal)) => {
let span = self.token.span;
self.bump();
Ok(TestBinderConstraint::Ambiguity { span })
}
_ if self.check_keyword(exp!(For)) => {
let bound_type_constraint = self.parse_test_binder_bound_type_constraint()?;
Ok(TestBinderConstraint::AliasOutlives { bound_type_constraint })
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ symbols! {
altivec,
alu32,
always,
ambiguity,
amdgpu,
amdgpu_dispatch_ptr,
analysis,
Expand Down
32 changes: 32 additions & 0 deletions tests/ui/assumptions_on_binders/test-infra-fails-properly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,36 @@ core::test_binder_constraints! {
}
}

core::test_binder_constraints! {
impl {
forall<'a> where 'a: 'static {
} expect {
ambiguity
//~^ ERROR forall expect clause failed
}
}
}

core::test_binder_constraints! {
impl {
forall<'a> where 'a: 'static {
//~^ ERROR forall expect clause failed
//~| ERROR unable to satisfy constraints involving placeholders due to unknown implied bounds
ambiguity
} expect {
}
}
}

core::test_binder_constraints! {
impl {
forall<'a> where 'a: 'static {
//~^ ERROR unable to satisfy constraints involving placeholders due to unknown implied bounds
ambiguity
} expect {
ambiguity
}
}
}

fn main() {}
53 changes: 52 additions & 1 deletion tests/ui/assumptions_on_binders/test-infra-fails-properly.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,57 @@ error: bound type test binder constraint must be alias (it's a AliasTyOutlivesVi
LL | for<> T: 'a
| ^

error: aborting due to 9 previous errors
error: forall expect clause failed
--> $DIR/test-infra-fails-properly.rs:81:13
|
LL | ambiguity
| ^^^^^^^^^
|
= note: expected: And(
[
Ambiguity(
$DIR/test-infra-fails-properly.rs:81:13: 81:22 (#0),
),
],
)
= note: actual: And(
[],
)

error: forall expect clause failed
--> $DIR/test-infra-fails-properly.rs:89:9
|
LL | forall<'a> where 'a: 'static {
| ^^^^^^
|
note: constraint from here
--> $DIR/test-infra-fails-properly.rs:89:9
|
LL | forall<'a> where 'a: 'static {
| ^^^^^^
= note: expected: And(
[],
)
= note: actual: And(
[
Ambiguity(
$DIR/test-infra-fails-properly.rs:89:9: 89:15 (#0),
),
],
)

error: unable to satisfy constraints involving placeholders due to unknown implied bounds
--> $DIR/test-infra-fails-properly.rs:89:9
|
LL | forall<'a> where 'a: 'static {
| ^^^^^^

error: unable to satisfy constraints involving placeholders due to unknown implied bounds
--> $DIR/test-infra-fails-properly.rs:100:9
|
LL | forall<'a> where 'a: 'static {
| ^^^^^^

error: aborting due to 13 previous errors

For more information about this error, try `rustc --explain E0658`.
Loading