Giter Club home page Giter Club logo

Comments (9)

shnewto avatar shnewto commented on June 19, 2024

I ran into this behavior yesterday using 0.0.180. It seems like the -A unsued added to the rustc args is suppressing more than just unused errors / warnings? I wasn't able to get a "found" error in any case until I added the following line to the test source. config.target_rustcflags = Some("-D unused".to_string());

from compiletest-rs.

iliekturtles avatar iliekturtles commented on June 19, 2024

I also ran into this issue and removing config.link_deps(); resolves the 0 unexpected errors issue (adding config.target_rustcflags = None; or config.target_rustcflags = Some("-D unused") has the same effect). I've included a formatted diff of the rustc commands called in both cases. The only differences is a number of additional -L options when the 0 unexpected errors happens.

config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string()); can be added to allow for references to the parent crate.

PATH="..."
"rustc" "tests/compile-fail\\vcw.rs"
"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Temp\\"
"--target=x86_64-pc-windows-msvc"
"--error-format" "json"
"-C" "prefer-dynamic"
"-o" "C:\\Users\\iliekturtles\\AppData\\Local\\Temp\\vcw.stage-id.exe"
-"-L" "D:\\Code\\Test\\rust\\uom\\target\\debug"
-"-L" "D:\\Code\\Test\\rust\\uom\\target\\debug\\deps"
-"-L" "C:\\Users\\iliekturtles\\.local\\share\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib"
-"-L" "C:\\Users\\iliekturtles\\.local\\share\\cargo\\bin"
-"-L" "C:\\Users\\iliekturtles\\.local\\share\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\bin"
-"-L" "C:\\Users\\iliekturtles\\bin"
-"-L" "C:\\Program" "Files\\Git\\mingw64\\bin"
-"-L" "C:\\Program" "Files\\Git\\usr\\local\\bin"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin"
-"-L" "C:\\Program" "Files\\Git\\mingw64\\bin"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin"
-"-L" "C:\\Users\\iliekturtles\\bin"
-"-L" "C:\\Program" "Files\\Common" "Files\\Microsoft" "Shared\\Microsoft" "Online" "Services"
-"-L" "C:\\Program" "Files" "(x86)\\Common" "Files\\Microsoft" "Shared\\Microsoft" "Online" "Services"
-"-L" "C:\\WINDOWS\\system32"
-"-L" "C:\\WINDOWS"
-"-L" "C:\\WINDOWS\\System32\\Wbem"
-"-L" "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\130\\Tools\\Binn"
-"-L" "C:\\Program" "Files\\Microsoft" "SQL" "Server\\130\\Tools\\Binn"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\130\\DTS\\Binn"
-"-L" "C:\\Program" "Files\\Microsoft" "SQL" "Server\\130\\DTS\\Binn"
-"-L" "C:\\Program" "Files\\Microsoft" "SQL" "Server\\Client" "SDK\\ODBC\\130\\Tools\\Binn"
-"-L" "C:\\Program" "Files\\dotnet"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\Client" "SDK\\ODBC\\130\\Tools\\Binn"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\140\\Tools\\Binn"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\140\\DTS\\Binn"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "SQL" "Server\\140\\Tools\\Binn\\ManagementStudio"
-"-L" "C:\\Program" "Files" "(x86)\\WebEx\\Productivity" "Tools"
-"-L" "C:\\Program" "Files\\TortoiseGit\\bin"
-"-L" "C:\\Program" "Files\\Git\\cmd"
-"-L" "C:\\Program" "Files\\Git\\mingw64\\bin"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin"
-"-L" "C:\\Users\\iliekturtles\\.local\\share\\cargo\\bin"
-"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Microsoft\\WindowsApps"
-"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Programs\\Git\\cmd"
-"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Programs\\Git\\mingw64\\bin"
-"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Programs\\Git\\usr\\bin"
-"-L" "C:\\Program" "Files" "(x86)\\Vim\\vim80"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin\\vendor_perl"
-"-L" "C:\\Program" "Files\\Git\\usr\\bin\\core_perl"
-"-L" "C:\\Program" "Files" "(x86)\\Microsoft" "Visual" "Studio\\2017\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin"
-"-L" "C:\\Users\\iliekturtles\\.local\\bin"
"-L" "C:\\Users\\iliekturtles\\AppData\\Local\\Temp\\vcw.stage-id.aux"
"-A" "unused"

from compiletest-rs.

laumann avatar laumann commented on June 19, 2024

@iliekturtles I think this is the same problem as #81. Many of the deleted -L have paths with spaces in them.

from compiletest-rs.

fpoli avatar fpoli commented on June 19, 2024

Any progress? I also got the 0 unexpected errors found, 1 expected errors not found, but I have no spaces in -L paths.

