about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJake Goulding <jake.goulding@gmail.com>2025-03-28 16:12:07 -0400
committerJake Goulding <jake.goulding@gmail.com>2025-06-04 10:40:04 -0400
commit9a50cb4a0caa07b7b751afb70464066e4d6985d3 (patch)
tree01a480f7f1053d317f9b207b6ba2516117083949 /tests
parentd2bf16ad6d80827800798a00ba584f95e9689573 (diff)
downloadrust-9a50cb4a0caa07b7b751afb70464066e4d6985d3.tar.gz
rust-9a50cb4a0caa07b7b751afb70464066e4d6985d3.zip
Introduce the `mismatched_lifetime_syntaxes` lint
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs318
-rw-r--r--tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr473
2 files changed, 791 insertions, 0 deletions
diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs
new file mode 100644
index 00000000000..ffeaab36bf3
--- /dev/null
+++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs
@@ -0,0 +1,318 @@
+#![deny(mismatched_lifetime_syntaxes)]
+
+// `elided_named_lifetimes` overlaps with `lifetime_style_mismatch`, ignore it for now
+#![allow(elided_named_lifetimes)]
+
+#[derive(Copy, Clone)]
+struct ContainsLifetime<'a>(&'a u8);
+
+struct S(u8);
+
+fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v
+}
+
+fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v
+}
+
+// ---
+
+fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime) -> ContainsLifetime<'_> {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v
+}
+
+fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v
+}
+
+fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v
+}
+
+fn explicit_bound_path_to_explicit_anonymous_path<'a>(
+    v: ContainsLifetime<'a>,
+    //~^ ERROR lifetime flowing from input to output with different syntax
+) -> ContainsLifetime<'_> {
+    v
+}
+
+// ---
+
+fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    ContainsLifetime(v)
+}
+
+fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    ContainsLifetime(v)
+}
+
+fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    ContainsLifetime(v)
+}
+
+fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    ContainsLifetime(v)
+}
+
+// ---
+
+fn implicit_path_to_implicit_ref(v: ContainsLifetime) -> &u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v.0
+}
+
+fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v.0
+}
+
+fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v.0
+}
+
+fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 {
+    //~^ ERROR lifetime flowing from input to output with different syntax
+    v.0
+}
+
+impl S {
+    fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &u8 {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        &self.0
+    }
+
+    fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        &self.0
+    }
+
+    // ---
+
+    fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        ContainsLifetime(&self.0)
+    }
+
+    fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        ContainsLifetime(&self.0)
+    }
+
+    fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        ContainsLifetime(&self.0)
+    }
+}
+
+// If a function uses the `'static` lifetime, we should not suggest
+// replacing it with an explicitly anonymous or implicit
+// lifetime. Only suggest using `'static` everywhere.
+mod static_suggestions {
+    #[derive(Copy, Clone)]
+    struct ContainsLifetime<'a>(&'a u8);
+
+    struct S(u8);
+
+    fn static_ref_to_implicit_ref(v: &'static u8) -> &u8 {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        v
+    }
+
+    fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        v
+    }
+
+    fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        ContainsLifetime(v)
+    }
+
+    fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        ContainsLifetime(v)
+    }
+
+    impl S {
+        fn static_ref_to_implicit_ref(&'static self) -> &u8 {
+            //~^ ERROR lifetime flowing from input to output with different syntax
+            &self.0
+        }
+
+        fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 {
+            //~^ ERROR lifetime flowing from input to output with different syntax
+            &self.0
+        }
+
+        fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime {
+            //~^ ERROR lifetime flowing from input to output with different syntax
+            ContainsLifetime(&self.0)
+        }
+
+        fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> {
+            //~^ ERROR lifetime flowing from input to output with different syntax
+            ContainsLifetime(&self.0)
+        }
+    }
+}
+
+/// `impl Trait` uses lifetimes in some additional ways.
+mod impl_trait {
+    #[derive(Copy, Clone)]
+    struct ContainsLifetime<'a>(&'a u8);
+
+    fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        move || _ = v
+    }
+
+    fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        move || _ = v
+    }
+
+    fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        move || _ = v
+    }
+
+    fn explicit_bound_path_to_impl_trait_precise_capture<'a>(
+        v: ContainsLifetime<'a>,
+        //~^ ERROR lifetime flowing from input to output with different syntax
+    ) -> impl FnOnce() + use<'_> {
+        move || _ = v
+    }
+}
+
+/// `dyn Trait` uses lifetimes in some additional ways.
+mod dyn_trait {
+    use std::iter;
+
+    #[derive(Copy, Clone)]
+    struct ContainsLifetime<'a>(&'a u8);
+
+    fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &u8> + '_> {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        Box::new(iter::once(v))
+    }
+
+    fn explicit_bound_path_to_dyn_trait_bound<'a>(
+        v: ContainsLifetime<'a>,
+        //~^ ERROR lifetime flowing from input to output with different syntax
+    ) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> {
+        Box::new(iter::once(v))
+    }
+}
+
+/// These tests serve to exercise edge cases of the lint formatting
+mod diagnostic_output {
+    fn multiple_outputs<'a>(v: &'a u8) -> (&u8, &u8) {
+        //~^ ERROR lifetime flowing from input to output with different syntax
+        (v, v)
+    }
+}
+
+/// These usages are expected to **not** trigger the lint
+mod acceptable_uses {
+    #[derive(Copy, Clone)]
+    struct ContainsLifetime<'a>(&'a u8);
+
+    struct S(u8);
+
+    fn implicit_ref_to_implicit_ref(v: &u8) -> &u8 {
+        v
+    }
+
+    fn explicit_anonymous_ref_to_explicit_anonymous_ref(v: &'_ u8) -> &'_ u8 {
+        v
+    }
+
+    fn explicit_bound_ref_to_explicit_bound_ref<'a>(v: &'a u8) -> &'a u8 {
+        v
+    }
+
+    fn implicit_path_to_implicit_path(v: ContainsLifetime) -> ContainsLifetime {
+        v
+    }
+
+    fn explicit_anonymous_path_to_explicit_anonymous_path(
+        v: ContainsLifetime<'_>,
+    ) -> ContainsLifetime<'_> {
+        v
+    }
+
+    fn explicit_bound_path_to_explicit_bound_path<'a>(
+        v: ContainsLifetime<'a>,
+    ) -> ContainsLifetime<'a> {
+        v
+    }
+
+    fn explicit_anonymous_ref_to_explicit_anonymous_path(v: &'_ u8) -> ContainsLifetime<'_> {
+        ContainsLifetime(v)
+    }
+
+    fn explicit_bound_ref_to_explicit_bound_path<'a>(v: &'a u8) -> ContainsLifetime<'a> {
+        ContainsLifetime(v)
+    }
+
+    fn explicit_anonymous_path_to_explicit_anonymous_ref(v: ContainsLifetime<'_>) -> &'_ u8 {
+        v.0
+    }
+
+    fn explicit_bound_path_to_explicit_bound_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 {
+        v.0
+    }
+
+    // These may be surprising, but ampersands count as enough of a
+    // visual indicator that a reference exists that we treat
+    // references with implicit lifetimes the same as if they were
+    // explicitly anonymous.
+    fn implicit_ref_to_explicit_anonymous_ref(v: &u8) -> &'_ u8 {
+        v
+    }
+
+    fn explicit_anonymous_ref_to_implicit_ref(v: &'_ u8) -> &u8 {
+        v
+    }
+
+    fn implicit_ref_to_explicit_anonymous_path(v: &u8) -> ContainsLifetime<'_> {
+        ContainsLifetime(v)
+    }
+
+    fn explicit_anonymous_path_to_implicit_ref(v: ContainsLifetime<'_>) -> &u8 {
+        v.0
+    }
+
+    impl S {
+        fn method_implicit_ref_to_explicit_anonymous_ref(&self) -> &'_ u8 {
+            &self.0
+        }
+
+        fn method_explicit_anonymous_ref_to_implicit_ref(&'_ self) -> &u8 {
+            &self.0
+        }
+
+        fn method_implicit_ref_to_explicit_anonymous_path(&self) -> ContainsLifetime<'_> {
+            ContainsLifetime(&self.0)
+        }
+    }
+
+    // `dyn Trait` has an "embedded" lifetime that we should **not**
+    // lint about.
+    fn dyn_trait_does_not_have_a_lifetime_generic(v: &u8) -> &dyn core::fmt::Debug {
+        v
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr
new file mode 100644
index 00000000000..57af0ac93cf
--- /dev/null
+++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr
@@ -0,0 +1,473 @@
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:11:47
+   |
+LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &u8 {
+   |                                               ^^        --- the lifetime gets resolved as `'a`
+   |                                               |
+   |                                               this lifetime flows to the output
+   |
+note: the lint level is defined here
+  --> $DIR/mismatched-lifetime-syntaxes.rs:1:9
+   |
+LL | #![deny(mismatched_lifetime_syntaxes)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: one option is to consistently use `'a`
+   |
+LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &'a u8 {
+   |                                                          ++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:16:57
+   |
+LL | fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 {
+   |                                                         ^^         -- the lifetime gets resolved as `'a`
+   |                                                         |
+   |                                                         this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL - fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 {
+LL + fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'a u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:23:48
+   |
+LL | fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime) -> ContainsLifetime<'_> {
+   |                                                ^^^^^^^^^^^^^^^^                      -- the lifetime gets resolved as `'_`
+   |                                                |
+   |                                                this lifetime flows to the output
+   |
+help: one option is to consistently use `'_`
+   |
+LL | fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime<'_>) -> ContainsLifetime<'_> {
+   |                                                                ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:28:65
+   |
+LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime {
+   |                                                                 ^^      ---------------- the lifetime gets resolved as `'_`
+   |                                                                 |
+   |                                                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'_`
+   |
+LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime<'_> {
+   |                                                                                         ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:33:65
+   |
+LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime {
+   |                                                                 ^^      ---------------- the lifetime gets resolved as `'a`
+   |                                                                 |
+   |                                                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime<'a> {
+   |                                                                                         ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:39:25
+   |
+LL |     v: ContainsLifetime<'a>,
+   |                         ^^ this lifetime flows to the output
+LL |
+LL | ) -> ContainsLifetime<'_> {
+   |                       -- the lifetime gets resolved as `'a`
+   |
+help: one option is to consistently use `'a`
+   |
+LL - ) -> ContainsLifetime<'_> {
+LL + ) -> ContainsLifetime<'a> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:47:37
+   |
+LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime {
+   |                                     ^^^     ---------------- the lifetime gets resolved as `'_`
+   |                                     |
+   |                                     this lifetime flows to the output
+   |
+help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
+   |
+LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime<'_> {
+   |                                                             ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:52:48
+   |
+LL | fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime {
+   |                                                ^^        ---------------- the lifetime gets resolved as `'_`
+   |                                                |
+   |                                                this lifetime flows to the output
+   |
+help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
+   |
+LL - fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime {
+LL + fn explicit_anonymous_ref_to_implicit_path(v: &u8) -> ContainsLifetime<'_> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:57:48
+   |
+LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime {
+   |                                                ^^        ---------------- the lifetime gets resolved as `'a`
+   |                                                |
+   |                                                this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime<'a> {
+   |                                                                          ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:62:58
+   |
+LL | fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> {
+   |                                                          ^^                         -- the lifetime gets resolved as `'a`
+   |                                                          |
+   |                                                          this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL - fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> {
+LL + fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'a> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:69:37
+   |
+LL | fn implicit_path_to_implicit_ref(v: ContainsLifetime) -> &u8 {
+   |                                     ^^^^^^^^^^^^^^^^     --- the lifetime gets resolved as `'_`
+   |                                     |
+   |                                     this lifetime flows to the output
+   |
+help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
+   |
+LL | fn implicit_path_to_implicit_ref(v: ContainsLifetime<'_>) -> &u8 {
+   |                                                     ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:74:47
+   |
+LL | fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 {
+   |                                               ^^^^^^^^^^^^^^^^      -- the lifetime gets resolved as `'_`
+   |                                               |
+   |                                               this lifetime flows to the output
+   |
+help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
+   |
+LL - fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 {
+LL + fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime<'_>) -> &u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:79:64
+   |
+LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &u8 {
+   |                                                                ^^      --- the lifetime gets resolved as `'a`
+   |                                                                |
+   |                                                                this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 {
+   |                                                                         ++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:84:74
+   |
+LL | fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 {
+   |                                                                          ^^       -- the lifetime gets resolved as `'a`
+   |                                                                          |
+   |                                                                          this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL - fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 {
+LL + fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:90:55
+   |
+LL |     fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &u8 {
+   |                                                       ^^          --- the lifetime gets resolved as `'a`
+   |                                                       |
+   |                                                       this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL |     fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &'a u8 {
+   |                                                                    ++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:95:65
+   |
+LL |     fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 {
+   |                                                                 ^^           -- the lifetime gets resolved as `'a`
+   |                                                                 |
+   |                                                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 {
+LL +     fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'a u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:102:56
+   |
+LL |     fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime {
+   |                                                        ^^          ---------------- the lifetime gets resolved as `'_`
+   |                                                        |
+   |                                                        this lifetime flows to the output
+   |
+help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
+   |
+LL -     fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime {
+LL +     fn method_explicit_anonymous_ref_to_implicit_path(&self) -> ContainsLifetime<'_> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:107:56
+   |
+LL |     fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime {
+   |                                                        ^^          ---------------- the lifetime gets resolved as `'a`
+   |                                                        |
+   |                                                        this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL |     fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime<'a> {
+   |                                                                                    ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:112:66
+   |
+LL |     fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> {
+   |                                                                  ^^                           -- the lifetime gets resolved as `'a`
+   |                                                                  |
+   |                                                                  this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> {
+LL +     fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'a> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:127:39
+   |
+LL |     fn static_ref_to_implicit_ref(v: &'static u8) -> &u8 {
+   |                                       ^^^^^^^        --- the lifetime gets resolved as `'static`
+   |                                       |
+   |                                       this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL |     fn static_ref_to_implicit_ref(v: &'static u8) -> &'static u8 {
+   |                                                       +++++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:132:49
+   |
+LL |     fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 {
+   |                                                 ^^^^^^^         -- the lifetime gets resolved as `'static`
+   |                                                 |
+   |                                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL -     fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 {
+LL +     fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'static u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:137:40
+   |
+LL |     fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime {
+   |                                        ^^^^^^^        ---------------- the lifetime gets resolved as `'static`
+   |                                        |
+   |                                        this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL |     fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime<'static> {
+   |                                                                       +++++++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:142:50
+   |
+LL |     fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> {
+   |                                                  ^^^^^^^                         -- the lifetime gets resolved as `'static`
+   |                                                  |
+   |                                                  this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL -     fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> {
+LL +     fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'static> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:148:40
+   |
+LL |         fn static_ref_to_implicit_ref(&'static self) -> &u8 {
+   |                                        ^^^^^^^          --- the lifetime gets resolved as `'static`
+   |                                        |
+   |                                        this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL |         fn static_ref_to_implicit_ref(&'static self) -> &'static u8 {
+   |                                                          +++++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:153:50
+   |
+LL |         fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 {
+   |                                                  ^^^^^^^           -- the lifetime gets resolved as `'static`
+   |                                                  |
+   |                                                  this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL -         fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 {
+LL +         fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'static u8 {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:158:41
+   |
+LL |         fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime {
+   |                                         ^^^^^^^          ---------------- the lifetime gets resolved as `'static`
+   |                                         |
+   |                                         this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL |         fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime<'static> {
+   |                                                                          +++++++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:163:51
+   |
+LL |         fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> {
+   |                                                   ^^^^^^^                           -- the lifetime gets resolved as `'static`
+   |                                                   |
+   |                                                   this lifetime flows to the output
+   |
+help: one option is to consistently use `'static`
+   |
+LL -         fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> {
+LL +         fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'static> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:175:55
+   |
+LL |     fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ {
+   |                                                       ^^                        -- the lifetime gets resolved as `'a`
+   |                                                       |
+   |                                                       this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ {
+LL +     fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + 'a {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:180:65
+   |
+LL |     fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> {
+   |                                                                 ^^                            -- the lifetime gets resolved as `'a`
+   |                                                                 |
+   |                                                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> {
+LL +     fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'a> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:185:72
+   |
+LL |     fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ {
+   |                                                                        ^^                      -- the lifetime gets resolved as `'a`
+   |                                                                        |
+   |                                                                        this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ {
+LL +     fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + 'a {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:191:29
+   |
+LL |         v: ContainsLifetime<'a>,
+   |                             ^^ this lifetime flows to the output
+LL |
+LL |     ) -> impl FnOnce() + use<'_> {
+   |                              -- the lifetime gets resolved as `'a`
+   |
+help: one option is to consistently use `'a`
+   |
+LL -     ) -> impl FnOnce() + use<'_> {
+LL +     ) -> impl FnOnce() + use<'a> {
+   |
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:205:54
+   |
+LL |     fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &u8> + '_> {
+   |                                                      ^^                                ---    -- the lifetimes get resolved as `'a`
+   |                                                      |                                 |
+   |                                                      |                                 the lifetimes get resolved as `'a`
+   |                                                      this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL |     fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &'a u8> + '_> {
+   |                                                                                         ++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:211:29
+   |
+LL |         v: ContainsLifetime<'a>,
+   |                             ^^ this lifetime flows to the output
+LL |
+LL |     ) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> {
+   |                                  ----------------    -- the lifetimes get resolved as `'a`
+   |                                  |
+   |                                  the lifetimes get resolved as `'a`
+   |
+help: one option is to consistently use `'a`
+   |
+LL |     ) -> Box<dyn Iterator<Item = ContainsLifetime<'a>> + '_> {
+   |                                                  ++++
+
+error: lifetime flowing from input to output with different syntax can be confusing
+  --> $DIR/mismatched-lifetime-syntaxes.rs:220:33
+   |
+LL |     fn multiple_outputs<'a>(v: &'a u8) -> (&u8, &u8) {
+   |                                 ^^         ---  --- the lifetimes get resolved as `'a`
+   |                                 |          |
+   |                                 |          the lifetimes get resolved as `'a`
+   |                                 this lifetime flows to the output
+   |
+help: one option is to consistently use `'a`
+   |
+LL |     fn multiple_outputs<'a>(v: &'a u8) -> (&'a u8, &'a u8) {
+   |                                             ++      ++
+
+error: aborting due to 34 previous errors
+