Skip to content

Commit cd82a29

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents bf947fc + febd008 commit cd82a29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1389
-423
lines changed

.github/workflows/clippy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ jobs:
3636
github_token: "${{ secrets.github_token }}"
3737

3838
- name: rust-toolchain
39-
uses: actions-rs/[email protected].3
39+
uses: actions-rs/[email protected].6
4040
with:
4141
toolchain: nightly
4242
target: x86_64-unknown-linux-gnu
4343
profile: minimal
4444

4545
- name: Checkout
46-
uses: actions/checkout@v2.0.0
46+
uses: actions/checkout@v2.3.3
4747

4848
- name: Run cargo update
4949
run: cargo update
@@ -63,7 +63,7 @@ jobs:
6363
- name: Set LD_LIBRARY_PATH (Linux)
6464
run: |
6565
SYSROOT=$(rustc --print sysroot)
66-
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
66+
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
6767
6868
- name: Build
6969
run: cargo build --features deny-warnings

.github/workflows/clippy_bors.yml

+15-20
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ env:
1111
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
1212
NO_FMT_TEST: 1
1313

14+
defaults:
15+
run:
16+
shell: bash
17+
1418
jobs:
1519
changelog:
1620
runs-on: ubuntu-latest
@@ -20,7 +24,7 @@ jobs:
2024
with:
2125
github_token: "${{ secrets.github_token }}"
2226
- name: Checkout
23-
uses: actions/checkout@v2.0.0
27+
uses: actions/checkout@v2.3.3
2428
with:
2529
ref: ${{ github.ref }}
2630

@@ -81,14 +85,14 @@ jobs:
8185
if: matrix.host == 'i686-unknown-linux-gnu'
8286

8387
- name: rust-toolchain
84-
uses: actions-rs/[email protected].3
88+
uses: actions-rs/[email protected].6
8589
with:
8690
toolchain: nightly
8791
target: ${{ matrix.host }}
8892
profile: minimal
8993

9094
- name: Checkout
91-
uses: actions/checkout@v2.0.0
95+
uses: actions/checkout@v2.3.3
9296

9397
- name: Run cargo update
9498
run: cargo update
@@ -105,14 +109,13 @@ jobs:
105109
run: bash setup-toolchain.sh
106110
env:
107111
HOST_TOOLCHAIN: ${{ matrix.host }}
108-
shell: bash
109112

110113
# Run
111114
- name: Set LD_LIBRARY_PATH (Linux)
112115
if: runner.os == 'Linux'
113116
run: |
114117
SYSROOT=$(rustc --print sysroot)
115-
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
118+
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
116119
- name: Link rustc dylib (MacOS)
117120
if: runner.os == 'macOS'
118121
run: |
@@ -122,41 +125,33 @@ jobs:
122125
- name: Set PATH (Windows)
123126
if: runner.os == 'Windows'
124127
run: |
125-
$sysroot = rustc --print sysroot
126-
$env:PATH += ';' + $sysroot + '\bin'
127-
echo "::set-env name=PATH::$env:PATH"
128+
SYSROOT=$(rustc --print sysroot)
129+
echo "$SYSROOT/bin" >> $GITHUB_PATH
128130
129131
- name: Build
130132
run: cargo build --features deny-warnings
131-
shell: bash
132133

133134
- name: Test
134135
run: cargo test --features deny-warnings
135-
shell: bash
136136

137137
- name: Test clippy_lints
138138
run: cargo test --features deny-warnings
139-
shell: bash
140139
working-directory: clippy_lints
141140

142141
- name: Test rustc_tools_util
143142
run: cargo test --features deny-warnings
144-
shell: bash
145143
working-directory: rustc_tools_util
146144

147145
- name: Test clippy_dev
148146
run: cargo test --features deny-warnings
149-
shell: bash
150147
working-directory: clippy_dev
151148

152149
- name: Test cargo-clippy
153150
run: ../target/debug/cargo-clippy
154-
shell: bash
155151
working-directory: clippy_workspace_tests
156152

157153
- name: Test clippy-driver
158154
run: bash .github/driver.sh
159-
shell: bash
160155
env:
161156
OS: ${{ runner.os }}
162157

@@ -165,7 +160,7 @@ jobs:
165160
run: |
166161
cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
167162
cargo cache
168-
shell: bash
163+
169164
integration_build:
170165
needs: changelog
171166
runs-on: ubuntu-latest
@@ -177,14 +172,14 @@ jobs:
177172
github_token: "${{ secrets.github_token }}"
178173