By the way, using // error-pattern: bla it works fine, it detects errors as expected.

from compiletest-rs.

laumann avatar laumann commented on June 19, 2024

@fpoli Not that I'm aware of. But your input wold indicate that's it not an issue with spaces in paths. A couple of questions:

  • What's your project? Can you link the code?
  • Have you tried the -D unused that @shnewto mentions?

If I understand you correctly, you're saying that

// error-pattern: bla

works, but

//~^ error-pattern: bla

does not?

from compiletest-rs.

fpoli avatar fpoli commented on June 19, 2024

This is the project: https://github.com/viperproject/prusti-dev

And this is the commit in which I try to replace //error-pattern: with //~ ERROR: viperproject/prusti-dev@8a7db41 (Travis build with the error: https://travis-ci.org/viperproject/prusti/jobs/397306881)

error-pattern is another test-suite special comment. I'm trying to get rid of it because it's undocumented (at least, it' not described in https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md) and less precise (it can't check the line number of the erro message).

error: 0 unexpected errors found, 3 expected errors not found
status: exit code: 101
command: "target/debug/prusti-driver" "tests/verify/fail/multiple-errors.rs"
"-L" "/tmp"
"--target=x86_64-unknown-linux-gnu"
"--error-format" "json"
"-C" "prefer-dynamic"
"-o" "/tmp/multiple-errors.stage-id"
"-Z" "mir-emit-validate=1"
"-Z" "borrowck=mir"
"--extern" "prusti_contracts=../target/debug/libprusti_contracts.rlib"
"-L" "/home/fpoli/src/prusti/prusti-dev/target/debug/build/backtrace-sys-cc31331497bea3dd/out/.libs"
"-L" "/home/fpoli/src/prusti/prusti-dev/target/debug"
"-L" "/home/fpoli/src/prusti/prusti-dev/target/debug/deps"
"-L" "/home/fpoli/.rustup/toolchains/nightly-2018-05-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib"
"-L" "/home/fpoli/.rustup/toolchains/nightly-2018-05-30-x86_64-unknown-linux-gnu/lib"
"-L" "/home/fpoli/.rustup/toolchains/nightly-2018-05-30-x86_64-unknown-linux-gnu/lib/"
"-L" "/usr/lib/jvm/default-java/jre/lib/amd64/server/"
"-L" "../target/debug/"
"-L" "/tmp/multiple-errors.stage-id.aux"
"-A" "unused"

Unfortunately in my case -D unused breaks some other unrelated ui tests. I'm working on it.

from compiletest-rs.

fpoli avatar fpoli commented on June 19, 2024

In my case -D unused doesn't solve the problem. Maybe because the error that I'm trying to test is generated from a compiler driver by using span_err_with_code.

from compiletest-rs.

fpoli avatar fpoli commented on June 19, 2024

It seems that the problem only affects macros: in this situation, the wrong file name and line number are read from the span.

In the example reported below the file name should be "tests/verify/fail/unreachable-fail.rs" and the line number should be 22, from the innermost span (inside expansion keys). However, push_expected_errors only considers the outer span, that has file name "" and line number 3.

