add tests
This commit is contained in:
parent
a2db928053
commit
5139facb36
4 changed files with 90 additions and 1 deletions
|
|
@ -473,7 +473,10 @@ where
|
|||
// fails to reach a fixpoint but ends up getting an error after
|
||||
// running for some additional step.
|
||||
//
|
||||
// cc trait-system-refactor-initiative#105
|
||||
// FIXME(@lcnr): While I believe an error here to be possible, we
|
||||
// currently don't have any test which actually triggers it. @lqd
|
||||
// created a minimization for an ICE in typenum, but that one no
|
||||
// longer fails here. cc trait-system-refactor-initiative#105.
|
||||
let source = CandidateSource::BuiltinImpl(BuiltinImplSource::Misc);
|
||||
let certainty = Certainty::Maybe { cause, opaque_types_jank: OpaqueTypesJank::AllGood };
|
||||
self.probe_trait_candidate(source)
|
||||
|
|
|
|||
9
tests/ui/indexing/ambiguity-after-deref-step.rs
Normal file
9
tests/ui/indexing/ambiguity-after-deref-step.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Regression test making sure that indexing fails with an ambiguity
|
||||
// error if one of the deref-steps encounters an inference variable.
|
||||
|
||||
fn main() {
|
||||
let x = &Default::default();
|
||||
//~^ ERROR type annotations needed for `&_`
|
||||
x[1];
|
||||
let _: &Vec<()> = x;
|
||||
}
|
||||
17
tests/ui/indexing/ambiguity-after-deref-step.stderr
Normal file
17
tests/ui/indexing/ambiguity-after-deref-step.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0282]: type annotations needed for `&_`
|
||||
--> $DIR/ambiguity-after-deref-step.rs:5:9
|
||||
|
|
||||
LL | let x = &Default::default();
|
||||
| ^
|
||||
LL |
|
||||
LL | x[1];
|
||||
| - type must be known at this point
|
||||
|
|
||||
help: consider giving `x` an explicit type, where the placeholders `_` are specified
|
||||
|
|
||||
LL | let x: &_ = &Default::default();
|
||||
| ++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
60
tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs
Normal file
60
tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//@ compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// Regression test for trait-system-refactor-initiative#105. We previously encountered
|
||||
// an ICE in typenum as `forced_ambiguity` failed. While this test no longer causes
|
||||
// `forced_ambiguity` to error, we still want to use it as a regression test.
|
||||
|
||||
pub struct UInt<U, B> {
|
||||
_msb: U,
|
||||
_lsb: B,
|
||||
}
|
||||
pub struct B1;
|
||||
pub trait Sub<Rhs> {
|
||||
type Output;
|
||||
}
|
||||
impl<U, B> Sub<B1> for UInt<UInt<U, B>, B1> {
|
||||
type Output = ();
|
||||
}
|
||||
impl<U> Sub<B1> for UInt<U, ()>
|
||||
where
|
||||
U: Sub<B1>,
|
||||
U::Output: Send,
|
||||
{
|
||||
type Output = ();
|
||||
}
|
||||
|
||||
pub trait Op<N, R, I> {
|
||||
fn op(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
trait OpIf<N, R, I> {}
|
||||
|
||||
impl<N, Ur, Br, I> Op<N, UInt<Ur, Br>, I> for ()
|
||||
where
|
||||
N: Sub<I>,
|
||||
(): OpIf<N, UInt<UInt<Ur, Br>, N::Output>, I>,
|
||||
{
|
||||
}
|
||||
impl<N, R, Ui, Bi> OpIf<N, R, UInt<Ui, Bi>> for ()
|
||||
where
|
||||
UInt<Ui, Bi>: Sub<B1>,
|
||||
(): Op<N, R, <UInt<Ui, Bi> as Sub<B1>>::Output>,
|
||||
{
|
||||
}
|
||||
impl<N, R> OpIf<N, R, ()> for () where R: Sub<N> {}
|
||||
|
||||
pub trait Compute {
|
||||
type Output;
|
||||
}
|
||||
|
||||
pub fn repro<Ul, Bl>()
|
||||
where
|
||||
UInt<Ul, Bl>: Compute,
|
||||
<UInt<Ul, Bl> as Compute>::Output: Sub<B1>,
|
||||
(): Op<UInt<(), Bl>, (), ()>,
|
||||
{
|
||||
().op();
|
||||
}
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue