Skip to content

compiletest: Refactor compile-fail to regex. #14283

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

Merged
merged 1 commit into from
May 20, 2014

Conversation

Ryman
Copy link
Contributor

@Ryman Ryman commented May 18, 2014

Edit: This now only covers refactoring to regex.


let mut error_patterns = Vec::new();
// FIXME: Would be nice to use the regex! macro here (when it's available at stage0)
let re = Regex::new(r"^.*(//)~(?P<adjusts>[\^]*)\s*(?P<kind>\S*)\s*(?P<msg>.*)").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could wrap this in a private function that returns the regex object. Use #[cfg(stage0)] to have it construct it at runtime and unwrap, and #[cfg(not(stage0))] to have it use the macro and a static.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex is unnecessarily complicated. You can ditch the ^.* at the start, remove that first group, and replace the [\^] with \^. This looks like

let re = Regex::new(r"//~(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)").unwrap();

You can tell where this starts using pos(0).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could wrap this in a private function that returns the regex object. Use #[cfg(stage0)] to have it construct it at runtime and unwrap, and #[cfg(not(stage0))] to have it use the macro and a static.

It's not really a perf problem, just a nice to have, think it's worth adding this (minor) complexity?

This regex is unnecessarily complicated.

Yeah, I didn't really clean up the final version, mybad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a perf problem, just a nice to have, think it's worth adding this (minor) complexity?

I guess the answer depends on whether we can expect to get rid of the stage0 case.

Although I actually question whether we even need it. make check-stage0-cfail tells me

make: *** No rule to make target `x86_64-apple-darwin/stage0/bin/compiletest', needed by `tmp/check-stage0-T-x86_64-apple-darwin-H-x86_64-apple-darwin-cfail.ok'.  Stop

It appears the first compiletest I can build is the stage1 compiletest. It's built using the stage0 rustc, but I don't see why we can't ask the build system to compile the regex_macros crate.

That said, since it's probably more complicated than a 1-line change, it may make more sense just to stick with the dynamic approach. Of course this approach is unnecessarily recompiling the regex for every file, but I don't know if that performance hit is noticeable.

@Ryman Ryman changed the title compiletest: Ignore commented expected errors & refactor to regex. compiletest: Refactor compile-fail to regex. May 20, 2014
@Ryman
Copy link
Contributor Author

Ryman commented May 20, 2014

@kballard r?

@@ -33,6 +33,8 @@ use getopts::{optopt, optflag, reqopt};
use common::Config;
use common::{Pretty, DebugInfoGdb, Codegen};
use util::logv;
use regex::Regex;
use errors::EXPECTED_PATTERN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is unnecessary, you're referring to the pattern as errors::EXPECTED_PATTERN below (which works because errors is in scope).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

bors added a commit that referenced this pull request May 20, 2014
…llard

Edit: This now only covers refactoring to regex.
@bors bors closed this May 20, 2014
@bors bors merged commit 66d8c3c into rust-lang:master May 20, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Mar 13, 2023
Load proc-macros for rustc_private crates

If the client support our server status notification there is no need to show the pop up for workspace fetching failures since that's already going to be shown in the status.
cc rust-lang/rust-analyzer#14193
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 3, 2025
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 this pull request may close these issues.

3 participants