179174
- name: rust-toolchain
180-
uses: actions-rs/[email protected].3
175+
uses: actions-rs/[email protected].6
181176
with:
182177
toolchain: nightly
183178
target: x86_64-unknown-linux-gnu
184179
profile: minimal
185180

186181
- name: Checkout
187-
uses: actions/checkout@v2.0.0
182+
uses: actions/checkout@v2.3.3
188183

189184
- name: Run cargo update
190185
run: cargo update
@@ -258,14 +253,14 @@ jobs:
258253
github_token: "${{ secrets.github_token }}"
259254

260255
- name: rust-toolchain
261-
uses: actions-rs/[email protected].3
256+
uses: actions-rs/[email protected].6
262257
with:
263258
toolchain: nightly
264259
target: x86_64-unknown-linux-gnu
265260
profile: minimal
266261

267262
- name: Checkout
268-
uses: actions/checkout@v2.0.0
263+
uses: actions/checkout@v2.3.3
269264

270265
- name: Run cargo update
271266
run: cargo update

.github/workflows/clippy_dev.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ jobs:
2323
steps:
2424
# Setup
2525
- name: rust-toolchain
26-
uses: actions-rs/[email protected].3
26+
uses: actions-rs/[email protected].6
2727
with:
2828
toolchain: nightly
2929
target: x86_64-unknown-linux-gnu
3030
profile: minimal
3131
components: rustfmt
3232

3333
- name: Checkout
34-
uses: actions/checkout@v2.0.0
34+
uses: actions/checkout@v2.3.3
3535

3636
# Run
3737
- name: Build

.github/workflows/deploy.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
steps:
2222
# Setup
2323
- name: Checkout
24-
uses: actions/checkout@v2.0.0
24+
uses: actions/checkout@v2.3.3
2525

2626
- name: Checkout
27-
uses: actions/checkout@v2.0.0
27+
uses: actions/checkout@v2.3.3
2828
with:
2929
ref: ${{ env.TARGET_BRANCH }}
3030
path: 'out'
@@ -34,10 +34,10 @@ jobs:
3434
if: startswith(github.ref, 'refs/tags/')
3535
run: |
3636
TAG=$(basename ${{ github.ref }})
37-
echo "::set-env name=TAG_NAME::$TAG"
37+
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
3838
- name: Set beta to true
3939
if: github.ref == 'refs/heads/beta'
40-
run: echo "::set-env name=BETA::true"
40+
run: echo "BETA=true" >> $GITHUB_ENV
4141

4242
- name: Use scripts and templates from master branch
4343
run: |

.github/workflows/remark.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
steps:
1717
# Setup
1818
- name: Checkout
19-
uses: actions/checkout@v2.0.0
19+
uses: actions/checkout@v2.3.3
2020

2121
- name: Setup Node.js
22-
uses: actions/setup-node@v1.1.0
22+
uses: actions/setup-node@v1.4.4
2323

2424
- name: Install remark
2525
run: npm install remark-cli remark-lint remark-lint-maximum-line-length remark-preset-lint-recommended

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,7 @@ Released 2018-09-13
18921892
[`print_with_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_with_newline
18931893
[`println_empty_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#println_empty_string
18941894
[`ptr_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
1895+
[`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
18951896
[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
18961897
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
18971898
[`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
@@ -1917,6 +1918,7 @@ Released 2018-09-13
19171918
[`rest_pat_in_fully_bound_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#rest_pat_in_fully_bound_structs
19181919
[`result_map_or_into_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_or_into_option
19191920
[`result_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_unit_fn
1921+
[`result_unit_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err
19201922
[`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
19211923
[`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
19221924
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
3434
semver = "0.10"
3535
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
3636
tempfile = { version = "3.1.0", optional = true }
37-
lazy_static = "1.0"
3837

3938
[dev-dependencies]
4039
cargo_metadata = "0.11.1"
4140
compiletest_rs = { version = "0.5.0", features = ["tmp"] }
4241
tester = "0.7"
43-
lazy_static = "1.0"
4442
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
4543
serde = { version = "1.0", features = ["derive"] }
4644
derive-new = "0.5"

clippy_dev/src/update_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn run(update_mode: UpdateMode) {
2929
false,
3030
update_mode == UpdateMode::Change,
3131
|| {
32-
format!("pub static ref ALL_LINTS: Vec<Lint> = vec!{:#?};", sorted_usable_lints)
32+
format!("vec!{:#?}", sorted_usable_lints)
3333
.lines()
3434
.map(ToString::to_string)
3535
.collect::<Vec<_>>()

clippy_lints/src/consts.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub enum Constant {
4040
Tuple(Vec<Constant>),
4141
/// A raw pointer.
4242
RawPtr(u128),
43+
/// A reference
44+
Ref(Box<Constant>),
4345
/// A literal with syntax error.
4446
Err(Symbol),
4547
}
@@ -66,6 +68,7 @@ impl PartialEq for Constant {
6668
(&Self::Bool(l), &Self::Bool(r)) => l == r,
6769
(&Self::Vec(ref l), &Self::Vec(ref r)) | (&Self::Tuple(ref l), &Self::Tuple(ref r)) => l == r,
6870
(&Self::Repeat(ref lv, ref ls), &Self::Repeat(ref rv, ref rs)) => ls == rs && lv == rv,
71+
(&Self::Ref(ref lb), &Self::Ref(ref rb)) => *lb == *rb,
6972
// TODO: are there inter-type equalities?
7073
_ => false,
7174
}
@@ -110,6 +113,9 @@ impl Hash for Constant {
110113
Self::RawPtr(u) => {
111114
u.hash(state);
112115
},
116+
Self::Ref(ref r) => {
117+
r.hash(state);
118+
},
113119
Self::Err(ref s) => {
114120
s.hash(state);
115121
},
@@ -144,6 +150,7 @@ impl Constant {
144150
x => x,
145151
}
146152
},
153+
(&Self::Ref(ref lb), &Self::Ref(ref rb)) => Self::partial_cmp(tcx, cmp_type, lb, rb),
147154
// TODO: are there any useful inter-type orderings?
148155
_ => None,
149156
}
@@ -239,7 +246,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
239246
ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op {
240247
UnOp::UnNot => self.constant_not(&o, self.typeck_results.expr_ty(e)),
241248
UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
242-
UnOp::UnDeref => Some(o),
249+
UnOp::UnDeref => Some(if let Constant::Ref(r) = o { *r } else { o }),
243250
}),
244251
ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right),
245252
ExprKind::Call(ref callee, ref args) => {
@@ -269,6 +276,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
269276
}
270277
},
271278
ExprKind::Index(ref arr, ref index) => self.index(arr, index),
279+
ExprKind::AddrOf(_, _, ref inner) => self.expr(inner).map(|r| Constant::Ref(Box::new(r))),
272280
// TODO: add other expressions.
273281
_ => None,
274282
}

clippy_lints/src/doc.rs

+13
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,26 @@ declare_clippy_lint! {
3232
/// **Known problems:** Lots of bad docs won’t be fixed, what the lint checks
3333
/// for is limited, and there are still false positives.
3434
///
35+
/// In addition, when writing documentation comments, including `[]` brackets
36+
/// inside a link text would trip the parser. Therfore, documenting link with
37+
/// `[`SmallVec<[T; INLINE_CAPACITY]>`]` and then [`SmallVec<[T; INLINE_CAPACITY]>`]: SmallVec
38+
/// would fail.
39+
///
3540
/// **Examples:**
3641
/// ```rust
3742
/// /// Do something with the foo_bar parameter. See also
3843
/// /// that::other::module::foo.
3944
/// // ^ `foo_bar` and `that::other::module::foo` should be ticked.
4045
/// fn doit(foo_bar: usize) {}
4146
/// ```
47+
///
48+
/// ```rust
49+
/// // Link text with `[]` brackets should be written as following:
50+
/// /// Consume the array and return the inner
51+
/// /// [`SmallVec<[T; INLINE_CAPACITY]>`][SmallVec].
52+
/// /// [SmallVec]: SmallVec
53+
/// fn main() {}
54+
/// ```
4255
pub DOC_MARKDOWN,
4356
pedantic,
4457
"presence of `_`, `::` or camel-case outside backticks in documentation"

clippy_lints/src/format.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::paths;
22
use crate::utils::{
3-
is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet,
3+
is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet, snippet_opt,
44
span_lint_and_then,
55
};
66
use if_chain::if_chain;
@@ -132,7 +132,11 @@ fn on_new_v1<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<Strin
132132
then {
133133
// `format!("foo")` expansion contains `match () { () => [], }`
134134
if tup.is_empty() {
135-
return Some(format!("{:?}.to_string()", s.as_str()));
135+
if let Some(s_src) = snippet_opt(cx, lit.span) {
136+
// Simulate macro expansion, converting {{ and }} to { and }.
137+
let s_expand = s_src.replace("{{", "{").replace("}}", "}");
138+
return Some(format!("{}.to_string()", s_expand))
139+
}
136140
} else if s.as_str().is_empty() {
137141
return on_argumentv1_new(cx, &tup[0], arms);
138142
}

0 commit comments

Comments
 (0)