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

hir_analysis: skip self type of host effect preds in variances_of #137613

Merged
merged 2 commits into from
Feb 26, 2025
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
4 changes: 4 additions & 0 deletions compiler/rustc_hir_analysis/src/variance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ fn variance_of_opaque(
ty::ClauseKind::Trait(ty::TraitPredicate {
trait_ref: ty::TraitRef { def_id: _, args, .. },
polarity: _,
})
| ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
trait_ref: ty::TraitRef { def_id: _, args, .. },
constness: _,
}) => {
for arg in &args[1..] {
arg.visit_with(&mut collector);
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/traits/const-traits/variance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(rustc_attrs, const_trait_impl)]
#![allow(internal_features)]
#![rustc_variance_of_opaques]

#[const_trait]
trait Foo {}

impl const Foo for () {}

fn foo<'a: 'a>() -> impl const Foo {}
//~^ ERROR ['a: *]

fn main() {}
8 changes: 8 additions & 0 deletions tests/ui/traits/const-traits/variance.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: ['a: *]
--> $DIR/variance.rs:10:21
|
LL | fn foo<'a: 'a>() -> impl const Foo {}
| ^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Loading