From 7175980ff51636f03824d67869e9a237c7d76ad5 Mon Sep 17 00:00:00 2001
From: Ellen <supbscripter@gmail.com>
Date: Mon, 13 Dec 2021 19:14:35 +0000
Subject: [PATCH 1/2] awdawdawd

---
 compiler/rustc_ast_lowering/src/lib.rs       |  3 +--
 compiler/rustc_hir/src/hir.rs                | 14 --------------
 compiler/rustc_resolve/src/late/lifetimes.rs |  9 ++++-----
 3 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index c04b0471cb7..4f571cd87a2 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -53,7 +53,7 @@ use rustc_hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
 use rustc_hir::def_id::{DefId, DefPathHash, LocalDefId, CRATE_DEF_ID};
 use rustc_hir::definitions::{DefKey, DefPathData, Definitions};
 use rustc_hir::intravisit;
-use rustc_hir::{ConstArg, GenericArg, InferKind, ParamName};
+use rustc_hir::{ConstArg, GenericArg, ParamName};
 use rustc_index::vec::{Idx, IndexVec};
 use rustc_query_system::ich::StableHashingContext;
 use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
@@ -1114,7 +1114,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                         return GenericArg::Infer(hir::InferArg {
                             hir_id: self.lower_node_id(ty.id),
                             span: self.lower_span(ty.span),
-                            kind: InferKind::Type,
                         });
                     }
                     // We parse const arguments as path types as we cannot distinguish them during
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index fdf7a8102a0..b8fe43ae10d 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -255,23 +255,9 @@ pub struct ConstArg {
     pub span: Span,
 }
 
-#[derive(Copy, Clone, Encodable, Debug, HashStable_Generic)]
-pub enum InferKind {
-    Const,
-    Type,
-}
-
-impl InferKind {
-    #[inline]
-    pub fn is_type(self) -> bool {
-        matches!(self, InferKind::Type)
-    }
-}
-
 #[derive(Encodable, Debug, HashStable_Generic)]
 pub struct InferArg {
     pub hir_id: HirId,
-    pub kind: InferKind,
     pub span: Span,
 }
 
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs
index c94c56df75b..05098defead 100644
--- a/compiler/rustc_resolve/src/late/lifetimes.rs
+++ b/compiler/rustc_resolve/src/late/lifetimes.rs
@@ -2541,8 +2541,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
                                 GenericParamDefKind::Type { object_lifetime_default, .. } => {
                                     Some(object_lifetime_default)
                                 }
-                                GenericParamDefKind::Lifetime
-                                | GenericParamDefKind::Const { .. } => None,
+                                GenericParamDefKind::Const { .. } => Some(Set1::Empty),
+                                GenericParamDefKind::Lifetime => None,
                             })
                             .collect()
                     })
@@ -2569,12 +2569,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
                 }
                 GenericArg::Const(ct) => {
                     self.visit_anon_const(&ct.value);
+                    i += 1;
                 }
                 GenericArg::Infer(inf) => {
                     self.visit_id(inf.hir_id);
-                    if inf.kind.is_type() {
-                        i += 1;
-                    }
+                    i += 1;
                 }
             }
         }

From 0a0f01410d378fc9d1ca27fe5a42f01092e0cf3e Mon Sep 17 00:00:00 2001
From: Ellen <supbscripter@gmail.com>
Date: Mon, 13 Dec 2021 19:47:10 +0000
Subject: [PATCH 2/2] test

---
 .../auxiliary/trait_object_lt_defaults_lib.rs |  1 +
 .../defaults/trait_object_lt_defaults.rs      | 24 +++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs
 create mode 100644 src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs

diff --git a/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs b/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs
new file mode 100644
index 00000000000..26a2c47ffb2
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs
@@ -0,0 +1 @@
+pub struct Foo<'a, const N: usize, T: 'a + ?Sized>(pub &'a T, [(); N]);
diff --git a/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs b/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs
new file mode 100644
index 00000000000..a1828727ecd
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs
@@ -0,0 +1,24 @@
+// aux-build:trait_object_lt_defaults_lib.rs
+// run-pass
+#![allow(dead_code)]
+extern crate trait_object_lt_defaults_lib;
+
+// Tests that `A<'a, 3, dyn Test>` is short for `A<'a, 3, dyn Test + 'a>`
+// and `Foo<'a, 3, dyn Test>` is short for `Foo<'a, 3, dyn Test + 'a>`
+// Test is in `const-generics/defaults` because it relies on param ordering
+
+trait Test {}
+
+struct A<'a, const N: usize, T: ?Sized + 'a>(&'a T, [(); N]);
+fn blah<'a>(mut a: A<'a, 3, dyn Test>, arg: &'a (dyn Test + 'a)) {
+    a.0 = arg;
+}
+
+fn other_blah<'a>(
+    mut a: trait_object_lt_defaults_lib::Foo<'a, 3, dyn Test>,
+    arg: &'a (dyn Test + 'a),
+) {
+    a.0 = arg;
+}
+
+fn main() {}