about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2020-10-18 22:40:50 +0100
committervarkor <github@varkor.com>2020-10-18 22:40:50 +0100
commitc0d29fe7d7a32dbadad161fe8a39bc996da3c633 (patch)
tree51a2fadcac062945bae5bccc87b2b3b5a03252c2 /compiler
parent28928c750c2c82b1bf27bd6100542f01a377e748 (diff)
downloadrust-c0d29fe7d7a32dbadad161fe8a39bc996da3c633.tar.gz
rust-c0d29fe7d7a32dbadad161fe8a39bc996da3c633.zip
Fix issue with specifying generic arguments for primitive types
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_typeck/src/collect/type_of.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs
index 4b3250a1d44..5fb6eaf69df 100644
--- a/compiler/rustc_typeck/src/collect/type_of.rs
+++ b/compiler/rustc_typeck/src/collect/type_of.rs
@@ -112,12 +112,16 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
                         tcx.sess.delay_span_bug(tcx.def_span(def_id), "anon const with Res::Err");
                         return None;
                     }
-                    _ => span_bug!(
-                        DUMMY_SP,
-                        "unexpected anon const res {:?} in path: {:?}",
-                        res,
-                        path,
-                    ),
+                    _ => {
+                        // If the user tries to specify generics on a type that does not take them,
+                        // e.g. `usize<T>`, we may hit this branch, in which case we treat it as if
+                        // no arguments have been passed. An error should already have been emitted.
+                        tcx.sess.delay_span_bug(
+                            tcx.def_span(def_id),
+                            &format!("unexpected anon const res {:?} in path: {:?}", res, path),
+                        );
+                        return None;
+                    }
                 };
 
                 generics