Auto merge of #11338 - y21:issue11337, r=Centri3

allow trait alias DefIds in `implements_trait_with_env_from_iter`

Fixes #11337

changelog: none
This commit is contained in:
bors 2023-08-24 22:28:29 +00:00
commit 19eaafb920
3 changed files with 16 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#![feature(lint_reasons)]
#![feature(never_type)]
#![feature(rustc_private)]
#![feature(assert_matches)]
#![recursion_limit = "512"]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)]

View File

@ -27,6 +27,7 @@
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause};
use std::assert_matches::debug_assert_matches;
use std::iter;
use crate::{match_def_path, path_res, paths};
@ -259,7 +260,11 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
})),
);
debug_assert_eq!(tcx.def_kind(trait_id), DefKind::Trait);
debug_assert_matches!(
tcx.def_kind(trait_id),
DefKind::Trait | DefKind::TraitAlias,
"`DefId` must belong to a trait or trait alias"
);
#[cfg(debug_assertions)]
assert_generic_args_match(tcx, trait_id, trait_ref.args);

View File

@ -0,0 +1,9 @@
#![feature(trait_alias)]
trait Confusing<F> = Fn(i32) where F: Fn(u32);
fn alias<T: Confusing<F>, F>(_: T, _: F) {}
fn main() {
alias(|_| {}, |_| {});
}