Account for single where
bound being removed
This commit is contained in:
parent
c85bb274f6
commit
29bdf9ea51
4 changed files with 22 additions and 7 deletions
|
@ -5123,8 +5123,24 @@ fn point_at_assoc_type_restriction(
|
||||||
{
|
{
|
||||||
// The following block is to determine the right span to delete for this bound
|
// The following block is to determine the right span to delete for this bound
|
||||||
// that will leave valid code after the suggestion is applied.
|
// that will leave valid code after the suggestion is applied.
|
||||||
let span = if let Some(hir::WherePredicate::BoundPredicate(next)) =
|
let span = if pred.origin == hir::PredicateOrigin::WhereClause
|
||||||
predicates.peek()
|
&& generics
|
||||||
|
.predicates
|
||||||
|
.iter()
|
||||||
|
.filter(|p| {
|
||||||
|
matches!(
|
||||||
|
p,
|
||||||
|
hir::WherePredicate::BoundPredicate(p)
|
||||||
|
if hir::PredicateOrigin::WhereClause == p.origin
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
== 1
|
||||||
|
{
|
||||||
|
// There's only one `where` bound, that needs to be removed. Remove the whole
|
||||||
|
// `where` clause.
|
||||||
|
generics.where_clause_span
|
||||||
|
} else if let Some(hir::WherePredicate::BoundPredicate(next)) = predicates.peek()
|
||||||
&& pred.origin == next.origin
|
&& pred.origin == next.origin
|
||||||
{
|
{
|
||||||
// There's another bound, include the comma for the current one.
|
// There's another bound, include the comma for the current one.
|
||||||
|
@ -5174,7 +5190,7 @@ fn point_at_assoc_type_restriction(
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
path.span,
|
path.span,
|
||||||
"replace the associated type with the type specified in this `impl`",
|
"replace the associated type with the type specified in this `impl`",
|
||||||
format!("{}", tcx.type_of(new.def_id).skip_binder(),),
|
tcx.type_of(new.def_id).skip_binder().to_string(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ LL | Self::A: Copy,
|
||||||
| ---- unsatisfied trait bound introduced here
|
| ---- unsatisfied trait bound introduced here
|
||||||
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
||||||
|
|
|
|
||||||
|
LL - where
|
||||||
LL - Self::A: Copy,
|
LL - Self::A: Copy,
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -19,7 +19,6 @@ impl Grault for () {
|
||||||
|
|
||||||
impl<T: Grault> Grault for (T,)
|
impl<T: Grault> Grault for (T,)
|
||||||
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
|
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
|
||||||
where
|
|
||||||
|
|
||||||
{
|
{
|
||||||
type A = ();
|
type A = ();
|
||||||
|
|
|
@ -20,8 +20,8 @@ LL | Self::A: Baz,
|
||||||
| --- unsatisfied trait bound introduced here
|
| --- unsatisfied trait bound introduced here
|
||||||
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
||||||
|
|
|
|
||||||
|
LL - where
|
||||||
LL - Self::A: Baz,
|
LL - Self::A: Baz,
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue