Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #120335

Merged
merged 28 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0e6f7c6
Add AsyncFn family of traits
compiler-errors Dec 20, 2023
fde86e5
We do not need impl_trait_in_assoc_ty
compiler-errors Dec 20, 2023
17b4333
select AsyncFn traits during overloaded call op
compiler-errors Dec 20, 2023
2c2f3ed
Provide more context on recursive `impl` evaluation overflow
estebank Dec 28, 2023
c85bb27
Account for trailing comma in removal suggestion
estebank Dec 28, 2023
29bdf9e
Account for single `where` bound being removed
estebank Jan 4, 2024
db7cd57
Remove track_errors entirely
oli-obk Jan 23, 2024
849d884
Remove --fatal-warnings on wasm targets
djkoloski Jan 23, 2024
83ef18c
coverage: Dismantle `Instrumentor` into ordinary functions
Zalathar Jan 24, 2024
572d7e9
coverage: Flatten the functions for extracting/refining coverage spans
Zalathar Jan 24, 2024
64f590a
Assert that a single scope is passed to `for_scope`
Urgau Jan 22, 2024
cc34dc2
Correctly explain `ensure_forwards_result_if_red`
oli-obk Jan 24, 2024
e088016
Let `ctor_sub_tys` return any Iterator they want
Nadrieril Jan 24, 2024
d992d9c
On E0308 involving `dyn Trait`, mention trait objects
estebank Jan 24, 2024
796814d
Account for expected `dyn Trait` found `impl Trait`
estebank Jan 24, 2024
bdab213
Most of the `DeconstructedPat` `Debug` impl is reusable
Nadrieril Jan 24, 2024
354b45f
Improve `Range: Debug` impl
Nadrieril Jan 24, 2024
8f3af4c
rustc_data_structures: use either instead of itertools
cuviper Jan 24, 2024
8c6cf3c
Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk
matthiaskrgr Jan 25, 2024
fd92d88
Rollup merge of #119389 - estebank:issue-116925, r=TaKO8Ki
matthiaskrgr Jan 25, 2024
0c45e3c
Rollup merge of #119895 - oli-obk:track_errors_3, r=matthewjasper
matthiaskrgr Jan 25, 2024
55d5ea3
Rollup merge of #120230 - Urgau:for_scope-single-scope, r=michaelwoer…
matthiaskrgr Jan 25, 2024
565961b
Rollup merge of #120278 - djkoloski:remove_fatal_warnings_wasm, r=oli…
matthiaskrgr Jan 25, 2024
72b70ec
Rollup merge of #120292 - Zalathar:dismantle, r=oli-obk
matthiaskrgr Jan 25, 2024
0cbef47
Rollup merge of #120315 - estebank:issue-102629-2, r=wesleywiser
matthiaskrgr Jan 25, 2024
b677c77
Rollup merge of #120317 - Nadrieril:dont-force-slice-of-ty, r=compile…
matthiaskrgr Jan 25, 2024
a1ecced
Rollup merge of #120318 - Nadrieril:share-debug-impl, r=compiler-errors
matthiaskrgr Jan 25, 2024
8c1ba59
Rollup merge of #120325 - cuviper:either-data, r=compiler-errors
matthiaskrgr Jan 25, 2024
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
Prev Previous commit
Next Next commit
Account for trailing comma in removal suggestion
  • Loading branch information
