Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
425a9c0a0e
commit
27e6726cb8
3 changed files with 32 additions and 1 deletions
|
|
@ -2878,7 +2878,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// we check if `TraitB` can be reachable from `S`
|
||||
// to determine whether to note `TraitA` is sealed trait.
|
||||
if let ty::Adt(adt, _) = ty.kind() {
|
||||
let visibilities = tcx.effective_visibilities(());
|
||||
let visibilities = &tcx.resolutions(()).effective_visibilities;
|
||||
visibilities.effective_vis(local).is_none_or(|v| {
|
||||
v.at_level(Level::Reexported)
|
||||
.is_accessible_from(adt.did(), tcx)
|
||||
|
|
|
|||
11
tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs
Normal file
11
tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// This test is for regression of issue #145611
|
||||
// There should not be cycle error in effective_visibilities query.
|
||||
|
||||
trait LocalTrait {}
|
||||
struct SomeType;
|
||||
fn impls_trait<T: LocalTrait>() {}
|
||||
fn foo() -> impl Sized {
|
||||
impls_trait::<SomeType>(); //~ ERROR the trait bound `SomeType: LocalTrait` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
20
tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr
Normal file
20
tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0277]: the trait bound `SomeType: LocalTrait` is not satisfied
|
||||
--> $DIR/trait-bound-adt-issue-145611.rs:8:19
|
||||
|
|
||||
LL | impls_trait::<SomeType>();
|
||||
| ^^^^^^^^ the trait `LocalTrait` is not implemented for `SomeType`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/trait-bound-adt-issue-145611.rs:4:1
|
||||
|
|
||||
LL | trait LocalTrait {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `impls_trait`
|
||||
--> $DIR/trait-bound-adt-issue-145611.rs:6:19
|
||||
|
|
||||
LL | fn impls_trait<T: LocalTrait>() {}
|
||||
| ^^^^^^^^^^ required by this bound in `impls_trait`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue