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

fix silent overflows on Step impls #36365

Merged
merged 11 commits into from
Nov 7, 2016

Conversation

matthew-piziak
Copy link
Contributor

Part of #36110

r? @eddyb

@@ -916,6 +916,20 @@ fn test_range_step() {
}

#[test]
#[should_panic]
fn test_range_overflow_unsigned() {
let mut it = u8::MAX..;
Copy link
Member

Choose a reason for hiding this comment

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

Won't these tests fail if compiled in release mode?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, that's a good point. Then these have to be run-fail with the overflow checking forced on (see src/test/run-fail/*overflow*.rs).

Copy link
Member

Choose a reason for hiding this comment

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

See #36372 for reference on making these tests.

@eddyb
Copy link
Member

eddyb commented Sep 13, 2016

@bors r+ Thanks!

@bors
Copy link
Contributor

bors commented Sep 13, 2016

📌 Commit 065bf4b has been approved by eddyb

@bors
Copy link
Contributor

bors commented Sep 14, 2016

⌛ Testing commit 065bf4b with merge 0154682...

@bors
Copy link
Contributor

bors commented Sep 14, 2016

💔 Test failed - auto-win-msvc-64-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

On Tue, Sep 13, 2016 at 7:18 PM, bors notifications@github.com wrote:

💔 Test failed - auto-win-msvc-64-opt-rustbuild
https://buildbot.rust-lang.org/builders/auto-win-msvc-64-opt-rustbuild/builds/2486


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#36365 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95EWeF6rKv73hOHXH5igvSEAkWotsks5qp1lbgaJpZM4J5OGd
.

@bors
Copy link
Contributor

bors commented Sep 15, 2016

⌛ Testing commit 065bf4b with merge 16ca4ec...

@bors
Copy link
Contributor

bors commented Sep 15, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@bluss
Copy link
Member

bluss commented Sep 24, 2016

Test doesn't pass and needs update

@alexcrichton
Copy link
Member

Could this also use the strategy in another PR to use Add::add and Sub::sub (UFCS) instead of the unstable attributes?

@matthew-piziak
Copy link
Contributor Author

Sorry for the inactivity. I've been traveling for a few weeks.

@alexcrichton Can you elaborate, or link the PR if you remember which one it was?

@@ -95,11 +95,13 @@ macro_rules! step_impl_unsigned {
}

#[inline]
#[rustc_inherit_overflow_checks]
fn add_one(&self) -> Self {
*self + 1
Copy link
Member

Choose a reason for hiding this comment

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

Add::add(*self, 1) is what @alexcrichton meant. Similar situation on the rest.

@alexcrichton
Copy link
Member

Looks like travis failures may be legit?

@matthew-piziak
Copy link
Contributor Author

I'm missing something here. My tests are failing on explicit panic instead of overflowing as expected.

@alexcrichton
Copy link
Member

The current failures look like:

failures:
thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:298

---- [run-fail] run-fail/iter-step-overflow-debug.rs stdout ----

error: failure produced the wrong error: exit code: 0
status: exit code: 0
command: /build/build/x86_64-unknown-linux-gnu/test/run-fail/iter-step-overflow-debug.stage2-x86_64-unknown-linux-gnu 
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread 'main' panicked at 'attempt to add with overflow', src/libcore/ops.rs:315
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'main' panicked at 'attempt to add with overflow', src/libcore/ops.rs:315

------------------------------------------

thread '[run-fail] run-fail/iter-step-overflow-debug.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2377
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- [run-fail] run-fail/iter-step-overflow-ndebug.rs stdout ----

error: no error pattern specified in "/build/src/test/run-fail/iter-step-overflow-ndebug.rs"
thread '[run-fail] run-fail/iter-step-overflow-ndebug.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:1588


failures:
    [run-fail] run-fail/iter-step-overflow-debug.rs
    [run-fail] run-fail/iter-step-overflow-ndebug.rs

I think these tests should be run-pass tests instead of run-fail tests perhaps?

@alexcrichton
Copy link
Member

Looks like travis may unfortunately still be failing?

---- [run-pass] run-pass/iter-step-overflow-ndebug.rs stdout ----

error: test run failed!
status: exit code: 101
command: /build/build/x86_64-unknown-linux-gnu/test/run-pass/iter-step-overflow-ndebug.stage2-x86_64-unknown-linux-gnu 
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread 'main' panicked at 'assertion failed: `(left == right)` (left: `255`, right: `0`)', /build/src/test/run-pass/iter-step-overflow-ndebug.rs:15
note: Run with `RUST_BACKTRACE=1` for a backtrace.

------------------------------------------

thread '[run-pass] run-pass/iter-step-overflow-ndebug.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2377
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    [run-pass] run-pass/iter-step-overflow-ndebug.rs

@steveklabnik
Copy link
Member

Looks like travis is passing now, r? @eddyb

@eddyb
Copy link
Member

eddyb commented Nov 7, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Nov 7, 2016

📌 Commit 8f19d5c has been approved by eddyb

@bors
Copy link
Contributor

bors commented Nov 7, 2016

⌛ Testing commit 8f19d5c with merge 57f971b...

bors added a commit that referenced this pull request Nov 7, 2016
fix silent overflows on `Step` impls

Part of #36110

r? @eddyb
@bors bors mentioned this pull request Nov 7, 2016
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.

7 participants