Change:
<!-- While learning rust from the book i tried printing the second(.1) value in a tuple, and it broke the format string and wouldn't compile --I tried this code: I expected to see this happen: printing of the value 1. Instead, this happened: it gave the following error: if you intended to print , you can escape it using rustc <!-- 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. --:
Only printing an identifer is supported, arbitrary expressions are not: https://rust-
There's more discussion about this in or in many other places, it's a thing that keeps coming up.
The error message could be nicer, so I'll convert it into a diagnostics issue.

Discussion:
let byte_pos = self.to_span_index(end); let start = InnerOffset(byte_pos.0 + 1); let field = self.argument(start); <del> // We can only parse `foo.bar` field access, any deeper nesting, // or another type of expression, like method calls, are not supported </del> <ins> // We can only parse simple `foo.bar` field access or `foo.0` tuple index access, any // deeper nesting, or another type of expression, like method calls, are not supported </ins> if !self.consume('}') { return; } if let ArgumentNamed(_) = arg.position { <del> if let ArgumentNamed(_) = field.position { self.errors.insert( 0, ParseError { description: "field access isn't supported".to_string(), note: None, label: "not supported".to_string(), span: InnerSpan::new(arg.position_span.start, field.position_span.end), secondary_label: None, suggestion: Suggestion::UsePositional, }, ); } </del> <ins> match field.position { ArgumentNamed(_) => { self.errors.insert( 0, ParseError { description: "field access isn't supported".to_string(), note: None, label: "not supported".to_string(), span: InnerSpan::new( arg.position_span.start, field.position_span.end, ), secondary_label: None, suggestion: Suggestion::UsePositional, }, ); } ArgumentIs(_) => { self.errors.insert( 0, ParseError { description: "tuple index access isn't supported".to_string(), note: None, label: "not supported".to_string(), span: InnerSpan::new( arg.position_span.start, field.position_span.end, ), secondary_label: None, suggestion: Suggestion::UsePositional, }, ); } _ => {} }; </ins> } } }

<ins> // Checks that there is a suggestion for simple tuple index access expression (used where an // identifier is expected in a format arg) to use positional arg instead. // Issue: <https://github.com/rust-lang/rust/issues/122535>. //@ run-rustfix fn main() { let x = (1,); println!("{0}", x.0); //~^ ERROR invalid format string } </ins>

<ins> // Checks that there is a suggestion for simple tuple index access expression (used where an // identifier is expected in a format arg) to use positional arg instead. // Issue: <https://github.com/rust-lang/rust/issues/122535>. //@ run-rustfix fn main() { let x = (1,); println!("{x.0}"); //~^ ERROR invalid format string } </ins>

<ins> error: invalid format string: tuple index access isn't supported --> $DIR/format-args-non-identifier-diagnostics.rs:8:16 | LL |     println!("{x.0}"); |                ^^^ not supported in format string | help: consider using a positional formatting argument instead | LL |     println!("{0}", x.0); |                ~  +++++ error: aborting due to 1 previous error </ins>