Fix compiler docs
This commit is contained in:
parent
3416fa1882
commit
adc24d1b5e
10 changed files with 32 additions and 16 deletions
|
@ -707,10 +707,12 @@ pub(super) fn check_opaque_for_cycles<'tcx>(
|
|||
/// check those cases in the `param_env` of that function, which may have
|
||||
/// bounds not on this opaque type:
|
||||
///
|
||||
/// type X<T> = impl Clone
|
||||
/// ```ignore (illustrative)
|
||||
/// type X<T> = impl Clone;
|
||||
/// fn f<T: Clone>(t: T) -> X<T> {
|
||||
/// t
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Without this check the above code is incorrectly accepted: we would ICE if
|
||||
/// some tried, for example, to clone an `Option<X<&mut ()>>`.
|
||||
|
|
|
@ -114,9 +114,9 @@ pub fn identify_constrained_generic_params<'tcx>(
|
|||
/// ```
|
||||
/// The impl's predicates are collected from left to right. Ignoring
|
||||
/// the implicit `Sized` bounds, these are
|
||||
/// * T: Debug
|
||||
/// * U: Iterator
|
||||
/// * <U as Iterator>::Item = T -- a desugared ProjectionPredicate
|
||||
/// * `T: Debug`
|
||||
/// * `U: Iterator`
|
||||
/// * `<U as Iterator>::Item = T` -- a desugared ProjectionPredicate
|
||||
///
|
||||
/// When we, for example, try to go over the trait-reference
|
||||
/// `IntoIter<u32> as Trait`, we substitute the impl parameters with fresh
|
||||
|
@ -132,12 +132,16 @@ pub fn identify_constrained_generic_params<'tcx>(
|
|||
///
|
||||
/// We *do* have to be somewhat careful when projection targets contain
|
||||
/// projections themselves, for example in
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<S,U,V,W> Trait for U where
|
||||
/// /* 0 */ S: Iterator<Item = U>,
|
||||
/// /* - */ U: Iterator,
|
||||
/// /* 1 */ <U as Iterator>::Item: ToOwned<Owned=(W,<V as Iterator>::Item)>
|
||||
/// /* 2 */ W: Iterator<Item = V>
|
||||
/// /* 3 */ V: Debug
|
||||
/// ```
|
||||
///
|
||||
/// we have to evaluate the projections in the order I wrote them:
|
||||
/// `V: Debug` requires `V` to be evaluated. The only projection that
|
||||
/// *determines* `V` is 2 (1 contains it, but *does not determine it*,
|
||||
|
|
|
@ -130,8 +130,10 @@ fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node
|
|||
///
|
||||
/// Example
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<A, B> Foo<A> for B { /* impl2 */ }
|
||||
/// impl<C> Foo<Vec<C>> for C { /* impl1 */ }
|
||||
/// ```
|
||||
///
|
||||
/// Would return `S1 = [C]` and `S2 = [Vec<C>, C]`.
|
||||
fn get_impl_substs<'tcx>(
|
||||
|
@ -225,13 +227,17 @@ fn unconstrained_parent_impl_substs<'tcx>(
|
|||
///
|
||||
/// For example forbid the following:
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<A> Tr for A { }
|
||||
/// impl<B> Tr for (B, B) { }
|
||||
/// ```
|
||||
///
|
||||
/// Note that only consider the unconstrained parameters of the base impl:
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<S, I: IntoIterator<Item = S>> Tr<S> for I { }
|
||||
/// impl<T> Tr<T> for Vec<T> { }
|
||||
/// ```
|
||||
///
|
||||
/// The substs for the parent impl here are `[T, Vec<T>]`, which repeats `T`,
|
||||
/// but `S` is constrained in the parent impl, so `parent_substs` is only
|
||||
|
@ -256,8 +262,10 @@ fn check_duplicate_params<'tcx>(
|
|||
///
|
||||
/// For example forbid the following:
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<A> Tr for A { }
|
||||
/// impl Tr for &'static i32 { }
|
||||
/// ```
|
||||
fn check_static_lifetimes<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
parent_substs: &Vec<GenericArg<'tcx>>,
|
||||
|
|
|
@ -184,7 +184,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
/// modes #42640) may look like `Some(x)` but in fact have
|
||||
/// implicit deref patterns attached (e.g., it is really
|
||||
/// `&Some(x)`). In that case, we return the "outermost" type
|
||||
/// (e.g., `&Option<T>).
|
||||
/// (e.g., `&Option<T>`).
|
||||
pub(crate) fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
|
||||
// Check for implicit `&` types wrapping the pattern; note
|
||||
// that these are never attached to binding patterns, so
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue