allow trait alias DefIds in implements_trait_with_env_from_iter

This commit is contained in:
y21 2023-08-14 19:10:33 +02:00
parent b5bfd1176b
commit f746e19169
3 changed files with 16 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#![feature(lint_reasons)] #![feature(lint_reasons)]
#![feature(never_type)] #![feature(never_type)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(assert_matches)]
#![recursion_limit = "512"] #![recursion_limit = "512"]
#![cfg_attr(feature = "deny-warnings", deny(warnings))] #![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)] #![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::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt; use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause}; use rustc_trait_selection::traits::{Obligation, ObligationCause};
use std::assert_matches::debug_assert_matches;
use std::iter; use std::iter;
use crate::{match_def_path, path_res, paths}; 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)] #[cfg(debug_assertions)]
assert_generic_args_match(tcx, trait_id, trait_ref.args); 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(|_| {}, |_| {});
}