From 03f0ca0cf4bf427516f9d87a959b7c97c9ff9447 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Oct 2020 19:32:59 +0100 Subject: Add test --- src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs | 11 +++++++++-- .../ui/or-patterns/exhaustiveness-unreachable-pattern.stderr | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs index a1147cb5cfc..97a8f526176 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs @@ -77,10 +77,17 @@ fn main() { (false | true, false | true) => {} } match (true, true) { - (true, false) => {} - (false, true) => {} + (true, true) => {} + (false, false) => {} (false | true, false | true) => {} } + // https://github.com/rust-lang/rust/issues/76836 + match None { + Some(false) => {} + None | Some(true + | false) => {} // expected unreachable warning here + } + // A subpattern that is unreachable in all branches is overall unreachable. match (true, true) { (false, true) => {} diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr index d92b545a869..e83cd247a57 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr @@ -101,13 +101,13 @@ LL | Some(0 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:89:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:96:15 | LL | | true) => {} | ^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:95:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:102:15 | LL | | true, | ^^^^ -- cgit 1.4.1-3-g733a5 From 25e272e3886ecdc91f3e42436cedbe5a6fc6ff29 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Oct 2020 22:08:19 +0100 Subject: Fix unreachable sub-branch detection This fixes https://github.com/rust-lang/rust/issues/76836 --- .../rustc_mir_build/src/thir/pattern/_match.rs | 120 +++++++++++++++------ .../src/thir/pattern/check_match.rs | 8 +- .../exhaustiveness-unreachable-pattern.rs | 2 +- .../exhaustiveness-unreachable-pattern.stderr | 16 ++- 4 files changed, 105 insertions(+), 41 deletions(-) (limited to 'src/test') diff --git a/compiler/rustc_mir_build/src/thir/pattern/_match.rs b/compiler/rustc_mir_build/src/thir/pattern/_match.rs index e0de1351ac3..d72a679dd5d 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/_match.rs @@ -1,5 +1,11 @@ -//! Note: most of the tests relevant to this file can be found (at the time of writing) in -//! src/tests/ui/pattern/usefulness. +//! Note: tests specific to this file can be found in: +//! - ui/pattern/usefulness +//! - ui/or-patterns +//! - ui/consts/const_in_pattern +//! - ui/rfc-2008-non-exhaustive +//! - probably many others +//! I (Nadrieril) prefer to put new tests in `ui/pattern/usefulness` unless there's a specific +//! reason not to, for example if they depend on a particular feature like or_patterns. //! //! This file includes the logic for exhaustiveness and usefulness checking for //! pattern-matching. Specifically, given a list of patterns for a type, we can @@ -1361,8 +1367,9 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { #[derive(Clone, Debug)] crate enum Usefulness<'tcx> { - /// Carries a list of unreachable subpatterns. Used only in the presence of or-patterns. - Useful(Vec), + /// Carries, for each column in the matrix, a set of sub-branches that have been found to be + /// unreachable. Used only in the presence of or-patterns, otherwise it stays empty. + Useful(Vec>), /// Carries a list of witnesses of non-exhaustiveness. UsefulWithWitness(Vec>), NotUseful, @@ -1410,6 +1417,23 @@ impl<'tcx> Usefulness<'tcx> { }; UsefulWithWitness(new_witnesses) } + Useful(mut unreachables) => { + if !unreachables.is_empty() { + // When we apply a constructor, there are `arity` columns of the matrix that + // corresponded to its arguments. All the unreachables found in these columns + // will, after `apply`, come from the first column. So we take the union of all + // the corresponding sets and put them in the first column. + // Note that `arity` may be 0, in which case we just push a new empty set. + let len = unreachables.len(); + let arity = ctor_wild_subpatterns.len(); + let mut unioned = FxHashSet::default(); + for set in unreachables.drain((len - arity)..) { + unioned.extend(set) + } + unreachables.push(unioned); + } + Useful(unreachables) + } x => x, } } @@ -2091,13 +2115,14 @@ crate fn is_useful<'p, 'tcx>( // If the first pattern is an or-pattern, expand it. if let Some(vs) = v.expand_or_pat() { - // We need to push the already-seen patterns into the matrix in order to detect redundant - // branches like `Some(_) | Some(0)`. We also keep track of the unreachable subpatterns. - let mut matrix = matrix.clone(); - // `Vec` of all the unreachable branches of the current or-pattern. - let mut unreachable_branches = Vec::new(); - // Subpatterns that are unreachable from all branches. E.g. in the following case, the last - // `true` is unreachable only from one branch, so it is overall reachable. + // We expand the or pattern, trying each of its branches in turn and keeping careful track + // of possible unreachable sub-branches. + // + // If two branches have detected some unreachable sub-branches, we need to be careful. If + // they were detected in columns that are not the current one, we want to keep only the + // sub-branches that were unreachable in _all_ branches. Eg. in the following, the last + // `true` is unreachable in the second branch of the first or-pattern, but not otherwise. + // Therefore we don't want to lint that it is unreachable. // // ``` // match (true, true) { @@ -2105,41 +2130,72 @@ crate fn is_useful<'p, 'tcx>( // (false | true, false | true) => {} // } // ``` - let mut unreachable_subpats = FxHashSet::default(); - // Whether any branch at all is useful. + // If however the sub-branches come from the current column, they come from the inside of + // the current or-pattern, and we want to keep them all. Eg. in the following, we _do_ want + // to lint that the last `false` is unreachable. + // ``` + // match None { + // Some(false) => {} + // None | Some(true | false) => {} + // } + // ``` + + let mut matrix = matrix.clone(); + // We keep track of sub-branches separately depending on whether they come from this column + // or from others. + let mut unreachables_this_column: FxHashSet = FxHashSet::default(); + let mut unreachables_other_columns: Vec> = Vec::default(); + // Whether at least one branch is reachable. let mut any_is_useful = false; for v in vs { let res = is_useful(cx, &matrix, &v, witness_preference, hir_id, is_under_guard, false); match res { - Useful(pats) => { - if !any_is_useful { - any_is_useful = true; - // Initialize with the first set of unreachable subpatterns encountered. - unreachable_subpats = pats.into_iter().collect(); - } else { - // Keep the patterns unreachable from both this and previous branches. - unreachable_subpats = - pats.into_iter().filter(|p| unreachable_subpats.contains(p)).collect(); + Useful(unreachables) => { + if let Some((this_column, other_columns)) = unreachables.split_last() { + // We keep the union of unreachables found in the first column. + unreachables_this_column.extend(this_column); + // We keep the intersection of unreachables found in other columns. + if unreachables_other_columns.is_empty() { + unreachables_other_columns = other_columns.to_vec(); + } else { + unreachables_other_columns = unreachables_other_columns + .into_iter() + .zip(other_columns) + .map(|(x, y)| x.intersection(&y).copied().collect()) + .collect(); + } } + any_is_useful = true; } - NotUseful => unreachable_branches.push(v.head().span), - UsefulWithWitness(_) => { - bug!("Encountered or-pat in `v` during exhaustiveness checking") + NotUseful => { + unreachables_this_column.insert(v.head().span); } + UsefulWithWitness(_) => bug!( + "encountered or-pat in the expansion of `_` during exhaustiveness checking" + ), } - // If pattern has a guard don't add it to the matrix + + // If pattern has a guard don't add it to the matrix. if !is_under_guard { + // We push the already-seen patterns into the matrix in order to detect redundant + // branches like `Some(_) | Some(0)`. matrix.push(v); } } - if any_is_useful { - // Collect all the unreachable patterns. - unreachable_branches.extend(unreachable_subpats); - return Useful(unreachable_branches); + + return if any_is_useful { + let mut unreachables = if unreachables_other_columns.is_empty() { + let n_columns = v.len(); + (0..n_columns - 1).map(|_| FxHashSet::default()).collect() + } else { + unreachables_other_columns + }; + unreachables.push(unreachables_this_column); + Useful(unreachables) } else { - return NotUseful; - } + NotUseful + }; } // FIXME(Nadrieril): Hack to work around type normalization issues (see #72476). diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 30b700a1d4f..317b8dc205e 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -389,9 +389,11 @@ fn check_arms<'p, 'tcx>( hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {} } } - Useful(unreachable_subpatterns) => { - for span in unreachable_subpatterns { - unreachable_pattern(cx.tcx, span, id, None); + Useful(unreachables) => { + for set in unreachables { + for span in set { + unreachable_pattern(cx.tcx, span, id, None); + } } } UsefulWithWitness(_) => bug!(), diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs index 97a8f526176..512f1e283cb 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs @@ -85,7 +85,7 @@ fn main() { match None { Some(false) => {} None | Some(true - | false) => {} // expected unreachable warning here + | false) => {} //~ ERROR unreachable } // A subpattern that is unreachable in all branches is overall unreachable. diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr index e83cd247a57..3956a42c536 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr @@ -77,15 +77,15 @@ LL | (1 | 1,) => {} | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:53:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:55:15 | -LL | | 0 +LL | | 0] => {} | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:55:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:53:15 | -LL | | 0] => {} +LL | | 0 | ^ error: unreachable pattern @@ -100,6 +100,12 @@ error: unreachable pattern LL | Some(0 | ^ +error: unreachable pattern + --> $DIR/exhaustiveness-unreachable-pattern.rs:88:19 + | +LL | | false) => {} + | ^^^^^ + error: unreachable pattern --> $DIR/exhaustiveness-unreachable-pattern.rs:96:15 | @@ -112,5 +118,5 @@ error: unreachable pattern LL | | true, | ^^^^ -error: aborting due to 18 previous errors +error: aborting due to 19 previous errors -- cgit 1.4.1-3-g733a5 From 107a29a90146ac418c71f306691cd4857ce15c03 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 5 Nov 2020 22:17:26 +0000 Subject: Emit lints in the order in which they occur in the file. --- compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 9 +++++---- .../ui/or-patterns/exhaustiveness-unreachable-pattern.stderr | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 317b8dc205e..205ad850c0c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -390,10 +390,11 @@ fn check_arms<'p, 'tcx>( } } Useful(unreachables) => { - for set in unreachables { - for span in set { - unreachable_pattern(cx.tcx, span, id, None); - } + let mut unreachables: Vec<_> = unreachables.into_iter().flatten().collect(); + // Emit lints in the order in which they occur in the file. + unreachables.sort_unstable(); + for span in unreachables { + unreachable_pattern(cx.tcx, span, id, None); } } UsefulWithWitness(_) => bug!(), diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr index 3956a42c536..e968310d108 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr @@ -77,15 +77,15 @@ LL | (1 | 1,) => {} | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:55:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:53:15 | -LL | | 0] => {} +LL | | 0 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:53:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:55:15 | -LL | | 0 +LL | | 0] => {} | ^ error: unreachable pattern -- cgit 1.4.1-3-g733a5 From 0af959d3a23a98e163b26fa577e4c34f3e67726d Mon Sep 17 00:00:00 2001 From: ankushduacodes Date: Fri, 6 Nov 2020 09:25:58 +0530 Subject: Fixing Spelling Typos --- compiler/rustc_mir/src/transform/check_unsafety.rs | 2 +- compiler/rustc_typeck/src/check/pat.rs | 2 +- src/test/ui/error-codes/E0027.stderr | 4 ++-- src/test/ui/structs/struct-field-cfg.stderr | 2 +- src/test/ui/structs/struct-pat-derived-error.stderr | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/test') diff --git a/compiler/rustc_mir/src/transform/check_unsafety.rs b/compiler/rustc_mir/src/transform/check_unsafety.rs index 3d68b862df2..acec3e8f82f 100644 --- a/compiler/rustc_mir/src/transform/check_unsafety.rs +++ b/compiler/rustc_mir/src/transform/check_unsafety.rs @@ -693,7 +693,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { // should only issue a warning for the sake of backwards compatibility. // // The solution those 2 expectations is to always take the minimum of both lints. - // This prevent any new errors (unless both lints are explicitely set to `deny`). + // This prevent any new errors (unless both lints are explicitly set to `deny`). let lint = if tcx.lint_level_at_node(SAFE_PACKED_BORROWS, lint_root).0 <= tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, lint_root).0 { diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 53bc2069b76..f76f42dea1e 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1500,7 +1500,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_suggestion( sp, &format!( - "if you don't care about {} missing field{}, you can explicitely ignore {}", + "if you don't care about {} missing field{}, you can explicitly ignore {}", if len == 1 { "this" } else { "these" }, if len == 1 { "" } else { "s" }, if len == 1 { "it" } else { "them" }, diff --git a/src/test/ui/error-codes/E0027.stderr b/src/test/ui/error-codes/E0027.stderr index c09f1ff1f2a..cf0ff631148 100644 --- a/src/test/ui/error-codes/E0027.stderr +++ b/src/test/ui/error-codes/E0027.stderr @@ -8,7 +8,7 @@ help: include the missing field in the pattern | LL | Dog { age: x, name } => {} | ^^^^^^ -help: if you don't care about this missing field, you can explicitely ignore it +help: if you don't care about this missing field, you can explicitly ignore it | LL | Dog { age: x, .. } => {} | ^^^^ @@ -23,7 +23,7 @@ help: include the missing fields in the pattern | LL | Dog { name, age } => {} | ^^^^^^^^^^^^^ -help: if you don't care about these missing fields, you can explicitely ignore them +help: if you don't care about these missing fields, you can explicitly ignore them | LL | Dog { .. } => {} | ^^^^^^ diff --git a/src/test/ui/structs/struct-field-cfg.stderr b/src/test/ui/structs/struct-field-cfg.stderr index b913b929079..740ea3829dc 100644 --- a/src/test/ui/structs/struct-field-cfg.stderr +++ b/src/test/ui/structs/struct-field-cfg.stderr @@ -22,7 +22,7 @@ help: include the missing field in the pattern | LL | let Foo { present } = foo; | ^^^^^^^^^^^ -help: if you don't care about this missing field, you can explicitely ignore it +help: if you don't care about this missing field, you can explicitly ignore it | LL | let Foo { .. } = foo; | ^^^^^^ diff --git a/src/test/ui/structs/struct-pat-derived-error.stderr b/src/test/ui/structs/struct-pat-derived-error.stderr index f3e9ce76f1e..921d060faa3 100644 --- a/src/test/ui/structs/struct-pat-derived-error.stderr +++ b/src/test/ui/structs/struct-pat-derived-error.stderr @@ -20,7 +20,7 @@ help: include the missing fields in the pattern | LL | let A { x, y, b, c } = self.d; | ^^^^^^ -help: if you don't care about these missing fields, you can explicitely ignore them +help: if you don't care about these missing fields, you can explicitly ignore them | LL | let A { x, y, .. } = self.d; | ^^^^ -- cgit 1.4.1-3-g733a5 From f197da655ffe5df52dc5bf19ead9067c8439700c Mon Sep 17 00:00:00 2001 From: Daiki Ihara Date: Tue, 3 Nov 2020 22:55:49 +0900 Subject: fix shellcheck error of SC2148 --- compiler/rustc_codegen_cranelift/scripts/config.sh | 1 + src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh | 1 + src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh | 1 + src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh | 1 + src/ci/docker/host-x86_64/dist-various-1/install-mips-musl.sh | 1 + src/ci/docker/host-x86_64/dist-various-1/install-mipsel-musl.sh | 1 + src/ci/docker/host-x86_64/dist-various-2/shared.sh | 1 + src/ci/docker/host-x86_64/dist-x86_64-linux/shared.sh | 1 + src/ci/docker/scripts/android-base-apt-get.sh | 1 + src/ci/docker/scripts/android-ndk.sh | 1 + src/ci/docker/scripts/android-sdk.sh | 1 + src/ci/docker/scripts/cross-apt-packages.sh | 1 + src/ci/docker/scripts/crosstool-ng-1.24.sh | 1 + src/ci/docker/scripts/crosstool-ng.sh | 1 + src/ci/docker/scripts/emscripten.sh | 1 + src/ci/docker/scripts/make3.sh | 1 + src/ci/docker/scripts/musl-toolchain.sh | 1 + src/ci/docker/scripts/musl.sh | 1 + src/ci/docker/scripts/rustbuild-setup.sh | 1 + src/ci/docker/scripts/sccache.sh | 1 + src/test/run-make/thumb-none-qemu/script.sh | 1 + src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh | 1 + 22 files changed, 22 insertions(+) (limited to 'src/test') diff --git a/compiler/rustc_codegen_cranelift/scripts/config.sh b/compiler/rustc_codegen_cranelift/scripts/config.sh index af181f4f724..6120a550a27 100644 --- a/compiler/rustc_codegen_cranelift/scripts/config.sh +++ b/compiler/rustc_codegen_cranelift/scripts/config.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash set -e unamestr=`uname` diff --git a/src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh b/src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh index b8735692789..4b207031df8 100644 --- a/src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh +++ b/src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh @@ -1,3 +1,4 @@ +#!/bin/sh hide_output() { set +x on_err=" diff --git a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh index b8735692789..4b207031df8 100644 --- a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh +++ b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh @@ -1,3 +1,4 @@ +#!/bin/sh hide_output() { set +x on_err=" diff --git a/src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh b/src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh index fb067a79a5c..3a40f6cddb3 100644 --- a/src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh +++ b/src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex # Mirrored from https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-1.24.0.tar.gz diff --git a/src/ci/docker/host-x86_64/dist-various-1/install-mips-musl.sh b/src/ci/docker/host-x86_64/dist-various-1/install-mips-musl.sh index 9584258d234..abab1809346 100755 --- a/src/ci/docker/host-x86_64/dist-various-1/install-mips-musl.sh +++ b/src/ci/docker/host-x86_64/dist-various-1/install-mips-musl.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex mkdir /usr/local/mips-linux-musl diff --git a/src/ci/docker/host-x86_64/dist-various-1/install-mipsel-musl.sh b/src/ci/docker/host-x86_64/dist-various-1/install-mipsel-musl.sh index 50a8e554b16..779acb2d841 100755 --- a/src/ci/docker/host-x86_64/dist-various-1/install-mipsel-musl.sh +++ b/src/ci/docker/host-x86_64/dist-various-1/install-mipsel-musl.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex mkdir /usr/local/mipsel-linux-musl diff --git a/src/ci/docker/host-x86_64/dist-various-2/shared.sh b/src/ci/docker/host-x86_64/dist-various-2/shared.sh index 7abace65b9c..267d8b79cc2 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/shared.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/shared.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash hide_output() { { set +x; } 2>/dev/null on_err=" diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/shared.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/shared.sh index b8735692789..4b207031df8 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/shared.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/shared.sh @@ -1,3 +1,4 @@ +#!/bin/sh hide_output() { set +x on_err=" diff --git a/src/ci/docker/scripts/android-base-apt-get.sh b/src/ci/docker/scripts/android-base-apt-get.sh index 1795b1696d3..f1761f80643 100644 --- a/src/ci/docker/scripts/android-base-apt-get.sh +++ b/src/ci/docker/scripts/android-base-apt-get.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex apt-get update diff --git a/src/ci/docker/scripts/android-ndk.sh b/src/ci/docker/scripts/android-ndk.sh index dafcb3cb7a7..ba70c62ea30 100644 --- a/src/ci/docker/scripts/android-ndk.sh +++ b/src/ci/docker/scripts/android-ndk.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex URL=https://dl.google.com/android/repository diff --git a/src/ci/docker/scripts/android-sdk.sh b/src/ci/docker/scripts/android-sdk.sh index e35be697a8d..23360d30951 100755 --- a/src/ci/docker/scripts/android-sdk.sh +++ b/src/ci/docker/scripts/android-sdk.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex export ANDROID_HOME=/android/sdk diff --git a/src/ci/docker/scripts/cross-apt-packages.sh b/src/ci/docker/scripts/cross-apt-packages.sh index 2de376443ad..57cb6d5cda8 100644 --- a/src/ci/docker/scripts/cross-apt-packages.sh +++ b/src/ci/docker/scripts/cross-apt-packages.sh @@ -1,3 +1,4 @@ +#!/bin/sh apt-get update && apt-get install -y --no-install-recommends \ automake \ bison \ diff --git a/src/ci/docker/scripts/crosstool-ng-1.24.sh b/src/ci/docker/scripts/crosstool-ng-1.24.sh index fb067a79a5c..3a40f6cddb3 100644 --- a/src/ci/docker/scripts/crosstool-ng-1.24.sh +++ b/src/ci/docker/scripts/crosstool-ng-1.24.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex # Mirrored from https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-1.24.0.tar.gz diff --git a/src/ci/docker/scripts/crosstool-ng.sh b/src/ci/docker/scripts/crosstool-ng.sh index 2773e687ebe..1d0c28c8e58 100644 --- a/src/ci/docker/scripts/crosstool-ng.sh +++ b/src/ci/docker/scripts/crosstool-ng.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex url="https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-1.22.0.tar.gz" diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index 9481ee95399..61596a1ca30 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex hide_output() { diff --git a/src/ci/docker/scripts/make3.sh b/src/ci/docker/scripts/make3.sh index 47cb4158229..283700d06f6 100644 --- a/src/ci/docker/scripts/make3.sh +++ b/src/ci/docker/scripts/make3.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex curl -f https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - diff --git a/src/ci/docker/scripts/musl-toolchain.sh b/src/ci/docker/scripts/musl-toolchain.sh index c56338a4f95..e83367db35b 100644 --- a/src/ci/docker/scripts/musl-toolchain.sh +++ b/src/ci/docker/scripts/musl-toolchain.sh @@ -1,3 +1,4 @@ +#!/bin/sh # This script runs `musl-cross-make` to prepare C toolchain (Binutils, GCC, musl itself) # and builds static libunwind that we distribute for static target. # diff --git a/src/ci/docker/scripts/musl.sh b/src/ci/docker/scripts/musl.sh index 58393a5719a..c5d6cdeba03 100644 --- a/src/ci/docker/scripts/musl.sh +++ b/src/ci/docker/scripts/musl.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex hide_output() { diff --git a/src/ci/docker/scripts/rustbuild-setup.sh b/src/ci/docker/scripts/rustbuild-setup.sh index 94d7e600eac..baf2a686871 100644 --- a/src/ci/docker/scripts/rustbuild-setup.sh +++ b/src/ci/docker/scripts/rustbuild-setup.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index cebba57344b..292b3c1d562 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -ex case "$(uname -m)" in diff --git a/src/test/run-make/thumb-none-qemu/script.sh b/src/test/run-make/thumb-none-qemu/script.sh index 045d02a8ed2..a8aa72af184 100644 --- a/src/test/run-make/thumb-none-qemu/script.sh +++ b/src/test/run-make/thumb-none-qemu/script.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -exuo pipefail CRATE=example diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh index ec93c980160..54645e9e257 100644 --- a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh +++ b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh @@ -1,3 +1,4 @@ +#!/bin/sh set -exuo pipefail function build { -- cgit 1.4.1-3-g733a5