Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 870657c

Browse files
Rollup merge of #147180 - lcnr:forced_ambiguity-error, r=jdonszelmann
add tests fixes rust-lang/trait-system-refactor-initiative#105 the index test is for #146637 r? types
2 parents 3102f00 + 5139fac commit 870657c

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

‎compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,10 @@ where
473473
// fails to reach a fixpoint but ends up getting an error after
474474
// running for some additional step.
475475
//
476-
// cc trait-system-refactor-initiative#105
476+
// FIXME(@lcnr): While I believe an error here to be possible, we
477+
// currently don't have any test which actually triggers it. @lqd
478+
// created a minimization for an ICE in typenum, but that one no
479+
// longer fails here. cc trait-system-refactor-initiative#105.
477480
let source = CandidateSource::BuiltinImpl(BuiltinImplSource::Misc);
478481
let certainty = Certainty::Maybe { cause, opaque_types_jank: OpaqueTypesJank::AllGood };
479482
self.probe_trait_candidate(source)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Regression test making sure that indexing fails with an ambiguity
2+
// error if one of the deref-steps encounters an inference variable.
3+
4+
fn main() {
5+
let x = &Default::default();
6+
//~^ ERROR type annotations needed for `&_`
7+
x[1];
8+
let _: &Vec<()> = x;
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0282]: type annotations needed for `&_`
2+
--> $DIR/ambiguity-after-deref-step.rs:5:9
3+
|
4+
LL | let x = &Default::default();
5+
| ^
6+
LL |
7+
LL | x[1];
8+
| - type must be known at this point
9+
|
10+
help: consider giving `x` an explicit type, where the placeholders `_` are specified
11+
|
12+
LL | let x: &_ = &Default::default();
13+
| ++++
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0282`.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
// Regression test for trait-system-refactor-initiative#105. We previously encountered
5+
// an ICE in typenum as `forced_ambiguity` failed. While this test no longer causes
6+
// `forced_ambiguity` to error, we still want to use it as a regression test.
7+
8+
pub struct UInt<U, B> {
9+
_msb: U,
10+
_lsb: B,
11+
}
12+
pub struct B1;
13+
pub trait Sub<Rhs> {
14+
type Output;
15+
}
16+
impl<U, B> Sub<B1> for UInt<UInt<U, B>, B1> {
17+
type Output = ();
18+
}
19+
impl<U> Sub<B1> for UInt<U, ()>
20+
where
21+
U: Sub<B1>,
22+
U::Output: Send,
23+
{
24+
type Output = ();
25+
}
26+
27+
pub trait Op<N, R, I> {
28+
fn op(&self) {
29+
unimplemented!()
30+
}
31+
}
32+
trait OpIf<N, R, I> {}
33+
34+
impl<N, Ur, Br, I> Op<N, UInt<Ur, Br>, I> for ()
35+
where
36+
N: Sub<I>,
37+
(): OpIf<N, UInt<UInt<Ur, Br>, N::Output>, I>,
38+
{
39+
}
40+
impl<N, R, Ui, Bi> OpIf<N, R, UInt<Ui, Bi>> for ()
41+
where
42+
UInt<Ui, Bi>: Sub<B1>,
43+
(): Op<N, R, <UInt<Ui, Bi> as Sub<B1>>::Output>,
44+
{
45+
}
46+
impl<N, R> OpIf<N, R, ()> for () where R: Sub<N> {}
47+
48+
pub trait Compute {
49+
type Output;
50+
}
51+
52+
pub fn repro<Ul, Bl>()
53+
where
54+
UInt<Ul, Bl>: Compute,
55+
<UInt<Ul, Bl> as Compute>::Output: Sub<B1>,
56+
(): Op<UInt<(), Bl>, (), ()>,
57+
{
58+
().op();
59+
}
60+
fn main() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /