Skipping borrowck because of trivial const
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index acdeea9..168157c 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -115,6 +115,11 @@ fn mir_borrowck(
     def: LocalDefId,
 ) -> Result<&FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'_>>, ErrorGuaranteed> {
     assert!(!tcx.is_typeck_child(def.to_def_id()));
+    if tcx.is_trivial_const(def) {
+        debug!("Skipping borrowck because of trivial const");
+        let opaque_types = Default::default();
+        return Ok(tcx.arena.alloc(opaque_types));
+    }
     let (input_body, _) = tcx.mir_promoted(def);
     debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
 
diff --git a/compiler/rustc_mir_transform/src/trivial_const.rs b/compiler/rustc_mir_transform/src/trivial_const.rs
index 027e9ec..a2ab6ff 100644
--- a/compiler/rustc_mir_transform/src/trivial_const.rs
+++ b/compiler/rustc_mir_transform/src/trivial_const.rs
@@ -59,6 +59,10 @@ pub(crate) fn trivial_const<'a, 'tcx: 'a, F, B>(
         return None;
     }
 
+    if !tcx.opaque_types_defined_by(def).is_empty() {
+        return None;
+    }
+
     let body = body_provider();
 
     if body.has_opaque_types() {
diff --git a/tests/ui/traits/const-traits/trivial-const-ice-149278.rs b/tests/ui/traits/const-traits/trivial-const-ice-149278.rs
new file mode 100644
index 0000000..bfc49eb
--- /dev/null
+++ b/tests/ui/traits/const-traits/trivial-const-ice-149278.rs
@@ -0,0 +1,11 @@
+trait Trait2: Sized {}
+
+impl Trait2 for () {
+    const FOO: () = {
+        //~^ ERROR const `FOO` is not a member of trait `Trait2`
+        //~^^ ERROR item does not constrain `Assoc::{opaque#0}`
+        type Assoc = impl Copy; //~ ERROR `impl Trait` in type aliases is unstable
+    };
+}
+
+fn main() {}
diff --git a/tests/ui/traits/const-traits/trivial-const-ice-149278.stderr b/tests/ui/traits/const-traits/trivial-const-ice-149278.stderr
new file mode 100644
index 0000000..9b328bd
--- /dev/null
+++ b/tests/ui/traits/const-traits/trivial-const-ice-149278.stderr
@@ -0,0 +1,37 @@
+error[E0438]: const `FOO` is not a member of trait `Trait2`
+  --> $DIR/trivial-const-ice-149278.rs:4:5
+   |
+LL | /     const FOO: () = {
+LL | |
+LL | |
+LL | |         type Assoc = impl Copy;
+LL | |     };
+   | |______^ not a member of trait `Trait2`
+
+error[E0658]: `impl Trait` in type aliases is unstable
+  --> $DIR/trivial-const-ice-149278.rs:7:22
+   |
+LL |         type Assoc = impl Copy;
+   |                      ^^^^^^^^^
+   |
+   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
+   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error: item does not constrain `Assoc::{opaque#0}`
+  --> $DIR/trivial-const-ice-149278.rs:4:11
+   |
+LL |     const FOO: () = {
+   |           ^^^
+   |
+   = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
+note: this opaque type is supposed to be constrained
+  --> $DIR/trivial-const-ice-149278.rs:7:22
+   |
+LL |         type Assoc = impl Copy;
+   |                      ^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0438, E0658.
+For more information about an error, try `rustc --explain E0438`.
diff --git a/tests/ui/traits/next-solver/opaques/trivial-const-defines-opaque.rs b/tests/ui/traits/next-solver/opaques/trivial-const-defines-opaque.rs
new file mode 100644
index 0000000..addaba90
--- /dev/null
+++ b/tests/ui/traits/next-solver/opaques/trivial-const-defines-opaque.rs
@@ -0,0 +1,15 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Sized;
+
+#[define_opaque(Tait)]
+const FOO: Tait = 1;
+
+fn main() {
+    let _: Tait = FOO;
+}