Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
managed to reduce the test case a bit.
Also happens for this code using a function instead of an associated type:
claim
initial example fixed by , associated function fixed by instead

Discussion:
} } <ins> /// The resolution of a path or export. </ins> #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(HashStable_Generic)] pub enum Res<Id = hir::HirId> {

}; if let Some(path) = path { <del> let arg_index = path </del> <ins> // We've encountered an `AnonConst` in some path, so we need to // figure out which generic parameter it corresponds to and return // the relevant type. let (arg_index, segment) = path </ins> .segments .iter() <del> .filter_map(|seg| seg.args.as_ref()) .map(|generic_args| generic_args.args) .find_map(|args| { </del> <ins> .filter_map(|seg| seg.args.as_ref().map(|args| (args.args, seg))) .find_map(|(args, seg)| { </ins> args.iter() .filter(|arg| arg.is_const()) .enumerate() .filter(|(_, arg)| arg.id() == hir_id) <del> .map(|(index, _)| index) </del> <ins> .map(|(index, _)| (index, seg)) </ins> .next() }) .unwrap_or_else(|| { bug!("no arg matching AnonConst in path"); }); <del> // We've encountered an `AnonConst` in some path, so we need to // figure out which generic parameter it corresponds to and return // the relevant type. let generics = match path.res { Res::Def(DefKind::Ctor(..), def_id) | Res::Def(DefKind::AssocTy, def_id) => { </del> <ins> // Try to use the segment resolution if it is valid, otherwise we // default to the path resolution. let res = segment.res.filter(|&r| r != Res::Err).unwrap_or(path.res); let generics = match res { Res::Def(DefKind::Ctor(..), def_id) => { </ins> tcx.generics_of(tcx.parent(def_id).unwrap()) } Res::Def(_, def_id) => tcx.generics_of(def_id),

tcx.sess.delay_span_bug( DUMMY_SP, &format!( <del> "unexpected const parent path def, parent: {:?}, def: {:?}", parent_node, res </del> <ins> "unexpected anon const res {:?} in path: {:?}", res, path, </ins> ), ); return tcx.types.err;

tcx.sess.delay_span_bug( DUMMY_SP, &format!( <del> "missing generic parameter for `AnonConst`, parent {:?}", parent_node </del> <ins> "missing generic parameter for `AnonConst`, parent: {:?}, res: {:?}", parent_node, res </ins> ), ); tcx.types.err

#![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] #![feature(nll)] <ins> #![feature(or_patterns)] </ins> #![feature(try_blocks)] #![feature(never_type)] #![feature(slice_partition_dedup)]

<ins> // check-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash trait T<const A: usize> { fn f(); } struct S; impl T<0usize> for S { fn f() {} } fn main() { let _err = <S as T<0usize>>::f(); } </ins>

<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/issue70273-assoc-fn.rs:3:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default </ins>

<ins> // run-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash trait T<const A: usize> { fn l<const N: bool>() -> usize; fn r<const N: bool>() -> bool; } struct S; impl<const N: usize> T<N> for S { fn l<const M: bool>() -> usize { N } fn r<const M: bool>() -> bool { M } } fn main() { assert_eq!(<S as T<123>>::l::<true>(), 123); assert!(<S as T<123>>::r::<true>()); } </ins>

<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/type_of_anon_const.rs:3:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default </ins>