Skip to content

Commit 373e909

Browse files
committed
add a comment
1 parent 94703ce commit 373e909

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/librustc/ty/wf.rs

+23
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ struct WfPredicates<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
114114
out: Vec<traits::PredicateObligation<'tcx>>,
115115
}
116116

117+
/// Controls whether we "elaborate" supertraits and so forth on the WF
118+
/// predicates. This is a kind of hack to address #43784. The
119+
/// underlying problem in that issue was a trait structure like:
120+
///
121+
/// ```
122+
/// trait Foo: Copy { }
123+
/// trait Bar: Foo { }
124+
/// impl<T: Bar> Foo for T { }
125+
/// impl<T> Bar for T { }
126+
/// ```
127+
///
128+
/// Here, in the `Foo` impl, we will check that `T: Copy` holds -- but
129+
/// we decide that this is true because `T: Bar` is in the
130+
/// where-clauses (and we can elaborate that to include `T:
131+
/// Copy`). This wouldn't be a problem, except that when we check the
132+
/// `Bar` impl, we decide that `T: Foo` must hold because of the `Foo`
133+
/// impl. And so nowhere did we check that `T: Copy` holds!
134+
///
135+
/// To resolve this, we elaborate the WF requirements that must be
136+
/// proven when checking impls. This means that (e.g.) the `impl Bar
137+
/// for T` will be forced to prove not only that `T: Foo` but also `T:
138+
/// Copy` (which it won't be able to do, because there is no `Copy`
139+
/// impl for `T`).
117140
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
118141
enum Elaborate {
119142
All,

0 commit comments

Comments
 (0)