]> git.lizzy.rs Git - rust.git/commitdiff
Show bound lifetimes when comparing types in diagnostics
authorMatthew Jasper <mjjasper1@gmail.com>
Wed, 3 Mar 2021 12:14:35 +0000 (12:14 +0000)
committerRémy Rakic <remy.rakic+github@gmail.com>
Sun, 15 Aug 2021 06:44:35 +0000 (08:44 +0200)
compiler/rustc_infer/src/infer/error_reporting/mod.rs
compiler/rustc_infer/src/infer/mod.rs

index 50048534aaee5e75727342b74af0c1e0837f667a..0a049f83e3146539035269b66a4e573af4ca6220 100644 (file)
@@ -1191,16 +1191,26 @@ fn lifetime_display(lifetime: Region<'_>) -> String {
                     //         |   |
                     //         |   elided as they were the same
                     //         not elided, they were different, but irrelevant
+                    //
+                    // For bound lifetimes, keep the names of the lifetimes,
+                    // even if they are the same so that it's clear what's happening
+                    // if we have something like
+                    //
+                    // for<'r, 's> fn(Inv<'r>, Inv<'s>)
+                    // for<'r> fn(Inv<'r>, Inv<'r>)
                     let lifetimes = sub1.regions().zip(sub2.regions());
                     for (i, lifetimes) in lifetimes.enumerate() {
                         let l1 = lifetime_display(lifetimes.0);
                         let l2 = lifetime_display(lifetimes.1);
-                        if lifetimes.0 == lifetimes.1 {
-                            values.0.push_normal("'_");
-                            values.1.push_normal("'_");
-                        } else {
+                        if lifetimes.0 != lifetimes.1 {
                             values.0.push_highlighted(l1);
                             values.1.push_highlighted(l2);
+                        } else if lifetimes.0.is_late_bound() {
+                            values.0.push_normal(l1);
+                            values.1.push_normal(l2);
+                        } else {
+                            values.0.push_normal("'_");
+                            values.1.push_normal("'_");
                         }
                         self.push_comma(&mut values.0, &mut values.1, len, i);
                     }
index 10217a5f5749809d6615794d19f942a039c788d6..930d9e7d7c58f10cc3fdb0b6d823e8a39b69136e 100644 (file)
@@ -1,4 +1,5 @@
 pub use self::freshen::TypeFreshener;
+pub use self::lexical_region_resolve::RegionResolutionError;
 pub use self::LateBoundRegionConversionTime::*;
 pub use self::RegionVariableOrigin::*;
 pub use self::SubregionOrigin::*;