estebank committed Jan 19, 2024
commit c85bb274f6376c0e8b1289d6cb8f187b011b8fd7
Original file line number Diff line number Diff line change
Expand Up @@ -5100,11 +5100,14 @@ fn point_at_assoc_type_restriction(
return;
};
let name = tcx.item_name(proj.projection_ty.def_id);
for pred in generics.predicates {
let mut predicates = generics.predicates.iter().peekable();
let mut prev: Option<&hir::WhereBoundPredicate<'_>> = None;
while let Some(pred) = predicates.next() {
let hir::WherePredicate::BoundPredicate(pred) = pred else {
continue;
};
for bound in pred.bounds {
let mut bounds = pred.bounds.iter().peekable();
while let Some(bound) = bounds.next() {
let Some(trait_ref) = bound.trait_ref() else {
continue;
};
Expand All @@ -5118,8 +5121,27 @@ fn point_at_assoc_type_restriction(
&& let hir::QPath::Resolved(None, inner_path) = inner_path
&& let Res::SelfTyAlias { .. } = inner_path.res
{
// The following block is to determine the right span to delete for this bound
// that will leave valid code after the suggestion is applied.
let span = if let Some(hir::WherePredicate::BoundPredicate(next)) =
predicates.peek()
&& pred.origin == next.origin
{
// There's another bound, include the comma for the current one.
pred.span.until(next.span)
} else if let Some(prev) = prev
&& pred.origin == prev.origin
{
// Last bound, try to remove the previous comma.
prev.span.shrink_to_hi().to(pred.span)
} else if pred.origin == hir::PredicateOrigin::WhereClause {
pred.span.with_hi(generics.where_clause_span.hi())
} else {
pred.span
};

err.span_suggestion_verbose(
pred.span, // FIXME: include the trailing comma.
span,
"associated type for the current `impl` cannot be restricted in `where` \
clauses, remove this bound",
"",
Expand Down Expand Up @@ -5168,6 +5190,7 @@ fn point_at_assoc_type_restriction(
);
}
}
prev = Some(pred);
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/impl-wf-cycle-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ LL | Self::A: Baz,
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
LL - Self::A: Baz,
LL + ,
|

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-types/impl-wf-cycle-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LL | Self::A: Copy,
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
LL - Self::A: Copy,
LL + ,
LL +
|

error: aborting due to 1 previous error
Expand Down
31 changes: 31 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-5.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// run-rustfix

trait Baz {}
impl Baz for () {}
impl<T> Baz for (T,) {}

trait Fiz {}
impl Fiz for bool {}

trait Grault {
type A;
type B;
}

impl Grault for () {
type A = ();
type B = bool;
}

impl<T> Grault for (T,)
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
where
T: Grault,
{
type A = ();
type B = bool;
}

fn main() {
let _: <((),) as Grault>::A = ();
}
32 changes: 32 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-5.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// run-rustfix

trait Baz {}
impl Baz for () {}
impl<T> Baz for (T,) {}

trait Fiz {}
impl Fiz for bool {}

trait Grault {
type A;
type B;
}

impl Grault for () {
type A = ();
type B = bool;
}

impl<T> Grault for (T,)
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
where
T: Grault,
Self::A: Baz,
{
type A = ();
type B = bool;
}

fn main() {
let _: <((),) as Grault>::A = ();
}
31 changes: 31 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-5.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
--> $DIR/impl-wf-cycle-5.rs:20:1
|
LL | / impl<T> Grault for (T,)
LL | |
LL | | where
LL | | T: Grault,
LL | | Self::A: Baz,
| |_________________^
LL | {
LL | type A = ();
| ------ associated type `<(T,) as Grault>::A` is specified here
|
note: required for `(T,)` to implement `Grault`
--> $DIR/impl-wf-cycle-5.rs:20:9
|
LL | impl<T> Grault for (T,)
| ^^^^^^ ^^^^
...
LL | Self::A: Baz,
| --- unsatisfied trait bound introduced here
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
LL - T: Grault,
LL - Self::A: Baz,
LL + T: Grault,
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0275`.
31 changes: 31 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-6.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// run-rustfix

trait Baz {}
impl Baz for () {}
impl<T> Baz for (T,) {}

trait Fiz {}
impl Fiz for bool {}

trait Grault {
type A;
type B;
}

impl Grault for () {
type A = ();
type B = bool;
}

impl<T: Grault> Grault for (T,)
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
where

{
type A = ();
type B = bool;
}

fn main() {
let _: <((),) as Grault>::A = ();
}
31 changes: 31 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-6.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// run-rustfix

trait Baz {}
impl Baz for () {}
impl<T> Baz for (T,) {}

trait Fiz {}
impl Fiz for bool {}

trait Grault {
type A;
type B;
}

impl Grault for () {
type A = ();
type B = bool;
}

impl<T: Grault> Grault for (T,)
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
where
Self::A: Baz,
{
type A = ();
type B = bool;
}

fn main() {
let _: <((),) as Grault>::A = ();
}
29 changes: 29 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-6.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
--> $DIR/impl-wf-cycle-6.rs:20:1
|
LL | / impl<T: Grault> Grault for (T,)
LL | |
LL | | where
LL | | Self::A: Baz,
| |_________________^
LL | {
LL | type A = ();
| ------ associated type `<(T,) as Grault>::A` is specified here
|
note: required for `(T,)` to implement `Grault`
--> $DIR/impl-wf-cycle-6.rs:20:17
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
...
LL | Self::A: Baz,
| --- unsatisfied trait bound introduced here
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
|
LL - Self::A: Baz,
LL +
|

error: aborting due to 1 previous error

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