Improve code for assert_index_within_bounds (#409)

* [core] improve code around assert_index_within_bounds

* [core] further simplify assert_index_within_bounds
16 jobs for master in 6 minutes and 3 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Check
passed #522319
linux-docker
check-std

00:01:42

passed #522320
linux-docker
check-wasm

00:01:51

 
  Workspace
passed #522321
linux-docker
build-std

00:01:58

passed #522322
linux-docker
build-wasm

00:02:21

passed #522325
linux-docker
clippy-std

00:01:33

failed #522326
linux-docker
clippy-wasm

00:00:28

passed #522324
linux-docker
codecov

00:03:20

failed #522327
linux-docker
fmt

00:00:33

passed #522323
linux-docker
test

00:02:36

 
  Examples
passed #522330
linux-docker
examples-clippy-std

00:01:10

skipped #522331
linux-docker
examples-clippy-wasm
skipped #522332
linux-docker
examples-contract-build
skipped #522329
linux-docker
examples-fmt
passed #522333
linux-docker
examples-generate-metadata

00:01:47

failed #522328
linux-docker
examples-test

00:01:08

 
  Publish
skipped #522334
linux-docker
publish-docs
 
Name Stage Failure
failed
examples-test Examples
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `accumulator`.

Caused by:
process didn't exit successfully: `sccache rustc --crate-name accumulator --edition=2018 accumulator/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --crate-type rlib --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="ink-as-dependency"' --cfg 'feature="ink_abi"' --cfg 'feature="std"' --cfg 'feature="test-env"' --cfg 'feature="type-metadata"' -C metadata=bbb50e3067ead159 --out-dir /ci-cache/ink/targets/master/examples-test/debug/deps -C incremental=/ci-cache/ink/targets/master/examples-test/debug/incremental -L dependency=/ci-cache/ink/targets/master/examples-test/debug/deps --extern ink_abi=/ci-cache/ink/targets/master/examples-test/debug/deps/libink_abi-b8813d74222f7132.rlib --extern ink_core=/ci-cache/ink/targets/master/examples-test/debug/deps/libink_core-2c6ef1c5b6e1aa34.rlib --extern ink_lang=/ci-cache/ink/targets/master/examples-test/debug/deps/libink_lang-23ea27bb0ef8caf5.rlib --extern ink_primitives=/ci-cache/ink/targets/master/examples-test/debug/deps/libink_primitives-bccecbb521a13249.rlib --extern scale=/ci-cache/ink/targets/master/examples-test/debug/deps/libparity_scale_codec-c3631c7641942e00.rlib --extern type_metadata=/ci-cache/ink/targets/master/examples-test/debug/deps/libtype_metadata-c0386e9c4bc54772.rlib` (exit code: 101)
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
failed
fmt Workspace
-            assert!(index < self.len(),
+ assert!(
+ index < self.len(),
"index out of bounds: the len is {} but the index is {}",
self.len(),
index
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
failed
clippy-wasm Workspace
error: could not compile `ink_alloc`.

Caused by:
process didn't exit successfully: `/usr/local/rustup/toolchains/nightly-2020-05-14-x86_64-unknown-linux-gnu/bin/clippy-driver rustc --crate-name ink_alloc --edition=2018 alloc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -Cembed-bitcode=no -C debuginfo=2 -C metadata=df46c1e1c856e644 -C extra-filename=-df46c1e1c856e644 --out-dir /ci-cache/ink/targets/master/clippy-wasm/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/ci-cache/ink/targets/master/clippy-wasm/wasm32-unknown-unknown/debug/incremental -L dependency=/ci-cache/ink/targets/master/clippy-wasm/wasm32-unknown-unknown/debug/deps -L dependency=/ci-cache/ink/targets/master/clippy-wasm/debug/deps --extern wee_alloc=/ci-cache/ink/targets/master/clippy-wasm/wasm32-unknown-unknown/debug/deps/libwee_alloc-1754bd530752b402.rmeta` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1