mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Don't elaborate effects predicates into bounds list unless we're actually collecting implied bounds, not super bounds
This commit is contained in:
parent
a846d55d46
commit
4f3d06f5aa
@ -9,6 +9,8 @@ use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::hir_ty_lowering::OnlySelfBounds;
|
||||
|
||||
/// Collects together a list of type bounds. These lists of bounds occur in many places
|
||||
/// in Rust's syntax:
|
||||
///
|
||||
@ -50,6 +52,7 @@ impl<'tcx> Bounds<'tcx> {
|
||||
span: Span,
|
||||
polarity: ty::PredicatePolarity,
|
||||
constness: ty::BoundConstness,
|
||||
only_self_bounds: OnlySelfBounds,
|
||||
) {
|
||||
let clause = (
|
||||
bound_trait_ref
|
||||
@ -66,7 +69,10 @@ impl<'tcx> Bounds<'tcx> {
|
||||
self.clauses.push(clause);
|
||||
}
|
||||
|
||||
if !tcx.features().effects {
|
||||
// FIXME(effects): Lift this out of `push_trait_bound`, and move it somewhere else.
|
||||
// Perhaps moving this into `lower_poly_trait_ref`, just like we lower associated
|
||||
// type bounds.
|
||||
if !tcx.features().effects || only_self_bounds.0 {
|
||||
return;
|
||||
}
|
||||
// For `T: ~const Tr` or `T: const Tr`, we need to add an additional bound on the
|
||||
|
@ -719,6 +719,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
span,
|
||||
polarity,
|
||||
constness,
|
||||
only_self_bounds,
|
||||
);
|
||||
|
||||
let mut dup_constraints = FxIndexMap::default();
|
||||
|
@ -39,7 +39,6 @@ impl const Foo for NonConstAdd {
|
||||
#[const_trait]
|
||||
trait Baz {
|
||||
type Qux: Add;
|
||||
//~^ ERROR the trait bound
|
||||
}
|
||||
|
||||
impl const Baz for NonConstAdd {
|
||||
|
@ -12,17 +12,5 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
|
||||
= note: the next trait solver must be enabled globally for the effects feature to work correctly
|
||||
= help: use `-Znext-solver` to enable
|
||||
|
||||
error[E0277]: the trait bound `Add::{synthetic#0}: Compat` is not satisfied
|
||||
--> $DIR/assoc-type.rs:41:15
|
||||
|
|
||||
LL | type Qux: Add;
|
||||
| ^^^ the trait `Compat` is not implemented for `Add::{synthetic#0}`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait Baz where Add::{synthetic#0}: Compat {
|
||||
| ++++++++++++++++++++++++++++++++
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user