matrix:
fast_finish: true
include:
- # Linux builders, all docker images
- - env: IMAGE=arm-android
- - env: IMAGE=armhf-gnu
- - env: IMAGE=cross DEPLOY=1
- - env: IMAGE=dist-aarch64-linux DEPLOY=1
- - env: IMAGE=dist-android DEPLOY=1
- - env: IMAGE=dist-arm-linux DEPLOY=1
- - env: IMAGE=dist-armhf-linux DEPLOY=1
- - env: IMAGE=dist-armv7-linux DEPLOY=1
- - env: IMAGE=dist-fuchsia DEPLOY=1
- - env: IMAGE=dist-i586-gnu-i686-musl DEPLOY=1
- - env: IMAGE=dist-i686-freebsd DEPLOY=1
- - env: IMAGE=dist-i686-linux DEPLOY=1
- - env: IMAGE=dist-mips-linux DEPLOY=1
- - env: IMAGE=dist-mips64-linux DEPLOY=1
- - env: IMAGE=dist-mips64el-linux DEPLOY=1
- - env: IMAGE=dist-mipsel-linux DEPLOY=1
- - env: IMAGE=dist-powerpc-linux DEPLOY=1
- - env: IMAGE=dist-powerpc64-linux DEPLOY=1
- - env: IMAGE=dist-powerpc64le-linux DEPLOY=1
- - env: IMAGE=dist-s390x-linux DEPLOY=1
- - env: IMAGE=dist-x86_64-freebsd DEPLOY=1
- - env: IMAGE=dist-x86_64-linux DEPLOY=1 ALLOW_TRY=1
- - env: IMAGE=dist-x86_64-musl DEPLOY=1
- - env: IMAGE=dist-x86_64-netbsd DEPLOY=1
- - env: IMAGE=asmjs
- - env: IMAGE=i686-gnu
- - env: IMAGE=i686-gnu-nopt
- # - env: IMAGE=wasm32 issue 42646
- - env: IMAGE=x86_64-gnu
- - env: IMAGE=x86_64-gnu-full-bootstrap
- - env: IMAGE=x86_64-gnu-aux
- - env: IMAGE=x86_64-gnu-debug
- - env: IMAGE=x86_64-gnu-nopt
+ # Images used in testing PR and try-build should be run first.
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1
- - env: IMAGE=x86_64-gnu-distcheck
- - env: IMAGE=x86_64-gnu-incremental
+ - env: IMAGE=dist-x86_64-linux DEPLOY=1 ALLOW_TRY=1
+
+ # "alternate" deployments, these are "nightlies" but don't have assertions
+ # turned on, they're deployed to a different location primarily for projects
+ # which are stuck on nightly and don't want llvm assertions in the artifacts
+ # that they use.
+ - env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1
+ - env: >
+ RUST_CHECK_TARGET=dist
+ RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler"
+ SRC=.
+ DEPLOY_ALT=1
+ RUSTC_RETRY_LINKER_ON_SEGFAULT=1
+ SCCACHE_ERROR_LOG=/tmp/sccache.log
+ MACOSX_DEPLOYMENT_TARGET=10.7
+ os: osx
+ osx_image: xcode7
+
+ # macOS builders. These are placed near the beginning because they are very
+ # slow to run.
# OSX builders running tests, these run the full test suite.
#
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
- install: &osx_install_sccache >
- travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin &&
- chmod +x /usr/local/bin/sccache &&
- travis_retry curl -o /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
- chmod +x /usr/local/bin/stamp
- env: >
RUST_CHECK_TARGET=check
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
- install: *osx_install_sccache
# OSX builders producing releases. These do not run the full test suite and
# just produce a bunch of artifacts.
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
- install:
- - travis_retry brew update
- - travis_retry brew install xz
- - *osx_install_sccache
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended --enable-sanitizers --enable-profiler"
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
- install:
- - travis_retry brew update
- - travis_retry brew install xz
- - *osx_install_sccache
- # "alternate" deployments, these are "nightlies" but don't have assertions
- # turned on, they're deployed to a different location primarily for projects
- # which are stuck on nightly and don't want llvm assertions in the artifacts
- # that they use.
- - env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1
- - env: >
- RUST_CHECK_TARGET=dist
- RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler"
- SRC=.
- DEPLOY_ALT=1
- RUSTC_RETRY_LINKER_ON_SEGFAULT=1
- SCCACHE_ERROR_LOG=/tmp/sccache.log
- MACOSX_DEPLOYMENT_TARGET=10.7
- os: osx
- osx_image: xcode7
- install:
- - travis_retry brew update
- - travis_retry brew install xz
- - *osx_install_sccache
+ # Linux builders, remaining docker images
+ - env: IMAGE=arm-android
+ - env: IMAGE=armhf-gnu
+ - env: IMAGE=cross DEPLOY=1
+ - env: IMAGE=dist-aarch64-linux DEPLOY=1
+ - env: IMAGE=dist-android DEPLOY=1
+ - env: IMAGE=dist-arm-linux DEPLOY=1
+ - env: IMAGE=dist-armhf-linux DEPLOY=1
+ - env: IMAGE=dist-armv7-linux DEPLOY=1
+ - env: IMAGE=dist-fuchsia DEPLOY=1
+ - env: IMAGE=dist-i586-gnu-i686-musl DEPLOY=1
+ - env: IMAGE=dist-i686-freebsd DEPLOY=1
+ - env: IMAGE=dist-i686-linux DEPLOY=1
+ - env: IMAGE=dist-mips-linux DEPLOY=1
+ - env: IMAGE=dist-mips64-linux DEPLOY=1
+ - env: IMAGE=dist-mips64el-linux DEPLOY=1
+ - env: IMAGE=dist-mipsel-linux DEPLOY=1
+ - env: IMAGE=dist-powerpc-linux DEPLOY=1
+ - env: IMAGE=dist-powerpc64-linux DEPLOY=1
+ - env: IMAGE=dist-powerpc64le-linux DEPLOY=1
+ - env: IMAGE=dist-s390x-linux DEPLOY=1
+ - env: IMAGE=dist-x86_64-freebsd DEPLOY=1
+ - env: IMAGE=dist-x86_64-musl DEPLOY=1
+ - env: IMAGE=dist-x86_64-netbsd DEPLOY=1
+ - env: IMAGE=asmjs
+ - env: IMAGE=i686-gnu
+ - env: IMAGE=i686-gnu-nopt
+ # - env: IMAGE=wasm32 issue 42646
+ - env: IMAGE=x86_64-gnu
+ - env: IMAGE=x86_64-gnu-full-bootstrap
+ - env: IMAGE=x86_64-gnu-aux
+ - env: IMAGE=x86_64-gnu-debug
+ - env: IMAGE=x86_64-gnu-nopt
+ - env: IMAGE=x86_64-gnu-distcheck
+ - env: IMAGE=x86_64-gnu-incremental
env:
global:
# AWS_SECRET_ACCESS_KEY=...
- secure: "Pixhh0hXDqGCdOyLtGFjli3J2AtDWIpyb2btIrLe956nCBDRutRoMm6rv5DI9sFZN07Mms7VzNNvhc9wCW1y63JAm414d2Co7Ob8kWMZlz9l9t7ACHuktUiis8yr+S4Quq1Vqd6pqi7pf2J++UxC8R/uLeqVrubzr6+X7AbmEFE="
-# Note that this is overridden on OSX builders
-install: >
- travis_retry curl -o $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl &&
- chmod +x $HOME/stamp &&
- export PATH=$PATH:$HOME
+before_install:
+ # If we are building a pull request, do the build if $ALLOW_PR == 1
+ # Otherwise, do the build if we are on the auto branch, or the try branch and $ALLOW_TRY == 1
+ - >
+ if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
+ if [[ "$ALLOW_PR" == "1" ]]; then
+ export SKIP_BUILD=false;
+ else
+ export SKIP_BUILD=true;
+ fi;
+ elif [[ "$TRAVIS_BRANCH" == "auto" || ( "$ALLOW_TRY" == "1" && "$TRAVIS_BRANCH" == "try" ) ]]; then
+ export SKIP_BUILD=false;
+ else
+ export SKIP_BUILD=true;
+ fi
+ - >
+ if [[ "$SKIP_BUILD" == false ]]; then
+ zcat $HOME/docker/rust-ci.tar.gz | docker load || true
+ fi
+ - mkdir -p $HOME/rustsrc
+
+install:
+ - >
+ if [[ "$SKIP_BUILD" == true ]]; then
+ echo echo skipping, not a full build > $HOME/stamp &&
+ chmod +x $HOME/stamp &&
+ export PATH=$PATH:$HOME;
+ else
+ case "$TRAVIS_OS_NAME" in
+ linux)
+ travis_retry curl -fo $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl &&
+ chmod +x $HOME/stamp &&
+ export PATH=$PATH:$HOME
+ ;;
+ osx)
+ if [[ "$RUST_CHECK_TARGET" == dist ]]; then
+ travis_retry brew update &&
+ travis_retry brew install xz;
+ fi &&
+ travis_retry curl -fo /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin &&
+ chmod +x /usr/local/bin/sccache &&
+ travis_retry curl -fo /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
+ chmod +x /usr/local/bin/stamp
+ ;;
+ esac
+ fi
before_script:
- >
echo "#### Disk usage before running script:";
df -h;
du . | sort -nr | head -n100
- # If we are building a pull request, do the build if $ALLOW_PR == 1
- # Otherwise, do the build if we are on the auto branch, or the try branch and $ALLOW_TRY == 1
- >
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
- if [[ "$ALLOW_PR" == "1" ]]; then
- SKIP_BUILD=false;
- else
- SKIP_BUILD=true;
- fi
- elif [[ "$TRAVIS_BRANCH" == "auto" || ( "$ALLOW_TRY" == "1" && "$TRAVIS_BRANCH" == "try" ) ]]; then
- SKIP_BUILD=false;
+ RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
+ if [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
else
- SKIP_BUILD=true;
- fi
-
- if [[ "$SKIP_BUILD" == true ]]; then
- export RUN_SCRIPT="echo 'skipping, not a full build'";
- else
- RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
- export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
- else
- export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
- fi
+ export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
fi
# Log time information from this machine and an external machine for insight into possible
# clock drift. Timezones don't matter since relative deltas give all the necessary info.
script:
- >
- date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'
+ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
- stamp sh -x -c "$RUN_SCRIPT"
- >
- date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'
+ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
after_success:
- >
grep -v missing |
xargs docker save |
gzip > $HOME/docker/rust-ci.tar.gz
-before_install:
- - zcat $HOME/docker/rust-ci.tar.gz | docker load || true
- - mkdir -p $HOME/rustsrc
notifications:
email: false
will run all the tests on every platform we support. If it all works out,
@bors will merge your code into `master` and close the pull request.
-[merge-queue]: https://buildbot.rust-lang.org/homu/queue/rust
+[merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust
Speaking of tests, Rust has a comprehensive test suite. More information about
it can be found
AWS_SECRET_ACCESS_KEY:
secure: 1UkmbiDd15tWtYbMm5O2Uqm0b0Ur8v1MoSlydxl4ojcroPeerRMlUges0l57py8c
SCCACHE_DIGEST: f808afabb4a4eb1d7112bcb3fa6be03b61e93412890c88e177c667eb37f46353d7ec294e559b16f9f4b5e894f2185fe7670a0df15fd064889ecbd80f0c34166c
+
+ # By default schannel checks revocation of certificates unlike some other SSL
+ # backends, but we've historically had problems on CI where a revocation
+ # server goes down presumably. See #43333 for more info
+ CARGO_HTTP_CHECK_REVOKE: false
+
matrix:
# 32/64 bit MSVC tests
- MSYS_BITS: 64
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "bin_lib"
+version = "0.1.0"
+
+[[package]]
+name = "bin_lib_no_cfg_test"
+version = "0.1.0"
+
[[package]]
name = "bitflags"
version = "0.7.0"
"toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "borrow_error"
+version = "0.1.0"
+
[[package]]
name = "bufstream"
version = "0.1.3"
[[package]]
name = "cargo"
version = "0.21.0"
-source = "git+https://github.com/rust-lang/cargo#1566c92b5d28e435613918e59dc94755f99d73b1"
+source = "git+https://github.com/rust-lang/cargo#5982cf904be1d72f575dcbd1e750c07bf730b966"
replace = "cargo 0.21.0"
[[package]]
"psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_ignored 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "completion"
+version = "0.1.0"
+
[[package]]
name = "core"
version = "0.0.0"
dependencies = [
"curl 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
dependencies = [
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "find_all_refs"
+version = "0.1.0"
+
+[[package]]
+name = "find_all_refs_no_cfg_test"
+version = "0.1.0"
+
[[package]]
name = "flate2"
version = "0.2.19"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "goto_def"
+version = "0.1.0"
+
[[package]]
name = "graphviz"
version = "0.0.0"
"pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "highlight"
+version = "0.1.0"
+
+[[package]]
+name = "hover"
+version = "0.1.0"
+
[[package]]
name = "idna"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "multiple_bins"
+version = "0.1.0"
+
[[package]]
name = "net2"
version = "0.2.29"
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "reformat"
+version = "0.1.0"
+
+[[package]]
+name = "reformat_with_range"
+version = "0.1.0"
+
[[package]]
name = "regex"
version = "0.1.80"
name = "remote-test-server"
version = "0.1.0"
+[[package]]
+name = "rename"
+version = "0.1.0"
+
[[package]]
name = "rls"
version = "0.1.0"
"languageserver-types 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"racer 2.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-analysis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-analysis 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-data 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustfmt-nightly 0.1.8 (git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustfmt-nightly 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rls-analysis"
-version = "0.4.2"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "rustfmt-nightly"
-version = "0.1.8"
-source = "git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492#7333dfc95b4af5c7283ba03f33c50f108d2be3f5"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "serde"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
"dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
-"checksum rls-analysis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34c9957e6a7e336978f9262dff7552f80b6c8588483f221a8e63f5b436010862"
+"checksum rls-analysis 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ea940411ed2ad6d1e705fc2a0b146a0a3f30f8098ba4e61b45b4e5f2bfa7ed63"
"checksum rls-data 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e502ac679bc35e023e982506c32d0278ef89e29af1e4ad21cb70c44b525b87a9"
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
"checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff"
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
-"checksum rustfmt-nightly 0.1.8 (git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492)" = "<none>"
+"checksum rustfmt-nightly 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6693f90ac7d0a2291aa309f5214f5f3ac1bd79961c11116fcf6d5545749bf2e7"
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
"checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d"
"checksum semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd61b85a0fa777f7fb7c454b9189b2941b110d1385ce84d7f76efdf1606a85"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-"checksum serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6a7c6b751a2e8d5df57a5ff71b5b4fc8aaee9ee28ff1341d640dd130bb5f4f7a"
-"checksum serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2f6ca58905ebd3c3b285a8a6d4f3ac92b92c0d7951d5649b1bdd212549c06639"
+"checksum serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "433d7d9f8530d5a939ad5e0e72a6243d2e42a24804f70bf592c679363dcacb2f"
+"checksum serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "7b707cf0d4cab852084f573058def08879bb467fda89d99052485e7d00edd624"
"checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a"
"checksum serde_ignored 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c10e798e4405d7dcec3658989e35ee6706f730a9ed7c1184d5ebd84317e82f46"
"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b"
"tools/rust-installer",
"tools/cargo",
"tools/rls",
+ # FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude
+ "tools/rls/test_data/borrow_error",
+ "tools/rls/test_data/completion",
+ "tools/rls/test_data/find_all_refs",
+ "tools/rls/test_data/find_all_refs_no_cfg_test",
+ "tools/rls/test_data/goto_def",
+ "tools/rls/test_data/highlight",
+ "tools/rls/test_data/hover",
+ "tools/rls/test_data/rename",
+ "tools/rls/test_data/reformat",
+ "tools/rls/test_data/bin_lib_no_cfg_test",
+ "tools/rls/test_data/multiple_bins",
+ "tools/rls/test_data/bin_lib",
+ "tools/rls/test_data/reformat_with_range",
]
# Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit
// This... is a bit of a hack how we detect this. Ideally this
// information should be encoded in the crate I guess? Would likely
// require an RFC amendment to RFC 1513, however.
- if crate_name == "panic_abort" {
+ //
+ // `compiler_builtins` are unconditionally compiled with panic=abort to
+ // workaround undefined references to `rust_eh_unwind_resume` generated
+ // otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
+ if crate_name == "panic_abort" ||
+ crate_name == "compiler_builtins" && stage != "0" {
cmd.arg("-C").arg("panic=abort");
}
use std::collections::HashSet;
use std::env;
+use std::ffi::OsString;
use std::iter;
use std::fmt;
use std::fs::{self, File};
/// Runs `cargo test` for `cargo` packaged with Rust.
pub fn cargo(build: &Build, stage: u32, host: &str) {
- let ref compiler = Compiler::new(stage, host);
-
- // Configure PATH to find the right rustc. NB. we have to use PATH
- // and not RUSTC because the Cargo test suite has tests that will
- // fail if rustc is not spelled `rustc`.
- let path = build.sysroot(compiler).join("bin");
- let old_path = env::var_os("PATH").unwrap_or_default();
- let newpath = env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("");
+ let compiler = &Compiler::new(stage, host);
let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
// available.
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
- try_run(build, cargo.env("PATH", newpath));
+ try_run(build, cargo.env("PATH", &path_for_cargo(build, compiler)));
+}
+
+/// Runs `cargo test` for the rls.
+pub fn rls(build: &Build, stage: u32, host: &str) {
+ let compiler = &Compiler::new(stage, host);
+
+ let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
+ cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
+
+ // Don't build tests dynamically, just a pain to work with
+ cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
+
+ build.add_rustc_lib_path(compiler, &mut cargo);
+
+ try_run(build, &mut cargo);
+}
+
+fn path_for_cargo(build: &Build, compiler: &Compiler) -> OsString {
+ // Configure PATH to find the right rustc. NB. we have to use PATH
+ // and not RUSTC because the Cargo test suite has tests that will
+ // fail if rustc is not spelled `rustc`.
+ let path = build.sysroot(compiler).join("bin");
+ let old_path = env::var_os("PATH").unwrap_or_default();
+ env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
}
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
check-aux:
$(Q)$(BOOTSTRAP) test \
src/tools/cargotest \
- cargo \
+ src/tools/cargo \
+ src/tools/rls \
src/test/pretty \
src/test/run-pass/pretty \
src/test/run-fail/pretty \
.dep(|s| s.name("librustc"))
.host(true)
.run(move |s| check::cargotest(build, s.stage, s.target));
- rules.test("check-cargo", "cargo")
+ rules.test("check-cargo", "src/tools/cargo")
.dep(|s| s.name("tool-cargo"))
.host(true)
.run(move |s| check::cargo(build, s.stage, s.target));
+ rules.test("check-rls", "src/tools/rls")
+ .dep(|s| s.name("tool-rls"))
+ .host(true)
+ .run(move |s| check::rls(build, s.stage, s.target));
rules.test("check-tidy", "src/tools/tidy")
.dep(|s| s.name("tool-tidy").stage(0))
.default(true)
download_ndk() {
mkdir -p /android/ndk
cd /android/ndk
- curl -O $URL/$1
+ curl -fO $URL/$1
unzip -q $1
rm $1
mv android-ndk-* ndk
download_sdk() {
mkdir -p /android/sdk
cd /android/sdk
- curl -O $URL/$1
+ curl -fO $URL/$1
unzip -q $1
rm -rf $1
}
set -ex
url="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2"
-curl $url | tar xjf -
+curl -f $url | tar xjf -
cd crosstool-ng
./configure --prefix=/usr/local
make -j$(nproc)
set -ex
-curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb
+curl -fOL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb
dpkg -i dumb-init_*.deb
rm dumb-init_*.deb
}
# Download last known good emscripten from WebAssembly waterfall
-BUILD=$(curl -L https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \
+BUILD=$(curl -fL https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \
jq '.build | tonumber')
-curl -L https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \
+curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \
hide_output tar xvkj
# node 8 is required to run wasm
cd /
-curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
+curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
tar -xJ
# Make emscripten use wasm-ready node and LLVM tools
}
cd /
-curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
+curl -fL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
tar -xz
cd /emsdk-portable
# node 8 is required to run wasm
cd /
-curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
+curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
tar -xJ
set -ex
-curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf -
+curl -f https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf -
cd make-3.81
./configure --prefix=/usr
make
set -ex
-curl -o /usr/local/bin/sccache \
+curl -fo /usr/local/bin/sccache \
https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl
chmod +x /usr/local/bin/sccache
/// A `Weak` pointer is useful for keeping a temporary reference to the value
/// within [`Rc`] without extending its lifetime. It is also used to prevent
/// circular references between [`Rc`] pointers, since mutual owning references
-/// would never allow either [`Arc`] to be dropped. For example, a tree could
+/// would never allow either [`Rc`] to be dropped. For example, a tree could
/// have strong [`Rc`] pointers from parent nodes to children, and `Weak`
/// pointers from children back to their parents.
///
}
macro_rules! default_impl {
- ($t:ty, $v:expr, $doc:expr) => {
+ ($t:ty, $v:expr, $doc:tt) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for $t {
#[inline]
/// This type does not support transmission of an error other than that an error
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
+///
+/// An important thing to remember is that the type `fmt::Error` should not be
+/// confused with `std::io::Error` or `std::error::Error`, which you may also
+/// have in scope.
+///
+/// # Examples
+///
+/// ```rust
+/// use std::fmt::{self, write};
+///
+/// let mut output = String::new();
+/// match write(&mut output, format_args!("Hello {}!", "world")) {
+/// Err(fmt::Error) => panic!("An error occurred"),
+/// _ => (),
+/// }
+/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error;
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(stage0)]
pub fn size_of<T>() -> usize {
unsafe { intrinsics::size_of::<T>() }
}
+/// Returns the size of a type in bytes.
+///
+/// More specifically, this is the offset in bytes between successive
+/// items of the same type, including alignment padding.
+///
+/// # Examples
+///
+/// ```
+/// use std::mem;
+///
+/// assert_eq!(4, mem::size_of::<i32>());
+/// ```
+#[inline]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(not(stage0))]
+pub const fn size_of<T>() -> usize {
+ unsafe { intrinsics::size_of::<T>() }
+}
+
/// Returns the size of the pointed-to value in bytes.
///
/// This is usually the same as `size_of::<T>()`. However, when `T` *has* no
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(stage0)]
pub fn align_of<T>() -> usize {
unsafe { intrinsics::min_align_of::<T>() }
}
+/// Returns the [ABI]-required minimum alignment of a type.
+///
+/// Every reference to a value of the type `T` must be a multiple of this number.
+///
+/// This is the alignment used for struct fields. It may be smaller than the preferred alignment.
+///
+/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface
+///
+/// # Examples
+///
+/// ```
+/// use std::mem;
+///
+/// assert_eq!(4, mem::align_of::<i32>());
+/// ```
+#[inline]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(not(stage0))]
+pub const fn align_of<T>() -> usize {
+ unsafe { intrinsics::min_align_of::<T>() }
+}
+
/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to.
///
/// Every reference to a value of the type `T` must be a multiple of this number.
// `def_id.index` (`def_id.krate` is the same as the item's).
type_param_to_index: _, // Don't hash this
has_self,
+ has_late_bound_regions,
} = *self;
parent.hash_stable(hcx, hasher);
regions.hash_stable(hcx, hasher);
types.hash_stable(hcx, hasher);
has_self.hash_stable(hcx, hasher);
+ has_late_bound_regions.hash_stable(hcx, hasher);
}
}
"detects parenthesized generic parameters in type and module names"
}
+declare_lint! {
+ pub LATE_BOUND_LIFETIME_ARGUMENTS,
+ Warn,
+ "detects generic lifetime arguments in path segments with late bound lifetime parameters"
+}
+
declare_lint! {
pub DEPRECATED,
Warn,
LEGACY_CONSTRUCTOR_VISIBILITY,
MISSING_FRAGMENT_SPECIFIER,
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
+ LATE_BOUND_LIFETIME_ARGUMENTS,
DEPRECATED
)
}
use hir;
use hir::def::Def;
use hir::def_id::DefId;
-use ty::TyCtxt;
+use ty::{TyCtxt, layout};
use ty::subst::Substs;
use util::common::ErrorReported;
use rustc_const_math::*;
IndexOpFeatureGated,
Math(ConstMathErr),
+ LayoutError(layout::LayoutError<'tcx>),
ErroneousReferencedConstant(Box<ConstEvalErr<'tcx>>),
MiscCatchAll => simple!("unsupported constant expr"),
IndexOpFeatureGated => simple!("the index operation on const values is unstable"),
Math(ref err) => Simple(err.description().into_cow()),
+ LayoutError(ref err) => Simple(err.to_string().into_cow()),
ErroneousReferencedConstant(_) => simple!("could not evaluate referenced constant"),
}
let cnum = CrateNum::new(i + 1);
let found_strategy = sess.cstore.panic_strategy(cnum);
- if desired_strategy == found_strategy {
+ let is_compiler_builtins = sess.cstore.is_compiler_builtins(cnum);
+ if is_compiler_builtins || desired_strategy == found_strategy {
continue
}
use session::{early_error, early_warn, Session};
use session::search_paths::SearchPaths;
-use rustc_back::{LinkerFlavor, PanicStrategy};
+use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::Target;
use lint;
use middle::cstore;
Some("a number");
pub const parse_panic_strategy: Option<&'static str> =
Some("either `panic` or `abort`");
+ pub const parse_relro_level: Option<&'static str> =
+ Some("one of: `full`, `partial`, or `off`");
pub const parse_sanitizer: Option<&'static str> =
Some("one of: `address`, `leak`, `memory` or `thread`");
pub const parse_linker_flavor: Option<&'static str> =
#[allow(dead_code)]
mod $mod_set {
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer};
- use rustc_back::{LinkerFlavor, PanicStrategy};
+ use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
$(
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
true
}
+ fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
+ match v {
+ Some(s) => {
+ match s.parse::<RelroLevel>() {
+ Ok(level) => *slot = Some(level),
+ _ => return false
+ }
+ },
+ _ => return false
+ }
+ true
+ }
+
fn parse_sanitizer(slote: &mut Option<Sanitizer>, v: Option<&str>) -> bool {
match v {
Some("address") => *slote = Some(Sanitizer::Address),
"extra arguments to prepend to the linker invocation (space separated)"),
profile: bool = (false, parse_bool, [TRACKED],
"insert profiling code"),
+ relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
+ "choose which RELRO level to use"),
}
pub fn default_lib_output() -> CrateType {
"target-features" => PrintRequest::TargetFeatures,
"relocation-models" => PrintRequest::RelocationModels,
"code-models" => PrintRequest::CodeModels,
- "target-spec-json" if nightly_options::is_unstable_enabled(matches)
- => PrintRequest::TargetSpec,
+ "target-spec-json" => {
+ if nightly_options::is_unstable_enabled(matches) {
+ PrintRequest::TargetSpec
+ } else {
+ early_error(error_format,
+ &format!("the `-Z unstable-options` flag must also be passed to \
+ enable the target-spec-json print option"));
+ }
+ },
req => {
early_error(error_format, &format!("unknown print request `{}`", req))
}
use super::{Passes, CrateType, OptLevel, DebugInfoLevel,
OutputTypes, Externs, ErrorOutputType, Sanitizer};
use syntax::feature_gate::UnstableFeatures;
- use rustc_back::PanicStrategy;
+ use rustc_back::{PanicStrategy, RelroLevel};
pub trait DepTrackingHash {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType);
impl_dep_tracking_hash_via_hash!(Option<String>);
impl_dep_tracking_hash_via_hash!(Option<(String, u64)>);
impl_dep_tracking_hash_via_hash!(Option<PanicStrategy>);
+ impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
impl_dep_tracking_hash_via_hash!(Option<cstore::NativeLibraryKind>);
impl_dep_tracking_hash_via_hash!(CrateType);
impl_dep_tracking_hash_via_hash!(PanicStrategy);
+ impl_dep_tracking_hash_via_hash!(RelroLevel);
impl_dep_tracking_hash_via_hash!(Passes);
impl_dep_tracking_hash_via_hash!(OptLevel);
impl_dep_tracking_hash_via_hash!(DebugInfoLevel);
use std::path::PathBuf;
use std::rc::Rc;
use super::{OutputType, OutputTypes, Externs};
- use rustc_back::PanicStrategy;
+ use rustc_back::{PanicStrategy, RelroLevel};
use syntax::symbol::Symbol;
fn optgroups() -> getopts::Options {
opts = reference.clone();
opts.debugging_opts.mir_opt_level = 3;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
+
+ opts = reference.clone();
+ opts.debugging_opts.relro_level = Some(RelroLevel::Full);
+ assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
}
}
pub type_param_to_index: BTreeMap<DefIndex, u32>,
pub has_self: bool,
+ pub has_late_bound_regions: bool,
}
impl Generics {
pub mod slice;
pub mod dynamic_lib;
+use std::str::FromStr;
+
use serialize::json::{Json, ToJson};
macro_rules! linker_flavor {
}
}
}
+
+#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
+pub enum RelroLevel {
+ Full,
+ Partial,
+ Off,
+}
+
+impl RelroLevel {
+ pub fn desc(&self) -> &str {
+ match *self {
+ RelroLevel::Full => "full",
+ RelroLevel::Partial => "partial",
+ RelroLevel::Off => "off",
+ }
+ }
+}
+
+impl FromStr for RelroLevel {
+ type Err = ();
+
+ fn from_str(s: &str) -> Result<RelroLevel, ()> {
+ match s {
+ "full" => Ok(RelroLevel::Full),
+ "partial" => Ok(RelroLevel::Partial),
+ "off" => Ok(RelroLevel::Off),
+ _ => Err(()),
+ }
+ }
+}
+
+impl ToJson for RelroLevel {
+ fn to_json(&self) -> Json {
+ match *self {
+ RelroLevel::Full => "full".to_json(),
+ RelroLevel::Partial => "partial".to_json(),
+ RelroLevel::Off => "off".to_json(),
+ }
+ }
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use target::TargetOptions;
+use target::{TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
linker_is_gnu: true,
has_rpath: true,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
.. Default::default()
}
// except according to those terms.
use LinkerFlavor;
-use target::{LinkArgs, TargetOptions};
+use target::{LinkArgs, TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
exe_allocation_crate: super::maybe_jemalloc(),
.. Default::default()
}
// except according to those terms.
use LinkerFlavor;
-use target::{LinkArgs, TargetOptions};
+use target::{LinkArgs, TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
exe_allocation_crate: super::maybe_jemalloc(),
.. Default::default()
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use target::TargetOptions;
+use target::{TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
executables: true,
has_rpath: false,
target_family: Some("unix".to_string()),
+ relro_level: RelroLevel::Full,
linker_is_gnu: true,
no_integrated_as: true,
.. Default::default()
// except according to those terms.
use LinkerFlavor;
-use target::{LinkArgs, TargetOptions};
+use target::{LinkArgs, TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
exe_allocation_crate: super::maybe_jemalloc(),
has_elf_tls: true,
.. Default::default()
use std::io::prelude::*;
use syntax::abi::{Abi, lookup as lookup_abi};
-use {LinkerFlavor, PanicStrategy};
+use {LinkerFlavor, PanicStrategy, RelroLevel};
mod android_base;
mod apple_base;
/// the functions in the executable are not randomized and can be used
/// during an exploit of a vulnerability in any code.
pub position_independent_executables: bool,
+ /// Either partial, full, or off. Full RELRO makes the dynamic linker
+ /// resolve all symbols at startup and marks the GOT read-only before
+ /// starting the program, preventing overwriting the GOT.
+ pub relro_level: RelroLevel,
/// Format that archives should be emitted in. This affects whether we use
/// LLVM to assemble an archive or fall back to the system linker, and
/// currently only "gnu" is used to fall into LLVM. Unknown strings cause
has_rpath: false,
no_default_libraries: true,
position_independent_executables: false,
+ relro_level: RelroLevel::Off,
pre_link_objects_exe: Vec::new(),
pre_link_objects_dll: Vec::new(),
post_link_objects: Vec::new(),
Some(Ok(()))
})).unwrap_or(Ok(()))
} );
+ ($key_name:ident, RelroLevel) => ( {
+ let name = (stringify!($key_name)).replace("_", "-");
+ obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
+ match s.parse::<RelroLevel>() {
+ Ok(level) => base.options.$key_name = level,
+ _ => return Some(Err(format!("'{}' is not a valid value for \
+ relro-level. Use 'full', 'partial, or 'off'.",
+ s))),
+ }
+ Some(Ok(()))
+ })).unwrap_or(Ok(()))
+ } );
($key_name:ident, list) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.find(&name[..]).map(|o| o.as_array()
key!(has_rpath, bool);
key!(no_default_libraries, bool);
key!(position_independent_executables, bool);
+ try!(key!(relro_level, RelroLevel));
key!(archive_format);
key!(allow_asm, bool);
key!(custom_unwind_resume, bool);
target_option_val!(has_rpath);
target_option_val!(no_default_libraries);
target_option_val!(position_independent_executables);
+ target_option_val!(relro_level);
target_option_val!(archive_format);
target_option_val!(allow_asm);
target_option_val!(custom_unwind_resume);
// except according to those terms.
use LinkerFlavor;
-use target::{LinkArgs, TargetOptions};
+use target::{LinkArgs, TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
.. Default::default()
}
}
// except according to those terms.
use LinkerFlavor;
-use target::{LinkArgs, TargetOptions};
+use target::{LinkArgs, TargetOptions, RelroLevel};
use std::default::Default;
pub fn opts() -> TargetOptions {
is_like_openbsd: true,
pre_link_args: args,
position_independent_executables: true,
+ relro_level: RelroLevel::Full,
.. Default::default()
}
}
// except according to those terms.
use LinkerFlavor;
-use target::{Target, TargetResult};
+use target::{Target, TargetResult, RelroLevel};
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
base.max_atomic_width = Some(64);
+ // ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO
+ // for now. https://github.com/rust-lang/rust/pull/43170#issuecomment-315411474
+ base.relro_level = RelroLevel::Partial;
+
// see #36994
base.exe_allocation_crate = None;
.span_suggestion(err.span,
&format!("to force the closure to take ownership of {} \
(and any other referenced variables), \
- use the `move` keyword, as shown:",
+ use the `move` keyword",
cmt_path_or_string),
suggestion)
.emit();
Ok(true)
}
-fn range_covered_by_constructor(tcx: TyCtxt, span: Span,
+fn constructor_covered_by_range(tcx: TyCtxt, span: Span,
ctor: &Constructor,
from: &ConstVal, to: &ConstVal,
end: RangeEnd)
match *ctor {
ConstantValue(ref value) => {
let to = cmp_to(value)?;
- let end = (to != Ordering::Greater) ||
- (end == RangeEnd::Excluded && to == Ordering::Equal);
+ let end = (to == Ordering::Less) ||
+ (end == RangeEnd::Included && to == Ordering::Equal);
Ok(cmp_from(value)? && end)
},
ConstantRange(ref from, ref to, RangeEnd::Included) => {
let to = cmp_to(to)?;
- let end = (to != Ordering::Greater) ||
- (end == RangeEnd::Excluded && to == Ordering::Equal);
+ let end = (to == Ordering::Less) ||
+ (end == RangeEnd::Included && to == Ordering::Equal);
Ok(cmp_from(from)? && end)
},
ConstantRange(ref from, ref to, RangeEnd::Excluded) => {
"unexpected const-val {:?} with ctor {:?}", value, constructor)
},
_ => {
- match range_covered_by_constructor(
+ match constructor_covered_by_range(
cx.tcx, pat.span, constructor, value, value, RangeEnd::Included
) {
Ok(true) => Some(vec![]),
}
PatternKind::Range { ref lo, ref hi, ref end } => {
- match range_covered_by_constructor(
+ match constructor_covered_by_range(
cx.tcx, pat.span, constructor, lo, hi, end.clone()
) {
Ok(true) => Some(vec![]),
use rustc::util::common::ErrorReported;
use rustc::util::nodemap::DefIdMap;
+use syntax::abi::Abi;
use syntax::ast;
use rustc::hir::{self, Expr};
use syntax_pos::Span;
_ => signal!(e, TypeckError),
};
+ if tcx.fn_sig(def_id).abi() == Abi::RustIntrinsic {
+ let layout_of = |ty: Ty<'tcx>| {
+ ty.layout(tcx, ty::ParamEnv::empty(traits::Reveal::All))
+ .map_err(|err| {
+ ConstEvalErr { span: e.span, kind: LayoutError(err) }
+ })
+ };
+ match &tcx.item_name(def_id).as_str()[..] {
+ "size_of" => {
+ let size = layout_of(substs.type_at(0))?.size(tcx);
+ return Ok(Integral(Usize(ConstUsize::new(size.bytes(),
+ tcx.sess.target.uint_type).unwrap())));
+ }
+ "min_align_of" => {
+ let align = layout_of(substs.type_at(0))?.align(tcx);
+ return Ok(Integral(Usize(ConstUsize::new(align.abi(),
+ tcx.sess.target.uint_type).unwrap())));
+ }
+ _ => signal!(e, TypeckError)
+ }
+ }
+
let body = if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) {
if fn_like.constness() == hir::Constness::Const {
/// Prints out a message with a suggested edit of the code.
///
+ /// In case of short messages and a simple suggestion,
+ /// rustc displays it as a label like
+ ///
+ /// "try adding parentheses: `(tup.0).1`"
+ ///
+ /// The message
+ /// * should not end in any punctuation (a `:` is added automatically)
+ /// * should not be a question
+ /// * should not contain any parts like "the following", "as shown"
+ /// * may look like "to do xyz, use" or "to do xyz, use abc"
+ /// * may contain a name of a function, variable or type, but not whole expressions
+ ///
/// See `diagnostic::CodeSuggestion` for more information.
pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self {
self.suggestions.push(CodeSuggestion {
// This substitution is only removal, don't show it
format!("help: {}", sugg.msg)
} else {
- format!("help: {} `{}`", sugg.msg, substitution)
+ format!("help: {}: `{}`", sugg.msg, substitution)
};
primary_span.push_span_label(sugg.substitution_spans().next().unwrap(), msg);
} else {
// and "annotations lines", where the highlight lines have the `^`.
// Sort the annotations by (start, end col)
+ // The labels are reversed, sort and then reversed again.
+ // Consider a list of annotations (A1, A2, C1, C2, B1, B2) where
+ // the letter signifies the span. Here we are only sorting by the
+ // span and hence, the order of the elements with the same span will
+ // not change. On reversing the ordering (|a, b| but b.cmp(a)), you get
+ // (C1, C2, B1, B2, A1, A2). All the elements with the same span are
+ // still ordered first to last, but all the elements with different
+ // spans are ordered by their spans in last to first order. Last to
+ // first order is important, because the jiggly lines and | are on
+ // the left, so the rightmost span needs to be rendered first,
+ // otherwise the lines would end up needing to go over a message.
+
let mut annotations = line.annotations.clone();
- annotations.sort();
- annotations.reverse();
+ annotations.sort_by(|a,b| b.start_col.cmp(&a.start_col));
// First, figure out where each label will be positioned.
//
FutureIncompatibleInfo {
id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES),
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
- }
+ },
+ FutureIncompatibleInfo {
+ id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS),
+ reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
+ },
]);
// Register renamed and removed lints
return
}
- if !self.sess.crate_types.borrow().iter().all(|ct| {
- match *ct {
- // Link the runtime
- config::CrateTypeExecutable => true,
- // This crate will be compiled with the required
- // instrumentation pass
- config::CrateTypeRlib => false,
- _ => {
- self.sess.err(&format!("Only executables and rlibs can be \
- compiled with `-Z sanitizer`"));
- false
+ // firstyear 2017 - during testing I was unable to access an OSX machine
+ // to make this work on different crate types. As a result, today I have
+ // only been able to test and support linux as a target.
+ if self.sess.target.target.llvm_target == "x86_64-unknown-linux-gnu" {
+ if !self.sess.crate_types.borrow().iter().all(|ct| {
+ match *ct {
+ // Link the runtime
+ config::CrateTypeStaticlib |
+ config::CrateTypeExecutable => true,
+ // This crate will be compiled with the required
+ // instrumentation pass
+ config::CrateTypeRlib |
+ config::CrateTypeDylib |
+ config::CrateTypeCdylib =>
+ false,
+ _ => {
+ self.sess.err(&format!("Only executables, staticlibs, \
+ cdylibs, dylibs and rlibs can be compiled with \
+ `-Z sanitizer`"));
+ false
+ }
}
+ }) {
+ return
+ }
+ } else {
+ if !self.sess.crate_types.borrow().iter().all(|ct| {
+ match *ct {
+ // Link the runtime
+ config::CrateTypeExecutable => true,
+ // This crate will be compiled with the required
+ // instrumentation pass
+ config::CrateTypeRlib => false,
+ _ => {
+ self.sess.err(&format!("Only executables and rlibs can be \
+ compiled with `-Z sanitizer`"));
+ false
+ }
+ }
+ }) {
+ return
}
- }) {
- return
}
let mut uses_std = false;
info!("loading sanitizer: {}", name);
let symbol = Symbol::intern(name);
- let dep_kind = DepKind::Implicit;
+ let dep_kind = DepKind::Explicit;
let (_, data) =
self.resolve_crate(&None, symbol, symbol, None, DUMMY_SP,
PathKind::Crate, dep_kind);
self.sess.err(&format!("the crate `{}` is not a sanitizer runtime",
name));
}
+ } else {
+ self.sess.err(&format!("Must link std to be compiled with `-Z sanitizer`"));
}
}
}
self.visit_operand(func, location);
let fn_ty = func.ty(self.mir, self.tcx);
- let (is_shuffle, is_const_fn) = match fn_ty.sty {
- ty::TyFnDef(def_id, _) => {
- (self.tcx.fn_sig(def_id).abi() == Abi::PlatformIntrinsic &&
- self.tcx.item_name(def_id).as_str().starts_with("simd_shuffle"),
- self.tcx.is_const_fn(def_id))
+ let (mut is_shuffle, mut is_const_fn) = (false, false);
+ if let ty::TyFnDef(def_id, _) = fn_ty.sty {
+ match self.tcx.fn_sig(def_id).abi() {
+ Abi::RustIntrinsic |
+ Abi::PlatformIntrinsic => {
+ assert!(!self.tcx.is_const_fn(def_id));
+ match &self.tcx.item_name(def_id).as_str()[..] {
+ "size_of" | "min_align_of" => is_const_fn = true,
+
+ name if name.starts_with("simd_shuffle") => {
+ is_shuffle = true;
+ }
+
+ _ => {}
+ }
+ }
+ _ => {
+ is_const_fn = self.tcx.is_const_fn(def_id);
+ }
}
- _ => (false, false)
- };
+ }
for (i, arg) in args.iter().enumerate() {
self.nest(|this| {
}
ExprKind::MethodCall(ref segment, ..) => {
if let Some(ref params) = segment.parameters {
- match **params {
- PathParameters::AngleBracketed(ref param_data) => {
- if !param_data.bindings.is_empty() {
- let binding_span = param_data.bindings[0].span;
- self.err_handler().span_err(binding_span,
- "type bindings cannot be used in method calls");
- }
- }
- PathParameters::Parenthesized(..) => {
- self.err_handler().span_err(expr.span,
- "parenthesized parameters cannot be used on method calls");
- }
+ if let PathParameters::Parenthesized(..) = **params {
+ self.err_handler().span_err(expr.span,
+ "parenthesized parameters cannot be used on method calls");
}
}
}
use rustc::middle::const_val::ConstEvalErr;
use rustc::middle::const_val::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal, MiscCatchAll};
use rustc::middle::const_val::ErrKind::{ErroneousReferencedConstant, MiscBinaryOp, NonConstPath};
-use rustc::middle::const_val::ErrKind::{TypeckError, Math};
+use rustc::middle::const_val::ErrKind::{TypeckError, Math, LayoutError};
use rustc_const_math::{ConstMathErr, Op};
use rustc::hir::def::{Def, CtorKind};
use rustc::hir::def_id::DefId;
Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shl)), .. }) |
Err(ConstEvalErr { kind: IndexOpFeatureGated, .. }) => {}
Err(ConstEvalErr { kind: TypeckError, .. }) => {}
+ Err(ConstEvalErr {
+ kind: LayoutError(ty::layout::LayoutError::Unknown(_)), ..
+ }) => {}
Err(msg) => {
self.tcx.sess.add_lint(CONST_ERR,
ex.id,
.map(|suggestion| import_candidate_to_paths(&suggestion)).collect::<Vec<_>>();
enum_candidates.sort();
for (sp, variant_path, enum_path) in enum_candidates {
- let msg = format!("there is an enum variant `{}`, did you mean to use `{}`?",
- variant_path,
- enum_path);
if sp == DUMMY_SP {
+ let msg = format!("there is an enum variant `{}`, \
+ try using `{}`?",
+ variant_path,
+ enum_path);
err.help(&msg);
} else {
- err.span_help(sp, &msg);
+ err.span_suggestion(span, "you can try using the variant's enum",
+ enum_path);
}
}
}
let self_is_available = this.self_value_is_available(path[0].ctxt, span);
match candidate {
AssocSuggestion::Field => {
- err.span_label(span, format!("did you mean `self.{}`?", path_str));
+ err.span_suggestion(span, "try",
+ format!("self.{}", path_str));
if !self_is_available {
err.span_label(span, format!("`self` value is only available in \
methods with `self` parameter"));
}
}
AssocSuggestion::MethodWithSelf if self_is_available => {
- err.span_label(span, format!("did you mean `self.{}(...)`?",
- path_str));
+ err.span_suggestion(span, "try",
+ format!("self.{}", path_str));
}
AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => {
- err.span_label(span, format!("did you mean `Self::{}`?", path_str));
+ err.span_suggestion(span, "try",
+ format!("Self::{}", path_str));
}
}
return err;
if let Some(suggestion) = suggestion {
if suggestion != name {
if let MacroKind::Bang = kind {
- err.help(&format!("did you mean `{}!`?", suggestion));
+ err.span_suggestion(span, "you could try the macro",
+ format!("{}!", suggestion));
} else {
- err.help(&format!("did you mean `{}`?", suggestion));
+ err.span_suggestion(span, "try", suggestion.to_string());
}
} else {
err.help("have you added the `#[macro_use]` on the module/import?");
use rustc::hir::def_id::CrateNum;
use rustc::hir::svh::Svh;
use rustc_back::tempdir::TempDir;
-use rustc_back::PanicStrategy;
+use rustc_back::{PanicStrategy, RelroLevel};
use rustc_incremental::IncrementalHashesMap;
use context::get_reloc_model;
use llvm;
}
}
+ let relro_level = match sess.opts.debugging_opts.relro_level {
+ Some(level) => level,
+ None => t.options.relro_level,
+ };
+ match relro_level {
+ RelroLevel::Full => {
+ cmd.full_relro();
+ },
+ RelroLevel::Partial => {
+ cmd.partial_relro();
+ },
+ RelroLevel::Off => {},
+ }
+
// Pass optimization flags down to the linker.
cmd.optimize();
fn add_object(&mut self, path: &Path);
fn gc_sections(&mut self, keep_metadata: bool);
fn position_independent_executable(&mut self);
+ fn partial_relro(&mut self);
+ fn full_relro(&mut self);
fn optimize(&mut self);
fn debuginfo(&mut self);
fn no_default_libraries(&mut self);
fn output_filename(&mut self, path: &Path) { self.cmd.arg("-o").arg(path); }
fn add_object(&mut self, path: &Path) { self.cmd.arg(path); }
fn position_independent_executable(&mut self) { self.cmd.arg("-pie"); }
+ fn partial_relro(&mut self) { self.linker_arg("-z,relro"); }
+ fn full_relro(&mut self) { self.linker_arg("-z,relro,-z,now"); }
fn args(&mut self, args: &[String]) { self.cmd.args(args); }
fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
// noop
}
+ fn partial_relro(&mut self) {
+ // noop
+ }
+
+ fn full_relro(&mut self) {
+ // noop
+ }
+
fn no_default_libraries(&mut self) {
// Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
// as there's been trouble in the past of linking the C++ standard
// noop
}
+ fn partial_relro(&mut self) {
+ // noop
+ }
+
+ fn full_relro(&mut self) {
+ // noop
+ }
+
fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}
use rustc::ty::cast::{CastTy, IntTy};
use rustc::ty::subst::{Kind, Substs, Subst};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use {abi, adt, base, machine};
+use {adt, base, machine};
+use abi::{self, Abi};
use callee;
use builder::Builder;
use common::{self, CrateContext, const_get_elt, val_ty};
func, fn_ty)
};
- let mut const_args = IndexVec::with_capacity(args.len());
+ let mut arg_vals = IndexVec::with_capacity(args.len());
for arg in args {
match self.const_operand(arg, span) {
- Ok(arg) => { const_args.push(arg); },
+ Ok(arg) => { arg_vals.push(arg); },
Err(err) => if failure.is_ok() { failure = Err(err); }
}
}
if let Some((ref dest, target)) = *destination {
- match MirConstContext::trans_def(self.ccx, def_id, substs, const_args) {
- Ok(value) => self.store(dest, value, span),
- Err(err) => if failure.is_ok() { failure = Err(err); }
+ if fn_ty.fn_sig(tcx).abi() == Abi::RustIntrinsic {
+ let value = match &tcx.item_name(def_id).as_str()[..] {
+ "size_of" => {
+ let llval = C_uint(self.ccx,
+ self.ccx.size_of(substs.type_at(0)));
+ Const::new(llval, tcx.types.usize)
+ }
+ "min_align_of" => {
+ let llval = C_uint(self.ccx,
+ self.ccx.align_of(substs.type_at(0)));
+ Const::new(llval, tcx.types.usize)
+ }
+ _ => span_bug!(span, "{:?} in constant", terminator.kind)
+ };
+ self.store(dest, value, span);
+ } else {
+ match MirConstContext::trans_def(self.ccx, def_id, substs, arg_vals) {
+ Ok(value) => self.store(dest, value, span),
+ Err(err) => if failure.is_ok() { failure = Err(err); }
+ }
}
target
} else {
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
Ok(s) => {
err.span_suggestion(self.cast_span,
- "try casting to a reference instead:",
+ "try casting to a reference instead",
format!("&{}{}", mtstr, s));
}
Err(_) => {
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
Ok(s) => {
err.span_suggestion(self.cast_span,
- "try casting to a `Box` instead:",
+ "try casting to a `Box` instead",
format!("Box<{}>", s));
}
Err(_) => span_help!(err, self.cast_span, "did you mean `Box<{}>`?", tstr),
use syntax::ast;
use syntax_pos::{self, Span};
use rustc::hir;
+use rustc::hir::print;
use rustc::hir::def::Def;
use rustc::ty::{self, Ty, AssociatedItem};
use errors::{DiagnosticBuilder, CodeMapper};
let cause = self.misc(expr.span);
let expr_ty = self.resolve_type_vars_with_obligations(checked_ty);
let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e);
+
+ // If the expected type is an enum with any variants whose sole
+ // field is of the found type, suggest such variants. See Issue
+ // #42764.
+ if let ty::TyAdt(expected_adt, substs) = expected.sty {
+ let mut compatible_variants = vec![];
+ for variant in &expected_adt.variants {
+ if variant.fields.len() == 1 {
+ let sole_field = &variant.fields[0];
+ let sole_field_ty = sole_field.ty(self.tcx, substs);
+ if self.can_coerce(expr_ty, sole_field_ty) {
+ let mut variant_path = self.tcx.item_path_str(variant.did);
+ variant_path = variant_path.trim_left_matches("std::prelude::v1::")
+ .to_string();
+ compatible_variants.push(variant_path);
+ }
+ }
+ }
+ if !compatible_variants.is_empty() {
+ let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr));
+ let suggestions = compatible_variants.iter()
+ .map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
+ err.span_suggestions(expr.span,
+ "perhaps you meant to use a variant of the expected type",
+ suggestions);
+ }
+ }
+
if let Some(suggestion) = self.check_ref(expr,
checked_ty,
expected) {
use super::{probe, MethodCallee};
+use astconv::AstConv;
use check::{FnCtxt, LvalueOp, callee};
use hir::def_id::DefId;
use rustc::ty::subst::Substs;
fn instantiate_method_substs(&mut self,
pick: &probe::Pick<'tcx>,
segment: &hir::PathSegment,
- substs: &Substs<'tcx>)
+ parent_substs: &Substs<'tcx>)
-> &'tcx Substs<'tcx> {
- let supplied_method_types = match segment.parameters {
- hir::AngleBracketedParameters(ref data) => &data.types,
- _ => bug!("unexpected generic arguments: {:?}", segment.parameters),
- };
-
// Determine the values for the generic parameters of the method.
// If they were not explicitly supplied, just construct fresh
// variables.
- let num_supplied_types = supplied_method_types.len();
let method_generics = self.tcx.generics_of(pick.item.def_id);
- let num_method_types = method_generics.types.len();
-
- if num_supplied_types > 0 && num_supplied_types != num_method_types {
- if num_method_types == 0 {
- struct_span_err!(self.tcx.sess,
- self.span,
- E0035,
- "does not take type parameters")
- .span_label(self.span, "called with unneeded type parameters")
- .emit();
- } else {
- struct_span_err!(self.tcx.sess,
- self.span,
- E0036,
- "incorrect number of type parameters given for this method: \
- expected {}, found {}",
- num_method_types,
- num_supplied_types)
- .span_label(self.span,
- format!("Passed {} type argument{}, expected {}",
- num_supplied_types,
- if num_supplied_types != 1 { "s" } else { "" },
- num_method_types))
- .emit();
- }
- }
+ let mut fn_segment = Some((segment, method_generics));
+ self.fcx.check_path_parameter_count(self.span, &mut fn_segment, true);
// Create subst for early-bound lifetime parameters, combining
// parameters from the type and those from the method.
- //
- // FIXME -- permit users to manually specify lifetimes
- let supplied_start = substs.len() + method_generics.regions.len();
+ let (supplied_types, supplied_lifetimes) = match segment.parameters {
+ hir::AngleBracketedParameters(ref data) => (&data.types, &data.lifetimes),
+ _ => bug!("unexpected generic arguments: {:?}", segment.parameters),
+ };
+ assert_eq!(method_generics.parent_count(), parent_substs.len());
Substs::for_item(self.tcx, pick.item.def_id, |def, _| {
let i = def.index as usize;
- if i < substs.len() {
- substs.region_at(i)
+ if i < parent_substs.len() {
+ parent_substs.region_at(i)
+ } else if let Some(lifetime) =
+ supplied_lifetimes.get(i - parent_substs.len()) {
+ AstConv::ast_region_to_region(self.fcx, lifetime, Some(def))
} else {
self.region_var_for_def(self.span, def)
}
}, |def, cur_substs| {
let i = def.index as usize;
- if i < substs.len() {
- substs.type_at(i)
- } else if let Some(ast_ty) = supplied_method_types.get(i - supplied_start) {
+ if i < parent_substs.len() {
+ parent_substs.type_at(i)
+ } else if let Some(ast_ty) =
+ supplied_types.get(i - parent_substs.len() - method_generics.regions.len()) {
self.to_ty(ast_ty)
} else {
self.type_var_for_def(self.span, def, cur_substs)
// variables. If the user provided some types, we may still need
// to add defaults. If the user provided *too many* types, that's
// a problem.
- self.check_path_parameter_count(span, &mut type_segment);
- self.check_path_parameter_count(span, &mut fn_segment);
+ self.check_path_parameter_count(span, &mut type_segment, false);
+ self.check_path_parameter_count(span, &mut fn_segment, false);
let (fn_start, has_self) = match (type_segment, fn_segment) {
(_, Some((_, generics))) => {
/// Report errors if the provided parameters are too few or too many.
fn check_path_parameter_count(&self,
span: Span,
- segment: &mut Option<(&hir::PathSegment, &ty::Generics)>) {
+ segment: &mut Option<(&hir::PathSegment, &ty::Generics)>,
+ is_method_call: bool) {
let (lifetimes, types, infer_types, bindings) = {
match segment.map(|(s, _)| &s.parameters) {
Some(&hir::AngleBracketedParameters(ref data)) => {
None => (&[][..], &[][..], true, &[][..])
}
};
+ let infer_lifetimes = lifetimes.len() == 0;
let count_lifetime_params = |n| {
format!("{} lifetime parameter{}", n, if n == 1 { "" } else { "s" })
format!("{} type parameter{}", n, if n == 1 { "" } else { "s" })
};
- // Check provided lifetime parameters.
- let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
- if lifetimes.len() > lifetime_defs.len() {
- let expected_text = count_lifetime_params(lifetime_defs.len());
- let actual_text = count_lifetime_params(lifetimes.len());
- struct_span_err!(self.tcx.sess, span, E0088,
- "too many lifetime parameters provided: \
- expected at most {}, found {}",
- expected_text, actual_text)
- .span_label(span, format!("expected {}", expected_text))
- .emit();
- } else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
- let expected_text = count_lifetime_params(lifetime_defs.len());
- let actual_text = count_lifetime_params(lifetimes.len());
- struct_span_err!(self.tcx.sess, span, E0090,
- "too few lifetime parameters provided: \
- expected {}, found {}",
- expected_text, actual_text)
- .span_label(span, format!("expected {}", expected_text))
- .emit();
- }
-
- // The case where there is not enough lifetime parameters is not checked,
- // because this is not possible - a function never takes lifetime parameters.
- // See discussion for Pull Request 36208.
-
// Check provided type parameters.
let type_defs = segment.map_or(&[][..], |(_, generics)| {
if generics.parent.is_none() {
// type parameters, we force instantiate_value_path to
// use inference variables instead of the provided types.
*segment = None;
- } else if !infer_types && types.len() < required_len {
+ } else if types.len() < required_len && !infer_types {
let expected_text = count_type_params(required_len);
let actual_text = count_type_params(types.len());
struct_span_err!(self.tcx.sess, span, E0089,
"unexpected binding of associated item in expression path \
(only allowed in type paths)");
}
+
+ // Check provided lifetime parameters.
+ let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
+ let required_len = lifetime_defs.len();
+
+ // Prohibit explicit lifetime arguments if late bound lifetime parameters are present.
+ let has_late_bound_lifetime_defs =
+ segment.map_or(false, |(_, generics)| generics.has_late_bound_regions);
+ if has_late_bound_lifetime_defs && !lifetimes.is_empty() {
+ // Report this as a lint only if no error was reported previously.
+ if !is_method_call && (lifetimes.len() > lifetime_defs.len() ||
+ lifetimes.len() < required_len && !infer_lifetimes) {
+ self.tcx.sess.span_err(lifetimes[0].span,
+ "cannot specify lifetime arguments explicitly \
+ if late bound lifetime parameters are present");
+ *segment = None;
+ } else {
+ self.tcx.sess.add_lint(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS,
+ lifetimes[0].id, lifetimes[0].span,
+ format!("cannot specify lifetime arguments explicitly \
+ if late bound lifetime parameters are present"));
+ }
+ return;
+ }
+
+ if lifetimes.len() > lifetime_defs.len() {
+ let span = lifetimes[lifetime_defs.len()].span;
+ let expected_text = count_lifetime_params(lifetime_defs.len());
+ let actual_text = count_lifetime_params(lifetimes.len());
+ struct_span_err!(self.tcx.sess, span, E0088,
+ "too many lifetime parameters provided: \
+ expected at most {}, found {}",
+ expected_text, actual_text)
+ .span_label(span, format!("expected {}", expected_text))
+ .emit();
+ } else if lifetimes.len() < required_len && !infer_lifetimes {
+ let expected_text = count_lifetime_params(lifetime_defs.len());
+ let actual_text = count_lifetime_params(lifetimes.len());
+ struct_span_err!(self.tcx.sess, span, E0090,
+ "too few lifetime parameters provided: \
+ expected {}, found {}",
+ expected_text, actual_text)
+ .span_label(span, format!("expected {}", expected_text))
+ .emit();
+ }
}
fn structurally_resolve_type_or_else<F>(&self, sp: Span, ty: Ty<'tcx>, f: F)
from a string reference. String concatenation \
appends the string on the right to the string \
on the left and may require reallocation. This \
- requires ownership of the string on the left."), suggestion);
+ requires ownership of the string on the left"), suggestion);
is_string_addition = true;
}
tcx.alloc_trait_def(def)
}
+fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ node: hir_map::Node<'tcx>)
+ -> bool {
+ struct LateBoundRegionsDetector<'a, 'tcx: 'a> {
+ tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ binder_depth: u32,
+ has_late_bound_regions: bool,
+ }
+
+ impl<'a, 'tcx> Visitor<'tcx> for LateBoundRegionsDetector<'a, 'tcx> {
+ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ NestedVisitorMap::None
+ }
+
+ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
+ if self.has_late_bound_regions { return }
+ match ty.node {
+ hir::TyBareFn(..) => {
+ self.binder_depth += 1;
+ intravisit::walk_ty(self, ty);
+ self.binder_depth -= 1;
+ }
+ _ => intravisit::walk_ty(self, ty)
+ }
+ }
+
+ fn visit_poly_trait_ref(&mut self,
+ tr: &'tcx hir::PolyTraitRef,
+ m: hir::TraitBoundModifier) {
+ if self.has_late_bound_regions { return }
+ self.binder_depth += 1;
+ intravisit::walk_poly_trait_ref(self, tr, m);
+ self.binder_depth -= 1;
+ }
+
+ fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) {
+ if self.has_late_bound_regions { return }
+
+ match self.tcx.named_region_map.defs.get(<.id).cloned() {
+ Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {}
+ Some(rl::Region::LateBound(debruijn, _)) |
+ Some(rl::Region::LateBoundAnon(debruijn, _))
+ if debruijn.depth < self.binder_depth => {}
+ _ => self.has_late_bound_regions = true,
+ }
+ }
+ }
+
+ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ generics: &'tcx hir::Generics,
+ decl: &'tcx hir::FnDecl)
+ -> bool {
+ let mut visitor = LateBoundRegionsDetector {
+ tcx, binder_depth: 1, has_late_bound_regions: false
+ };
+ for lifetime in &generics.lifetimes {
+ if tcx.named_region_map.late_bound.contains(&lifetime.lifetime.id) {
+ return true;
+ }
+ }
+ visitor.visit_fn_decl(decl);
+ visitor.has_late_bound_regions
+ }
+
+ match node {
+ hir_map::NodeTraitItem(item) => match item.node {
+ hir::TraitItemKind::Method(ref sig, _) =>
+ has_late_bound_regions(tcx, &sig.generics, &sig.decl),
+ _ => false,
+ },
+ hir_map::NodeImplItem(item) => match item.node {
+ hir::ImplItemKind::Method(ref sig, _) =>
+ has_late_bound_regions(tcx, &sig.generics, &sig.decl),
+ _ => false,
+ },
+ hir_map::NodeForeignItem(item) => match item.node {
+ hir::ForeignItemFn(ref fn_decl, _, ref generics) =>
+ has_late_bound_regions(tcx, generics, fn_decl),
+ _ => false,
+ },
+ hir_map::NodeItem(item) => match item.node {
+ hir::ItemFn(ref fn_decl, .., ref generics, _) =>
+ has_late_bound_regions(tcx, generics, fn_decl),
+ _ => false,
+ },
+ _ => false
+ }
+}
+
fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId)
-> &'tcx ty::Generics {
regions: regions,
types: types,
type_param_to_index: type_param_to_index,
- has_self: has_self || parent_has_self
+ has_self: has_self || parent_has_self,
+ has_late_bound_regions: has_late_bound_regions(tcx, node),
})
}
```
"##,
-E0035: r##"
-You tried to give a type parameter where it wasn't needed. Erroneous code
-example:
-
-```compile_fail,E0035
-struct Test;
-
-impl Test {
- fn method(&self) {}
-}
-
-fn main() {
- let x = Test;
-
- x.method::<i32>(); // Error: Test::method doesn't need type parameter!
-}
-```
-
-To fix this error, just remove the type parameter:
-
-```
-struct Test;
-
-impl Test {
- fn method(&self) {}
-}
-
-fn main() {
- let x = Test;
-
- x.method(); // OK, we're good!
-}
-```
-"##,
-
-E0036: r##"
-This error occurrs when you pass too many or not enough type parameters to
-a method. Erroneous code example:
-
-```compile_fail,E0036
-struct Test;
-
-impl Test {
- fn method<T>(&self, v: &[T]) -> usize {
- v.len()
- }
-}
-
-fn main() {
- let x = Test;
- let v = &[0];
-
- x.method::<i32, i32>(v); // error: only one type parameter is expected!
-}
-```
-
-To fix it, just specify a correct number of type parameters:
-
-```
-struct Test;
-
-impl Test {
- fn method<T>(&self, v: &[T]) -> usize {
- v.len()
- }
-}
-
-fn main() {
- let x = Test;
- let v = &[0];
-
- x.method::<i32>(v); // OK, we're good!
-}
-```
-
-Please note on the last example that we could have called `method` like this:
-
-```
-# struct Test;
-# impl Test { fn method<T>(&self, v: &[T]) -> usize { v.len() } }
-# let x = Test;
-# let v = &[0];
-x.method(v);
-```
-"##,
-
E0040: r##"
It is not allowed to manually call destructors in Rust. It is also not
necessary to do this since `drop` is called automatically whenever a value goes
}
register_diagnostics! {
+// E0035, merged into E0087/E0089
+// E0036, merged into E0087/E0089
// E0068,
// E0085,
// E0086,
/// # Examples
///
/// ```
- /// #![feature(float_bits_conv)]
/// assert_ne!((1f32).to_bits(), 1f32 as u32); // to_bits() is not casting!
/// assert_eq!((12.5f32).to_bits(), 0x41480000);
///
/// ```
- #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
+ #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline]
pub fn to_bits(self) -> u32 {
unsafe { ::mem::transmute(self) }
/// # Examples
///
/// ```
- /// #![feature(float_bits_conv)]
/// use std::f32;
/// let v = f32::from_bits(0x41480000);
/// let difference = (v - 12.5).abs();
/// let snan = 0x7F800001;
/// assert_ne!(f32::from_bits(snan).to_bits(), snan);
/// ```
- #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
+ #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline]
pub fn from_bits(mut v: u32) -> Self {
const EXP_MASK: u32 = 0x7F800000;
/// # Examples
///
/// ```
- /// #![feature(float_bits_conv)]
/// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
///
/// ```
- #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
+ #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline]
pub fn to_bits(self) -> u64 {
unsafe { ::mem::transmute(self) }
/// # Examples
///
/// ```
- /// #![feature(float_bits_conv)]
/// use std::f64;
/// let v = f64::from_bits(0x4029000000000000);
/// let difference = (v - 12.5).abs();
/// let snan = 0x7FF0000000000001;
/// assert_ne!(f64::from_bits(snan).to_bits(), snan);
/// ```
- #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
+ #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline]
pub fn from_bits(mut v: u64) -> Self {
const EXP_MASK: u64 = 0x7FF0000000000000;
#[test]
fn recursive_mkdir_slash() {
- check!(fs::create_dir_all(&Path::new("/")));
+ check!(fs::create_dir_all(Path::new("/")));
}
#[test]
fn recursive_mkdir_dot() {
- check!(fs::create_dir_all(&Path::new(".")));
+ check!(fs::create_dir_all(Path::new(".")));
}
#[test]
fn recursive_mkdir_empty() {
- check!(fs::create_dir_all(&Path::new("")));
+ check!(fs::create_dir_all(Path::new("")));
}
#[test]
#![feature(unwind_attributes)]
#![feature(vec_push_all)]
#![cfg_attr(test, feature(update_panic_count))]
-#![cfg_attr(test, feature(float_bits_conv))]
#![cfg_attr(not(stage0), default_lib_allocator)]
#![cfg_attr(stage0, feature(associated_consts))]
let mut options = OpenOptions::new();
options.read(true);
options.write(true);
- Ok(TcpStream(File::open(&Path::new(path.as_str()), &options)?))
+ Ok(TcpStream(File::open(Path::new(path.as_str()), &options)?))
}
pub fn connect_timeout(_addr: &SocketAddr, _timeout: Duration) -> Result<TcpStream> {
let mut options = OpenOptions::new();
options.read(true);
options.write(true);
- Ok(TcpListener(File::open(&Path::new(path.as_str()), &options)?))
+ Ok(TcpListener(File::open(Path::new(path.as_str()), &options)?))
}
pub fn accept(&self) -> Result<(TcpStream, SocketAddr)> {
let mut options = OpenOptions::new();
options.read(true);
options.write(true);
- Ok(UdpSocket(File::open(&Path::new(path.as_str()), &options)?, UnsafeCell::new(None)))
+ Ok(UdpSocket(File::open(Path::new(path.as_str()), &options)?, UnsafeCell::new(None)))
}
fn get_conn(&self) -> &mut Option<SocketAddr> {
fn bytes_to_path(b: &[u8]) -> PathBuf {
PathBuf::from(<OsStr as OsStrExt>::from_bytes(b))
}
- fn is_colon(b: &u8) -> bool { *b == b':' }
+ fn is_semicolon(b: &u8) -> bool { *b == b';' }
let unparsed = unparsed.as_bytes();
SplitPaths {
- iter: unparsed.split(is_colon as fn(&u8) -> bool)
+ iter: unparsed.split(is_semicolon as fn(&u8) -> bool)
.map(bytes_to_path as fn(&[u8]) -> PathBuf)
}
}
where I: Iterator<Item=T>, T: AsRef<OsStr>
{
let mut joined = Vec::new();
- let sep = b':';
+ let sep = b';';
for (i, path) in paths.enumerate() {
let path = path.as_ref().as_bytes();
// except according to those terms.
use collections::hash_map::HashMap;
-use env;
+use env::{self, split_paths};
use ffi::OsStr;
+use os::unix::ffi::OsStrExt;
use fmt;
use io::{self, Error, ErrorKind};
-use path::Path;
+use path::{Path, PathBuf};
use sys::fd::FileDesc;
use sys::fs::{File, OpenOptions};
use sys::pipe::{self, AnonPipe};
}
let program = if self.program.contains(':') || self.program.contains('/') {
- self.program.to_owned()
- } else {
- let mut path_env = ::env::var("PATH").unwrap_or(".".to_string());
-
- if ! path_env.ends_with('/') {
- path_env.push('/');
+ Some(PathBuf::from(&self.program))
+ } else if let Ok(path_env) = ::env::var("PATH") {
+ let mut program = None;
+ for mut path in split_paths(&path_env) {
+ path.push(&self.program);
+ if path.exists() {
+ program = Some(path);
+ break;
+ }
}
-
- path_env.push_str(&self.program);
-
- path_env
+ program
+ } else {
+ None
};
- if let Err(err) = syscall::execve(&program, &args) {
- io::Error::from_raw_os_error(err.errno as i32)
+ if let Some(program) = program {
+ if let Err(err) = syscall::execve(program.as_os_str().as_bytes(), &args) {
+ io::Error::from_raw_os_error(err.errno as i32)
+ } else {
+ panic!("return from exec without err");
+ }
} else {
- panic!("return from exec without err");
+ io::Error::new(io::ErrorKind::NotFound, "")
}
}
let mut opts = OpenOptions::new();
opts.read(readable);
opts.write(!readable);
- let fd = File::open(&Path::new("null:"), &opts)?;
+ let fd = File::open(Path::new("null:"), &opts)?;
Ok((ChildStdio::Owned(fd.into_fd()), None))
}
}
}
/// Replace the current process with a new executable
-pub fn execve(path: &str, args: &[[usize; 2]]) -> Result<usize> {
- unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(),
- args.as_ptr() as usize, args.len()) }
+pub fn execve<T: AsRef<[u8]>>(path: T, args: &[[usize; 2]]) -> Result<usize> {
+ unsafe { syscall4(SYS_EXECVE, path.as_ref().as_ptr() as usize,
+ path.as_ref().len(), args.as_ptr() as usize, args.len()) }
}
/// Exit the current process
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
/// A `Duration` type to represent a span of time, typically used for system
/// timeouts.
///
-/// Each `Duration` is composed of a number of seconds and nanosecond precision.
-/// APIs binding a system timeout will typically round up the nanosecond
-/// precision if the underlying system does not support that level of precision.
+/// Each `Duration` is composed of a whole number of seconds and a fractional part
+/// represented in nanoseconds. If the underlying system does not support
+/// nanosecond-level precision, APIs binding a system timeout will typically round up
+/// the number of nanoseconds.
///
/// `Duration`s implement many common traits, including [`Add`], [`Sub`], and other
/// [`ops`] traits.
}
impl Duration {
- /// Creates a new `Duration` from the specified number of seconds and
- /// additional nanosecond precision.
+ /// Creates a new `Duration` from the specified number of whole seconds and
+ /// additional nanoseconds.
///
- /// If the nanoseconds is greater than 1 billion (the number of nanoseconds
- /// in a second), then it will carry over into the seconds provided.
+ /// If the number of nanoseconds is greater than 1 billion (the number of
+ /// nanoseconds in a second), then it will carry over into the seconds provided.
///
/// # Panics
///
Duration { secs: secs, nanos: nanos }
}
- /// Creates a new `Duration` from the specified number of seconds.
+ /// Creates a new `Duration` from the specified number of whole seconds.
///
/// # Examples
///
Duration { secs: secs, nanos: nanos }
}
- /// Returns the number of whole seconds represented by this `Duration`.
+ /// Returns the number of _whole_ seconds contained by this `Duration`.
///
- /// The extra precision represented by this duration is ignored (i.e. extra
- /// nanoseconds are not represented in the returned value).
+ /// The returned value does not include the fractional (nanosecond) part of the
+ /// duration, which can be obtained using [`subsec_nanos`].
///
/// # Examples
///
#[inline]
pub fn as_secs(&self) -> u64 { self.secs }
- /// Returns the nanosecond precision represented by this `Duration`.
+ /// Returns the fractional part of this `Duration`, in nanoseconds.
///
/// This method does **not** return the length of the duration when
/// represented by nanoseconds. The returned number always represents a
/// use std::time::Duration;
///
/// let duration = Duration::from_millis(5010);
- /// assert_eq!(duration.subsec_nanos(), 10000000);
+ /// assert_eq!(duration.as_secs(), 5);
+ /// assert_eq!(duration.subsec_nanos(), 10_000_000);
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
// Predicates on exprs and stmts that the pretty-printer and parser use
-use ast::{self, BlockCheckMode};
+use ast;
/// Does this expression require a semicolon to be treated
/// as a statement? The negation of this: 'can this expression
ast::ExprKind::While(..) |
ast::ExprKind::WhileLet(..) |
ast::ExprKind::Loop(..) |
- ast::ExprKind::ForLoop(..) => false,
+ ast::ExprKind::ForLoop(..) |
+ ast::ExprKind::Catch(..) => false,
_ => true,
}
}
-pub fn expr_is_simple_block(e: &ast::Expr) -> bool {
- match e.node {
- ast::ExprKind::Block(ref block) => block.rules == BlockCheckMode::Default,
- _ => false,
- }
-}
-
/// this statement requires a semicolon after it.
/// note that in one case (`stmt_semi`), we've already
/// seen the semicolon, and thus don't need another.
s.print_bounds(" +", &bounds)?;
s.pclose()
});
- err.span_suggestion(sum_span, "try adding parentheses:", sum_with_parens);
+ err.span_suggestion(sum_span, "try adding parentheses", sum_with_parens);
}
TyKind::Ptr(..) | TyKind::BareFn(..) => {
err.span_label(sum_span, "perhaps you forgot parentheses?");
self.expect(&token::FatArrow)?;
let expr = self.parse_expr_res(RESTRICTION_STMT_EXPR, None)?;
- let require_comma =
- !classify::expr_is_simple_block(&expr)
+ let require_comma = classify::expr_requires_semi_to_be_stmt(&expr)
&& self.token != token::CloseDelim(token::Brace);
if require_comma {
`pub(in path::to::module)`: visible only on the specified path"##;
let path = self.parse_path(PathStyle::Mod)?;
let path_span = self.prev_span;
- let help_msg = format!("make this visible only to module `{}` with `in`:", path);
+ let help_msg = format!("make this visible only to module `{}` with `in`", path);
self.expect(&token::CloseDelim(token::Paren))?; // `)`
let mut err = self.span_fatal_help(path_span, msg, suggestion);
err.span_suggestion(path_span, &help_msg, format!("in {}", path));
// except according to those terms.
// ignore-arm
+// ignore-powerpc
// ignore-wasm
// ignore-emscripten
// ignore-windows
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// aux-build:derive-foo.rs
-// aux-build:derive-clona.rs
-// aux-build:attr_proc_macro.rs
-// aux-build:bang_proc_macro.rs
-
-#![feature(proc_macro)]
-#![allow(unused_macros)]
-
-#[macro_use]
-extern crate derive_foo;
-#[macro_use]
-extern crate derive_clona;
-extern crate attr_proc_macro;
-extern crate bang_proc_macro;
-
-use attr_proc_macro::attr_proc_macro;
-use bang_proc_macro::bang_proc_macro;
-
-macro_rules! FooWithLongNam {
- () => {}
-}
-
-macro_rules! attr_proc_mac {
- () => {}
-}
-
-#[derive(FooWithLongNan)]
-//~^ ERROR cannot find derive macro `FooWithLongNan` in this scope
-//~^^ HELP did you mean `FooWithLongName`?
-struct Foo;
-
-#[attr_proc_macra]
-//~^ ERROR cannot find attribute macro `attr_proc_macra` in this scope
-//~^^ HELP did you mean `attr_proc_macro`?
-struct Bar;
-
-#[FooWithLongNan]
-//~^ ERROR cannot find attribute macro `FooWithLongNan` in this scope
-struct Asdf;
-
-#[derive(Dlone)]
-//~^ ERROR cannot find derive macro `Dlone` in this scope
-//~^^ HELP did you mean `Clone`?
-struct A;
-
-#[derive(Dlona)]
-//~^ ERROR cannot find derive macro `Dlona` in this scope
-//~^^ HELP did you mean `Clona`?
-struct B;
-
-#[derive(attr_proc_macra)]
-//~^ ERROR cannot find derive macro `attr_proc_macra` in this scope
-struct C;
-
-fn main() {
- FooWithLongNama!();
- //~^ ERROR cannot find macro `FooWithLongNama!` in this scope
- //~^^ HELP did you mean `FooWithLongNam!`?
-
- attr_proc_macra!();
- //~^ ERROR cannot find macro `attr_proc_macra!` in this scope
- //~^^ HELP did you mean `attr_proc_mac!`?
-
- Dlona!();
- //~^ ERROR cannot find macro `Dlona!` in this scope
-
- bang_proc_macrp!();
- //~^ ERROR cannot find macro `bang_proc_macrp!` in this scope
- //~^^ HELP did you mean `bang_proc_macro!`?
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Test;
-
-impl Test {
- fn method(&self) {}
-}
-
-fn main() {
- let x = Test;
- x.method::<i32>(); //~ ERROR E0035
- //~| NOTE called with unneeded type parameters
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Test;
-
-impl Test {
- fn method<T>(&self, v: &[T]) -> usize {
- v.len()
- }
-}
-
-fn main() {
- let x = Test;
- let v = &[0];
- x.method::<i32, i32>(v); //~ ERROR E0036
- //~| NOTE Passed 2 type arguments, expected 1
-}
// except according to those terms.
fn f() {}
-fn g<'a>() {}
+fn g<'a>() -> &'a u8 { loop {} }
fn main() {
- f::<'static>();
- //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter [E0088]
- //~| NOTE expected 0 lifetime parameters
-
- g::<'static, 'static>();
- //~^ ERROR expected at most 0 lifetime parameters, found 2 lifetime parameters [E0088]
- //~| NOTE expected 0 lifetime parameters
+ f::<'static>(); //~ ERROR E0088
+ g::<'static, 'static>(); //~ ERROR E0088
}
+++ /dev/null
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
- &1 as Send;
- //~^ ERROR cast to unsized type
- //~| HELP try casting to a reference instead:
- //~| SUGGESTION &1 as &Send;
- Box::new(1) as Send;
- //~^ ERROR cast to unsized type
- //~| HELP try casting to a `Box` instead:
- //~| SUGGESTION Box::new(1) as Box<Send>;
-}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_fn)]
+
+struct Foo {
+ bytes: [u8; std::mem::size_of::<Foo>()]
+ //~^ ERROR unsupported cyclic reference between types/traits detected
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// All lifetime parameters in struct constructors are currently considered early bound,
+// i.e. `S::<ARGS>` is interpreted kinda like an associated item `S::<ARGS>::ctor`.
+// This behavior is a bit weird, because if equivalent constructor were written manually
+// it would get late bound lifetime parameters.
+// Variant constructors behave in the same way, lifetime parameters are considered
+// belonging to the enum and being early bound.
+// https://github.com/rust-lang/rust/issues/30904
+
+struct S<'a, 'b>(&'a u8, &'b u8);
+enum E<'a, 'b> {
+ V(&'a u8),
+ U(&'b u8),
+}
+
+fn main() {
+ S(&0, &0); // OK
+ S::<'static>(&0, &0);
+ //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter
+ S::<'static, 'static, 'static>(&0, &0);
+ //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters
+ E::V(&0); // OK
+ E::V::<'static>(&0);
+ //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter
+ E::V::<'static, 'static, 'static>(&0);
+ //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// error-pattern: main function not found
+
+// At time of authorship, a crate-level #![bench] with no `--test`
+// will cause compilation to error unconditionally with "main function
+// not found" (despite having one), similar to #[bench].
+//
+// (The non-crate level cases are in
+// issue-43106-gating-of-builtin-attrs.rs.)
+
+// See issue-12997-1.rs and issue-12997-2.rs to see how `#[bench]` is
+// handled in "weird places" when `--test` is passed.
+
+#![bench = "4100"]
+
+fn main() { }
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test enumerates as many compiler-builtin ungated attributes as
+// possible (that is, all the mutually compatible ones), and checks
+// that we get "expected" (*) warnings for each in the various weird
+// places that users might put them in the syntax.
+//
+// (*): The word "expected" is in quotes above because the cases where
+// warnings are and are not emitted might not match a user's intuition
+// nor the rustc developers' intent. I am really just trying to
+// capture today's behavior in a test, not so that it become enshrined
+// as the absolute behavior going forward, but rather so that we do
+// not change the behavior in the future without even being *aware* of
+// the change when it happens.
+//
+// At the time of authoring, the attributes here are listed in the
+// order that they occur in libsyntax/feature_gate.rs.
+//
+// Any builtin attributes that:
+//
+// - are not stable, or
+//
+// - could not be included here covering the same cases as the other
+// attributes without raising an *error* from rustc (note though
+// that warnings are of course expected)
+//
+// have their own test case referenced by filename in an inline
+// comment.
+//
+// The test feeds numeric inputs to each attribute that accepts them
+// without error. We do this for two reasons: (1.) to exercise how
+// inputs are handled by each, and (2.) to ease searching for related
+// occurrences in the source text.
+
+#![feature(rustc_attrs)] // For `rustc_error`; see note below.
+#![warn(unused_attributes, unknown_lints)]
+#![allow(dead_code)]
+
+// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
+
+#![warn (x5400)] //~ WARN unknown lint: `x5400`
+#![allow (x5300)] //~ WARN unknown lint: `x5300`
+#![forbid (x5200)] //~ WARN unknown lint: `x5200`
+#![deny (x5100)] //~ WARN unknown lint: `x5100`
+#![macro_reexport = "5000"] //~ WARN unused attribute
+#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
+#![macro_export = "4800"] //~ WARN unused attribute
+#![plugin_registrar = "4700"] //~ WARN unused attribute
+// skipping testing of cfg
+// skipping testing of cfg_attr
+#![main = "x4400"] //~ WARN unused attribute
+#![start = "x4300"] //~ WARN unused attribute
+// see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200"
+// see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100"
+#![simd = "4000"] //~ WARN unused attribute
+#![repr = "3900"] //~ WARN unused attribute
+#![path = "3800"] //~ WARN unused attribute
+#![abi = "3700"] //~ WARN unused attribute
+#![automatically_derived = "3600"] //~ WARN unused attribute
+#![no_mangle = "3500"]
+#![no_link = "3400"] //~ WARN unused attribute
+// see issue-43106-gating-of-derive.rs
+#![should_panic = "3200"] //~ WARN unused attribute
+#![ignore = "3100"] //~ WARN unused attribute
+#![no_implicit_prelude = "3000"]
+#![reexport_test_harness_main = "2900"]
+// see gated-link-args.rs
+// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
+// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
+#![proc_macro_derive = "2500"] //~ WARN unused attribute
+#![doc = "2400"]
+#![cold = "2300"]
+#![export_name = "2200"]
+// see issue-43106-gating-of-inline.rs
+#![link = "2000"]
+#![link_name = "1900"]
+#![link_section = "1800"]
+#![no_builtins = "1700"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "0300")
+#![no_mangle = "1600"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "3500")
+// see issue-43106-gating-of-rustc_deprecated.rs
+#![must_use = "1400"]
+// see issue-43106-gating-of-stable.rs
+// see issue-43106-gating-of-unstable.rs
+// see issue-43106-gating-of-deprecated.rs
+#![windows_subsystem = "1000"]
+
+// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES
+
+#![crate_name = "0900"]
+#![crate_type = "bin"] // cannot pass "0800" here
+
+// For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test)
+
+#![feature ( x0600)] //~ WARN unused or unknown feature
+
+// For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test)
+
+// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
+#![no_builtins = "0300"]
+#![recursion_limit = "0200"]
+#![type_length_limit = "0100"]
+
+// USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES
+
+#[warn(x5400)]
+//~^ WARN unknown lint: `x5400`
+mod warn {
+ mod inner { #![warn(x5400)] }
+ //~^ WARN unknown lint: `x5400`
+
+ #[warn(x5400)] fn f() { }
+ //~^ WARN unknown lint: `x5400`
+
+ #[warn(x5400)] struct S;
+ //~^ WARN unknown lint: `x5400`
+
+ #[warn(x5400)] type T = S;
+ //~^ WARN unknown lint: `x5400`
+
+ #[warn(x5400)] impl S { }
+ //~^ WARN unknown lint: `x5400`
+}
+
+#[allow(x5300)]
+//~^ WARN unknown lint: `x5300`
+mod allow {
+ mod inner { #![allow(x5300)] }
+ //~^ WARN unknown lint: `x5300`
+
+ #[allow(x5300)] fn f() { }
+ //~^ WARN unknown lint: `x5300`
+
+ #[allow(x5300)] struct S;
+ //~^ WARN unknown lint: `x5300`
+
+ #[allow(x5300)] type T = S;
+ //~^ WARN unknown lint: `x5300`
+
+ #[allow(x5300)] impl S { }
+ //~^ WARN unknown lint: `x5300`
+}
+
+#[forbid(x5200)]
+//~^ WARN unknown lint: `x5200`
+mod forbid {
+ mod inner { #![forbid(x5200)] }
+ //~^ WARN unknown lint: `x5200`
+
+ #[forbid(x5200)] fn f() { }
+ //~^ WARN unknown lint: `x5200`
+
+ #[forbid(x5200)] struct S;
+ //~^ WARN unknown lint: `x5200`
+
+ #[forbid(x5200)] type T = S;
+ //~^ WARN unknown lint: `x5200`
+
+ #[forbid(x5200)] impl S { }
+ //~^ WARN unknown lint: `x5200`
+}
+
+#[deny(x5100)]
+//~^ WARN unknown lint: `x5100`
+mod deny {
+ mod inner { #![deny(x5100)] }
+ //~^ WARN unknown lint: `x5100`
+
+ #[deny(x5100)] fn f() { }
+ //~^ WARN unknown lint: `x5100`
+
+ #[deny(x5100)] struct S;
+ //~^ WARN unknown lint: `x5100`
+
+ #[deny(x5100)] type T = S;
+ //~^ WARN unknown lint: `x5100`
+
+ #[deny(x5100)] impl S { }
+ //~^ WARN unknown lint: `x5100`
+}
+
+#[macro_reexport = "5000"]
+//~^ WARN unused attribute
+mod macro_reexport {
+ mod inner { #![macro_reexport="5000"] }
+ //~^ WARN unused attribute
+
+ #[macro_reexport = "5000"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[macro_reexport = "5000"] struct S;
+ //~^ WARN unused attribute
+
+ #[macro_reexport = "5000"] type T = S;
+ //~^ WARN unused attribute
+
+ #[macro_reexport = "5000"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[macro_use]
+mod macro_use {
+ mod inner { #![macro_use] }
+
+ #[macro_use] fn f() { }
+ //~^ WARN unused attribute
+
+ #[macro_use] struct S;
+ //~^ WARN unused attribute
+
+ #[macro_use] type T = S;
+ //~^ WARN unused attribute
+
+ #[macro_use] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[macro_export = "4800"]
+//~^ WARN unused attribute
+mod macro_export {
+ mod inner { #![macro_export="4800"] }
+ //~^ WARN unused attribute
+
+ #[macro_export = "4800"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[macro_export = "4800"] struct S;
+ //~^ WARN unused attribute
+
+ #[macro_export = "4800"] type T = S;
+ //~^ WARN unused attribute
+
+ #[macro_export = "4800"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[plugin_registrar = "4700"]
+//~^ WARN unused attribute
+mod plugin_registrar {
+ mod inner { #![plugin_registrar="4700"] }
+ //~^ WARN unused attribute
+
+ // for `fn f()` case, see gated-plugin_registrar.rs
+
+ #[plugin_registrar = "4700"] struct S;
+ //~^ WARN unused attribute
+
+ #[plugin_registrar = "4700"] type T = S;
+ //~^ WARN unused attribute
+
+ #[plugin_registrar = "4700"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[main = "4400"]
+//~^ WARN unused attribute
+mod main {
+ mod inner { #![main="4300"] }
+ //~^ WARN unused attribute
+
+ // for `fn f()` case, see feature-gate-main.rs
+
+ #[main = "4400"] struct S;
+ //~^ WARN unused attribute
+
+ #[main = "4400"] type T = S;
+ //~^ WARN unused attribute
+
+ #[main = "4400"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[start = "4300"]
+//~^ WARN unused attribute
+mod start {
+ mod inner { #![start="4300"] }
+ //~^ WARN unused attribute
+
+ // for `fn f()` case, see feature-gate-start.rs
+
+ #[start = "4300"] struct S;
+ //~^ WARN unused attribute
+
+ #[start = "4300"] type T = S;
+ //~^ WARN unused attribute
+
+ #[start = "4300"] impl S { }
+ //~^ WARN unused attribute
+}
+
+// At time of unit test authorship, if compiling without `--test` then
+// non-crate-level #[test] attributes seem to be ignored.
+
+#[test = "4200"]
+mod test { mod inner { #![test="4200"] }
+
+ fn f() { }
+
+ struct S;
+
+ type T = S;
+
+ impl S { }
+}
+
+// At time of unit test authorship, if compiling without `--test` then
+// non-crate-level #[bench] attributes seem to be ignored.
+
+#[bench = "4100"]
+mod bench {
+ mod inner { #![bench="4100"] }
+
+ #[bench = "4100"]
+ struct S;
+
+ #[bench = "4100"]
+ type T = S;
+
+ #[bench = "4100"]
+ impl S { }
+}
+
+#[simd = "4000"]
+//~^ WARN unused attribute
+mod simd {
+ mod inner { #![simd="4000"] }
+ //~^ WARN unused attribute
+
+ #[simd = "4000"] fn f() { }
+ //~^ WARN unused attribute
+
+ struct S; // for `struct S` case, see feature-gate-repr-simd.rs
+
+ #[simd = "4000"] type T = S;
+ //~^ WARN unused attribute
+
+ #[simd = "4000"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[repr = "3900"]
+//~^ WARN unused attribute
+mod repr {
+ mod inner { #![repr="3900"] }
+ //~^ WARN unused attribute
+
+ #[repr = "3900"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[repr = "3900"] struct S;
+ //~^ WARN unused attribute
+
+ #[repr = "3900"] type T = S;
+ //~^ WARN unused attribute
+
+ #[repr = "3900"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[path = "3800"]
+mod path {
+ mod inner { #![path="3800"] }
+
+ #[path = "3800"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[path = "3800"] struct S;
+ //~^ WARN unused attribute
+
+ #[path = "3800"] type T = S;
+ //~^ WARN unused attribute
+
+ #[path = "3800"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[abi = "3700"]
+//~^ WARN unused attribute
+mod abi {
+ mod inner { #![abi="3700"] }
+ //~^ WARN unused attribute
+
+ #[abi = "3700"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[abi = "3700"] struct S;
+ //~^ WARN unused attribute
+
+ #[abi = "3700"] type T = S;
+ //~^ WARN unused attribute
+
+ #[abi = "3700"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[automatically_derived = "3600"]
+//~^ WARN unused attribute
+mod automatically_derived {
+ mod inner { #![automatically_derived="3600"] }
+ //~^ WARN unused attribute
+
+ #[automatically_derived = "3600"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[automatically_derived = "3600"] struct S;
+ //~^ WARN unused attribute
+
+ #[automatically_derived = "3600"] type T = S;
+ //~^ WARN unused attribute
+
+ #[automatically_derived = "3600"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[no_mangle = "3500"]
+mod no_mangle {
+ mod inner { #![no_mangle="3500"] }
+
+ #[no_mangle = "3500"] fn f() { }
+ //~^ WARN function f is marked #[no_mangle], but not exported
+
+ #[no_mangle = "3500"] struct S;
+
+ #[no_mangle = "3500"] type T = S;
+
+ #[no_mangle = "3500"] impl S { }
+}
+
+#[no_link = "3400"]
+//~^ WARN unused attribute
+mod no_link {
+ mod inner { #![no_link="3400"] }
+ //~^ WARN unused attribute
+
+ #[no_link = "3400"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[no_link = "3400"] struct S;
+ //~^ WARN unused attribute
+
+ #[no_link = "3400"]type T = S;
+ //~^ WARN unused attribute
+
+ #[no_link = "3400"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[should_panic = "3200"]
+//~^ WARN unused attribute
+mod should_panic {
+ mod inner { #![should_panic="3200"] }
+ //~^ WARN unused attribute
+
+ #[should_panic = "3200"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[should_panic = "3200"] struct S;
+ //~^ WARN unused attribute
+
+ #[should_panic = "3200"] type T = S;
+ //~^ WARN unused attribute
+
+ #[should_panic = "3200"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[ignore = "3100"]
+//~^ WARN unused attribute
+mod ignore {
+ mod inner { #![ignore="3100"] }
+ //~^ WARN unused attribute
+
+ #[ignore = "3100"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[ignore = "3100"] struct S;
+ //~^ WARN unused attribute
+
+ #[ignore = "3100"] type T = S;
+ //~^ WARN unused attribute
+
+ #[ignore = "3100"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[no_implicit_prelude = "3000"]
+//~^ WARN unused attribute
+mod no_implicit_prelude {
+ mod inner { #![no_implicit_prelude="3000"] }
+ //~^ WARN unused attribute
+
+ #[no_implicit_prelude = "3000"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[no_implicit_prelude = "3000"] struct S;
+ //~^ WARN unused attribute
+
+ #[no_implicit_prelude = "3000"] type T = S;
+ //~^ WARN unused attribute
+
+ #[no_implicit_prelude = "3000"] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[reexport_test_harness_main = "2900"]
+//~^ WARN unused attribute
+mod reexport_test_harness_main {
+ mod inner { #![reexport_test_harness_main="2900"] }
+ //~^ WARN unused attribute
+
+ #[reexport_test_harness_main = "2900"] fn f() { }
+ //~^ WARN unused attribute
+
+ #[reexport_test_harness_main = "2900"] struct S;
+ //~^ WARN unused attribute
+
+ #[reexport_test_harness_main = "2900"] type T = S;
+ //~^ WARN unused attribute
+
+ #[reexport_test_harness_main = "2900"] impl S { }
+ //~^ WARN unused attribute
+}
+
+// Cannnot feed "2700" to `#[macro_escape]` without signaling an error.
+#[macro_escape]
+//~^ WARN macro_escape is a deprecated synonym for macro_use
+mod macro_escape {
+ mod inner { #![macro_escape] }
+ //~^ WARN macro_escape is a deprecated synonym for macro_use
+
+ #[macro_escape] fn f() { }
+ //~^ WARN unused attribute
+
+ #[macro_escape] struct S;
+ //~^ WARN unused attribute
+
+ #[macro_escape] type T = S;
+ //~^ WARN unused attribute
+
+ #[macro_escape] impl S { }
+ //~^ WARN unused attribute
+}
+
+#[no_std = "2600"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod no_std {
+ mod inner { #![no_std="2600"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[no_std = "2600"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_std = "2600"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_std = "2600"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_std = "2600"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+// At time of authorship, #[proc_macro_derive = "2500"] signals error
+// when it occurs on a mod (apart from crate-level). Therefore it goes
+// into its own file; see issue-43106-gating-of-proc_macro_derive.rs
+
+#[doc = "2400"]
+mod doc {
+ mod inner { #![doc="2400"] }
+
+ #[doc = "2400"] fn f() { }
+
+ #[doc = "2400"] struct S;
+
+ #[doc = "2400"] type T = S;
+
+ #[doc = "2400"] impl S { }
+}
+
+#[cold = "2300"]
+mod cold {
+ mod inner { #![cold="2300"] }
+
+ #[cold = "2300"] fn f() { }
+
+ #[cold = "2300"] struct S;
+
+ #[cold = "2300"] type T = S;
+
+ #[cold = "2300"] impl S { }
+}
+
+#[export_name = "2200"]
+mod export_name {
+ mod inner { #![export_name="2200"] }
+
+ #[export_name = "2200"] fn f() { }
+
+ #[export_name = "2200"] struct S;
+
+ #[export_name = "2200"] type T = S;
+
+ #[export_name = "2200"] impl S { }
+}
+
+// Note that this test ends with a `#[rustc_error] fn main()`, so it
+// will never invoke the linker. These are here nonetheless to point
+// out that we allow them at non-crate-level (though I do not know
+// whether they have the same effect here as at crate-level).
+
+#[link = "2000"]
+mod link {
+ mod inner { #![link="2000"] }
+
+ #[link = "2000"] fn f() { }
+
+ #[link = "2000"] struct S;
+
+ #[link = "2000"] type T = S;
+
+ #[link = "2000"] impl S { }
+}
+
+#[link_name = "1900"]
+mod link_name {
+ mod inner { #![link_name="1900"] }
+
+ #[link_name = "1900"] fn f() { }
+
+ #[link_name = "1900"] struct S;
+
+ #[link_name = "1900"] type T = S;
+
+ #[link_name = "1900"] impl S { }
+}
+
+#[link_section = "1800"]
+mod link_section {
+ mod inner { #![link_section="1800"] }
+
+ #[link_section = "1800"] fn f() { }
+
+ #[link_section = "1800"] struct S;
+
+ #[link_section = "1800"] type T = S;
+
+ #[link_section = "1800"] impl S { }
+}
+
+struct StructForDeprecated;
+
+#[deprecated = "1500"]
+mod deprecated {
+ mod inner { #![deprecated="1500"] }
+
+ #[deprecated = "1500"] fn f() { }
+
+ #[deprecated = "1500"] struct S1;
+
+ #[deprecated = "1500"] type T = super::StructForDeprecated;
+
+ #[deprecated = "1500"] impl super::StructForDeprecated { }
+}
+
+#[must_use = "1400"]
+mod must_use {
+ mod inner { #![must_use="1400"] }
+
+ #[must_use = "1400"] fn f() { }
+
+ #[must_use = "1400"] struct S;
+
+ #[must_use = "1400"] type T = S;
+
+ #[must_use = "1400"] impl S { }
+}
+
+#[windows_subsystem = "1000"]
+mod windows_subsystem {
+ mod inner { #![windows_subsystem="1000"] }
+
+ #[windows_subsystem = "1000"] fn f() { }
+
+ #[windows_subsystem = "1000"] struct S;
+
+ #[windows_subsystem = "1000"] type T = S;
+
+ #[windows_subsystem = "1000"] impl S { }
+}
+
+// BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES
+
+#[crate_name = "0900"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod crate_name {
+ mod inner { #![crate_name="0900"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[crate_name = "0900"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_name = "0900"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_name = "0900"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_name = "0900"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+#[crate_type = "0800"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod crate_type {
+ mod inner { #![crate_type="0800"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[crate_type = "0800"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_type = "0800"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_type = "0800"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[crate_type = "0800"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+#[feature(x0600)]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod feature {
+ mod inner { #![feature(x0600)] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[feature(x0600)] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[feature(x0600)] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[feature(x0600)] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[feature(x0600)] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+
+#[no_main = "0400"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod no_main_1 {
+ mod inner { #![no_main="0400"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[no_main = "0400"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_main = "0400"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_main = "0400"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[no_main = "0400"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+#[no_builtins = "0300"]
+mod no_builtins {
+ mod inner { #![no_builtins="0200"] }
+
+ #[no_builtins = "0300"] fn f() { }
+
+ #[no_builtins = "0300"] struct S;
+
+ #[no_builtins = "0300"] type T = S;
+
+ #[no_builtins = "0300"] impl S { }
+}
+
+#[recursion_limit="0200"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod recursion_limit {
+ mod inner { #![recursion_limit="0200"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[recursion_limit="0200"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[recursion_limit="0200"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[recursion_limit="0200"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[recursion_limit="0200"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+#[type_length_limit="0100"]
+//~^ WARN unused attribute
+//~| WARN crate-level attribute should be an inner attribute
+mod type_length_limit {
+ mod inner { #![type_length_limit="0100"] }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be in the root module
+
+ #[type_length_limit="0100"] fn f() { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[type_length_limit="0100"] struct S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[type_length_limit="0100"] type T = S;
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+
+ #[type_length_limit="0100"] impl S { }
+ //~^ WARN unused attribute
+ //~| WARN crate-level attribute should be an inner attribute
+}
+
+// Since we expect for the mix of attributes used here to compile
+// successfully, and we are just testing for the expected warnings of
+// various (mis)uses of attributes, we use the `rustc_error` attribute
+// on the `fn main()`.
+
+#[rustc_error]
+fn main() { //~ ERROR compilation successful
+ println!("Hello World");
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test just shows that a crate-level `#![deprecated]` does not
+// signal a warning or error. (This file sits on its own because a
+// crate-level `#![deprecated]` causes all that crate's item
+// definitions to be deprecated, which is a pain to work with.)
+//
+// (For non-crate-level cases, see issue-43106-gating-of-builtin-attrs.rs)
+
+#![feature(rustc_attrs)] // For `rustc_error`; see note below.
+#![allow(dead_code)]
+
+#![deprecated = "1100"]
+
+// Since we expect for the mix of attributes used here to compile
+// successfully, and we are just testing for the expected warnings of
+// various (mis)uses of attributes, we use the `rustc_error` attribute
+// on the `fn main()`.
+
+#[rustc_error]
+fn main() { //~ ERROR compilation successful
+ println!("Hello World");
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// `#![derive]` is interpreted (and raises errors) when it occurs at
+// contexts other than ADT definitions. This test checks cases where
+// the derive-macro does not exist.
+
+#![derive(x3300)]
+//~^ ERROR cannot find derive macro `x3300` in this scope
+
+#[derive(x3300)]
+//~^ ERROR cannot find derive macro `x3300` in this scope
+mod derive {
+ mod inner { #![derive(x3300)] }
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ fn derive() { }
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ union U { f: i32 }
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ enum E { }
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ struct S;
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ type T = S;
+
+ #[derive(x3300)]
+ //~^ ERROR cannot find derive macro `x3300` in this scope
+ impl S { }
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// `#![derive]` is interpreted (and raises errors) when it occurs at
+// contexts other than ADT definitions. This test checks cases where
+// the derive-macro exists.
+
+#![derive(Debug)]
+//~^ ERROR `derive` may only be applied to structs, enums and unions
+
+#[derive(Debug)]
+//~^ ERROR `derive` may only be applied to structs, enums and unions
+mod derive {
+ mod inner { #![derive(Debug)] }
+ //~^ ERROR `derive` may only be applied to structs, enums and unions
+
+ #[derive(Debug)]
+ //~^ ERROR `derive` may only be applied to structs, enums and unions
+ fn derive() { }
+
+ #[derive(Copy, Clone)] // (can't derive Debug for unions)
+ union U { f: i32 }
+
+ #[derive(Debug)]
+ struct S;
+
+ #[derive(Debug)]
+ enum E { }
+
+ #[derive(Debug)]
+ //~^ ERROR `derive` may only be applied to structs, enums and unions
+ type T = S;
+
+ #[derive(Debug)]
+ //~^ ERROR `derive` may only be applied to structs, enums and unions
+ impl S { }
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This is testing whether `#[inline]` signals an error or warning
+// when put in "weird" places.
+//
+// (This file sits on its own because it actually signals an error,
+// which would mess up the treatment of other cases in
+// issue-43106-gating-of-builtin-attrs.rs)
+
+// Crate-level is accepted, though it is almost certainly unused?
+#![inline = "2100"]
+
+#[inline = "2100"]
+//~^ ERROR attribute should be applied to function
+mod inline {
+ mod inner { #![inline="2100"] }
+ //~^ ERROR attribute should be applied to function
+
+ #[inline = "2100"] fn f() { }
+
+ #[inline = "2100"] struct S;
+ //~^ ERROR attribute should be applied to function
+
+ #[inline = "2100"] type T = S;
+ //~^ ERROR attribute should be applied to function
+
+ #[inline = "2100"] impl S { }
+ //~^ ERROR attribute should be applied to function
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Testing that crate-level `#![macro_escape]` is not gated beyond a
+// depecation warning. This file sits on its own, because crate-level
+// `#![macro_escape]` is incompatible with crate-level `#![macro_use]`
+// already present in issue-43106-gating-of-builtin-attrs.
+
+#![macro_escape]
+//~^ WARN macro_escape is a deprecated synonym for macro_use
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This is just a check-list of the cases where feeding arguments to
+// `#[macro_use]` is rejected. (The cases where no error is emitted
+// corresponds to cases where the attribute is currently unused, so we
+// get that warning; see issue-43106-gating-of-builtin-attrs.rs
+
+#![macro_use = "4900"] //~ ERROR arguments to macro_use are not allowed here
+
+#[macro_use = "2700"]
+//~^ ERROR arguments to macro_use are not allowed here
+mod macro_escape {
+ mod inner { #![macro_use="2700"] }
+ //~^ ERROR arguments to macro_use are not allowed here
+
+ #[macro_use = "2700"] fn f() { }
+
+ #[macro_use = "2700"] struct S;
+
+ #[macro_use = "2700"] type T = S;
+
+ #[macro_use = "2700"] impl S { }
+}
+
+fn main() { }
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// At time of authorship, #[proc_macro_derive = "2500"] will emit an
+// error when it occurs on a mod (apart from crate-level), but will
+// not descend further into the mod for other occurrences of the same
+// error.
+//
+// This file sits on its own because the the "weird" occurrences here
+// signal errors, making it incompatible with the "warnings only"
+// nature of issue-43106-gating-of-builtin-attrs.rs
+
+#[proc_macro_derive = "2500"]
+//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+mod proc_macro_derive1 {
+ mod inner { #![proc_macro_derive="2500"] }
+ // (no error issued here if there was one on outer module)
+}
+
+mod proc_macro_derive2 {
+ mod inner { #![proc_macro_derive="2500"] }
+ //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+
+ #[proc_macro_derive = "2500"] fn f() { }
+ //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`
+
+ #[proc_macro_derive = "2500"] struct S;
+ //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+
+ #[proc_macro_derive = "2500"] type T = S;
+ //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+
+ #[proc_macro_derive = "2500"] impl S { }
+ //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Testing gating of `#[rustc_deprecated]` in "weird" places.
+//
+// This file sits on its own because these signal errors, making
+// this test incompatible with the "warnings only" nature of
+// issue-43106-gating-of-builtin-attrs.rs
+
+#![rustc_deprecated = "1500"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+
+#[rustc_deprecated = "1500"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+mod rustc_deprecated {
+ mod inner { #![rustc_deprecated="1500"] }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[rustc_deprecated = "1500"] fn f() { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[rustc_deprecated = "1500"] struct S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+ //~| ERROR stability attributes may not be used outside of the standard library
+
+ #[rustc_deprecated = "1500"] type T = S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[rustc_deprecated = "1500"] impl S { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+}
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Testing gating of `#[stable]` in "weird" places.
+//
+// This file sits on its own because these signal errors, making
+// this test incompatible with the "warnings only" nature of
+// issue-43106-gating-of-builtin-attrs.rs
+
+#![stable = "1300"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+
+#[stable = "1300"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+mod stable {
+ mod inner { #![stable="1300"] }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[stable = "1300"] fn f() { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[stable = "1300"] struct S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+ //~| ERROR stability attributes may not be used outside of the standard library
+
+ #[stable = "1300"] type T = S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[stable = "1300"] impl S { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// error-pattern: main function not found
+
+// At time of authorship, crate-level #[test] attribute with no
+// `--test` signals unconditional error complaining of missing main
+// function (despite having one), similar to #[bench].
+//
+// (The non-crate level cases are in
+// issue-43106-gating-of-builtin-attrs.rs.)
+
+#![test = "4200"]
+
+fn main() { }
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Testing gating of `#[unstable]` in "weird" places.
+//
+// This file sits on its own because these signal errors, making
+// this test incompatible with the "warnings only" nature of
+// issue-43106-gating-of-builtin-attrs.rs
+
+#![unstable = "1200"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+
+#[unstable = "1200"]
+//~^ ERROR stability attributes may not be used outside of the standard library
+mod unstable {
+ mod inner { #![unstable="1200"] }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[unstable = "1200"] fn f() { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[unstable = "1200"] struct S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+ //~| ERROR stability attributes may not be used outside of the standard library
+
+ #[unstable = "1200"] type T = S;
+ //~^ ERROR stability attributes may not be used outside of the standard library
+
+ #[unstable = "1200"] impl S { }
+ //~^ ERROR stability attributes may not be used outside of the standard library
+}
enum Fruit { //~ HELP possible candidate is found in another module, you can import it into scope
//~^ HELP possible candidate is found in another module, you can import it into scope
Apple(i64),
- //~^ HELP there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`?
- //~| HELP there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`?
Orange(i64),
}
fn should_return_fruit() -> Apple {
//~^ ERROR cannot find type `Apple` in this scope
//~| NOTE not found in this scope
+ //~| HELP you can try using the variant's enum
Apple(5)
//~^ ERROR cannot find function `Apple` in this scope
//~| NOTE not found in this scope
fn should_return_fruit_too() -> Fruit::Apple {
//~^ ERROR expected type, found variant `Fruit::Apple`
+ //~| HELP you can try using the variant's enum
//~| NOTE not a type
Apple(5)
//~^ ERROR cannot find function `Apple` in this scope
fn bar() -> Variant3 {
//~^ ERROR cannot find type `Variant3` in this scope
+ //~| HELP you can try using the variant's enum
//~| NOTE not found in this scope
}
Variant1,
Variant2(),
Variant3(usize),
- //~^ HELP there is an enum variant `x::Enum::Variant3`, did you mean to use `x::Enum`?
Variant4 {},
}
}
+++ /dev/null
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
- printlx!("oh noes!");
- //~^ ERROR cannot find macro
- //~^^ HELP did you mean `println!`?
-}
+++ /dev/null
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test macro_undefined issue
-
-mod m {
- #[macro_export]
- macro_rules! kl {
- () => ()
- }
-}
-
-fn main() {
- k!();
- //~^ ERROR cannot find macro `k!` in this scope
- //~^^ HELP did you mean `kl!`?
- kl!();
- //~^ ERROR cannot find macro `kl!` in this scope
- //~^^ HELP have you added the `#[macro_use]` on the module/import?
-}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(late_bound_lifetime_arguments)]
+#![allow(unused)]
+
+struct S;
+
+impl S {
+ fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
+ fn late_implicit(self, _: &u8, _: &u8) {}
+ fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
+ fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
+
+ // 'late lifetimes here belong to nested types not to the tested functions.
+ fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8),
+ _: Box<for<'late> Fn(&'late u8)>)
+ -> &'a u8 { loop {} }
+ fn early_tricky_implicit<'a>(_: fn(&u8),
+ _: Box<Fn(&u8)>)
+ -> &'a u8 { loop {} }
+}
+
+fn method_call() {
+ S.late(&0, &0); // OK
+ S.late::<'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late::<'static, 'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late::<'static, 'static, 'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_early(&0); // OK
+ S.late_early::<'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_early::<'static, 'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_early::<'static, 'static, 'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+
+ S.late_implicit(&0, &0); // OK
+ S.late_implicit::<'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_implicit::<'static, 'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_implicit::<'static, 'static, 'static>(&0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_implicit_early(&0); // OK
+ S.late_implicit_early::<'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_implicit_early::<'static, 'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+ S.late_implicit_early::<'static, 'static, 'static>(&0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+
+ S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK
+ S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK
+}
+
+fn ufcs() {
+ S::late_early::<'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+
+ S::late_implicit_early::<'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+}
+
+fn lint_not_inference_error() {
+ fn f<'early, 'late, T: 'early>() {}
+
+ // Make sure `u8` is substituted and not replaced with an inference variable
+ f::<'static, u8>;
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ //~| WARN this was previously accepted
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(rustc_attrs)]
+#![allow(unused)]
+
+struct S;
+
+impl S {
+ fn early_and_type<'a, T>(self) -> &'a T { loop {} }
+}
+
+fn test() {
+ S.early_and_type::<u16>();
+}
+
+#[rustc_error]
+fn main() {} //~ ERROR compilation successful
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a`
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct S;
+
+impl S {
+ fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
+ fn late_implicit(self, _: &u8, _: &u8) {}
+ fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
+ fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
+ fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
+ fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} }
+ fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} }
+ fn life_and_type<'a, T>(self) -> &'a T { loop {} }
+}
+
+fn method_call() {
+ S.early(); // OK
+ S.early::<'static>();
+ //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter
+ S.early::<'static, 'static, 'static>();
+ //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters
+ let _: &u8 = S.life_and_type::<'static>();
+ S.life_and_type::<u8>();
+ S.life_and_type::<'static, u8>();
+}
+
+fn ufcs() {
+ S::late(S, &0, &0); // OK
+ S::late::<'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late::<'static, 'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late::<'static, 'static, 'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_early(S, &0); // OK
+ S::late_early::<'static, 'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_early::<'static, 'static, 'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+
+ S::late_implicit(S, &0, &0); // OK
+ S::late_implicit::<'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit::<'static, 'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit::<'static, 'static, 'static>(S, &0, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit_early(S, &0); // OK
+ S::late_implicit_early::<'static, 'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit_early::<'static, 'static, 'static>(S, &0);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit_self_early(&S); // OK
+ S::late_implicit_self_early::<'static, 'static>(&S);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_implicit_self_early::<'static, 'static, 'static>(&S);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_unused_early(S); // OK
+ S::late_unused_early::<'static, 'static>(S);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+ S::late_unused_early::<'static, 'static, 'static>(S);
+ //~^ ERROR cannot specify lifetime arguments explicitly
+
+ S::early(S); // OK
+ S::early::<'static>(S);
+ //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter
+ S::early::<'static, 'static, 'static>(S);
+ //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters
+ let _: &u8 = S::life_and_type::<'static>(S);
+ S::life_and_type::<u8>(S);
+ S::life_and_type::<'static, u8>(S);
+}
+
+fn main() {}
// except according to those terms.
fn main() {
- 0.clone::<T = u8>(); //~ ERROR type bindings cannot be used in method calls
+ 0.clone::<T = u8>(); //~ ERROR unexpected binding of associated item
}
impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
fn main() {
- 10.dup::<i32>(); //~ ERROR does not take type parameters
- 10.blah::<i32, i32>();
- //~^ ERROR incorrect number of type parameters given for this method: expected 1, found 2
+ 10.dup::<i32>(); //~ ERROR expected at most 0 type parameters, found 1 type parameter
+ 10.blah::<i32, i32>(); //~ ERROR expected at most 1 type parameter, found 2 type parameters
(box 10 as Box<bar>).dup();
//~^ ERROR E0038
//~| ERROR E0038
impl Foo {
#[rustc_dirty(label="Hir", cfg="cfail2")]
#[rustc_clean(label="Hir", cfg="cfail3")]
- #[rustc_metadata_clean(cfg="cfail2")] // Apparently unused lifetimes don't show up in the type.
+ #[rustc_metadata_clean(cfg="cfail2")]
#[rustc_metadata_clean(cfg="cfail3")]
pub fn add_lifetime_parameter_to_method<'a>(&self) { }
}
trait TraitAddLifetimeParameterToMethod {
#[rustc_dirty(label="Hir", cfg="cfail2")]
#[rustc_clean(label="Hir", cfg="cfail3")]
- #[rustc_metadata_clean(cfg="cfail2")] // Unused lifetimes don't seem to show up in type?
+ #[rustc_metadata_dirty(cfg="cfail2")]
#[rustc_metadata_clean(cfg="cfail3")]
fn method<'a>();
}
fn main() {
let xs = [0, 1, 2, 3];
- let y = unsafe { *xs.as_ptr().offset(4) };
+ let _y = unsafe { *xs.as_ptr().offset(4) };
}
--- /dev/null
+-include ../tools.mk
+
+# This test builds a shared object, then an executable that links it as a native
+# rust library (constrast to an rlib). The shared library and executable both
+# are compiled with address sanitizer, and we assert that a fault in the cdylib
+# is correctly detected.
+
+ifeq ($(TARGET),x86_64-unknown-linux-gnu)
+ASAN_SUPPORT=$(SANITIZER_SUPPORT)
+EXTRA_RUSTFLAG=
+endif
+
+all:
+ifeq ($(ASAN_SUPPORT),1)
+ $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs
+ $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
+ LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
+endif
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[no_mangle]
+pub extern fn overflow() {
+ let xs = [0, 1, 2, 3];
+ let _y = unsafe { *xs.as_ptr().offset(4) };
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern {
+ fn overflow();
+}
+
+fn main() {
+ unsafe { overflow() }
+}
--- /dev/null
+-include ../tools.mk
+
+# This test builds a shared object, then an executable that links it as a native
+# rust library (constrast to an rlib). The shared library and executable both
+# are compiled with address sanitizer, and we assert that a fault in the dylib
+# is correctly detected.
+
+ifeq ($(TARGET),x86_64-unknown-linux-gnu)
+ASAN_SUPPORT=$(SANITIZER_SUPPORT)
+EXTRA_RUSTFLAG=
+endif
+
+all:
+ifeq ($(ASAN_SUPPORT),1)
+ $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs
+ $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
+ LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
+endif
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[no_mangle]
+pub extern fn overflow() {
+ let xs = [0, 1, 2, 3];
+ let _y = unsafe { *xs.as_ptr().offset(4) };
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern {
+ fn overflow();
+}
+
+fn main() {
+ unsafe { overflow() }
+}
+++ /dev/null
--include ../tools.mk
-
-ifeq ($(TARGET),x86_64-unknown-linux-gnu)
-all:
- $(RUSTC) -Z sanitizer=leak --crate-type dylib --target $(TARGET) hello.rs 2>&1 | grep -q 'Only executables and rlibs can be compiled with `-Z sanitizer`'
-else
-all:
-endif
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
- println!("Hello, world!");
-}
--- /dev/null
+-include ../tools.mk
+
+# NOTE the address sanitizer only supports x86_64 linux and macOS
+
+ifeq ($(TARGET),x86_64-apple-darwin)
+ASAN_SUPPORT=$(SANITIZER_SUPPORT)
+EXTRA_RUSTFLAG=-C rpath
+else
+ifeq ($(TARGET),x86_64-unknown-linux-gnu)
+ASAN_SUPPORT=$(SANITIZER_SUPPORT)
+EXTRA_RUSTFLAG=
+endif
+endif
+
+all:
+ifeq ($(ASAN_SUPPORT),1)
+ $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | grep -q -- '-Z sanitizer'
+endif
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ println!("Hello, world!");
+}
--- /dev/null
+-include ../tools.mk
+
+# This test builds a staticlib, then an executable that links to it.
+# The staticlib and executable both are compiled with address sanitizer,
+# and we assert that a fault in the staticlib is correctly detected.
+
+ifeq ($(TARGET),x86_64-unknown-linux-gnu)
+ASAN_SUPPORT=$(SANITIZER_SUPPORT)
+EXTRA_RUSTFLAG=
+endif
+
+all:
+ifeq ($(ASAN_SUPPORT),1)
+ $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs
+ $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS)
+ LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
+endif
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[no_mangle]
+pub extern fn overflow() {
+ let xs = [0, 1, 2, 3];
+ let _y = unsafe { *xs.as_ptr().offset(4) };
+}
--- /dev/null
+// ignore-license
+void overflow();
+
+int main() {
+ overflow();
+ return 0;
+}
+
Ok(&my_string)
};
assert_eq!(res, Ok("test"));
+
+ do catch {
+ ()
+ }
+
+ ();
}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_fn)]
+
+use std::mem;
+
+// Get around the limitations of CTFE in today's Rust.
+const fn choice_u64(c: bool, a: u64, b: u64) -> u64 {
+ (-(c as i64) as u64) & a | (-(!c as i64) as u64) & b
+}
+
+const fn max_usize(a: usize, b: usize) -> usize {
+ choice_u64(a > b, a as u64, b as u64) as usize
+}
+
+const fn align_to(size: usize, align: usize) -> usize {
+ (size + (align - 1)) & !(align - 1)
+}
+
+const fn packed_union_size_of<A, B>() -> usize {
+ max_usize(mem::size_of::<A>(), mem::size_of::<B>())
+}
+
+const fn union_align_of<A, B>() -> usize {
+ max_usize(mem::align_of::<A>(), mem::align_of::<B>())
+}
+
+const fn union_size_of<A, B>() -> usize {
+ align_to(packed_union_size_of::<A, B>(), union_align_of::<A, B>())
+}
+
+macro_rules! fake_union {
+ ($name:ident { $a:ty, $b:ty }) => (
+ struct $name {
+ _align: ([$a; 0], [$b; 0]),
+ _bytes: [u8; union_size_of::<$a, $b>()]
+ }
+ )
+}
+
+// Check that we can (poorly) emulate unions by
+// calling size_of and align_of at compile-time.
+fake_union!(U { u16, [u8; 3] });
+
+fn test(u: U) {
+ assert_eq!(mem::size_of_val(&u._bytes), 4);
+}
+
+fn main() {
+ assert_eq!(mem::size_of::<U>(), 4);
+ assert_eq!(mem::align_of::<U>(), 2);
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-pretty issue #37199
+
+fn main() {
+ let x = 1;
+
+ match x {
+ 1 => loop { break; },
+ 2 => while true { break; },
+ 3 => if true { () },
+ 4 => if true { () } else { () },
+ 5 => match () { () => () },
+ 6 => { () },
+ 7 => unsafe { () },
+ _ => (),
+ }
+
+ match x {
+ 1 => loop { break; }
+ 2 => while true { break; }
+ 3 => if true { () }
+ 4 => if true { () } else { () }
+ 5 => match () { () => () }
+ 6 => { () }
+ 7 => unsafe { () }
+ _ => ()
+ }
+
+ let r: &i32 = &x;
+
+ match r {
+ // Absence of comma should not cause confusion between a pattern
+ // and a bitwise and.
+ &1 => if true { () } else { () }
+ &2 => (),
+ _ =>()
+ }
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// force-host
+// no-prefer-dynamic
+#![feature(proc_macro)]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_attribute]
+pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream {
+ input
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// force-host
+// no-prefer-dynamic
+#![feature(proc_macro)]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro]
+pub fn bang_proc_macro(input: TokenStream) -> TokenStream {
+ input
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Clona)]
+pub fn derive_clonea(input: TokenStream) -> TokenStream {
+ "".parse().unwrap()
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(FooWithLongName)]
+pub fn derive_foo(input: TokenStream) -> TokenStream {
+ "".parse().unwrap()
+}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:derive-foo.rs
+// aux-build:derive-clona.rs
+// aux-build:attr_proc_macro.rs
+// aux-build:bang_proc_macro.rs
+
+#![feature(proc_macro)]
+#![allow(unused_macros)]
+
+#[macro_use]
+extern crate derive_foo;
+#[macro_use]
+extern crate derive_clona;
+extern crate attr_proc_macro;
+extern crate bang_proc_macro;
+
+use attr_proc_macro::attr_proc_macro;
+use bang_proc_macro::bang_proc_macro;
+
+macro_rules! FooWithLongNam {
+ () => {}
+}
+
+macro_rules! attr_proc_mac {
+ () => {}
+}
+
+#[derive(FooWithLongNan)]
+struct Foo;
+
+#[attr_proc_macra]
+struct Bar;
+
+#[FooWithLongNan]
+struct Asdf;
+
+#[derive(Dlone)]
+struct A;
+
+#[derive(Dlona)]
+struct B;
+
+#[derive(attr_proc_macra)]
+struct C;
+
+fn main() {
+ FooWithLongNama!();
+
+ attr_proc_macra!();
+
+ Dlona!();
+
+ bang_proc_macrp!();
+}
--- /dev/null
+error: cannot find derive macro `FooWithLongNan` in this scope
+ --> $DIR/resolve-error.rs:37:10
+ |
+37 | #[derive(FooWithLongNan)]
+ | ^^^^^^^^^^^^^^ help: try: `FooWithLongName`
+
+error: cannot find attribute macro `attr_proc_macra` in this scope
+ --> $DIR/resolve-error.rs:40:3
+ |
+40 | #[attr_proc_macra]
+ | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro`
+
+error: cannot find attribute macro `FooWithLongNan` in this scope
+ --> $DIR/resolve-error.rs:43:3
+ |
+43 | #[FooWithLongNan]
+ | ^^^^^^^^^^^^^^
+
+error: cannot find derive macro `Dlone` in this scope
+ --> $DIR/resolve-error.rs:46:10
+ |
+46 | #[derive(Dlone)]
+ | ^^^^^ help: try: `Clone`
+
+error: cannot find derive macro `Dlona` in this scope
+ --> $DIR/resolve-error.rs:49:10
+ |
+49 | #[derive(Dlona)]
+ | ^^^^^ help: try: `Clona`
+
+error: cannot find derive macro `attr_proc_macra` in this scope
+ --> $DIR/resolve-error.rs:52:10
+ |
+52 | #[derive(attr_proc_macra)]
+ | ^^^^^^^^^^^^^^^
+
+error: cannot find macro `FooWithLongNama!` in this scope
+ --> $DIR/resolve-error.rs:56:5
+ |
+56 | FooWithLongNama!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!`
+
+error: cannot find macro `attr_proc_macra!` in this scope
+ --> $DIR/resolve-error.rs:58:5
+ |
+58 | attr_proc_macra!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!`
+
+error: cannot find macro `Dlona!` in this scope
+ --> $DIR/resolve-error.rs:60:5
+ |
+60 | Dlona!();
+ | ^^^^^
+
+error: cannot find macro `bang_proc_macrp!` in this scope
+ --> $DIR/resolve-error.rs:62:5
+ |
+62 | bang_proc_macrp!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!`
+
+error: aborting due to 10 previous errors
+
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ &1 as Send;
+ Box::new(1) as Send;
+}
--- /dev/null
+error[E0620]: cast to unsized type: `&{integer}` as `std::marker::Send`
+ --> $DIR/cast-to-unsized-trait-object-suggestion.rs:12:5
+ |
+12 | &1 as Send;
+ | ^^^^^^----
+ | |
+ | help: try casting to a reference instead: `&Send`
+
+error[E0620]: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send`
+ --> $DIR/cast-to-unsized-trait-object-suggestion.rs:13:5
+ |
+13 | Box::new(1) as Send;
+ | ^^^^^^^^^^^^^^^----
+ | |
+ | help: try casting to a `Box` instead: `Box<Send>`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(exclusive_range_pattern)]
+
+fn main() {
+ // These cases should generate no warning.
+ match 10 {
+ 1..10 => {},
+ 10 => {},
+ _ => {},
+ }
+
+ match 10 {
+ 1..10 => {},
+ 9...10 => {},
+ _ => {},
+ }
+
+ match 10 {
+ 1..10 => {},
+ 10...10 => {},
+ _ => {},
+ }
+
+ // These cases should generate an "unreachable pattern" warning.
+ match 10 {
+ 1..10 => {},
+ 9 => {},
+ _ => {},
+ }
+
+ match 10 {
+ 1..10 => {},
+ 8...9 => {},
+ _ => {},
+ }
+
+ match 10 {
+ 1..10 => {},
+ 9...9 => {},
+ _ => {},
+ }
+}
\ No newline at end of file
--- /dev/null
+warning: unreachable pattern
+ --> $DIR/issue-43253.rs:36:9
+ |
+36 | 9 => {},
+ | ^
+ |
+ = note: #[warn(unreachable_patterns)] on by default
+
+warning: unreachable pattern
+ --> $DIR/issue-43253.rs:42:9
+ |
+42 | 8...9 => {},
+ | ^^^^^
+
+warning: unreachable pattern
+ --> $DIR/issue-43253.rs:48:9
+ |
+48 | 9...9 => {},
+ | ^^^^^
+
17 | (&mut self).bar();
| ^^^^
| |
- | try removing `&mut` here
| cannot reborrow mutably
+ | try removing `&mut` here
error[E0596]: cannot borrow immutable argument `self` as mutable
--> $DIR/issue-31424.rs:23:15
16 | self.run(&mut self);
| ^^^^
| |
- | try removing `&mut` here
| cannot reborrow mutably
+ | try removing `&mut` here
error: aborting due to previous error
16 | get(&mut key);
| ^^^
| |
- | try removing `&mut` here
| cannot reborrow mutably
+ | try removing `&mut` here
error: aborting due to previous error
22 | test(&mut x);
| ^
| |
- | try removing `&mut` here
| cannot reborrow mutably
+ | try removing `&mut` here
error: aborting due to previous error
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+enum DoubleOption<T> {
+ FirstSome(T),
+ AlternativeSome(T),
+ Nothing,
+}
+
+fn this_function_expects_a_double_option<T>(d: DoubleOption<T>) {}
+
+fn main() {
+ let n: usize = 42;
+ this_function_expects_a_double_option(n);
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-42764.rs:21:43
+ |
+21 | this_function_expects_a_double_option(n);
+ | ^ expected enum `DoubleOption`, found usize
+ |
+ = note: expected type `DoubleOption<_>`
+ found type `usize`
+help: perhaps you meant to use a variant of the expected type
+ |
+21 | this_function_expects_a_double_option(DoubleOption::FirstSome(n));
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+21 | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n));
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// these two HELPs are actually in a new line between this line and the `enum Fruit` line
+enum Fruit { //~ HELP possible candidate is found in another module, you can import it into scope
+ //~^ HELP possible candidate is found in another module, you can import it into scope
+ Apple(i64),
+ //~^ HELP there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`?
+ //~| HELP there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`?
+ Orange(i64),
+}
+
+fn should_return_fruit() -> Apple {
+ //~^ ERROR cannot find type `Apple` in this scope
+ //~| NOTE not found in this scope
+ Apple(5)
+ //~^ ERROR cannot find function `Apple` in this scope
+ //~| NOTE not found in this scope
+}
+
+fn should_return_fruit_too() -> Fruit::Apple {
+ //~^ ERROR expected type, found variant `Fruit::Apple`
+ //~| NOTE not a type
+ Apple(5)
+ //~^ ERROR cannot find function `Apple` in this scope
+ //~| NOTE not found in this scope
+}
+
+fn bar() -> Variant3 {
+ //~^ ERROR cannot find type `Variant3` in this scope
+ //~| NOTE not found in this scope
+}
+
+fn main() {}
+
+mod x {
+ enum Enum {
+ Variant1,
+ Variant2(),
+ Variant3(usize),
+ //~^ HELP there is an enum variant `x::Enum::Variant3`, did you mean to use `x::Enum`?
+ Variant4 {},
+ }
+}
--- /dev/null
+error[E0412]: cannot find type `Apple` in this scope
+ --> $DIR/issue-35675.rs:20:29
+ |
+20 | fn should_return_fruit() -> Apple {
+ | ^^^^^
+ | |
+ | not found in this scope
+ | help: you can try using the variant's enum: `Fruit`
+
+error[E0425]: cannot find function `Apple` in this scope
+ --> $DIR/issue-35675.rs:23:5
+ |
+23 | Apple(5)
+ | ^^^^^ not found in this scope
+ |
+help: possible candidate is found in another module, you can import it into scope
+ |
+12 | use Fruit::Apple;
+ |
+
+error[E0573]: expected type, found variant `Fruit::Apple`
+ --> $DIR/issue-35675.rs:28:33
+ |
+28 | fn should_return_fruit_too() -> Fruit::Apple {
+ | ^^^^^^^^^^^^
+ | |
+ | not a type
+ | help: you can try using the variant's enum: `Fruit`
+
+error[E0425]: cannot find function `Apple` in this scope
+ --> $DIR/issue-35675.rs:31:5
+ |
+31 | Apple(5)
+ | ^^^^^ not found in this scope
+ |
+help: possible candidate is found in another module, you can import it into scope
+ |
+12 | use Fruit::Apple;
+ |
+
+error[E0412]: cannot find type `Variant3` in this scope
+ --> $DIR/issue-35675.rs:36:13
+ |
+36 | fn bar() -> Variant3 {
+ | ^^^^^^^^
+ | |
+ | not found in this scope
+ | help: you can try using the variant's enum: `x::Enum`
+
+error: aborting due to 5 previous errors
+
19 | let e = f.v[0];
| ^^^^^^
| |
- | help: consider using a reference instead `&f.v[0]`
| cannot move out of indexed content
+ | help: consider using a reference instead: `&f.v[0]`
error: aborting due to previous error
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ printlx!("oh noes!");
+}
--- /dev/null
+error: cannot find macro `printlx!` in this scope
+ --> $DIR/macro-name-typo.rs:12:5
+ |
+12 | printlx!("oh noes!");
+ | ^^^^^^^ help: you could try the macro: `println!`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test macro_undefined issue
+
+mod m {
+ #[macro_export]
+ macro_rules! kl {
+ () => ()
+ }
+}
+
+fn main() {
+ k!();
+ kl!();
+}
--- /dev/null
+error: cannot find macro `kl!` in this scope
+ --> $DIR/macro_undefined.rs:22:5
+ |
+22 | kl!();
+ | ^^
+ |
+ = help: have you added the `#[macro_use]` on the module/import?
+
+error: cannot find macro `k!` in this scope
+ --> $DIR/macro_undefined.rs:21:5
+ |
+21 | k!();
+ | ^ help: you could try the macro: `kl!`
+
+error: aborting due to 2 previous errors
+
14 | foo(|y: String| { });
| ^^^ --------------- implements `std::ops::Fn<(std::string::String,)>`
| |
- | requires `std::ops::Fn<(usize,)>`
| expected usize, found struct `std::string::String`
+ | requires `std::ops::Fn<(usize,)>`
|
= note: required by `foo`
18 | baz(|_| ());
| ^^^ ------ implements `std::ops::Fn<(_,)>`
| |
- | requires `for<'r> std::ops::Fn<(&'r (),)>`
| expected concrete lifetime, found bound lifetime parameter
+ | requires `for<'r> std::ops::Fn<(&'r (),)>`
|
= note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]`
= note: required by `baz`
--> $DIR/issue-19109.rs:14:5
|
13 | fn function(t: &mut Trait) {
- | - help: possibly return type missing here? `-> *mut Trait `
+ | - help: possibly return type missing here?: `-> *mut Trait `
14 | t as *mut Trait
| ^^^^^^^^^^^^^^^ expected (), found *-ptr
|
17 | once::<&str>("str").fuse().filter(|a: &str| true).count();
| ^^^^^^ -------------- implements `for<'r> std::ops::FnMut<(&'r str,)>`
| |
- | requires `for<'r> std::ops::FnMut<(&'r &str,)>`
| expected &str, found str
+ | requires `for<'r> std::ops::FnMut<(&'r &str,)>`
error: aborting due to 2 previous errors
25 | let z = call_it(3, f);
| ^^^^^^^
| |
- | requires `std::ops::FnMut<(isize, isize)>`
| expected isize, found usize
+ | requires `std::ops::FnMut<(isize, isize)>`
|
= note: required by `call_it`
--- /dev/null
+error: cannot find derive macro `FooWithLongNan` in this scope
+ --> $DIR/resolve-error.rs:37:10
+ |
+37 | #[derive(FooWithLongNan)]
+ | ^^^^^^^^^^^^^^ help: try: `FooWithLongName`
+
+error: cannot find attribute macro `attr_proc_macra` in this scope
+ --> $DIR/resolve-error.rs:40:3
+ |
+40 | #[attr_proc_macra]
+ | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro`
+
+error: cannot find attribute macro `FooWithLongNan` in this scope
+ --> $DIR/resolve-error.rs:43:3
+ |
+43 | #[FooWithLongNan]
+ | ^^^^^^^^^^^^^^
+
+error: cannot find derive macro `Dlone` in this scope
+ --> $DIR/resolve-error.rs:46:10
+ |
+46 | #[derive(Dlone)]
+ | ^^^^^ help: try: `Clone`
+
+error: cannot find derive macro `Dlona` in this scope
+ --> $DIR/resolve-error.rs:49:10
+ |
+49 | #[derive(Dlona)]
+ | ^^^^^ help: try: `Clona`
+
+error: cannot find derive macro `attr_proc_macra` in this scope
+ --> $DIR/resolve-error.rs:52:10
+ |
+52 | #[derive(attr_proc_macra)]
+ | ^^^^^^^^^^^^^^^
+
+error: cannot find macro `FooWithLongNama!` in this scope
+ --> $DIR/resolve-error.rs:56:5
+ |
+56 | FooWithLongNama!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!`
+
+error: cannot find macro `attr_proc_macra!` in this scope
+ --> $DIR/resolve-error.rs:58:5
+ |
+58 | attr_proc_macra!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!`
+
+error: cannot find macro `Dlona!` in this scope
+ --> $DIR/resolve-error.rs:60:5
+ |
+60 | Dlona!();
+ | ^^^^^
+
+error: cannot find macro `bang_proc_macrp!` in this scope
+ --> $DIR/resolve-error.rs:62:5
+ |
+62 | bang_proc_macrp!();
+ | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!`
+
+error: aborting due to previous error(s)
+
--> $DIR/issue-14254.rs:29:9
|
29 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:32:9
--> $DIR/issue-14254.rs:40:9
|
40 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-14254.rs:43:9
|
43 | x;
- | ^ did you mean `self.x`?
+ | ^ help: try: `self.x`
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-14254.rs:46:9
|
46 | y;
- | ^ did you mean `self.y`?
+ | ^ help: try: `self.y`
error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:49:9
--> $DIR/issue-14254.rs:52:9
|
52 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find value `b` in this scope
--> $DIR/issue-14254.rs:55:9
--> $DIR/issue-14254.rs:63:9
|
63 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-14254.rs:66:9
|
66 | x;
- | ^ did you mean `self.x`?
+ | ^ help: try: `self.x`
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-14254.rs:69:9
|
69 | y;
- | ^ did you mean `self.y`?
+ | ^ help: try: `self.y`
error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:72:9
--> $DIR/issue-14254.rs:75:9
|
75 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find value `b` in this scope
--> $DIR/issue-14254.rs:78:9
--> $DIR/issue-14254.rs:86:9
|
86 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:89:9
|
89 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:97:9
|
97 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:100:9
|
100 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:108:9
|
108 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:111:9
|
111 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:119:9
|
119 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:122:9
|
122 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:130:9
|
130 | baz();
- | ^^^ did you mean `self.baz(...)`?
+ | ^^^ help: try: `self.baz`
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:133:9
|
133 | bah;
- | ^^^ did you mean `Self::bah`?
+ | ^^^ help: try: `Self::bah`
error[E0601]: main function not found
--> $DIR/issue-2356.rs:35:5
|
35 | clone();
- | ^^^^^ did you mean `self.clone(...)`?
+ | ^^^^^ help: try: `self.clone`
error[E0425]: cannot find function `default` in this scope
--> $DIR/issue-2356.rs:43:5
|
43 | default();
- | ^^^^^^^ did you mean `Self::default`?
+ | ^^^^^^^ help: try: `Self::default`
error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:52:5
52 | whiskers -= other;
| ^^^^^^^^
| |
- | did you mean `self.whiskers`?
| `self` value is only available in methods with `self` parameter
+ | help: try: `self.whiskers`
error[E0425]: cannot find function `shave` in this scope
--> $DIR/issue-2356.rs:57:5
|
57 | shave(4);
- | ^^^^^ did you mean `Self::shave`?
+ | ^^^^^ help: try: `Self::shave`
error[E0425]: cannot find function `purr` in this scope
--> $DIR/issue-2356.rs:60:5
--> $DIR/issue-2356.rs:104:5
|
104 | whiskers = 0;
- | ^^^^^^^^ did you mean `self.whiskers`?
+ | ^^^^^^^^ help: try: `self.whiskers`
error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:110:5
110 | whiskers = 4;
| ^^^^^^^^
| |
- | did you mean `self.whiskers`?
| `self` value is only available in methods with `self` parameter
+ | help: try: `self.whiskers`
error[E0425]: cannot find function `purr_louder` in this scope
--> $DIR/issue-2356.rs:115:5
13 | impl K for isize {} //~ ERROR expected trait, found type alias `K`
| ^
| |
- | type aliases cannot be used for traits
| did you mean `I`?
+ | type aliases cannot be used for traits
error: cannot continue compilation due to previous error
26 | Z;
| ^
| |
- | did you mean `Z { /* fields */ }`?
| did you mean `S`?
| constructor is not visible here due to private fields
+ | did you mean `Z { /* fields */ }`?
|
help: possible better candidate is found in another module, you can import it into scope
|
36 | S;
| ^
| |
- | did you mean `S { /* fields */ }`?
| constructor is not visible here due to private fields
+ | did you mean `S { /* fields */ }`?
|
help: possible better candidate is found in another module, you can import it into scope
|
42 | xcrate::S;
| ^^^^^^^^^
| |
- | did you mean `xcrate::S { /* fields */ }`?
| constructor is not visible here due to private fields
+ | did you mean `xcrate::S { /* fields */ }`?
|
help: possible better candidate is found in another module, you can import it into scope
|
--> $DIR/resolve-assoc-suggestions.rs:32:9
|
32 | field;
- | ^^^^^ did you mean `self.field`?
+ | ^^^^^ help: try: `self.field`
error[E0412]: cannot find type `Type` in this scope
--> $DIR/resolve-assoc-suggestions.rs:36:16
|
36 | let _: Type;
- | ^^^^ did you mean `Self::Type`?
+ | ^^^^ help: try: `Self::Type`
error[E0531]: cannot find tuple struct/variant `Type` in this scope
--> $DIR/resolve-assoc-suggestions.rs:39:13
--> $DIR/resolve-assoc-suggestions.rs:52:9
|
52 | method;
- | ^^^^^^ did you mean `self.method(...)`?
+ | ^^^^^^ help: try: `self.method`
error: aborting due to 9 previous errors
--> $DIR/resolve-speculative-adjustment.rs:35:9
|
35 | field;
- | ^^^^^ did you mean `self.field`?
+ | ^^^^^ help: try: `self.field`
error[E0425]: cannot find function `method` in this scope
--> $DIR/resolve-speculative-adjustment.rs:38:9
|
38 | method();
- | ^^^^^^ did you mean `self.method(...)`?
+ | ^^^^^^ help: try: `self.method`
error: aborting due to 4 previous errors
--> $DIR/token-error-correct-3.rs:25:13
|
25 | fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here? `;`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here?: `;`
| |
| expected (), found enum `std::result::Result`
|
19 | f(cx);
| ^^
| |
- | did you mean `self.cx`?
| `self` value is only available in methods with `self` parameter
+ | help: try: `self.cx`
error: aborting due to previous error
12 | let x = "Hello " + "World!";
| ^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
|
-help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left.
+help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
12 | let x = "Hello ".to_owned() + "World!";
| ^^^^^^^^^^^^^^^^^^^
--> $DIR/suggestion-non-ascii.rs:14:21
|
14 | println!("☃{}", tup[0]);
- | ^^^^^^ help: to access tuple elements, use `tup.0`
+ | ^^^^^^ help: to access tuple elements, use: `tup.0`
error: aborting due to previous error
| ------------^^^
| | |
| | unexpected token
- | help: try parenthesizing the first index `((1, (2, 3)).1).1`
+ | help: try parenthesizing the first index: `((1, (2, 3)).1).1`
error: aborting due to previous error
25 | if x = x {
| ^^^^^
| |
- | help: did you mean to compare equality? `x == x`
| expected bool, found ()
+ | help: did you mean to compare equality?: `x == x`
|
= note: expected type `bool`
found type `()`
31 | if (x = x) {
| ^^^^^^^
| |
- | help: did you mean to compare equality? `x == x`
| expected bool, found ()
+ | help: did you mean to compare equality?: `x == x`
|
= note: expected type `bool`
found type `()`
37 | if y = (Foo { foo: x }) {
| ^^^^^^^^^^^^^^^^^^^^
| |
- | help: did you mean to compare equality? `y == (Foo { foo: x })`
| expected bool, found ()
+ | help: did you mean to compare equality?: `y == (Foo { foo: x })`
|
= note: expected type `bool`
found type `()`
43 | if 3 = x {
| ^^^^^
| |
- | help: did you mean to compare equality? `3 == x`
| expected bool, found ()
+ | help: did you mean to compare equality?: `3 == x`
|
= note: expected type `bool`
found type `()`
-Subproject commit 70b89fdd7e5e77a3b88fc68982861d39d155be29
+Subproject commit 618f802f0dcebc9f23a527afd3cd228c1fa468f8
"openssl", // BSD+advertising clause, cargo, mdbook
"pest", // MPL2, mdbook via handlebars
"thread-id", // Apache-2.0, mdbook
- "strings", // this is actually MIT/Apache-2.0 but it's not in the manifest yet
];
pub fn check(path: &Path, bad: &mut bool) {
pub tracking_issue: Option<u32>,
}
+impl Feature {
+ fn check_match(&self, other: &Feature)-> Result<(), Vec<&'static str>> {
+ let mut mismatches = Vec::new();
+ if self.level != other.level {
+ mismatches.push("stability level");
+ }
+ if self.level == Status::Stable || other.level == Status::Stable {
+ // As long as a feature is unstable, the since field tracks
+ // when the given part of the feature has been implemented.
+ // Mismatches are tolerable as features evolve and functionality
+ // gets added.
+ // Once a feature is stable, the since field tracks the first version
+ // it was part of the stable distribution, and mismatches are disallowed.
+ if self.since != other.since {
+ mismatches.push("since");
+ }
+ }
+ if self.tracking_issue != other.tracking_issue {
+ mismatches.push("tracking issue");
+ }
+ if mismatches.is_empty() {
+ Ok(())
+ } else {
+ Err(mismatches)
+ }
+ }
+}
+
pub type Features = HashMap<String, Feature>;
pub fn check(path: &Path, bad: &mut bool, quiet: bool) {
&mut |res, file, line| {
match res {
Ok((name, f)) => {
- let mut err = |msg: &str| {
- tidy_error!(bad, "{}:{}: {}", file.display(), line, msg);
- };
- if lang_features.contains_key(name) && name != "proc_macro" {
- err("duplicating a lang feature");
- }
- if let Some(ref s) = lib_features.get(name) {
- if s.level != f.level {
- err("different stability level than before");
- }
- if s.since != f.since {
- err("different `since` than before");
+ let mut check_features = |f: &Feature, list: &Features, display: &str| {
+ if let Some(ref s) = list.get(name) {
+ if let Err(m) = (&f).check_match(s) {
+ tidy_error!(bad,
+ "{}:{}: mismatches to {} in: {:?}",
+ file.display(),
+ line,
+ display,
+ &m);
+ }
}
- if s.tracking_issue != f.tracking_issue {
- err("different `tracking_issue` than before");
- }
- }
+ };
+ check_features(&f, &lang_features, "corresponding lang feature");
+ check_features(&f, &lib_features, "previous");
lib_features.insert(name.to_owned(), f);
},
Err(msg) => {