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

Make treat_err_as_bug Option<NonZeroUsize> #82255

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

nhwn
Copy link
Contributor

@nhwn nhwn commented Feb 18, 2021

rustc -Z treat-err-as-bug=N already requires N to be nonzero when the argument is parsed, so changing the type from Option<usize> to Option<NonZeroUsize> is a low-hanging fruit in terms of layout optimization.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 18, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 18, 2021

Historically we haven't tried very much to optimize the slow path (i.e. when an error is emitted). Does this help with normal compilation?

(to be clear, I think this is a good change, but if it affects normal perf it should at least have a perf run.)

@jyn514 jyn514 added I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-error-handling Area: Error handling labels Feb 18, 2021
@nhwn
Copy link
Contributor Author

nhwn commented Feb 18, 2021

I don't think this has any benefits for compilation on the happy path, so I'm not sure if a perf run is necessary (unless this somehow causes regressions).

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

Looks good to me, don't think this warrants a perf run.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 22, 2021

📌 Commit 8ddd846 has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2021
Rollup of 12 pull requests

Successful merges:

 - rust-lang#79423 (Enable smart punctuation)
 - rust-lang#81154 (Improve design of `assert_len`)
 - rust-lang#81235 (Improve suggestion for tuple struct pattern matching errors.)
 - rust-lang#81769 (Suggest `return`ing tail expressions that match return type)
 - rust-lang#81837 (Slight perf improvement on char::to_ascii_lowercase)
 - rust-lang#81969 (Avoid `cfg_if` in `std::os`)
 - rust-lang#81984 (Make WASI's `hard_link` behavior match other platforms.)
 - rust-lang#82091 (use PlaceRef abstractions more consistently)
 - rust-lang#82128 (add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice)
 - rust-lang#82166 (add s390x-unknown-linux-musl target)
 - rust-lang#82234 (Remove query parameters when skipping search results)
 - rust-lang#82255 (Make `treat_err_as_bug` Option<NonZeroUsize>)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0e5bca5 into rust-lang:master Feb 23, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 23, 2021
@nhwn nhwn deleted the nonzero-err-as-bug branch February 23, 2021 11:37
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2021
Use u32 over Option<u32> in DebugLoc

~~Changes `Option<u32>` fields in `DebugLoc` to `Option<NonZeroU32>`. Since the respective fields (`line` and `col`) are guaranteed to be 1-based, this layout optimization is a freebie.~~

EDIT: Changes `Option<u32>` fields in `DebugLoc` to `u32`. As `@bugadani` pointed out, an `Option<NonZeroU32>` is probably an unnecessary layer of abstraction since the `None` variant is always used as `UNKNOWN_LINE_NUMBER` (which is just `0`).  Also, `SourceInfo` in `metadata.rs` already uses a `u32` instead of an `Option<u32>` to encode the same information, so I think this change is warranted.

Since `@jyn514` raised some concerns over measuring performance in a similar PR (rust-lang#82255), does this need a perf run?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-error-handling Area: Error handling I-compiletime Issue: Problems and improvements with respect to compile times. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants