diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958d9b67bdf9b..3e00fb0ac5180 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ name: CI pull_request: branches: - "**" +defaults: + run: + shell: "python src/ci/exec-with-shell.py {0}" jobs: pr: name: PR @@ -34,10 +37,6 @@ jobs: if: "github.event_name == 'pull_request'" strategy: matrix: - name: - - mingw-check - - x86_64-gnu-llvm-8 - - x86_64-gnu-tools include: - name: mingw-check os: ubuntu-latest-xl @@ -68,79 +67,60 @@ jobs: run: src/ci/scripts/setup-environment.sh env: EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: decide whether to skip this job run: src/ci/scripts/should-skip-this.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: show the current environment run: src/ci/scripts/dump-environment.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install awscli run: src/ci/scripts/install-awscli.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install sccache run: src/ci/scripts/install-sccache.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install clang run: src/ci/scripts/install-clang.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install WIX run: src/ci/scripts/install-wix.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install InnoSetup run: src/ci/scripts/install-innosetup.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure the build happens on a partition with enough space run: src/ci/scripts/symlink-build-dir.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 packages run: src/ci/scripts/install-msys2-packages.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MinGW run: src/ci/scripts/install-mingw.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install ninja run: src/ci/scripts/install-ninja.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: run the build run: src/ci/scripts/run-build-from-ci.sh @@ -148,7 +128,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.CACHES_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}" TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh @@ -156,7 +135,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" - shell: "python src/ci/exec-with-shell.py {0}" try: name: try env: @@ -171,9 +149,6 @@ jobs: if: "github.event_name == 'push' && github.ref == 'refs/heads/try' && github.repository == 'rust-lang-ci/rust'" strategy: matrix: - name: - - dist-x86_64-linux - - dist-x86_64-linux-alt include: - name: dist-x86_64-linux os: ubuntu-latest-xl @@ -201,79 +176,60 @@ jobs: run: src/ci/scripts/setup-environment.sh env: EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: decide whether to skip this job run: src/ci/scripts/should-skip-this.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: show the current environment run: src/ci/scripts/dump-environment.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install awscli run: src/ci/scripts/install-awscli.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install sccache run: src/ci/scripts/install-sccache.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install clang run: src/ci/scripts/install-clang.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install WIX run: src/ci/scripts/install-wix.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install InnoSetup run: src/ci/scripts/install-innosetup.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure the build happens on a partition with enough space run: src/ci/scripts/symlink-build-dir.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 packages run: src/ci/scripts/install-msys2-packages.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MinGW run: src/ci/scripts/install-mingw.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install ninja run: src/ci/scripts/install-ninja.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: run the build run: src/ci/scripts/run-build-from-ci.sh @@ -281,7 +237,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.CACHES_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}" TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh @@ -289,7 +244,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" - shell: "python src/ci/exec-with-shell.py {0}" auto: name: auto env: @@ -304,64 +258,6 @@ jobs: if: "github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'" strategy: matrix: - name: - - arm-android - - armhf-gnu - - dist-aarch64-linux - - dist-android - - dist-arm-linux - - dist-armhf-linux - - dist-armv7-linux - - dist-i586-gnu-i586-i686-musl - - dist-i686-freebsd - - dist-i686-linux - - dist-i686-mingw - - dist-i686-msvc - - dist-mips-linux - - dist-mips64-linux - - dist-mips64el-linux - - dist-mipsel-linux - - dist-powerpc-linux - - dist-powerpc64-linux - - dist-powerpc64le-linux - - dist-s390x-linux - - dist-various-1 - - dist-various-2 - - dist-x86_64-apple - - dist-x86_64-apple-alt - - dist-x86_64-freebsd - - dist-x86_64-linux - - dist-x86_64-linux-alt - - dist-x86_64-mingw - - dist-x86_64-msvc - - dist-x86_64-msvc-alt - - dist-x86_64-musl - - dist-x86_64-netbsd - - i686-gnu - - i686-gnu-nopt - - i686-mingw-1 - - i686-mingw-2 - - i686-msvc-1 - - i686-msvc-2 - - mingw-check - - test-various - - wasm32 - - x86_64-apple - - x86_64-gnu - - x86_64-gnu-aux - - x86_64-gnu-debug - - x86_64-gnu-distcheck - - x86_64-gnu-full-bootstrap - - x86_64-gnu-llvm-8 - - x86_64-gnu-nopt - - x86_64-gnu-tools - - x86_64-mingw-1 - - x86_64-mingw-2 - - x86_64-msvc-1 - - x86_64-msvc-2 - - x86_64-msvc-aux - - x86_64-msvc-cargo - - x86_64-msvc-tools include: - name: arm-android os: ubuntu-latest-xl @@ -631,79 +527,60 @@ jobs: run: src/ci/scripts/setup-environment.sh env: EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: decide whether to skip this job run: src/ci/scripts/should-skip-this.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: show the current environment run: src/ci/scripts/dump-environment.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install awscli run: src/ci/scripts/install-awscli.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install sccache run: src/ci/scripts/install-sccache.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install clang run: src/ci/scripts/install-clang.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install WIX run: src/ci/scripts/install-wix.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install InnoSetup run: src/ci/scripts/install-innosetup.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure the build happens on a partition with enough space run: src/ci/scripts/symlink-build-dir.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MSYS2 packages run: src/ci/scripts/install-msys2-packages.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install MinGW run: src/ci/scripts/install-mingw.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: install ninja run: src/ci/scripts/install-ninja.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: run the build run: src/ci/scripts/run-build-from-ci.sh @@ -711,7 +588,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.CACHES_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}" TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh @@ -719,7 +595,6 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" - shell: "python src/ci/exec-with-shell.py {0}" master: name: master runs-on: ubuntu-latest @@ -741,7 +616,6 @@ jobs: run: src/ci/publish_toolstate.sh env: TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - shell: "python src/ci/exec-with-shell.py {0}" if: success() && !env.SKIP_JOB try-success: needs: diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index be2b0f36d14a7..f9d3b454246b1 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -13,7 +13,7 @@ use build_helper::output; use crate::Build; // The version number -pub const CFG_RELEASE_NUM: &str = "1.44.0"; +pub const CFG_RELEASE_NUM: &str = "1.45.0"; pub struct GitInfo { inner: Option, diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index df1467ea73a12..74581232af7cd 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -70,21 +70,6 @@ x--expand-yaml-anchors--remove: - &step if: success() && !env.SKIP_JOB - - &step-run - <<: *step - # While on Linux and macOS builders it just forwards the arguments to the - # system bash, this wrapper allows switching from the host's bash.exe to - # the one we install along with MSYS2 mid-build on Windows. - # - # Once the step to install MSYS2 is executed, the CI_OVERRIDE_SHELL - # environment variable is set pointing to our MSYS2's bash.exe. From that - # moment the host's bash.exe will not be called anymore. - # - # This is needed because we can't launch our own bash.exe from the host - # bash.exe, as that would load two different cygwin1.dll in memory, causing - # "cygwin heap mismatch" errors. - shell: python src/ci/exec-with-shell.py {0} - - &base-ci-job timeout-minutes: 600 runs-on: "${{ matrix.os }}" @@ -114,67 +99,67 @@ x--expand-yaml-anchors--remove: # are passed to the `setup-environment.sh` script encoded in JSON, # which then uses log commands to actually set them. EXTRA_VARIABLES: ${{ toJson(matrix.env) }} - <<: *step-run + <<: *step - name: decide whether to skip this job run: src/ci/scripts/should-skip-this.sh - <<: *step-run + <<: *step - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - <<: *step-run + <<: *step - name: show the current environment run: src/ci/scripts/dump-environment.sh - <<: *step-run + <<: *step - name: install awscli run: src/ci/scripts/install-awscli.sh - <<: *step-run + <<: *step - name: install sccache run: src/ci/scripts/install-sccache.sh - <<: *step-run + <<: *step - name: install clang run: src/ci/scripts/install-clang.sh - <<: *step-run + <<: *step - name: install WIX run: src/ci/scripts/install-wix.sh - <<: *step-run + <<: *step - name: install InnoSetup run: src/ci/scripts/install-innosetup.sh - <<: *step-run + <<: *step - name: ensure the build happens on a partition with enough space run: src/ci/scripts/symlink-build-dir.sh - <<: *step-run + <<: *step - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - <<: *step-run + <<: *step - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - <<: *step-run + <<: *step - name: install MSYS2 packages run: src/ci/scripts/install-msys2-packages.sh - <<: *step-run + <<: *step - name: install MinGW run: src/ci/scripts/install-mingw.sh - <<: *step-run + <<: *step - name: install ninja run: src/ci/scripts/install-ninja.sh - <<: *step-run + <<: *step - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - <<: *step-run + <<: *step # Disable automatic line ending conversion (again). On Windows, when we're # installing dependencies, something switches the git configuration directory or @@ -183,15 +168,15 @@ x--expand-yaml-anchors--remove: # appropriate line endings. - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - <<: *step-run + <<: *step - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - <<: *step-run + <<: *step - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - <<: *step-run + <<: *step - name: run the build run: src/ci/scripts/run-build-from-ci.sh @@ -199,7 +184,7 @@ x--expand-yaml-anchors--remove: AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} - <<: *step-run + <<: *step - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh @@ -212,7 +197,7 @@ x--expand-yaml-anchors--remove: # deploying artifacts from a dist builder if the variables are misconfigured, # erroring about invalid credentials instead. if: success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') - <<: *step-run + <<: *step # These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs. # Check out their documentation for more information on why they're needed. @@ -248,6 +233,21 @@ on: branches: - "**" +defaults: + run: + # While on Linux and macOS builders it just forwards the arguments to the + # system bash, this wrapper allows switching from the host's bash.exe to + # the one we install along with MSYS2 mid-build on Windows. + # + # Once the step to install MSYS2 is executed, the CI_OVERRIDE_SHELL + # environment variable is set pointing to our MSYS2's bash.exe. From that + # moment the host's bash.exe will not be called anymore. + # + # This is needed because we can't launch our own bash.exe from the host + # bash.exe, as that would load two different cygwin1.dll in memory, causing + # "cygwin heap mismatch" errors. + shell: python src/ci/exec-with-shell.py {0} + jobs: pr: <<: *base-ci-job @@ -257,10 +257,6 @@ jobs: if: github.event_name == 'pull_request' strategy: matrix: - name: - - mingw-check - - x86_64-gnu-llvm-8 - - x86_64-gnu-tools include: - name: mingw-check <<: *job-linux-xl @@ -281,9 +277,6 @@ jobs: if: github.event_name == 'push' && github.ref == 'refs/heads/try' && github.repository == 'rust-lang-ci/rust' strategy: matrix: - name: - - dist-x86_64-linux - - dist-x86_64-linux-alt include: - name: dist-x86_64-linux <<: *job-linux-xl @@ -301,64 +294,6 @@ jobs: if: github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust' strategy: matrix: - name: - - arm-android - - armhf-gnu - - dist-aarch64-linux - - dist-android - - dist-arm-linux - - dist-armhf-linux - - dist-armv7-linux - - dist-i586-gnu-i586-i686-musl - - dist-i686-freebsd - - dist-i686-linux - - dist-i686-mingw - - dist-i686-msvc - - dist-mips-linux - - dist-mips64-linux - - dist-mips64el-linux - - dist-mipsel-linux - - dist-powerpc-linux - - dist-powerpc64-linux - - dist-powerpc64le-linux - - dist-s390x-linux - - dist-various-1 - - dist-various-2 - - dist-x86_64-apple - - dist-x86_64-apple-alt - - dist-x86_64-freebsd - - dist-x86_64-linux - - dist-x86_64-linux-alt - - dist-x86_64-mingw - - dist-x86_64-msvc - - dist-x86_64-msvc-alt - - dist-x86_64-musl - - dist-x86_64-netbsd - - i686-gnu - - i686-gnu-nopt - - i686-mingw-1 - - i686-mingw-2 - - i686-msvc-1 - - i686-msvc-2 - - mingw-check - - test-various - - wasm32 - - x86_64-apple - - x86_64-gnu - - x86_64-gnu-aux - - x86_64-gnu-debug - - x86_64-gnu-distcheck - - x86_64-gnu-full-bootstrap - - x86_64-gnu-llvm-8 - - x86_64-gnu-nopt - - x86_64-gnu-tools - - x86_64-mingw-1 - - x86_64-mingw-2 - - x86_64-msvc-1 - - x86_64-msvc-2 - - x86_64-msvc-aux - - x86_64-msvc-cargo - - x86_64-msvc-tools include: ############################# # Linux/Docker builders # @@ -687,7 +622,7 @@ jobs: run: src/ci/publish_toolstate.sh env: TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} - <<: *step-run + <<: *step # These jobs don't actually test anything, but they're used to tell bors the # build completed, as there is no practical way to detect when a workflow is diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index a2071844d5dac..f422c3f66e147 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -99,7 +99,7 @@ #![feature(internal_uninit_const)] #![feature(lang_items)] #![feature(libc)] -#![cfg_attr(not(bootstrap), feature(negative_impls))] +#![feature(negative_impls)] #![feature(new_uninit)] #![feature(nll)] #![feature(optin_builtin_traits)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index e106b4354e4e9..d9107eef6ecdb 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -279,7 +279,6 @@ struct RcBox { /// type `T`. /// /// [get_mut]: #method.get_mut -#[cfg_attr(all(bootstrap, not(test)), lang = "rc")] #[cfg_attr(not(test), rustc_diagnostic_item = "Rc")] #[stable(feature = "rust1", since = "1.0.0")] pub struct Rc { diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 54df2b6085780..16d51ce7f860a 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -207,7 +207,6 @@ macro_rules! acquire { /// counting in general. /// /// [rc_examples]: ../../std/rc/index.html#examples -#[cfg_attr(all(bootstrap, not(test)), lang = "arc")] #[cfg_attr(not(test), rustc_diagnostic_item = "Arc")] #[stable(feature = "rust1", since = "1.0.0")] pub struct Arc { diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 6165941eb3dae..7784ec687ea9a 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -231,6 +231,5 @@ mod impls { /// Shared references can be cloned, but mutable references *cannot*! #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(not(bootstrap))] impl !Clone for &mut T {} } diff --git a/src/libcore/convert/num.rs b/src/libcore/convert/num.rs index 66ae760fc1f79..6dd0522f7f610 100644 --- a/src/libcore/convert/num.rs +++ b/src/libcore/convert/num.rs @@ -28,14 +28,7 @@ macro_rules! impl_float_to_int { #[doc(hidden)] #[inline] unsafe fn to_int_unchecked(self) -> $Int { - #[cfg(bootstrap)] - { - crate::intrinsics::float_to_int_approx_unchecked(self) - } - #[cfg(not(bootstrap))] - { - crate::intrinsics::float_to_int_unchecked(self) - } + crate::intrinsics::float_to_int_unchecked(self) } } )+ diff --git a/src/libcore/future/mod.rs b/src/libcore/future/mod.rs index a6b769147d068..e7f681c2e9450 100644 --- a/src/libcore/future/mod.rs +++ b/src/libcore/future/mod.rs @@ -2,7 +2,6 @@ //! Asynchronous values. -#[cfg(not(bootstrap))] use crate::{ ops::{Generator, GeneratorState}, pin::Pin, @@ -24,16 +23,13 @@ pub use self::future::Future; /// It also simplifies the HIR lowering of `.await`. #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] -#[cfg(not(bootstrap))] #[derive(Debug, Copy, Clone)] pub struct ResumeTy(NonNull>); #[unstable(feature = "gen_future", issue = "50547")] -#[cfg(not(bootstrap))] unsafe impl Send for ResumeTy {} #[unstable(feature = "gen_future", issue = "50547")] -#[cfg(not(bootstrap))] unsafe impl Sync for ResumeTy {} /// Wrap a generator in a future. @@ -43,7 +39,6 @@ unsafe impl Sync for ResumeTy {} // This is `const` to avoid extra errors after we recover from `const async fn` #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] -#[cfg(not(bootstrap))] #[inline] pub const fn from_generator(gen: T) -> impl Future where @@ -75,7 +70,6 @@ where #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] -#[cfg(not(bootstrap))] #[inline] pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { &mut *cx.0.as_ptr().cast() diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 75c7313089112..45633dc3ca51f 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -980,22 +980,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is /// [`std::mem::size_of_val`](../../std/mem/fn.size_of_val.html). - #[cfg(bootstrap)] - pub fn size_of_val(_: &T) -> usize; - /// The minimum alignment of the type of the value that `val` points to. - /// - /// The stabilized version of this intrinsic is - /// [`std::mem::min_align_of_val`](../../std/mem/fn.min_align_of_val.html). - #[cfg(bootstrap)] - pub fn min_align_of_val(_: &T) -> usize; - - /// The size of the referenced value in bytes. - /// - /// The stabilized version of this intrinsic is - /// [`std::mem::size_of_val`](../../std/mem/fn.size_of_val.html). - #[cfg(not(bootstrap))] pub fn size_of_val(_: *const T) -> usize; - #[cfg(not(bootstrap))] pub fn min_align_of_val(_: *const T) -> usize; /// Gets a static string slice containing the name of a type. @@ -1016,22 +1001,14 @@ extern "rust-intrinsic" { /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: /// This will statically either panic, or do nothing. - #[cfg(bootstrap)] - pub fn panic_if_uninhabited(); - - /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: - /// This will statically either panic, or do nothing. - #[cfg(not(bootstrap))] pub fn assert_inhabited(); /// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// zero-initialization: This will statically either panic, or do nothing. - #[cfg(not(bootstrap))] pub fn assert_zero_valid(); /// A guard for unsafe functions that cannot ever be executed if `T` has invalid /// bit patterns: This will statically either panic, or do nothing. - #[cfg(not(bootstrap))] pub fn assert_uninit_valid(); /// Gets a reference to a static `Location` indicating where it was called. @@ -1597,17 +1574,10 @@ extern "rust-intrinsic" { /// May assume inputs are finite. pub fn frem_fast(a: T, b: T) -> T; - /// Convert with LLVM’s fptoui/fptosi, which may return undef for values out of range - /// () - /// This is under stabilization at - #[cfg(bootstrap)] - pub fn float_to_int_approx_unchecked(value: Float) -> Int; - /// Convert with LLVM’s fptoui/fptosi, which may return undef for values out of range /// () /// /// Stabilized as `f32::to_int_unchecked` and `f64::to_int_unchecked`. - #[cfg(not(bootstrap))] pub fn float_to_int_unchecked(value: Float) -> Int; /// Returns the number of bits set in an integer type `T` @@ -1877,10 +1847,7 @@ extern "rust-intrinsic" { /// takes the data pointer and a pointer to the target-specific exception /// object that was caught. For more information see the compiler's /// source as well as std's catch implementation. - #[cfg(not(bootstrap))] pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; - #[cfg(bootstrap)] - pub fn r#try(f: fn(*mut u8), data: *mut u8, local_ptr: *mut u8) -> i32; /// Emits a `!nontemporal` store according to LLVM (see their docs). /// Probably will never become stable. diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 37369289c512e..bb68184c8dd77 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -70,7 +70,7 @@ macro_rules! step_identical_methods { fn sub_one(&self) -> Self { Sub::sub(*self, 1) } - } + }; } macro_rules! step_impl_unsigned { diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 1c7bce3fac583..3b7929f00168a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -99,7 +99,7 @@ #![feature(lang_items)] #![feature(link_llvm_intrinsics)] #![feature(llvm_asm)] -#![cfg_attr(not(bootstrap), feature(negative_impls))] +#![feature(negative_impls)] #![feature(never_type)] #![feature(nll)] #![feature(exhaustive_patterns)] diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index 73404a73e3d00..9c1b62cf42570 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -1,27 +1,3 @@ -#[cfg(bootstrap)] -#[doc(include = "panic.md")] -#[macro_export] -#[allow_internal_unstable(core_panic, track_caller)] -#[stable(feature = "core", since = "1.6.0")] -macro_rules! panic { - () => ( - $crate::panic!("explicit panic") - ); - ($msg:expr) => ( - $crate::panicking::panic($msg) - ); - ($msg:expr,) => ( - $crate::panic!($msg) - ); - ($fmt:expr, $($arg:tt)+) => ( - $crate::panicking::panic_fmt( - $crate::format_args!($fmt, $($arg)+), - $crate::panic::Location::caller(), - ) - ); -} - -#[cfg(not(bootstrap))] #[doc(include = "panic.md")] #[macro_export] #[allow_internal_unstable(core_panic, track_caller)] @@ -350,6 +326,7 @@ macro_rules! matches { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")] #[doc(alias = "?")] +#[rustfmt::skip] // rustfmt will eat the raw identifer in the r#try! below. macro_rules! r#try { ($expr:expr) => { match $expr { @@ -1341,25 +1318,6 @@ pub(crate) mod builtin { /// Read the [unstable book] for the usage. /// /// [unstable book]: ../unstable-book/library-features/asm.html - #[cfg(bootstrap)] - #[unstable( - feature = "llvm_asm", - issue = "70173", - reason = "inline assembly is not stable enough for use and is subject to change" - )] - #[macro_export] - #[allow_internal_unstable(asm)] - macro_rules! llvm_asm { - // Redirect to asm! for stage0 - ($($arg:tt)*) => { $crate::asm!($($arg)*) } - } - - /// Inline assembly. - /// - /// Read the [unstable book] for the usage. - /// - /// [unstable book]: ../unstable-book/library-features/asm.html - #[cfg(not(bootstrap))] #[unstable( feature = "llvm_asm", issue = "70173", @@ -1460,7 +1418,6 @@ pub(crate) mod builtin { } /// Keeps the item it's applied to if the passed path is accessible, and removes it otherwise. - #[cfg(not(bootstrap))] #[unstable( feature = "cfg_accessible", issue = "64797", diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 549933ceeb645..09a8b417e6e22 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -90,7 +90,7 @@ impl !Send for *mut T {} ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>" )] #[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable -#[cfg_attr(not(bootstrap), rustc_specialization_trait)] +#[rustc_specialization_trait] pub trait Sized { // Empty. } diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index bf39d56fc115c..f7ea7eba7b16b 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -495,9 +495,6 @@ impl MaybeUninit { #[inline(always)] #[rustc_diagnostic_item = "assume_init"] pub unsafe fn assume_init(self) -> T { - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); - #[cfg(not(bootstrap))] intrinsics::assert_inhabited::(); ManuallyDrop::into_inner(self.value) } @@ -562,9 +559,6 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_extra", issue = "63567")] #[inline(always)] pub unsafe fn read(&self) -> T { - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); - #[cfg(not(bootstrap))] intrinsics::assert_inhabited::(); self.as_ptr().read() } @@ -627,9 +621,6 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[inline(always)] pub unsafe fn get_ref(&self) -> &T { - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); - #[cfg(not(bootstrap))] intrinsics::assert_inhabited::(); &*self.value } @@ -748,9 +739,6 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[inline(always)] pub unsafe fn get_mut(&mut self) -> &mut T { - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); - #[cfg(not(bootstrap))] intrinsics::assert_inhabited::(); &mut *self.value } diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 3fa2b7a2d042c..b1bbcaeab8def 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -378,7 +378,6 @@ pub fn size_of_val(val: &T) -> usize { /// assert_eq!(13, unsafe { mem::size_of_val_raw(y) }); /// ``` #[inline] -#[cfg(not(bootstrap))] #[unstable(feature = "layout_for_ptr", issue = "69835")] pub unsafe fn size_of_val_raw(val: *const T) -> usize { intrinsics::size_of_val(val) @@ -509,7 +508,6 @@ pub fn align_of_val(val: &T) -> usize { /// assert_eq!(4, unsafe { mem::align_of_val_raw(&5i32) }); /// ``` #[inline] -#[cfg(not(bootstrap))] #[unstable(feature = "layout_for_ptr", issue = "69835")] pub unsafe fn align_of_val_raw(val: *const T) -> usize { intrinsics::min_align_of_val(val) @@ -621,10 +619,7 @@ pub const fn needs_drop() -> bool { #[allow(deprecated)] #[rustc_diagnostic_item = "mem_zeroed"] pub unsafe fn zeroed() -> T { - #[cfg(not(bootstrap))] intrinsics::assert_zero_valid::(); - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); MaybeUninit::zeroed().assume_init() } @@ -657,10 +652,7 @@ pub unsafe fn zeroed() -> T { #[allow(deprecated)] #[rustc_diagnostic_item = "mem_uninitialized"] pub unsafe fn uninitialized() -> T { - #[cfg(not(bootstrap))] intrinsics::assert_uninit_valid::(); - #[cfg(bootstrap)] - intrinsics::panic_if_uninhabited::(); MaybeUninit::uninit().assume_init() } @@ -924,7 +916,12 @@ pub fn drop(_x: T) {} #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn transmute_copy(src: &T) -> U { - ptr::read_unaligned(src as *const T as *const U) + // If U has a higher alignment requirement, src may not be suitably aligned. + if align_of::() > align_of::() { + ptr::read_unaligned(src as *const T as *const U) + } else { + ptr::read(src as *const T as *const U) + } } /// Opaque type representing the discriminant of an enum. diff --git a/src/libcore/ops/deref.rs b/src/libcore/ops/deref.rs index e2deeb556610c..6e96aa330ff19 100644 --- a/src/libcore/ops/deref.rs +++ b/src/libcore/ops/deref.rs @@ -81,7 +81,6 @@ impl Deref for &T { } } -#[cfg(not(bootstrap))] #[stable(feature = "rust1", since = "1.0.0")] impl !DerefMut for &T {} diff --git a/src/libcore/ops/index.rs b/src/libcore/ops/index.rs index 64dd633f75d2b..763b33606fe88 100644 --- a/src/libcore/ops/index.rs +++ b/src/libcore/ops/index.rs @@ -65,7 +65,7 @@ pub trait Index { /// Performs the indexing (`container[index]`) operation. #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(bootstrap), track_caller)] + #[track_caller] fn index(&self, index: Idx) -> &Self::Output; } @@ -167,6 +167,6 @@ see chapter in The Book : Index { /// Performs the mutable indexing (`container[index]`) operation. #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(bootstrap), track_caller)] + #[track_caller] fn index_mut(&mut self, index: Idx) -> &mut Self::Output; } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 3587f3f0ebf56..cc8d4c1ed1263 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -50,13 +50,9 @@ pub fn panic(expr: &str) -> ! { // truncation and padding (even though none is used here). Using // Arguments::new_v1 may allow the compiler to omit Formatter::pad from the // output binary, saving up to a few kilobytes. - #[cfg(not(bootstrap))] panic_fmt(fmt::Arguments::new_v1(&[expr], &[])); - #[cfg(bootstrap)] - panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), Location::caller()); } -#[cfg(not(bootstrap))] #[cold] #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[track_caller] @@ -69,29 +65,12 @@ fn panic_bounds_check(index: usize, len: usize) -> ! { panic!("index out of bounds: the len is {} but the index is {}", len, index) } -// For bootstrap, we need a variant with the old argument order, and a corresponding -// `panic_fmt`. -#[cfg(bootstrap)] -#[cold] -#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] -#[lang = "panic_bounds_check"] // needed by codegen for panic on OOB array/slice access -fn panic_bounds_check(location: &Location<'_>, index: usize, len: usize) -> ! { - if cfg!(feature = "panic_immediate_abort") { - unsafe { super::intrinsics::abort() } - } - - panic_fmt( - format_args!("index out of bounds: the len is {} but the index is {}", len, index), - location, - ) -} - /// The underlying implementation of libcore's `panic!` macro when formatting is used. #[cold] #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] -#[cfg_attr(not(bootstrap), track_caller)] -pub fn panic_fmt(fmt: fmt::Arguments<'_>, #[cfg(bootstrap)] location: &Location<'_>) -> ! { +#[track_caller] +pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { super::intrinsics::abort() } } @@ -103,9 +82,6 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, #[cfg(bootstrap)] location: &Location< fn panic_impl(pi: &PanicInfo<'_>) -> !; } - #[cfg(bootstrap)] - let pi = PanicInfo::internal_constructor(Some(&fmt), location); - #[cfg(not(bootstrap))] let pi = PanicInfo::internal_constructor(Some(&fmt), Location::caller()); unsafe { panic_impl(&pi) } diff --git a/src/libcore/prelude/v1.rs b/src/libcore/prelude/v1.rs index 6a51d39ab9d4e..b4fff3d67b555 100644 --- a/src/libcore/prelude/v1.rs +++ b/src/libcore/prelude/v1.rs @@ -69,7 +69,6 @@ pub use crate::macros::builtin::{ bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable, }; -#[cfg(not(bootstrap))] #[unstable( feature = "cfg_accessible", issue = "64797", diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs index 729e0b897c098..35a0852bbf545 100644 --- a/src/libcore/ptr/const_ptr.rs +++ b/src/libcore/ptr/const_ptr.rs @@ -706,7 +706,6 @@ impl *const T { } } -#[cfg(not(bootstrap))] #[lang = "const_slice_ptr"] impl *const [T] { /// Returns the length of a raw slice. diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 4913cd73a2a9a..84f28488c74b6 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -76,12 +76,15 @@ use crate::intrinsics::{self, is_aligned_and_not_null, is_nonoverlapping}; use crate::mem::{self, MaybeUninit}; #[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] pub use crate::intrinsics::copy_nonoverlapping; #[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] pub use crate::intrinsics::copy; #[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] pub use crate::intrinsics::write_bytes; mod non_null; diff --git a/src/libcore/ptr/mut_ptr.rs b/src/libcore/ptr/mut_ptr.rs index 3b7e83bf37fa6..dbd92ce5fcc5b 100644 --- a/src/libcore/ptr/mut_ptr.rs +++ b/src/libcore/ptr/mut_ptr.rs @@ -894,7 +894,6 @@ impl *mut T { } } -#[cfg(not(bootstrap))] #[lang = "mut_slice_ptr"] impl *mut [T] { /// Returns the length of a raw slice. diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index dc395bcfba5cc..7b357bb487a0a 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2831,13 +2831,13 @@ pub trait SliceIndex: private_slice_index::Sealed { /// Returns a shared reference to the output at this location, panicking /// if out of bounds. #[unstable(feature = "slice_index_methods", issue = "none")] - #[cfg_attr(not(bootstrap), track_caller)] + #[track_caller] fn index(self, slice: &T) -> &Self::Output; /// Returns a mutable reference to the output at this location, panicking /// if out of bounds. #[unstable(feature = "slice_index_methods", issue = "none")] - #[cfg_attr(not(bootstrap), track_caller)] + #[track_caller] fn index_mut(self, slice: &mut T) -> &mut Self::Output; } diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index f44a875c9d0d5..fd3e11858cef6 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -106,15 +106,6 @@ pub mod personalities { 1 // `ExceptionContinueSearch` } - // Similar to above, this corresponds to the `eh_unwind_resume` lang item - // that's only used on Windows currently. - // - // Note that we don't execute landing pads, so this is never called, so it's - // body is empty. - #[rustc_std_internal_symbol] - #[cfg(all(bootstrap, target_os = "windows", target_env = "gnu"))] - pub extern "C" fn rust_eh_unwind_resume() {} - // These two are called by our startup objects on i686-pc-windows-gnu, but // they don't need to do anything so the bodies are nops. #[rustc_std_internal_symbol] diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index 1622442a5eb45..f5d83c21da068 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -311,18 +311,6 @@ unsafe fn find_eh_action( eh::find_eh_action(lsda, &eh_context, foreign_exception) } -#[cfg(all( - bootstrap, - target_os = "windows", - any(target_arch = "x86", target_arch = "x86_64"), - target_env = "gnu" -))] -#[lang = "eh_unwind_resume"] -#[unwind(allowed)] -unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! { - uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception); -} - // Frame unwind info registration // // Each module's image contains a frame unwind info section (usually diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index 9eff37f17663a..8d8276b4159ac 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -213,7 +213,6 @@ extern "C" { // // This is fine since the MSVC runtime uses string comparison on the type name // to match TypeDescriptors rather than pointer equality. -#[cfg_attr(bootstrap, lang = "eh_catch_typeinfo")] static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { pVFTable: unsafe { &TYPE_INFO_VTABLE } as *const _ as *const _, spare: core::ptr::null_mut(), diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 3cbe852de7b5a..eb7677e9345f2 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -24,11 +24,10 @@ #![feature(decl_macro)] #![feature(extern_types)] #![feature(in_band_lifetimes)] -#![cfg_attr(not(bootstrap), feature(negative_impls))] +#![feature(negative_impls)] #![feature(optin_builtin_traits)] #![feature(rustc_attrs)] -#![cfg_attr(bootstrap, feature(specialization))] -#![cfg_attr(not(bootstrap), feature(min_specialization))] +#![feature(min_specialization)] #![recursion_limit = "256"] #[unstable(feature = "proc_macro_internals", issue = "27812")] @@ -274,14 +273,14 @@ impl !Send for Span {} impl !Sync for Span {} macro_rules! diagnostic_method { - ($name:ident, $level:expr) => ( + ($name:ident, $level:expr) => { /// Creates a new `Diagnostic` with the given `message` at the span /// `self`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn $name>(self, message: T) -> Diagnostic { Diagnostic::spanned(self, $level, message) } - ) + }; } impl Span { diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index db60760e4596f..37034141bb77d 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -119,7 +119,12 @@ pub struct ModuleConfig { } impl ModuleConfig { - fn new(kind: ModuleKind, sess: &Session, no_builtins: bool) -> ModuleConfig { + fn new( + kind: ModuleKind, + sess: &Session, + no_builtins: bool, + is_compiler_builtins: bool, + ) -> ModuleConfig { // If it's a regular module, use `$regular`, otherwise use `$other`. // `$regular` and `$other` are evaluated lazily. macro_rules! if_regular { @@ -160,7 +165,10 @@ impl ModuleConfig { passes: if_regular!( { let mut passes = sess.opts.cg.passes.clone(); - if sess.opts.debugging_opts.profile { + // compiler_builtins overrides the codegen-units settings, + // which is incompatible with -Zprofile which requires that + // only a single codegen unit is used per crate. + if sess.opts.debugging_opts.profile && !is_compiler_builtins { passes.push("insert-gcov-profiling".to_owned()); } passes @@ -406,6 +414,8 @@ pub fn start_async_codegen( let crate_name = tcx.crate_name(LOCAL_CRATE); let crate_hash = tcx.crate_hash(LOCAL_CRATE); let no_builtins = attr::contains_name(&tcx.hir().krate().item.attrs, sym::no_builtins); + let is_compiler_builtins = + attr::contains_name(&tcx.hir().krate().item.attrs, sym::compiler_builtins); let subsystem = attr::first_attr_value_str_by_name(&tcx.hir().krate().item.attrs, sym::windows_subsystem); let windows_subsystem = subsystem.map(|subsystem| { @@ -422,9 +432,12 @@ pub fn start_async_codegen( let linker_info = LinkerInfo::new(tcx); let crate_info = CrateInfo::new(tcx); - let regular_config = ModuleConfig::new(ModuleKind::Regular, sess, no_builtins); - let metadata_config = ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins); - let allocator_config = ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins); + let regular_config = + ModuleConfig::new(ModuleKind::Regular, sess, no_builtins, is_compiler_builtins); + let metadata_config = + ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins, is_compiler_builtins); + let allocator_config = + ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins, is_compiler_builtins); let (shared_emitter, shared_emitter_main) = SharedEmitter::new(); let (codegen_worker_send, codegen_worker_receive) = channel(); diff --git a/src/librustc_error_codes/error_codes/E0308.md b/src/librustc_error_codes/error_codes/E0308.md index b2c8437049001..e2c40f03019c1 100644 --- a/src/librustc_error_codes/error_codes/E0308.md +++ b/src/librustc_error_codes/error_codes/E0308.md @@ -12,8 +12,7 @@ let x: i32 = "I am not a number!"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. diff --git a/src/librustc_hir/def.rs b/src/librustc_hir/def.rs index 3334cc32a52f7..88049f85f45e4 100644 --- a/src/librustc_hir/def.rs +++ b/src/librustc_hir/def.rs @@ -77,6 +77,18 @@ pub enum DefKind { // Macro namespace Macro(MacroKind), + + // Not namespaced (or they are, but we don't treat them so) + ExternCrate, + Use, + ForeignMod, + AnonConst, + Field, + LifetimeParam, + GlobalAsm, + Impl, + Closure, + Generator, } impl DefKind { @@ -113,6 +125,16 @@ impl DefKind { DefKind::TyParam => "type parameter", DefKind::ConstParam => "const parameter", DefKind::Macro(macro_kind) => macro_kind.descr(), + DefKind::LifetimeParam => "lifetime parameter", + DefKind::Use => "import", + DefKind::ForeignMod => "foreign module", + DefKind::AnonConst => "constant expression", + DefKind::Field => "field", + DefKind::Impl => "implementation", + DefKind::Closure => "closure", + DefKind::Generator => "generator", + DefKind::ExternCrate => "extern crate", + DefKind::GlobalAsm => "global assembly block", } } @@ -124,7 +146,10 @@ impl DefKind { | DefKind::AssocOpaqueTy | DefKind::AssocFn | DefKind::Enum - | DefKind::OpaqueTy => "an", + | DefKind::OpaqueTy + | DefKind::Impl + | DefKind::Use + | DefKind::ExternCrate => "an", DefKind::Macro(macro_kind) => macro_kind.article(), _ => "a", } @@ -155,6 +180,18 @@ impl DefKind { | DefKind::AssocConst => ns == Namespace::ValueNS, DefKind::Macro(..) => ns == Namespace::MacroNS, + + // Not namespaced. + DefKind::AnonConst + | DefKind::Field + | DefKind::LifetimeParam + | DefKind::ExternCrate + | DefKind::Closure + | DefKind::Generator + | DefKind::Use + | DefKind::ForeignMod + | DefKind::GlobalAsm + | DefKind::Impl => false, } } } diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index b66e6101b504b..d342f8b0ad21c 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -2452,27 +2452,6 @@ pub enum ItemKind<'hir> { } impl ItemKind<'_> { - pub fn descr(&self) -> &str { - match *self { - ItemKind::ExternCrate(..) => "extern crate", - ItemKind::Use(..) => "`use` import", - ItemKind::Static(..) => "static item", - ItemKind::Const(..) => "constant item", - ItemKind::Fn(..) => "function", - ItemKind::Mod(..) => "module", - ItemKind::ForeignMod(..) => "extern block", - ItemKind::GlobalAsm(..) => "global asm item", - ItemKind::TyAlias(..) => "type alias", - ItemKind::OpaqueTy(..) => "opaque type", - ItemKind::Enum(..) => "enum", - ItemKind::Struct(..) => "struct", - ItemKind::Union(..) => "union", - ItemKind::Trait(..) => "trait", - ItemKind::TraitAlias(..) => "trait alias", - ItemKind::Impl { .. } => "implementation", - } - } - pub fn generics(&self) -> Option<&Generics<'_>> { Some(match *self { ItemKind::Fn(_, ref generics, _) @@ -2551,16 +2530,6 @@ pub enum ForeignItemKind<'hir> { Type, } -impl ForeignItemKind<'hir> { - pub fn descriptive_variant(&self) -> &str { - match *self { - ForeignItemKind::Fn(..) => "foreign function", - ForeignItemKind::Static(..) => "foreign static item", - ForeignItemKind::Type => "foreign type", - } - } -} - /// A variable captured by a closure. #[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable_Generic)] pub struct Upvar { diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index bb6e5700ccad4..d3bd0763ff171 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -192,12 +192,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .get_opt_name() .map(|parent_symbol| parent_symbol.to_string()); - let type_parent_desc = self - .tcx - .def_kind(parent_def_id) - .map(|parent_def_kind| parent_def_kind.descr(parent_def_id)); - - (parent_name, type_parent_desc) + (parent_name, Some(self.tcx.def_kind(parent_def_id).descr(parent_def_id))) } else { (None, None) }; diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 1fb260f66fa3b..39d8213f2629b 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -562,8 +562,8 @@ impl MetadataBlob { } impl EntryKind { - fn def_kind(&self) -> Option { - Some(match *self { + fn def_kind(&self) -> DefKind { + match *self { EntryKind::Const(..) => DefKind::Const, EntryKind::AssocConst(..) => DefKind::AssocConst, EntryKind::ImmStatic @@ -587,14 +587,13 @@ impl EntryKind { EntryKind::Enum(..) => DefKind::Enum, EntryKind::MacroDef(_) => DefKind::Macro(MacroKind::Bang), EntryKind::ForeignType => DefKind::ForeignTy, - - EntryKind::ForeignMod - | EntryKind::GlobalAsm - | EntryKind::Impl(_) - | EntryKind::Field - | EntryKind::Generator(_) - | EntryKind::Closure => return None, - }) + EntryKind::Impl(_) => DefKind::Impl, + EntryKind::Closure => DefKind::Closure, + EntryKind::ForeignMod => DefKind::ForeignMod, + EntryKind::GlobalAsm => DefKind::GlobalAsm, + EntryKind::Field => DefKind::Field, + EntryKind::Generator(_) => DefKind::Generator, + } } } @@ -679,11 +678,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } } - fn def_kind(&self, index: DefIndex) -> Option { + fn def_kind(&self, index: DefIndex) -> DefKind { if !self.is_proc_macro(index) { self.kind(index).def_kind() } else { - Some(DefKind::Macro(macro_kind(self.raw_proc_macro(index)))) + DefKind::Macro(macro_kind(self.raw_proc_macro(index))) } } @@ -1009,20 +1008,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { .get(self, child_index) .unwrap_or(Lazy::empty()); for child_index in child_children.decode((self, sess)) { - if let Some(kind) = self.def_kind(child_index) { - callback(Export { - res: Res::Def(kind, self.local_def_id(child_index)), - ident: self.item_ident(child_index, sess), - vis: self.get_visibility(child_index), - span: self - .root - .tables - .span - .get(self, child_index) - .unwrap() - .decode((self, sess)), - }); - } + let kind = self.def_kind(child_index); + callback(Export { + res: Res::Def(kind, self.local_def_id(child_index)), + ident: self.item_ident(child_index, sess), + vis: self.get_visibility(child_index), + span: self + .root + .tables + .span + .get(self, child_index) + .unwrap() + .decode((self, sess)), + }); } continue; } @@ -1033,10 +1031,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { let def_key = self.def_key(child_index); let span = self.get_span(child_index, sess); - if let (Some(kind), true) = ( - self.def_kind(child_index), - def_key.disambiguated_data.data.get_opt_name().is_some(), - ) { + if def_key.disambiguated_data.data.get_opt_name().is_some() { + let kind = self.def_kind(child_index); let ident = self.item_ident(child_index, sess); let vis = self.get_visibility(child_index); let def_id = self.local_def_id(child_index); diff --git a/src/librustc_metadata/rmeta/table.rs b/src/librustc_metadata/rmeta/table.rs index 752caff754eeb..bacb5a345fca9 100644 --- a/src/librustc_metadata/rmeta/table.rs +++ b/src/librustc_metadata/rmeta/table.rs @@ -42,10 +42,7 @@ macro_rules! fixed_size_encoding_byte_len_and_defaults { // but slicing `[u8]` with `i * N..` is optimized worse, due to the // possibility of `i * N` overflowing, than indexing `[[u8; N]]`. let b = unsafe { - std::slice::from_raw_parts( - b.as_ptr() as *const [u8; BYTE_LEN], - b.len() / BYTE_LEN, - ) + std::slice::from_raw_parts(b.as_ptr() as *const [u8; BYTE_LEN], b.len() / BYTE_LEN) }; b.get(i).map(|b| FixedSizeEncoding::from_bytes(b)) } @@ -61,7 +58,7 @@ macro_rules! fixed_size_encoding_byte_len_and_defaults { }; self.write_to_bytes(&mut b[i]); } - } + }; } impl FixedSizeEncoding for u32 { diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index a734cbc6fe933..48e89cab59937 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -6,7 +6,7 @@ use crate::ty::TyCtxt; use rustc_ast::ast::{self, Name, NodeId}; use rustc_data_structures::svh::Svh; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; +use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, Definitions}; use rustc_hir::intravisit; use rustc_hir::itemlikevisit::ItemLikeVisitor; @@ -229,10 +229,14 @@ impl<'hir> Map<'hir> { self.tcx.definitions.opt_local_def_id_to_hir_id(def_id) } - pub fn def_kind(&self, hir_id: HirId) -> Option { - let node = self.find(hir_id)?; + pub fn def_kind(&self, local_def_id: LocalDefId) -> DefKind { + // FIXME(eddyb) support `find` on the crate root. + if local_def_id.to_def_id().index == CRATE_DEF_INDEX { + return DefKind::Mod; + } - Some(match node { + let hir_id = self.local_def_id_to_hir_id(local_def_id); + match self.get(hir_id) { Node::Item(item) => match item.kind { ItemKind::Static(..) => DefKind::Static, ItemKind::Const(..) => DefKind::Const, @@ -245,11 +249,11 @@ impl<'hir> Map<'hir> { ItemKind::Union(..) => DefKind::Union, ItemKind::Trait(..) => DefKind::Trait, ItemKind::TraitAlias(..) => DefKind::TraitAlias, - ItemKind::ExternCrate(_) - | ItemKind::Use(..) - | ItemKind::ForeignMod(..) - | ItemKind::GlobalAsm(..) - | ItemKind::Impl { .. } => return None, + ItemKind::ExternCrate(_) => DefKind::ExternCrate, + ItemKind::Use(..) => DefKind::Use, + ItemKind::ForeignMod(..) => DefKind::ForeignMod, + ItemKind::GlobalAsm(..) => DefKind::GlobalAsm, + ItemKind::Impl { .. } => DefKind::Impl, }, Node::ForeignItem(item) => match item.kind { ForeignItemKind::Fn(..) => DefKind::Fn, @@ -270,7 +274,7 @@ impl<'hir> Map<'hir> { Node::Variant(_) => DefKind::Variant, Node::Ctor(variant_data) => { // FIXME(eddyb) is this even possible, if we have a `Node::Ctor`? - variant_data.ctor_hir_id()?; + assert_ne!(variant_data.ctor_hir_id(), None); let ctor_of = match self.find(self.get_parent_node(hir_id)) { Some(Node::Item(..)) => def::CtorOf::Struct, @@ -279,10 +283,20 @@ impl<'hir> Map<'hir> { }; DefKind::Ctor(ctor_of, def::CtorKind::from_hir(variant_data)) } - Node::AnonConst(_) - | Node::Field(_) - | Node::Expr(_) - | Node::Stmt(_) + Node::AnonConst(_) => DefKind::AnonConst, + Node::Field(_) => DefKind::Field, + Node::Expr(expr) => match expr.kind { + ExprKind::Closure(.., None) => DefKind::Closure, + ExprKind::Closure(.., Some(_)) => DefKind::Generator, + _ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)), + }, + Node::MacroDef(_) => DefKind::Macro(MacroKind::Bang), + Node::GenericParam(param) => match param.kind { + GenericParamKind::Lifetime { .. } => DefKind::LifetimeParam, + GenericParamKind::Type { .. } => DefKind::TyParam, + GenericParamKind::Const { .. } => DefKind::ConstParam, + }, + Node::Stmt(_) | Node::PathSegment(_) | Node::Ty(_) | Node::TraitRef(_) @@ -294,14 +308,8 @@ impl<'hir> Map<'hir> { | Node::Lifetime(_) | Node::Visibility(_) | Node::Block(_) - | Node::Crate(_) => return None, - Node::MacroDef(_) => DefKind::Macro(MacroKind::Bang), - Node::GenericParam(param) => match param.kind { - GenericParamKind::Lifetime { .. } => return None, - GenericParamKind::Type { .. } => DefKind::TyParam, - GenericParamKind::Const { .. } => DefKind::ConstParam, - }, - }) + | Node::Crate(_) => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)), + } } fn find_entry(&self, id: HirId) -> Option> { @@ -1084,11 +1092,5 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String { } pub fn provide(providers: &mut Providers<'_>) { - providers.def_kind = |tcx, def_id| { - if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { - tcx.hir().def_kind(hir_id) - } else { - bug!("calling local def_kind query provider for upstream DefId: {:?}", def_id); - } - }; + providers.def_kind = |tcx, def_id| tcx.hir().def_kind(def_id.expect_local()); } diff --git a/src/librustc_middle/middle/stability.rs b/src/librustc_middle/middle/stability.rs index 1dd14b7c4ffda..75850db2c2e89 100644 --- a/src/librustc_middle/middle/stability.rs +++ b/src/librustc_middle/middle/stability.rs @@ -246,7 +246,7 @@ pub enum EvalResult { fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool { // Check if `def_id` is a trait method. match tcx.def_kind(def_id) { - Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => { + DefKind::AssocFn | DefKind::AssocTy | DefKind::AssocConst => { if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container { // Trait methods do not declare visibility (even // for visibility info in cstore). Use containing diff --git a/src/librustc_middle/mir/interpret/allocation.rs b/src/librustc_middle/mir/interpret/allocation.rs index 8b9f09774853a..afc6a958296fc 100644 --- a/src/librustc_middle/mir/interpret/allocation.rs +++ b/src/librustc_middle/mir/interpret/allocation.rs @@ -13,8 +13,6 @@ use super::{ read_target_uint, write_target_uint, AllocId, InterpResult, Pointer, Scalar, ScalarMaybeUndef, }; -// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in -// `src/librustc_mir/interpret/snapshot.rs`. #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] #[derive(HashStable)] pub struct Allocation { diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index c7eaf9cdbd012..23fe3156a09ff 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -620,7 +620,7 @@ rustc_queries! { cache_on_disk_if { true } } - query def_kind(_: DefId) -> Option {} + query def_kind(_: DefId) -> DefKind {} query def_span(_: DefId) -> Span { // FIXME(mw): DefSpans are not really inputs since they are derived from // HIR. But at the moment HIR hashing still contains some hacks that allow diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 7f15179f7074f..7378460f7d15d 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -48,7 +48,7 @@ use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE}; -use rustc_hir::definitions::{DefPathData, DefPathHash, Definitions}; +use rustc_hir::definitions::{DefPathHash, Definitions}; use rustc_hir::lang_items; use rustc_hir::lang_items::PanicLocationLangItem; use rustc_hir::{HirId, Node, TraitCandidate}; @@ -1492,21 +1492,13 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns a displayable description and article for the given `def_id` (e.g. `("a", "struct")`). pub fn article_and_description(&self, def_id: DefId) -> (&'static str, &'static str) { - self.def_kind(def_id) - .map(|def_kind| (def_kind.article(), def_kind.descr(def_id))) - .unwrap_or_else(|| match self.def_key(def_id).disambiguated_data.data { - DefPathData::ClosureExpr => match self.generator_kind(def_id) { - None => ("a", "closure"), - Some(rustc_hir::GeneratorKind::Async(..)) => ("an", "async closure"), - Some(rustc_hir::GeneratorKind::Gen) => ("a", "generator"), - }, - DefPathData::LifetimeNs(..) => ("a", "lifetime"), - DefPathData::Impl => ("an", "implementation"), - DefPathData::TypeNs(..) | DefPathData::ValueNs(..) | DefPathData::MacroNs(..) => { - unreachable!() - } - _ => bug!("article_and_description called on def_id {:?}", def_id), - }) + match self.def_kind(def_id) { + DefKind::Generator => match self.generator_kind(def_id).unwrap() { + rustc_hir::GeneratorKind::Async(..) => ("an", "async closure"), + rustc_hir::GeneratorKind::Gen => ("a", "generator"), + }, + def_kind => (def_kind.article(), def_kind.descr(def_id)), + } } } diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 97bc3fdb100a1..ee269c15d2bef 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -2671,16 +2671,9 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn opt_associated_item(self, def_id: DefId) -> Option { - let is_associated_item = if let Some(hir_id) = self.hir().as_local_hir_id(def_id) { - match self.hir().get(hir_id) { - Node::TraitItem(_) | Node::ImplItem(_) => true, - _ => false, - } - } else { - match self.def_kind(def_id) { - Some(DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy) => true, - _ => false, - } + let is_associated_item = match self.def_kind(def_id) { + DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true, + _ => false, }; is_associated_item.then(|| self.associated_item(def_id)) diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index a8825e8fc614e..435245468bdba 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -889,7 +889,7 @@ pub trait PrettyPrinter<'tcx>: p!(write("::{:?}", promoted)); } else { match self.tcx().def_kind(did) { - Some(DefKind::Static | DefKind::Const | DefKind::AssocConst) => { + DefKind::Static | DefKind::Const | DefKind::AssocConst => { p!(print_value_path(did, substs)) } _ => { diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index 4b10a8ba8210b..b46caf7985208 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -16,7 +16,6 @@ use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; -use rustc_hir::definitions::DefPathData; use rustc_macros::HashStable; use rustc_span::Span; use rustc_target::abi::{Integer, Size, TargetDataLayout}; @@ -446,24 +445,24 @@ impl<'tcx> TyCtxt<'tcx> { /// those are not yet phased out). The parent of the closure's /// `DefId` will also be the context where it appears. pub fn is_closure(self, def_id: DefId) -> bool { - self.def_key(def_id).disambiguated_data.data == DefPathData::ClosureExpr + matches!(self.def_kind(def_id), DefKind::Closure | DefKind::Generator) } /// Returns `true` if `def_id` refers to a trait (i.e., `trait Foo { ... }`). pub fn is_trait(self, def_id: DefId) -> bool { - self.def_kind(def_id) == Some(DefKind::Trait) + self.def_kind(def_id) == DefKind::Trait } /// Returns `true` if `def_id` refers to a trait alias (i.e., `trait Foo = ...;`), /// and `false` otherwise. pub fn is_trait_alias(self, def_id: DefId) -> bool { - self.def_kind(def_id) == Some(DefKind::TraitAlias) + self.def_kind(def_id) == DefKind::TraitAlias } /// Returns `true` if this `DefId` refers to the implicit constructor for /// a tuple struct like `struct Foo(u32)`, and `false` otherwise. pub fn is_constructor(self, def_id: DefId) -> bool { - self.def_key(def_id).disambiguated_data.data == DefPathData::Ctor + matches!(self.def_kind(def_id), DefKind::Ctor(..)) } /// Given the def-ID of a fn or closure, returns the def-ID of diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index 1592207e4d291..777114b309663 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -341,7 +341,7 @@ pub fn const_eval_raw_provider<'tcx>( // because any code that existed before validation could not have failed // validation thus preventing such a hard error from being a backwards // compatibility hazard - Some(DefKind::Const | DefKind::AssocConst) => { + DefKind::Const | DefKind::AssocConst => { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); err.report_as_lint( tcx.at(tcx.def_span(def_id)), diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index ae4ad49fe667f..d2a94160da43c 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -643,7 +643,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // FIXME: The above is likely untrue. See // . Is it // okay to ignore `StorageDead`/`StorageLive` annotations during CTFE? - Some(DefKind::Static | DefKind::Const | DefKind::AssocConst) => {} + DefKind::Static | DefKind::Const | DefKind::AssocConst => {} _ => { // Mark locals that use `Storage*` annotations as dead on function entry. let always_live = AlwaysLiveLocals::new(self.body()); diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 5f75633ae591b..ff22cb19da951 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -779,7 +779,7 @@ fn compute_codegen_unit_name( cgu_def_id = Some(DefId { krate: def_id.krate, index: CRATE_DEF_INDEX }); } break; - } else if tcx.def_kind(current_def_id) == Some(DefKind::Mod) { + } else if tcx.def_kind(current_def_id) == DefKind::Mod { if cgu_def_id.is_none() { cgu_def_id = Some(current_def_id); } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 271c746aa0fef..1c44439a16713 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -72,10 +72,7 @@ impl<'tcx> MirPass<'tcx> for ConstProp { .expect("Non-local call to local provider is_const_fn"); let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some(); - let is_assoc_const = match tcx.def_kind(source.def_id()) { - Some(DefKind::AssocConst) => true, - _ => false, - }; + let is_assoc_const = tcx.def_kind(source.def_id()) == DefKind::AssocConst; // Only run const prop on functions, methods, closures and associated constants if !is_fn_like && !is_assoc_const { diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6c852d9e36709..8829b10d5dd79 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -807,17 +807,17 @@ fn write_mir_sig( trace!("write_mir_sig: {:?}", src.instance); let kind = tcx.def_kind(src.def_id()); let is_function = match kind { - Some(DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..)) => true, + DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) => true, _ => tcx.is_closure(src.def_id()), }; match (kind, src.promoted) { (_, Some(i)) => write!(w, "{:?} in ", i)?, - (Some(DefKind::Const | DefKind::AssocConst), _) => write!(w, "const ")?, - (Some(DefKind::Static), _) => { + (DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?, + (DefKind::Static, _) => { write!(w, "static {}", if tcx.is_mutable_static(src.def_id()) { "mut " } else { "" })? } (_, _) if is_function => write!(w, "fn ")?, - (None, _) => {} // things like anon const, not an item + (DefKind::AnonConst, _) => {} // things like anon const, not an item _ => bug!("Unexpected def kind {:?}", kind), } diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index c07087db607cc..6a356d9f6bbe2 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -549,12 +549,13 @@ impl DeadVisitor<'tcx> { id: hir::HirId, span: rustc_span::Span, name: ast::Name, - node_type: &str, participle: &str, ) { if !name.as_str().starts_with('_') { self.tcx.struct_span_lint_hir(lint::builtin::DEAD_CODE, id, span, |lint| { - lint.build(&format!("{} is never {}: `{}`", node_type, participle, name)).emit() + let def_id = self.tcx.hir().local_def_id(id); + let descr = self.tcx.def_kind(def_id).descr(def_id); + lint.build(&format!("{} is never {}: `{}`", descr, participle, name)).emit() }); } } @@ -600,7 +601,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { hir::ItemKind::Struct(..) => "constructed", // Issue #52325 _ => "used", }; - self.warn_dead_code(item.hir_id, span, item.ident.name, item.kind.descr(), participle); + self.warn_dead_code(item.hir_id, span, item.ident.name, participle); } else { // Only continue if we didn't warn intravisit::walk_item(self, item); @@ -614,13 +615,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { id: hir::HirId, ) { if self.should_warn_about_variant(&variant) { - self.warn_dead_code( - variant.id, - variant.span, - variant.ident.name, - "variant", - "constructed", - ); + self.warn_dead_code(variant.id, variant.span, variant.ident.name, "constructed"); } else { intravisit::walk_variant(self, variant, g, id); } @@ -628,20 +623,14 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) { if self.should_warn_about_foreign_item(fi) { - self.warn_dead_code( - fi.hir_id, - fi.span, - fi.ident.name, - fi.kind.descriptive_variant(), - "used", - ); + self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name, "used"); } intravisit::walk_foreign_item(self, fi); } fn visit_struct_field(&mut self, field: &'tcx hir::StructField<'tcx>) { if self.should_warn_about_field(&field) { - self.warn_dead_code(field.hir_id, field.span, field.ident.name, "field", "read"); + self.warn_dead_code(field.hir_id, field.span, field.ident.name, "read"); } intravisit::walk_struct_field(self, field); } @@ -654,7 +643,6 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { impl_item.hir_id, impl_item.span, impl_item.ident.name, - "associated const", "used", ); } @@ -663,13 +651,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { hir::ImplItemKind::Fn(_, body_id) => { if !self.symbol_is_live(impl_item.hir_id) { let span = self.tcx.sess.source_map().guess_head_span(impl_item.span); - self.warn_dead_code( - impl_item.hir_id, - span, - impl_item.ident.name, - "method", - "used", - ); + self.warn_dead_code(impl_item.hir_id, span, impl_item.ident.name, "used"); } self.visit_nested_body(body_id) } diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index 2e48fd9d659bd..167590d64c947 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -337,12 +337,14 @@ struct MissingStabilityAnnotations<'a, 'tcx> { } impl<'a, 'tcx> MissingStabilityAnnotations<'a, 'tcx> { - fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) { + fn check_missing_stability(&self, hir_id: HirId, span: Span) { let stab = self.tcx.stability().local_stability(hir_id); let is_error = !self.tcx.sess.opts.test && stab.is_none() && self.access_levels.is_reachable(hir_id); if is_error { - self.tcx.sess.span_err(span, &format!("{} has missing stability attribute", name)); + let def_id = self.tcx.hir().local_def_id(hir_id); + let descr = self.tcx.def_kind(def_id).descr(def_id); + self.tcx.sess.span_err(span, &format!("{} has missing stability attribute", descr)); } } } @@ -362,42 +364,42 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { // optional. They inherit stability from their parents when unannotated. hir::ItemKind::Impl { of_trait: None, .. } | hir::ItemKind::ForeignMod(..) => {} - _ => self.check_missing_stability(i.hir_id, i.span, i.kind.descr()), + _ => self.check_missing_stability(i.hir_id, i.span), } intravisit::walk_item(self, i) } fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) { - self.check_missing_stability(ti.hir_id, ti.span, "item"); + self.check_missing_stability(ti.hir_id, ti.span); intravisit::walk_trait_item(self, ti); } fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) { let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent_item(ii.hir_id)); if self.tcx.impl_trait_ref(impl_def_id).is_none() { - self.check_missing_stability(ii.hir_id, ii.span, "item"); + self.check_missing_stability(ii.hir_id, ii.span); } intravisit::walk_impl_item(self, ii); } fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, item_id: HirId) { - self.check_missing_stability(var.id, var.span, "variant"); + self.check_missing_stability(var.id, var.span); intravisit::walk_variant(self, var, g, item_id); } fn visit_struct_field(&mut self, s: &'tcx StructField<'tcx>) { - self.check_missing_stability(s.hir_id, s.span, "field"); + self.check_missing_stability(s.hir_id, s.span); intravisit::walk_struct_field(self, s); } fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) { - self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant()); + self.check_missing_stability(i.hir_id, i.span); intravisit::walk_foreign_item(self, i); } fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) { - self.check_missing_stability(md.hir_id, md.span, "macro"); + self.check_missing_stability(md.hir_id, md.span); } } @@ -585,7 +587,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { if tcx.stability().staged_api[&LOCAL_CRATE] { let krate = tcx.hir().krate(); let mut missing = MissingStabilityAnnotations { tcx, access_levels }; - missing.check_missing_stability(hir::CRATE_HIR_ID, krate.item.span, "crate"); + missing.check_missing_stability(hir::CRATE_HIR_ID, krate.item.span); intravisit::walk_crate(&mut missing, krate); krate.visit_all_item_likes(&mut missing.as_deep_visitor()); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 51e1588c71c42..0956c9f8285d8 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1,6 +1,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(in_band_lifetimes)] #![feature(nll)] +#![feature(or_patterns)] #![recursion_limit = "256"] use rustc_ast::ast::Ident; @@ -536,11 +537,10 @@ impl EmbargoVisitor<'tcx> { for item_id in module.item_ids { let hir_id = item_id.id; let item_def_id = self.tcx.hir().local_def_id(hir_id); - if let Some(def_kind) = self.tcx.def_kind(item_def_id) { - let item = self.tcx.hir().expect_item(hir_id); - let vis = ty::Visibility::from_hir(&item.vis, hir_id, self.tcx); - self.update_macro_reachable_def(hir_id, def_kind, vis, defining_mod); - } + let def_kind = self.tcx.def_kind(item_def_id); + let item = self.tcx.hir().expect_item(hir_id); + let vis = ty::Visibility::from_hir(&item.vis, hir_id, self.tcx); + self.update_macro_reachable_def(hir_id, def_kind, vis, defining_mod); } if let Some(exports) = self.tcx.module_exports(module_def_id) { for export in exports { @@ -611,7 +611,7 @@ impl EmbargoVisitor<'tcx> { } // These have type privacy, so are not reachable unless they're - // public + // public, or are not namespaced at all. DefKind::AssocConst | DefKind::AssocTy | DefKind::AssocOpaqueTy @@ -624,7 +624,17 @@ impl EmbargoVisitor<'tcx> { | DefKind::AssocFn | DefKind::Trait | DefKind::TyParam - | DefKind::Variant => (), + | DefKind::Variant + | DefKind::LifetimeParam + | DefKind::ExternCrate + | DefKind::Use + | DefKind::ForeignMod + | DefKind::AnonConst + | DefKind::Field + | DefKind::GlobalAsm + | DefKind::Impl + | DefKind::Closure + | DefKind::Generator => (), } } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index f9156be3f4ada..bd484fc7a90cf 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -906,7 +906,21 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => { self.r.define(parent, ident, MacroNS, (res, vis, span, expansion)) } - Res::Def(DefKind::TyParam | DefKind::ConstParam, _) + Res::Def( + DefKind::TyParam + | DefKind::ConstParam + | DefKind::ExternCrate + | DefKind::Use + | DefKind::ForeignMod + | DefKind::AnonConst + | DefKind::Field + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::Closure + | DefKind::Impl + | DefKind::Generator, + _, + ) | Res::Local(..) | Res::SelfTy(..) | Res::SelfCtor(..) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index e94d7d6a85fb4..7639de1c0f5e6 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2502,10 +2502,8 @@ impl<'a> Resolver<'a> { } let container = match parent.kind { - ModuleKind::Def(DefKind::Mod, _, _) => "module", - ModuleKind::Def(DefKind::Trait, _, _) => "trait", + ModuleKind::Def(kind, _, _) => kind.descr(parent.def_id().unwrap()), ModuleKind::Block(..) => "block", - _ => "enum", }; let old_noun = match old_binding.is_import() { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 1939b6261d57b..8456a0304fec6 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -760,9 +760,23 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { Res::Def(HirDefKind::Mod, def_id) => { Some(Ref { kind: RefKind::Mod, span, ref_id: id_from_def_id(def_id) }) } - Res::PrimTy(..) + + Res::Def( + HirDefKind::Macro(..) + | HirDefKind::ExternCrate + | HirDefKind::ForeignMod + | HirDefKind::LifetimeParam + | HirDefKind::AnonConst + | HirDefKind::Use + | HirDefKind::Field + | HirDefKind::GlobalAsm + | HirDefKind::Impl + | HirDefKind::Closure + | HirDefKind::Generator, + _, + ) + | Res::PrimTy(..) | Res::SelfTy(..) - | Res::Def(HirDefKind::Macro(..), _) | Res::ToolMod | Res::NonMacroAttr(..) | Res::SelfCtor(..) diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 85a870ae34c11..888ac2d047d32 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -9,7 +9,7 @@ #![feature(const_if_match)] #![feature(const_fn)] #![feature(const_panic)] -#![cfg_attr(not(bootstrap), feature(negative_impls))] +#![feature(negative_impls)] #![feature(nll)] #![feature(optin_builtin_traits)] #![feature(specialization)] diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index e579393434e00..f2d611cc3b064 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1485,7 +1485,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // ``` debug!("parent_def_kind: {:?}", self.tcx.def_kind(parent_did)); let is_raw_borrow_inside_fn_like_call = match self.tcx.def_kind(parent_did) { - Some(DefKind::Fn | DefKind::Ctor(..)) => target_ty.is_unsafe_ptr(), + DefKind::Fn | DefKind::Ctor(..) => target_ty.is_unsafe_ptr(), _ => false, }; diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 4f3eba9995638..19765c36ae26a 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -150,10 +150,10 @@ crate fn program_clauses_for(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> { // FIXME(eddyb) this should only be using `def_kind`. match tcx.def_key(def_id).disambiguated_data.data { DefPathData::TypeNs(..) => match tcx.def_kind(def_id) { - Some(DefKind::Trait | DefKind::TraitAlias) => program_clauses_for_trait(tcx, def_id), + DefKind::Trait | DefKind::TraitAlias => program_clauses_for_trait(tcx, def_id), // FIXME(eddyb) deduplicate this `associated_item` call with // `program_clauses_for_associated_type_{value,def}`. - Some(DefKind::AssocTy) => match tcx.associated_item(def_id).container { + DefKind::AssocTy => match tcx.associated_item(def_id).container { ty::AssocItemContainer::ImplContainer(_) => { program_clauses_for_associated_type_value(tcx, def_id) } @@ -161,13 +161,11 @@ crate fn program_clauses_for(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> { program_clauses_for_associated_type_def(tcx, def_id) } }, - Some( - DefKind::Struct - | DefKind::Enum - | DefKind::TyAlias - | DefKind::Union - | DefKind::OpaqueTy, - ) => program_clauses_for_type_def(tcx, def_id), + DefKind::Struct + | DefKind::Enum + | DefKind::TyAlias + | DefKind::Union + | DefKind::OpaqueTy => program_clauses_for_type_def(tcx, def_id), _ => List::empty(), }, DefPathData::Impl => program_clauses_for_impl(tcx, def_id), diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 72220d93d929d..ecee2a75ae146 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -93,10 +93,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>( } Err(_) => { let item_span = tcx.def_span(self_type_did); - let self_descr = tcx - .def_kind(self_type_did) - .map(|kind| kind.descr(self_type_did)) - .unwrap_or("type"); + let self_descr = tcx.def_kind(self_type_did).descr(self_type_did); struct_span_err!( tcx.sess, drop_impl_span, @@ -243,8 +240,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( if !assumptions_in_impl_context.iter().any(predicate_matches_closure) { let item_span = tcx.hir().span(self_type_hir_id); - let self_descr = - tcx.def_kind(self_type_did).map(|kind| kind.descr(self_type_did)).unwrap_or("type"); + let self_descr = tcx.def_kind(self_type_did).descr(self_type_did); struct_span_err!( tcx.sess, *predicate_sp, diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index dbda735aa99c8..1aa3e916656ab 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -1564,10 +1564,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { base_did: DefId, ) { let struct_path = self.tcx().def_path_str(base_did); - let kind_name = match self.tcx().def_kind(base_did) { - Some(def_kind) => def_kind.descr(base_did), - _ => " ", - }; + let kind_name = self.tcx().def_kind(base_did).descr(base_did); let mut err = struct_span_err!( self.tcx().sess, field.span, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 65bcb19b20a89..6f05770b75a0d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -831,6 +831,13 @@ fn primary_body_of( } fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool { + // FIXME(#71104) some `LocalDefId` do not seem to have a corresponding `HirId`. + if let Some(def_id) = def_id.as_local() { + if tcx.hir().opt_local_def_id_to_hir_id(def_id).is_none() { + return false; + } + } + // Closures' tables come from their outermost function, // as they are part of the same "inference environment". let outer_def_id = tcx.closure_base_def_id(def_id); @@ -838,11 +845,8 @@ fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool { return tcx.has_typeck_tables(outer_def_id); } - // FIXME(#71104) Should really be using just `as_local_hir_id` but - // some `LocalDefId` do not seem to have a corresponding HirId. - if let Some(id) = - def_id.as_local().and_then(|def_id| tcx.hir().opt_local_def_id_to_hir_id(def_id)) - { + if let Some(def_id) = def_id.as_local() { + let id = tcx.hir().local_def_id_to_hir_id(def_id); primary_body_of(tcx, id).is_some() } else { false @@ -4965,11 +4969,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } Some(Node::Ctor(hir::VariantData::Tuple(fields, _))) => { sugg_call = fields.iter().map(|_| "_").collect::>().join(", "); - match hir.as_local_hir_id(def_id).and_then(|hir_id| hir.def_kind(hir_id)) { - Some(hir::def::DefKind::Ctor(hir::def::CtorOf::Variant, _)) => { + match self.tcx.def_kind(def_id) { + DefKind::Ctor(CtorOf::Variant, _) => { msg = "instantiate this tuple variant"; } - Some(hir::def::DefKind::Ctor(hir::def::CtorOf::Struct, _)) => { + DefKind::Ctor(CtorOf::Struct, _) => { msg = "instantiate this tuple struct"; } _ => {} diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e9af0ee5c2343..28af797be2235 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -278,7 +278,7 @@ fn build_type_alias_type(cx: &DocContext<'_>, did: DefId) -> Option } pub fn build_ty(cx: &DocContext, did: DefId) -> Option { - match cx.tcx.def_kind(did)? { + match cx.tcx.def_kind(did) { DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::Const | DefKind::Static => { Some(cx.tcx.type_of(did).clean(cx)) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ad9d54c345cfa..5522576ecbec0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2134,7 +2134,7 @@ impl Clean> for doctree::Impl<'_> { let for_ = self.for_.clean(cx); let type_alias = for_.def_id().and_then(|did| match cx.tcx.def_kind(did) { - Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)), + DefKind::TyAlias => Some(cx.tcx.type_of(did).clean(cx)), _ => None, }); let make_item = |trait_: Option, for_: Type, items: Vec| Item { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 24817170e36ee..535077dbb862b 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -209,7 +209,7 @@ pub fn get_real_types( res.extend(adds); } else if !ty.is_full_generic() { if let Some(kind) = - ty.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) + ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((ty, kind)); } @@ -226,9 +226,7 @@ pub fn get_real_types( if !adds.is_empty() { res.extend(adds); } else if !ty.is_full_generic() { - if let Some(kind) = - ty.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + if let Some(kind) = ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((ty.clone(), kind)); } } @@ -236,7 +234,7 @@ pub fn get_real_types( } } } else { - if let Some(kind) = arg.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) { + if let Some(kind) = arg.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((arg.clone(), kind)); } if let Some(gens) = arg.generics() { @@ -246,9 +244,7 @@ pub fn get_real_types( if !adds.is_empty() { res.extend(adds); } - } else if let Some(kind) = - gen.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + } else if let Some(kind) = gen.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((gen.clone(), kind)); } } @@ -275,7 +271,7 @@ pub fn get_all_types( if !args.is_empty() { all_types.extend(args); } else { - if let Some(kind) = arg.type_.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) { + if let Some(kind) = arg.type_.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { all_types.insert((arg.type_.clone(), kind)); } } @@ -285,9 +281,7 @@ pub fn get_all_types( FnRetTy::Return(ref return_type) => { let mut ret = get_real_types(generics, &return_type, cx, 0); if ret.is_empty() { - if let Some(kind) = - return_type.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + if let Some(kind) = return_type.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { ret.insert((return_type.clone(), kind)); } } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index cacc28b6e60e4..7565bdeb4096e 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2305,7 +2305,7 @@ macro_rules! read_primitive { value => Err(ExpectedError("Number".to_owned(), value.to_string())), } } - } + }; } impl crate::Decoder for Decoder { diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 41bdfea53e559..5cd2a25b11768 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -149,23 +149,35 @@ pub trait AsciiExt { macro_rules! delegating_ascii_methods { () => { #[inline] - fn is_ascii(&self) -> bool { self.is_ascii() } + fn is_ascii(&self) -> bool { + self.is_ascii() + } #[inline] - fn to_ascii_uppercase(&self) -> Self::Owned { self.to_ascii_uppercase() } + fn to_ascii_uppercase(&self) -> Self::Owned { + self.to_ascii_uppercase() + } #[inline] - fn to_ascii_lowercase(&self) -> Self::Owned { self.to_ascii_lowercase() } + fn to_ascii_lowercase(&self) -> Self::Owned { + self.to_ascii_lowercase() + } #[inline] - fn eq_ignore_ascii_case(&self, o: &Self) -> bool { self.eq_ignore_ascii_case(o) } + fn eq_ignore_ascii_case(&self, o: &Self) -> bool { + self.eq_ignore_ascii_case(o) + } #[inline] - fn make_ascii_uppercase(&mut self) { self.make_ascii_uppercase(); } + fn make_ascii_uppercase(&mut self) { + self.make_ascii_uppercase(); + } #[inline] - fn make_ascii_lowercase(&mut self) { self.make_ascii_lowercase(); } - } + fn make_ascii_lowercase(&mut self) { + self.make_ascii_lowercase(); + } + }; } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c0675eeba98da..e2092cfefa369 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -1,111 +1,5 @@ //! Asynchronous values. -#[cfg(bootstrap)] -use core::{ - cell::Cell, - marker::Unpin, - ops::{Drop, Generator, GeneratorState}, - pin::Pin, - ptr::NonNull, - task::{Context, Poll}, -}; - #[doc(inline)] #[stable(feature = "futures_api", since = "1.36.0")] pub use core::future::*; - -/// Wrap a generator in a future. -/// -/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give -/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`). -// This is `const` to avoid extra errors after we recover from `const async fn` -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -pub const fn from_generator>(x: T) -> impl Future { - GenFuture(x) -} - -/// A wrapper around generators used to implement `Future` for `async`/`await` code. -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -struct GenFuture>(T); - -// We rely on the fact that async/await futures are immovable in order to create -// self-referential borrows in the underlying generator. -#[cfg(bootstrap)] -impl> !Unpin for GenFuture {} - -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -impl> Future for GenFuture { - type Output = T::Return; - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - // Safe because we're !Unpin + !Drop mapping to a ?Unpin value - let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) }; - let _guard = unsafe { set_task_context(cx) }; - match gen.resume(()) { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), - } - } -} - -#[cfg(bootstrap)] -thread_local! { - static TLS_CX: Cell>>> = Cell::new(None); -} - -#[cfg(bootstrap)] -struct SetOnDrop(Option>>); - -#[cfg(bootstrap)] -impl Drop for SetOnDrop { - fn drop(&mut self) { - TLS_CX.with(|tls_cx| { - tls_cx.set(self.0.take()); - }); - } -} - -// Safety: the returned guard must drop before `cx` is dropped and before -// any previous guard is dropped. -#[cfg(bootstrap)] -unsafe fn set_task_context(cx: &mut Context<'_>) -> SetOnDrop { - // transmute the context's lifetime to 'static so we can store it. - let cx = core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx); - let old_cx = TLS_CX.with(|tls_cx| tls_cx.replace(Some(NonNull::from(cx)))); - SetOnDrop(old_cx) -} - -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -/// Polls a future in the current thread-local task waker. -pub fn poll_with_tls_context(f: Pin<&mut F>) -> Poll -where - F: Future, -{ - let cx_ptr = TLS_CX.with(|tls_cx| { - // Clear the entry so that nested `get_task_waker` calls - // will fail or set their own value. - tls_cx.replace(None) - }); - let _reset = SetOnDrop(cx_ptr); - - let mut cx_ptr = cx_ptr.expect( - "TLS Context not set. This is a rustc bug. \ - Please file an issue on https://github.com/rust-lang/rust.", - ); - - // Safety: we've ensured exclusive access to the context by - // removing the pointer from TLS, only to be replaced once - // we're done with it. - // - // The pointer that was inserted came from an `&mut Context<'_>`, - // so it is safe to treat as mutable. - unsafe { F::poll(f, cx_ptr.as_mut()) } -} diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9d2810cacc2bf..5fd15bb8fe4f3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -242,7 +242,7 @@ #![feature(atomic_mut_ptr)] #![feature(box_syntax)] #![feature(c_variadic)] -#![cfg_attr(not(bootstrap), feature(cfg_accessible))] +#![feature(cfg_accessible)] #![feature(cfg_target_has_atomic)] #![feature(cfg_target_thread_local)] #![feature(char_error_internals)] @@ -281,7 +281,7 @@ #![feature(maybe_uninit_ref)] #![feature(maybe_uninit_slice)] #![feature(needs_panic_runtime)] -#![cfg_attr(not(bootstrap), feature(negative_impls))] +#![feature(negative_impls)] #![feature(never_type)] #![feature(nll)] #![feature(optin_builtin_traits)] @@ -298,8 +298,7 @@ #![feature(shrink_to)] #![feature(slice_concat_ext)] #![feature(slice_internals)] -#![cfg_attr(bootstrap, feature(specialization))] -#![cfg_attr(not(bootstrap), feature(min_specialization))] +#![feature(min_specialization)] #![feature(staged_api)] #![feature(std_internals)] #![feature(stdsimd)] diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 10078bd4aee82..343b2ee12735f 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -271,44 +271,12 @@ pub unsafe fn r#try R>(f: F) -> Result> let mut data = Data { f: ManuallyDrop::new(f) }; let data_ptr = &mut data as *mut _ as *mut u8; - return if do_try(do_call::, data_ptr, do_catch::) == 0 { + return if intrinsics::r#try(do_call::, data_ptr, do_catch::) == 0 { Ok(ManuallyDrop::into_inner(data.r)) } else { Err(ManuallyDrop::into_inner(data.p)) }; - // Compatibility wrapper around the try intrinsic for bootstrap. - // - // We also need to mark it #[inline(never)] to work around a bug on MinGW - // targets: the unwinding implementation was relying on UB, but this only - // becomes a problem in practice if inlining is involved. - #[cfg(not(bootstrap))] - use intrinsics::r#try as do_try; - #[cfg(bootstrap)] - #[inline(never)] - unsafe fn do_try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32 { - use crate::mem::MaybeUninit; - #[cfg(target_env = "msvc")] - type TryPayload = [u64; 2]; - #[cfg(not(target_env = "msvc"))] - type TryPayload = *mut u8; - - let mut payload: MaybeUninit = MaybeUninit::uninit(); - let payload_ptr = payload.as_mut_ptr() as *mut u8; - let r = intrinsics::r#try(try_fn, data, payload_ptr); - if r != 0 { - #[cfg(target_env = "msvc")] - { - catch_fn(data, payload_ptr) - } - #[cfg(not(target_env = "msvc"))] - { - catch_fn(data, payload.assume_init()) - } - } - r - } - // We consider unwinding to be rare, so mark this function as cold. However, // do not mark it no-inline -- that decision is best to leave to the // optimizer (in most cases this function is not inlined even as a normal, @@ -320,9 +288,7 @@ pub unsafe fn r#try R>(f: F) -> Result> obj } - // See comment on do_try above for why #[inline(never)] is needed on bootstrap. - #[cfg_attr(bootstrap, inline(never))] - #[cfg_attr(not(bootstrap), inline)] + #[inline] fn do_call R, R>(data: *mut u8) { unsafe { let data = data as *mut Data; diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 92e3ea8485036..0fbd6b62f18ff 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -54,7 +54,6 @@ pub use core::prelude::v1::{ PartialEq, PartialOrd, RustcDecodable, RustcEncodable, }; -#[cfg(not(bootstrap))] #[unstable( feature = "cfg_accessible", issue = "64797", diff --git a/src/stage0.txt b/src/stage0.txt index 1c7c9f9aff095..150d7a0943db0 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.(x+1).0` for Cargo where they were released on `date`. -date: 2020-03-12 +date: 2020-04-22 rustc: beta cargo: beta @@ -20,7 +20,7 @@ cargo: beta # bootstrapping issues with use of new syntax in this repo. If you're looking at # the beta/stable branch, this key should be omitted, as we don't want to depend # on rustfmt from nightly there. -rustfmt: nightly-2020-01-31 +rustfmt: nightly-2020-04-22 # When making a stable release the process currently looks like: # diff --git a/src/test/ui/associated-const/associated-const-dead-code.rs b/src/test/ui/associated-const/associated-const-dead-code.rs index c47e474d2dd74..e659bdb83f9c1 100644 --- a/src/test/ui/associated-const/associated-const-dead-code.rs +++ b/src/test/ui/associated-const/associated-const-dead-code.rs @@ -4,7 +4,7 @@ struct MyFoo; impl MyFoo { const BAR: u32 = 1; - //~^ ERROR associated const is never used: `BAR` + //~^ ERROR associated constant is never used: `BAR` } fn main() { diff --git a/src/test/ui/associated-const/associated-const-dead-code.stderr b/src/test/ui/associated-const/associated-const-dead-code.stderr index 172aed733fca9..9b6bbb68a71f7 100644 --- a/src/test/ui/associated-const/associated-const-dead-code.stderr +++ b/src/test/ui/associated-const/associated-const-dead-code.stderr @@ -1,4 +1,4 @@ -error: associated const is never used: `BAR` +error: associated constant is never used: `BAR` --> $DIR/associated-const-dead-code.rs:6:5 | LL | const BAR: u32 = 1; diff --git a/src/test/ui/issues/issue-17718-const-naming.rs b/src/test/ui/issues/issue-17718-const-naming.rs index d30b95843f300..7386478f9f08c 100644 --- a/src/test/ui/issues/issue-17718-const-naming.rs +++ b/src/test/ui/issues/issue-17718-const-naming.rs @@ -3,6 +3,6 @@ const foo: isize = 3; //~^ ERROR: should have an upper case name -//~^^ ERROR: constant item is never used +//~^^ ERROR: constant is never used fn main() {} diff --git a/src/test/ui/issues/issue-17718-const-naming.stderr b/src/test/ui/issues/issue-17718-const-naming.stderr index 4c0aa0553ebd2..ce4ebcb5e3ef6 100644 --- a/src/test/ui/issues/issue-17718-const-naming.stderr +++ b/src/test/ui/issues/issue-17718-const-naming.stderr @@ -1,4 +1,4 @@ -error: constant item is never used: `foo` +error: constant is never used: `foo` --> $DIR/issue-17718-const-naming.rs:4:1 | LL | const foo: isize = 3; diff --git a/src/test/ui/json-bom-plus-crlf-multifile.stderr b/src/test/ui/json-bom-plus-crlf-multifile.stderr index 99f91cc881617..8d3c316e467bd 100644 --- a/src/test/ui/json-bom-plus-crlf-multifile.stderr +++ b/src/test/ui/json-bom-plus-crlf-multifile.stderr @@ -12,11 +12,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":612,"byte_end":618,"line_start":17,"line_end":17,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:17:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -33,11 +32,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":672,"byte_end":678,"line_start":19,"line_end":19,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:19:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -54,11 +52,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":735,"byte_end":741,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:23:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -75,11 +72,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":792,"byte_end":798,"line_start":25,"line_end":25,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:25:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/json-bom-plus-crlf.stderr b/src/test/ui/json-bom-plus-crlf.stderr index 3e84f5ef54d2c..ed6b583f329d6 100644 --- a/src/test/ui/json-bom-plus-crlf.stderr +++ b/src/test/ui/json-bom-plus-crlf.stderr @@ -12,11 +12,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":606,"byte_end":607,"line_start":16,"line_end":16,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":597,"byte_end":603,"line_start":16,"line_end":16,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":606,"byte_end":607,"line_start":16,"line_end":16,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:16:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -33,11 +32,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":666,"byte_end":667,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":657,"byte_end":663,"line_start":18,"line_end":18,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":666,"byte_end":667,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:18:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -54,11 +52,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":730,"byte_end":731,"line_start":22,"line_end":22,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":720,"byte_end":726,"line_start":21,"line_end":21,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":730,"byte_end":731,"line_start":22,"line_end":22,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:22:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. @@ -75,11 +72,10 @@ let x: i32 = \"I am not a number!\"; // type `i32` assigned to variable `x` ``` -This error occurs when the compiler was unable to infer the concrete type of a -variable. It can happen in several cases, the most common being a mismatch -between the type that the compiler inferred for a variable based on its -initializing expression, on the one hand, and the type the author explicitly -assigned to the variable, on the other hand. +This error occurs when the compiler is unable to infer the concrete type of a +variable. It can occur in several cases, the most common being a mismatch +between two types: the type the author explicitly assigned, and the type the +compiler inferred. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":786,"byte_end":794,"line_start":24,"line_end":25,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":777,"byte_end":783,"line_start":24,"line_end":24,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:24:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.rs b/src/test/ui/lint/dead-code/lint-dead-code-1.rs index 09977f8df51cf..896147fcc7738 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-1.rs @@ -17,14 +17,14 @@ mod foo2 { } pub static pub_static: isize = 0; -static priv_static: isize = 0; //~ ERROR: static item is never used +static priv_static: isize = 0; //~ ERROR: static is never used const used_static: isize = 0; pub static used_static2: isize = used_static; const USED_STATIC: isize = 0; const STATIC_USED_IN_ENUM_DISCRIMINANT: isize = 10; pub const pub_const: isize = 0; -const priv_const: isize = 0; //~ ERROR: constant item is never used +const priv_const: isize = 0; //~ ERROR: constant is never used const used_const: isize = 0; pub const used_const2: isize = used_const; const USED_CONST: isize = 1; diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr index 0a08aa6da9ac0..af97ea98b2b6d 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: static item is never used: `priv_static` +error: static is never used: `priv_static` --> $DIR/lint-dead-code-1.rs:20:1 | LL | static priv_static: isize = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: constant item is never used: `priv_const` +error: constant is never used: `priv_const` --> $DIR/lint-dead-code-1.rs:27:1 | LL | const priv_const: isize = 0; diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.rs b/src/test/ui/lint/dead-code/lint-dead-code-3.rs index 4397522f3f32f..6826d2cd67eb9 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-3.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-3.rs @@ -12,7 +12,7 @@ extern { struct Foo; //~ ERROR: struct is never constructed impl Foo { - fn foo(&self) { //~ ERROR: method is never used + fn foo(&self) { //~ ERROR: associated function is never used bar() } } @@ -58,7 +58,7 @@ mod blah { enum c_void {} //~ ERROR: enum is never used extern { - fn free(p: *const c_void); //~ ERROR: foreign function is never used + fn free(p: *const c_void); //~ ERROR: function is never used } // Check provided method diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr index aab25c481e6c7..a2614a0bf74b3 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr @@ -10,7 +10,7 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: method is never used: `foo` +error: associated function is never used: `foo` --> $DIR/lint-dead-code-3.rs:15:5 | LL | fn foo(&self) { @@ -28,7 +28,7 @@ error: enum is never used: `c_void` LL | enum c_void {} | ^^^^^^ -error: foreign function is never used: `free` +error: function is never used: `free` --> $DIR/lint-dead-code-3.rs:61:5 | LL | fn free(p: *const c_void); diff --git a/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.rs b/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.rs index 8f750ae62f5e4..38faa24691604 100644 --- a/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.rs +++ b/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.rs @@ -1,4 +1,4 @@ #![feature(staged_api)] -//~^ ERROR crate has missing stability attribute +//~^ ERROR module has missing stability attribute fn main() {} diff --git a/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.stderr b/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.stderr index b6c9564e904c4..c7ade234d3dcc 100644 --- a/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.stderr +++ b/src/test/ui/stability-attribute/missing-stability-attr-at-top-level.stderr @@ -1,4 +1,4 @@ -error: crate has missing stability attribute +error: module has missing stability attribute --> $DIR/missing-stability-attr-at-top-level.rs:1:1 | LL | / #![feature(staged_api)] diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 028483b7d95b5..3a8a5491255a0 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -831,12 +831,28 @@ fn extract_gdb_version(full_version_line: &str) -> Option { // GDB versions look like this: "major.minor.patch?.yyyymmdd?", with both // of the ? sections being optional - // We will parse up to 3 digits for minor and patch, ignoring the date - // We limit major to 1 digit, otherwise, on openSUSE, we parse the openSUSE version + // We will parse up to 3 digits for each component, ignoring the date + + // We skip text in parentheses. This avoids accidentally parsing + // the openSUSE version, which looks like: + // GNU gdb (GDB; openSUSE Leap 15.0) 8.1 + // This particular form is documented in the GNU coding standards: + // https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion // don't start parsing in the middle of a number let mut prev_was_digit = false; + let mut in_parens = false; for (pos, c) in full_version_line.char_indices() { + if in_parens { + if c == ')' { + in_parens = false; + } + continue; + } else if c == '(' { + in_parens = true; + continue; + } + if prev_was_digit || !c.is_digit(10) { prev_was_digit = c.is_digit(10); continue; @@ -876,7 +892,7 @@ fn extract_gdb_version(full_version_line: &str) -> Option { None => (line, None), }; - if major.len() != 1 || minor.is_empty() { + if minor.is_empty() { continue; } diff --git a/src/tools/compiletest/src/tests.rs b/src/tools/compiletest/src/tests.rs index 388ad75757f61..31c151d29e916 100644 --- a/src/tools/compiletest/src/tests.rs +++ b/src/tools/compiletest/src/tests.rs @@ -7,9 +7,9 @@ fn test_extract_gdb_version() { )*}}} test! { - 7000001: "GNU gdb (GDB) CentOS (7.0.1-45.el5.centos)", + 7000001: "GNU gdb (GDB) CentOS 7.0.1-45.el5.centos", - 7002000: "GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)", + 7002000: "GNU gdb (GDB) Red Hat Enterprise Linux 7.2-90.el6", 7004000: "GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04", 7004001: "GNU gdb (GDB) 7.4.1-debian",