]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #77224 - RalfJung:rollup-hdvb96c, r=RalfJung
authorbors <bors@rust-lang.org>
Sat, 26 Sep 2020 17:50:26 +0000 (17:50 +0000)
committerbors <bors@rust-lang.org>
Sat, 26 Sep 2020 17:50:26 +0000 (17:50 +0000)
Rollup of 12 pull requests

Successful merges:

 - #75454 (Explicitly document the size guarantees that Option makes.)
 - #76631 (Add `x.py setup`)
 - #77076 (Add missing code examples on slice iter types)
 - #77093 (merge `need_type_info_err(_const)`)
 - #77122 (Add `#![feature(const_fn_floating_point_arithmetic)]`)
 - #77127 (Update mdBook)
 - #77161 (Remove TrustedLen requirement from BuilderMethods::switch)
 - #77166 (update Miri)
 - #77181 (Add doc alias for pointer primitive)
 - #77204 (Remove stray word from `ClosureKind::extends` docs)
 - #77207 (Rename `whence` to `span`)
 - #77211 (Remove unused #[allow(...)] statements from compiler/)

Failed merges:

 - #77170 (Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`)

r? `@ghost`

compiler/rustc_builtin_macros/src/format.rs
src/test/ui/fmt/format-args-capture-missing-variables.rs
src/test/ui/fmt/format-args-capture-missing-variables.stderr

index 5d6f791f1371935efc298b714e85c54363e7e496..550524e652af7eb20327b5ac4b17503cea1552d4 100644 (file)
@@ -543,9 +543,12 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
                             let idx = self.args.len();
                             self.arg_types.push(Vec::new());
                             self.arg_unique_types.push(Vec::new());
-                            self.args.push(
-                                self.ecx.expr_ident(self.fmtsp, Ident::new(name, self.fmtsp)),
-                            );
+                            let span = if self.is_literal {
+                                *self.arg_spans.get(self.curpiece).unwrap_or(&self.fmtsp)
+                            } else {
+                                self.fmtsp
+                            };
+                            self.args.push(self.ecx.expr_ident(span, Ident::new(name, span)));
                             self.names.insert(name, idx);
                             self.verify_arg_type(Exact(idx), ty)
                         } else {
index 3c596ae3bb899e5ea796cdc98e9e5104a3329b4d..3a4b6144b04dbf9928a0fd7efcea5559953b6251 100644 (file)
@@ -5,7 +5,7 @@ fn main() {
     //~^ ERROR: cannot find value `foo` in this scope
     //~^^ ERROR: cannot find value `bar` in this scope
 
-    format!("{foo}");                //~ ERROR: cannot find value `foo` in this scope
+    format!("{foo}"); //~ ERROR: cannot find value `foo` in this scope
 
     format!("{valuea} {valueb}", valuea=5, valuec=7);
     //~^ ERROR cannot find value `valueb` in this scope
@@ -16,7 +16,7 @@ fn main() {
         {foo}
 
     "##);
-    //~^^^^^ ERROR: cannot find value `foo` in this scope
+    //~^^^ ERROR: cannot find value `foo` in this scope
 
-    panic!("{foo} {bar}", bar=1);    //~ ERROR: cannot find value `foo` in this scope
+    panic!("{foo} {bar}", bar=1); //~ ERROR: cannot find value `foo` in this scope
 }
index c3d740eef9d3cd1684e54e35d55104ba2c5aca94..ec2faa4185b3e82a892a30164d2017ce809a4eb9 100644 (file)
@@ -7,45 +7,40 @@ LL |     format!("{valuea} {valueb}", valuea=5, valuec=7);
    |             formatting specifier missing
 
 error[E0425]: cannot find value `foo` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:4:13
+  --> $DIR/format-args-capture-missing-variables.rs:4:17
    |
 LL |     format!("{} {foo} {} {bar} {}", 1, 2, 3);
-   |             ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+   |                 ^^^^^ not found in this scope
 
 error[E0425]: cannot find value `bar` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:4:13
+  --> $DIR/format-args-capture-missing-variables.rs:4:26
    |
 LL |     format!("{} {foo} {} {bar} {}", 1, 2, 3);
-   |             ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+   |                          ^^^^^ not found in this scope
 
 error[E0425]: cannot find value `foo` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:8:13
+  --> $DIR/format-args-capture-missing-variables.rs:8:14
    |
 LL |     format!("{foo}");
-   |             ^^^^^^^ not found in this scope
+   |              ^^^^^ not found in this scope
 
 error[E0425]: cannot find value `valueb` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:10:13
+  --> $DIR/format-args-capture-missing-variables.rs:10:23
    |
 LL |     format!("{valuea} {valueb}", valuea=5, valuec=7);
-   |             ^^^^^^^^^^^^^^^^^^^ not found in this scope
+   |                       ^^^^^^^^ not found in this scope
 
 error[E0425]: cannot find value `foo` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:14:13
+  --> $DIR/format-args-capture-missing-variables.rs:16:9
    |
-LL |       format!(r##"
-   |  _____________^
-LL | |
-LL | |         {foo}
-LL | |
-LL | |     "##);
-   | |_______^ not found in this scope
+LL |         {foo}
+   |         ^^^^^ not found in this scope
 
 error[E0425]: cannot find value `foo` in this scope
-  --> $DIR/format-args-capture-missing-variables.rs:21:12
+  --> $DIR/format-args-capture-missing-variables.rs:21:13
    |
 LL |     panic!("{foo} {bar}", bar=1);
-   |            ^^^^^^^^^^^^^ not found in this scope
+   |             ^^^^^ not found in this scope
 
 error: aborting due to 7 previous errors