Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0 unexpected errors #48

Closed
Andlon opened this issue Sep 24, 2016 · 9 comments
Closed

0 unexpected errors #48

Andlon opened this issue Sep 24, 2016 · 9 comments

Comments

@Andlon
Copy link

Andlon commented Sep 24, 2016

Hi!

I briefly evaluated using compiletest-rs for the rulinalg library and ran into some issues. I unfortunately don't have the time to create a completely minimal example, but the example is already quite minimal.

I also pushed the code to the compiletest branch on my fork of rulinalg. The crux of the matter is that compiletest-rs says:

error: 0 unexpected errors found, 1 expected errors not found

when rustc clearly shows that there should be an unexpected error.

Edit: This was using the nightly compiler:

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.13.0-nightly (1265cbf4e 2016-09-15)
@shnewto
Copy link

shnewto commented Jan 19, 2018

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());

@iliekturtles
Copy link

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"

@laumann
Copy link
Collaborator

laumann commented Apr 11, 2018

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

@fpoli
Copy link
Contributor

fpoli commented Jun 27, 2018

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.

@laumann
Copy link
Collaborator

laumann commented Jun 27, 2018

@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?

@fpoli
Copy link
Contributor

fpoli commented Jun 27, 2018

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.

@fpoli
Copy link
Contributor

fpoli commented Jun 27, 2018

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.

@fpoli
Copy link
Contributor

fpoli commented Jun 27, 2018

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"
}

@fpoli
Copy link
Contributor

fpoli commented Jul 20, 2018

This is fixed in rust-lang/rust#52175

fpoli added a commit to fpoli/compiletest-rs that referenced this issue Jul 24, 2018
Closes Manishearth#48

This commit corresponds to 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d on rust-lang/rust
fpoli added a commit to fpoli/compiletest-rs that referenced this issue Jul 27, 2018
Closes Manishearth#48

This commit corresponds to 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d on rust-lang/rust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants