Skip to content
Open
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
19 changes: 14 additions & 5 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::marker::PhantomData;
use std::mem;
use std::ops::ControlFlow;

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::thinvec::ExtractIf;
use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::InferCtxt;
Expand All @@ -19,7 +20,7 @@ use rustc_next_trait_solver::solve::{
};
use rustc_span::Span;
use thin_vec::ThinVec;
use tracing::instrument;
use tracing::{debug, instrument};

use self::derive_errors::*;
use super::Certainty;
Expand Down Expand Up @@ -57,6 +58,7 @@ pub struct FulfillmentCtxt<'tcx, E: 'tcx> {

#[derive(Default, Debug)]
struct ObligationStorage<'tcx> {
dedup: FxHashSet<(ty::ParamEnv<'tcx>, ty::Predicate<'tcx>)>,
/// Obligations which resulted in an overflow in fulfillment itself.
///
/// We cannot eagerly return these as error so we instead store them here
Expand All @@ -67,7 +69,14 @@ struct ObligationStorage<'tcx> {
}

impl<'tcx> ObligationStorage<'tcx> {
fn register(
fn register(&mut self, obligation: PredicateObligation<'tcx>) {
if self.dedup.insert((obligation.param_env, obligation.predicate)) {
self.pending.push((obligation, None));
} else {
debug!("skipping already registered obligation: {obligation:?}");
}
}
fn readd_pending(
&mut self,
obligation: PredicateObligation<'tcx>,
stalled_on: Option<GoalStalledOn<TyCtxt<'tcx>>>,
Expand Down Expand Up @@ -161,7 +170,7 @@ where
obligation: PredicateObligation<'tcx>,
) {
assert_eq!(self.usable_in_snapshot, infcx.num_open_snapshots());
self.obligations.register(obligation, None);
self.obligations.register(obligation);
}

fn collect_remaining_errors(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<E> {
Expand Down Expand Up @@ -205,7 +214,7 @@ where
// Only goals proven via the trait solver should be region dependent.
Certainty::Yes => {}
Certainty::Maybe(_) => {
self.obligations.register(obligation, None);
self.obligations.readd_pending(obligation, None);
}
}
continue;
Expand Down Expand Up @@ -256,7 +265,7 @@ where
infcx.push_hir_typeck_potentially_region_dependent_goal(obligation);
}
}
Certainty::Maybe(_) => self.obligations.register(obligation, stalled_on),
Certainty::Maybe(_) => self.obligations.readd_pending(obligation, stalled_on),
}
}

Expand Down
26 changes: 1 addition & 25 deletions tests/ui/const-generics/issues/issue-88119.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ note: required by a bound in `<&T as ConstName>`
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`

error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:21:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:21:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`

error[E0275]: overflow evaluating the requirement `&mut T: [const] ConstName`
--> $DIR/issue-88119.rs:26:49
|
Expand All @@ -66,18 +54,6 @@ note: required by a bound in `<&mut T as ConstName>`
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`

error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:28:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
note: required by a bound in `<&mut T as ConstName>`
--> $DIR/issue-88119.rs:28:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`

error[E0275]: overflow evaluating the requirement `&&mut u8: ConstName`
--> $DIR/issue-88119.rs:33:35
|
Expand All @@ -90,6 +66,6 @@ error[E0275]: overflow evaluating the requirement `&mut &u8: ConstName`
LL | pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES;
| ^^^^^^^^

error: aborting due to 11 previous errors
error: aborting due to 9 previous errors

For more information about this error, try `rustc --explain E0275`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ error[E0277]: the trait bound `U: [const] Other` is not satisfied
LL | T::Assoc::<U>::func();
| ^^^^^^^^^^^^^

error[E0277]: the trait bound `U: [const] Other` is not satisfied
--> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5
|
LL | <T as Trait>::Assoc::<U>::func();
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const fn fails<T: [const] Trait, U: Other>() {
T::Assoc::<U>::func();
//~^ ERROR the trait bound `U: [const] Other` is not satisfied
<T as Trait>::Assoc::<U>::func();
//~^ ERROR the trait bound `U: [const] Other` is not satisfied
//[current]~^ ERROR the trait bound `U: [const] Other` is not satisfied
}

const fn works<T: [const] Trait, U: [const] Other>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ error[E0277]: the trait bound `T: [const] Trait` is not satisfied
LL | T::Assoc::func();
| ^^^^^^^^

error[E0277]: the trait bound `T: [const] Trait` is not satisfied
--> $DIR/assoc-type-const-bound-usage-fail.rs:19:5
|
LL | <T as Trait>::Assoc::func();
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const fn unqualified<T: Trait>() {
T::Assoc::func();
//~^ ERROR the trait bound `T: [const] Trait` is not satisfied
<T as Trait>::Assoc::func();
//~^ ERROR the trait bound `T: [const] Trait` is not satisfied
//[current]~^ ERROR the trait bound `T: [const] Trait` is not satisfied
}

const fn works<T: [const] Trait>() {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/traits/const-traits/trait-where-clause-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const fn test1<T: [const] Foo + Bar>() {
T::b();
//~^ ERROR the trait bound
T::c::<T>();
//~^ ERROR the trait bound
}

const fn test2<T: [const] Foo + [const] Bar>() {
Expand Down
14 changes: 1 addition & 13 deletions tests/ui/traits/const-traits/trait-where-clause-const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ note: required by a bound in `Foo::b`
LL | fn b() where Self: [const] Bar;
| ^^^^^^^^^^^ required by this bound in `Foo::b`

error[E0277]: the trait bound `T: [const] Bar` is not satisfied
--> $DIR/trait-where-clause-const.rs:23:12
|
LL | T::c::<T>();
| ^
|
note: required by a bound in `Foo::c`
--> $DIR/trait-where-clause-const.rs:16:13
|
LL | fn c<T: [const] Bar>();
| ^^^^^^^^^^^ required by this bound in `Foo::c`

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading