X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Ftraits%2Fon_unimplemented.rs;h=b39c00a56e349ad13c5933b9f6e55c9f69d1b176;hb=f49f38871389041671cc710a044e8360091840a3;hp=c1c814f9b0371218a0415b78d2b8479cd394cd4e;hpb=eec3a9c4af5067c37f5b681599a48b4e21098260;p=rust.git diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index c1c814f9b03..b39c00a56e3 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -248,6 +248,8 @@ fn verify( Position::ArgumentNamed(s) if s == sym::from_method => (), // `{from_desugaring}` is allowed Position::ArgumentNamed(s) if s == sym::from_desugaring => (), + // `{ItemContext}` is allowed + Position::ArgumentNamed(s) if s == sym::item_context => (), // So is `{A}` if A is a type parameter Position::ArgumentNamed(s) => match generics.params.iter().find(|param| { param.name == s @@ -296,6 +298,7 @@ pub fn format( let s = self.0.as_str(); let parser = Parser::new(&s, None, vec![], false); + let item_context = (options.get(&sym::item_context)).unwrap_or(&empty_string); parser.map(|p| match p { Piece::String(s) => s, @@ -311,6 +314,8 @@ pub fn format( } else if s == sym::from_desugaring || s == sym::from_method { // don't break messages using these two arguments incorrectly &empty_string + } else if s == sym::item_context { + &item_context } else { bug!("broken on_unimplemented {:?} for {:?}: \ no argument matching {:?}",