]> git.lizzy.rs Git - rust.git/commitdiff
Explain redundant mapping.
authorCamille GILLOT <gillot.camille@gmail.com>
Mon, 24 Oct 2022 17:15:42 +0000 (17:15 +0000)
committerCamille GILLOT <gillot.camille@gmail.com>
Sat, 12 Nov 2022 10:01:50 +0000 (10:01 +0000)
compiler/rustc_middle/src/ty/mod.rs

index 169e8e792ab245bc050c70ac5769aa4f5373a7da..ce1b1d6973e180a74be1d137234ed6b7d6e9661f 100644 (file)
@@ -1332,6 +1332,10 @@ pub fn remap_generic_params_to_declaration_params(
         let id_substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
         debug!(?id_substs);
 
+        // This zip may have several times the same lifetime in `substs` paired with a different
+        // lifetime from `id_substs`.  In that case, we actually want to pick the last one, as it
+        // is the one we introduced in the impl-trait desugaring to be meaningful.  The other ones
+        // are redundant.
         let map = substs.iter().zip(id_substs);
 
         let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> = match origin {