Example of error message in JSON

 {
  "message": "unreachable!(..) statement might be reachable",
  "code": {
    "code": "P0004",
    "explanation": null
  },
  "level": "error",
  "spans": [
    {
      "file_name": "<panic macros>",
      "byte_start": 71,
      "byte_end": 175,
      "line_start": 3,
      "line_end": 4,
      "column_start": 1,
      "column_end": 74,
      "is_primary": true,
      "text": [
        {
          "text": "$ crate :: rt :: begin_panic (",
          "highlight_start": 1,
          "highlight_end": 31
        },
        {
          "text": "$ msg , & ( file ! (  ) , line ! (  ) , __rust_unstable_column ! (  ) ) ) } )",
          "highlight_start": 1,
          "highlight_end": 74
        }
      ],
      "label": null,
      "suggested_replacement": null,
      "suggestion_applicability": null,
      "expansion": {
        "span": {
          "file_name": "<unreachable macros>",
          "byte_start": 12,
          "byte_end": 66,
          "line_start": 1,
          "line_end": 1,
          "column_start": 13,
          "column_end": 67,
          "is_primary": false,
          "text": [
            {
              "text": "(  ) => ( { panic ! ( \"internal error: entered unreachable code\" ) } ) ; (",
              "highlight_start": 13,
              "highlight_end": 67
            }
          ],
          "label": null,
          "suggested_replacement": null,
          "suggestion_applicability": null,
          "expansion": {
            "span": {
              "file_name": "tests/verify/fail/unreachable-fail.rs",
              "byte_start": 352,
              "byte_end": 366,
              "line_start": 22,
              "line_end": 22,
              "column_start": 13,
              "column_end": 27,
              "is_primary": false,
              "text": [
                {
                  "text": "            unreachable!()  //~ ERROR unreachable!(..) statement might be reachable",
                  "highlight_start": 13,
                  "highlight_end": 27
                }
              ],
              "label": null,
              "suggested_replacement": null,
              "suggestion_applicability": null,
              "expansion": null
            },
            "macro_decl_name": "unreachable!",
            "def_site_span": {
              "file_name": "<unreachable macros>",
              "byte_start": 0,
              "byte_end": 334,
              "line_start": 1,
              "line_end": 8,
              "column_start": 1,
              "column_end": 12,
              "is_primary": false,
              "text": [
                {
                  "text": "(  ) => ( { panic ! ( \"internal error: entered unreachable code\" ) } ) ; (",
                  "highlight_start": 1,
                  "highlight_end": 75
                },
                {
                  "text": "$ msg : expr ) => ( { unreachable ! ( \"{}\" , $ msg ) } ) ; ( $ msg : expr , )",
                  "highlight_start": 1,
                  "highlight_end": 78
                },
                {
                  "text": "=> ( { unreachable ! ( $ msg ) } ) ; ( $ fmt : expr , $ ( $ arg : tt ) * ) =>",
                  "highlight_start": 1,
                  "highlight_end": 78
                },
                {
                  "text": "(",
                  "highlight_start": 1,
                  "highlight_end": 2
                },
                {
                  "text": "{",
                  "highlight_start": 1,
                  "highlight_end": 2
                },
                {
                  "text": "panic ! (",
                  "highlight_start": 1,
                  "highlight_end": 10
                },
                {
                  "text": "concat ! ( \"internal error: entered unreachable code: \" , $ fmt ) , $ ( $ arg",
                  "highlight_start": 1,
                  "highlight_end": 78
                },
                {
                  "text": ") * ) } ) ;",
                  "highlight_start": 1,
                  "highlight_end": 12
                }
              ],
              "label": null,
              "suggested_replacement": null,
              "suggestion_applicability": null,
              "expansion": null
            }
          }
        },
        "macro_decl_name": "panic!",
        "def_site_span": {
          "file_name": "<panic macros>",
          "byte_start": 0,
          "byte_end": 427,
          "line_start": 1,
          "line_end": 10,
          "column_start": 1,
          "column_end": 68,
          "is_primary": false,
          "text": [
            {
              "text": "(  ) => ( { panic ! ( \"explicit panic\" ) } ) ; ( $ msg : expr ) => (",
              "highlight_start": 1,
              "highlight_end": 69
            },
            {
              "text": "{",
              "highlight_start": 1,
              "highlight_end": 2
            },
            {
              "text": "$ crate :: rt :: begin_panic (",
              "highlight_start": 1,
              "highlight_end": 31
            },
            {
              "text": "$ msg , & ( file ! (  ) , line ! (  ) , __rust_unstable_column ! (  ) ) ) } )",
              "highlight_start": 1,
              "highlight_end": 78
            },
            {
              "text": "; ( $ msg : expr , ) => ( { panic ! ( $ msg ) } ) ; (",
              "highlight_start": 1,
              "highlight_end": 54
            },
            {
              "text": "$ fmt : expr , $ ( $ arg : tt ) + ) => (",
              "highlight_start": 1,
              "highlight_end": 41
            },
            {
              "text": "{",
              "highlight_start": 1,
              "highlight_end": 2
            },
            {
              "text": "$ crate :: rt :: begin_panic_fmt (",
              "highlight_start": 1,
              "highlight_end": 35
            },
            {
              "text": "& format_args ! ( $ fmt , $ ( $ arg ) + ) , & (",
              "highlight_start": 1,
              "highlight_end": 48
            },
            {
              "text": "file ! (  ) , line ! (  ) , __rust_unstable_column ! (  ) ) ) } ) ;",
              "highlight_start": 1,
              "highlight_end": 68
            }
          ],
          "label": null,
          "suggested_replacement": null,
          "suggestion_applicability": null,
          "expansion": null
        }
      }
    }
  ],
  "children": [
    
  ],
  "rendered": "error[P0004]: unreachable!(..) statement might be reachable\n  --> tests/verify/fail/unreachable-fail.rs:22:13\n   |\n22 |             unreachable!()  //~ ERROR unreachable!(..) statement might be reachable\n   |             ^^^^^^^^^^^^^^\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"
}

from compiletest-rs.

fpoli avatar fpoli commented on June 19, 2024

This is fixed in rust-lang/rust#52175

from compiletest-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.