fn report_invalid_references(&self, numbered_position_args: bool) {
        let mut e;
        let sp = if self.is_literal {
            MultiSpan::from_spans(self.arg_spans.clone())
        } else {
            MultiSpan::from_span(self.fmtsp)
        };
        let mut refs: Vec<_> = self
            .invalid_refs
            .iter()
            .map(|(r, pos)| (r.to_string(), self.arg_spans.get(*pos)))
            .collect();

        if self.names.is_empty() && !numbered_position_args {
            e = self.ecx.mut_span_err(
                sp,
                &format!(
                    "{} positional argument{} in format string, but {}",
                         self.pieces.len(),
                         if self.pieces.len() > 1 { "s" } else { "" },
                    self.describe_num_args()
                ),
            );
        } else {
            let (arg_list, mut sp) = match refs.len() {
                1 => {
                    let (reg, pos) = refs.pop().unwrap();
                    (
                        format!("argument {}", reg),
                        MultiSpan::from_span(*pos.unwrap_or(&self.fmtsp)),
                    )
                }
                _ => {
                    let pos =
                        MultiSpan::from_spans(refs.iter().map(|(_, p)| *p.unwrap()).collect());
                    let mut refs: Vec<String> = refs.iter().map(|(s, _)| s.to_owned()).collect();
                    let reg = refs.pop().unwrap();
                    (
                        format!(
                            "arguments {head} and {tail}",
                            tail = reg,
                            head = refs.join(", ")
                        ),
                        pos,
                    )
                }
            };
            if !self.is_literal {
                sp = MultiSpan::from_span(self.fmtsp);
            }

            e = self.ecx.mut_span_err(sp,
                &format!("invalid reference to positional {} ({})",
                         arg_list,
                         self.describe_num_args()));
            e.note("positional arguments are zero-based");
        };

        e.emit();
    }
/// Handle invalid references to positional arguments. Output different
/// errors for the case where all arguments are positional and for when
/// there are named arguments or numbered positional arguments in the
/// format string.
Handle invalid references to positional arguments. Output different
errors for the case where all arguments are positional and for when
there are named arguments or numbered positional arguments in the
format string.
Handle invalid references to positional arguments . Output different errors for the case where all arguments are positional and for when there are named arguments or numbered positional arguments in the format string .
fn report_invalid_references(&self, numbered_position_args: bool) {
        let mut e;
        let sp = if self.is_literal {
            MultiSpan::from_spans(self.arg_spans.clone())
        } else {
            MultiSpan::from_span(self.fmtsp)
        };
        let mut refs: Vec<_> = self
            .invalid_refs
            .iter()
            .map(|(r, pos)| (r.to_string(), self.arg_spans.get(*pos)))
            .collect();
        if self.names.is_empty() && !numbered_position_args {
            e = self.ecx.mut_span_err(
                sp,
                &format!(
                    "{} positional argument{} in format string, but {}",
                         self.pieces.len(),
                         if self.pieces.len() > 1 { "s" } else { "" },
                    self.describe_num_args()
                ),
            );
        } else {
            let (arg_list, mut sp) = match refs.len() {
                1 => {
                    let (reg, pos) = refs.pop().unwrap();
                    (
                        format!("argument {}", reg),
                        MultiSpan::from_span(*pos.unwrap_or(&self.fmtsp)),
                    )
                }
                _ => {
                    let pos =
                        MultiSpan::from_spans(refs.iter().map(|(_, p)| *p.unwrap()).collect());
                    let mut refs: Vec<String> = refs.iter().map(|(s, _)| s.to_owned()).collect();
                    let reg = refs.pop().unwrap();
                    (
                        format!(
                            "arguments {head} and {tail}",
                            tail = reg,
                            head = refs.join(", ")
                        ),
                        pos,
                    )
                }
            };
            if !self.is_literal {
                sp = MultiSpan::from_span(self.fmtsp);
            }
            e = self.ecx.mut_span_err(sp,
                &format!("invalid reference to positional {} ({})",
                         arg_list,
                         self.describe_num_args()));
            e.note("positional arguments are zero-based");
        };
        e.emit();
    }
fn report_invalid_references ( & self , numbered_position_args : bool ) { let mut e ; let sp = if self . is_literal { MultiSpan :: from_spans ( self . arg_spans . clone ( ) ) } else { MultiSpan :: from_span ( self . fmtsp ) } ; let mut refs : Vec < _ > = self . invalid_refs . iter ( ) . map ( | ( r , pos ) | ( r . to_string ( ) , self . arg_spans . get ( * pos ) ) ) . collect ( ) ; if self . names . is_empty ( ) && ! numbered_position_args { e = self . ecx . mut_span_err ( sp , & format ! ( " " self pieces len ( ) if self pieces len ( ) 1 { " " } else { " " } self describe_num_args ( ) ) , ) ; } else { let ( arg_list , mut sp ) = match refs . len ( ) { 1 => { let ( reg , pos ) = refs . pop ( ) . unwrap ( ) ; ( format ! ( " " reg ) , MultiSpan :: from_span ( * pos . unwrap_or ( & self . fmtsp ) ) , ) } _ => { let pos = MultiSpan :: from_spans ( refs . iter ( ) . map ( | ( _ , p ) | * p . unwrap ( ) ) . collect ( ) ) ; let mut refs : Vec < String > = refs . iter ( ) . map ( | ( s , _ ) | s . to_owned ( ) ) . collect ( ) ; let reg = refs . pop ( ) . unwrap ( ) ; ( format ! ( " " tail reg head refs join ( " " ) ) , pos , ) } } ; if ! self . is_literal { sp = MultiSpan :: from_span ( self . fmtsp ) ; } e = self . ecx . mut_span_err ( sp , & format ! ( " " arg_list self describe_num_args ( ) ) ) ; e . note ( " " ) ; } ; e . emit ( ) ; }
Handle invalid references to positional arguments.
Handle invalid references to positional arguments .
&self
numbered_position_args
bool
&self
numbered_position_args
bool