This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
compiler/rustc_trait_selection/src/traits Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,27 @@ fn overlap_within_probe(
185
185
186
186
debug ! ( "overlap: unification check succeeded" ) ;
187
187
188
- // Are any of the obligations unsatisfiable? If so, no overlap.
188
+ // There's no overlap if obligations are unsatisfiable or if the obligation negated is
189
+ // satisfied.
190
+ //
191
+ // For example, given these two impl headers:
192
+ //
193
+ // `impl<'a> From<&'a str> for Box<dyn Error>`
194
+ // `impl<E> From<E> for Box<dyn Error> where E: Error`
195
+ //
196
+ // So we have:
197
+ //
198
+ // `Box<dyn Error>: From<&'?a str>`
199
+ // `Box<dyn Error>: From<?E>`
200
+ //
201
+ // After equating the two headers:
202
+ //
203
+ // `Box<dyn Error> = Box<dyn Error>`
204
+ // So, `?E = &'?a str` and then given the where clause `&'?a str: Error`.
205
+ //
206
+ // If the obligation `&'?a str: Error` holds, it means that there's overlap. If that doesn't
207
+ // hold we need to check if `&'?a str: !Error` holds, if doesn't hold there's overlap because
208
+ // at some point an impl for `&'?a str: Error` could be added.
189
209
let infcx = selcx. infcx ( ) ;
190
210
let tcx = infcx. tcx ;
191
211
let opt_failing_obligation = a_impl_header
You can’t perform that action at this time.
0 commit comments