Skip to content

Commit ac880e5

Browse files
authoredJul 4, 2021
Rollup merge of #86623 - GuillaumeGomez:prevent-explanation-removal, r=Mark-Simulacrum
Add check to ensure error code explanations are not removed anymore even if not emitted The error explanations are useful in case you use older version of the compiler. Even more if they had an explanation. If they are not emitted, their explanations should be updated but not removed (as we did for a few of them, like E0001). r? `@Mark-Simulacrum`
2 parents 5d555bf + d6962ff commit ac880e5

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
 

‎src/ci/docker/host-x86_64/mingw-check/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ COPY scripts/sccache.sh /scripts/
2828
RUN sh /scripts/sccache.sh
2929

3030
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
31+
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
3132

3233
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
3334
ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
@@ -37,6 +38,7 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
3738
python3 ../x.py test --stage 2 src/tools/tidy && \
3839
python3 ../x.py doc --stage 0 library/test && \
3940
/scripts/validate-toolstate.sh && \
41+
/scripts/validate-error-codes.sh && \
4042
# Runs checks to ensure that there are no ES5 issues in our JS code.
4143
es-check es5 ../src/librustdoc/html/static/*.js && \
4244
eslint ../src/librustdoc/html/static/*.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Checks that no error code explanation is removed.
3+
4+
set -eo pipefail
5+
6+
if [[ -z "$BASE_COMMIT" ]]; then
7+
echo "not checking error code explanations removal"
8+
exit 0
9+
fi
10+
11+
echo "Check if an error code explanation was removed..."
12+
13+
if (git diff "$BASE_COMMIT" --name-status | grep '^D' \
14+
| grep --quiet "compiler/rustc_error_codes/src/error_codes/"); then
15+
echo "Error code explanations should never be removed!"
16+
echo "Take a look at E0001 to see how to handle it."
17+
exit 1
18+
fi
19+
20+
echo "No error code explanation was removed!"

‎src/ci/docker/run.sh

+9
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ else
219219
command="/checkout/src/ci/run.sh"
220220
fi
221221

222+
if [ "$CI" != "" ]; then
223+
# Get some needed information for $BASE_COMMIT
224+
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
225+
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
226+
else
227+
BASE_COMMIT=""
228+
fi
229+
222230
docker \
223231
run \
224232
--workdir /checkout/obj \
@@ -237,6 +245,7 @@ docker \
237245
--env TOOLSTATE_PUBLISH \
238246
--env RUST_CI_OVERRIDE_RELEASE_CHANNEL \
239247
--env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
248+
--env BASE_COMMIT="$BASE_COMMIT" \
240249
--init \
241250
--rm \
242251
rust-ci \

0 commit comments

Comments
 (0)