Skip to content

Commit b6302a9

Browse files
committed
Merge branch 'master' into fix-wasm-time
2 parents 5585855 + 1742f17 commit b6302a9

File tree

11 files changed

+53
-109
lines changed

11 files changed

+53
-109
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- stable
1616
- beta
1717
- nightly
18-
- '1.41.0'
18+
- '1.46.0'
1919
features:
2020
-
2121
- derive
@@ -29,31 +29,16 @@ jobs:
2929
profile: minimal
3030
override: true
3131
id: toolchain
32-
- name: Cache Cargo registry
33-
uses: actions/cache@v2
34-
with:
35-
path: ~/.cargo/registry
36-
key: cargo-registry-test-${{ runner.os }}-${{ matrix.features }}-${{ hashFiles('Cargo.*') }}
37-
restore-keys: |
38-
cargo-registry-test-${{ runner.os }}-${{ matrix.features }}-
39-
cargo-registry-test-${{ runner.os }}-
40-
- name: Cache Cargo build
41-
uses: actions/cache@v2
42-
with:
43-
path: target
44-
key: cargo-target-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
45-
restore-keys: |
46-
cargo-target-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-
47-
cargo-target-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-
32+
- uses: Swatinem/rust-cache@v1
4833
- run: echo 'RUSTFLAGS=--allow unknown_lints' >> $GITHUB_ENV
49-
if: matrix.toolchain == '1.41.0'
34+
if: matrix.toolchain == '1.46.0'
5035
- name: Build `oauth1-request`
5136
uses: actions-rs/cargo@v1
5237
with:
5338
command: build
5439
args: --verbose --tests --manifest-path oauth1-request/Cargo.toml --features=${{ matrix.features }}
5540
- name: Build `examples`
56-
if: ${{ matrix.toolchain != '1.41.0' }}
41+
if: ${{ matrix.toolchain != '1.46.0' }}
5742
uses: actions-rs/cargo@v1
5843
with:
5944
command: build
@@ -82,22 +67,7 @@ jobs:
8267
profile: minimal
8368
override: true
8469
id: toolchain
85-
- name: Cache Cargo registry
86-
uses: actions/cache@v2
87-
with:
88-
path: ~/.cargo/registry
89-
key: cargo-registry-derive-test-${{ runner.os }}-${{ matrix.features }}-${{ hashFiles('Cargo.*') }}
90-
restore-keys: |
91-
cargo-registry-derive-test-${{ runner.os }}-${{ matrix.features }}-
92-
cargo-registry-derive-test-${{ runner.os }}-
93-
- name: Cache Cargo build
94-
uses: actions/cache@v2
95-
with:
96-
path: target
97-
key: cargo-target-derive-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
98-
restore-keys: |
99-
cargo-target-derive-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-
100-
cargo-target-derive-test-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-
70+
- uses: Swatinem/rust-cache@v1
10171
- name: Build `oauth1-request-derive`
10272
uses: actions-rs/cargo@v1
10373
with:
@@ -148,25 +118,22 @@ jobs:
148118
profile: minimal
149119
override: true
150120
id: toolchain
151-
- name: Cache Cargo registry
152-
uses: actions/cache@v2
153-
with:
154-
path: ~/.cargo/registry
155-
key: cargo-registry-credentials-msrv-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('Cargo.*') }}
156-
restore-keys: |
157-
cargo-registry-credentials-msrv-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-
158-
cargo-registry-credentials-msrv-${{ steps.toolchain.outputs.rustc_hash }}-
159-
- name: Cache Cargo build
160-
uses: actions/cache@v2
121+
- uses: Swatinem/rust-cache@v1
122+
- uses: actions/checkout@v2
161123
with:
162-
path: target
163-
key: cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
164-
restore-keys: |
165-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
166-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-
167-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-
168-
# Remove the virtual manifest because Rust 1.13.0 run fails when built as a workspace member.
169-
- run: rm Cargo.toml
124+
repository: rust-lang/crates.io-index
125+
ref: 46a429eac9f70fd7281922780d7dd42e2fb7ab77
126+
path: crates.io-index
127+
- name: Workaround compatibility issues of Cargo
128+
run: |
129+
# Remove the virtual manifest because Rust 1.13.0 run fails when built as a workspace member.
130+
rm Cargo.toml
131+
# Reference: <https://github.com/mcgoo/vcpkg-rs/blob/f75707b/.github/workflows/rust-1.12.yml>
132+
mkdir -p oauth-credentials/.cargo
133+
cat <<EOF >> oauth-credentials/.cargo/config
134+
[source.crates-io]
135+
registry = "file://$GITHUB_WORKSPACE/crates.io-index"
136+
EOF
170137
- name: Build `oauth-credentials`
171138
uses: actions-rs/cargo@v1
172139
with:
@@ -196,23 +163,7 @@ jobs:
196163
profile: minimal
197164
override: true
198165
id: toolchain
199-
- name: Cache Cargo registry
200-
uses: actions/cache@v2
201-
with:
202-
path: ~/.cargo/registry
203-
key: cargo-registry-credentials-test-${{ runner.os }}-${{ matrix.features }}-${{ hashFiles('Cargo.*') }}
204-
restore-keys: |
205-
cargo-registry-credentials-test-${{ runner.os }}-${{ matrix.features }}-
206-
cargo-registry-credentials-test-${{ runner.os }}-
207-
- name: Cache Cargo build
208-
uses: actions/cache@v2
209-
with:
210-
path: target
211-
key: cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
212-
restore-keys: |
213-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.*') }}
214-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.features }}-
215-
cargo-target-credentials-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-
166+
- uses: Swatinem/rust-cache@v1
216167
- name: Build `oauth-credentials`
217168
uses: actions-rs/cargo@v1
218169
with:
@@ -234,20 +185,7 @@ jobs:
234185
toolchain: stable
235186
profile: minimal
236187
id: toolchain
237-
- name: Cache Cargo registry
238-
uses: actions/cache@v2
239-
with:
240-
path: ~/.cargo/registry
241-
key: cargo-registry-min-deps-${{ runner.os }}-${{ hashFiles('Cargo.*') }}
242-
restore-keys: |
243-
cargo-registry-min-deps-${{ runner.os }}-
244-
- name: Cache Cargo build
245-
uses: actions/cache@v2
246-
with:
247-
path: target
248-
key: cargo-target-min-deps-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.*') }}
249-
restore-keys: |
250-
cargo-target-min-deps-${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-
188+
- uses: Swatinem/rust-cache@v1
251189
- name: Cargo update
252190
uses: actions-rs/cargo@v1
253191
with:

examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bytes = "1"
2525
env_logger = "0.8"
2626
form_urlencoded = "1"
2727
futures = "0.3"
28-
hmac = "0.10"
28+
hmac = "0.11"
2929
http = "0.2"
3030
http-body = "0.4"
3131
hyper = { version = "0.14", features = ["client", "http1", "runtime", "server", "stream"] }

examples/src/server/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ where
268268
if let Some(t) = token {
269269
key.extend(t.secret.as_bytes());
270270
}
271-
Hmac::<Sha1>::new_varkey(&key).unwrap()
271+
Hmac::<Sha1>::new_from_slice(&key).unwrap()
272272
};
273273

274274
let base = create_base_string(&req, &params);

oauth-credentials/src/serde_imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Credentials<T> {
145145
let visitor = Visitor {
146146
marker: PhantomData,
147147
};
148-
d.deserialize_struct(CREDENTIALS, &FIELDS, visitor)
148+
d.deserialize_struct(CREDENTIALS, FIELDS, visitor)
149149
}
150150
}
151151

oauth1-request-derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ proc-macro = true
1616

1717
[dependencies]
1818
proc-macro2 = "1"
19-
proc-macro-crate = "0.1.2"
19+
proc-macro-crate = "1"
2020
proc-macro-error = "1"
2121
quote = "1"
2222
syn = { version = "1", features = ["full"] }
2323

2424
[dev-dependencies]
25-
compiletest_rs = "0.5"
25+
compiletest_rs = "0.7"
2626
oauth1-request = "0.5"
2727
version-sync = "0.9"

oauth1-request-derive/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod method_body;
2424
mod util;
2525

2626
use proc_macro2::{Span, TokenStream};
27+
use proc_macro_crate::FoundCrate;
2728
use proc_macro_error::{abort, abort_if_dirty, emit_error, proc_macro_error};
2829
use quote::quote;
2930
use syn::spanned::Spanned;
@@ -57,7 +58,11 @@ fn expand_derive_oauth1_authorize(mut input: DeriveInput) -> TokenStream {
5758
let dummy = format!("_impl_ToOAuth1Request_for_{}", name);
5859
let dummy = Ident::new(&dummy, Span::call_site());
5960

60-
let krate = proc_macro_crate::crate_name("oauth1-request").unwrap();
61+
let krate = match proc_macro_crate::crate_name("oauth1-request").unwrap() {
62+
FoundCrate::Name(krate) => krate,
63+
// This is used in `oauth1_request`'s doctests.
64+
FoundCrate::Itself => std::env::var("CARGO_CRATE_NAME").unwrap(),
65+
};
6166
let krate = Ident::new(&krate, Span::call_site());
6267

6368
add_trait_bounds(&mut input.generics);

oauth1-request-derive/tests/compiletest.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ use std::process::Command;
44
use std::{env, fs};
55

66
fn run_mode(mode: &'static str) {
7-
let mut config = compiletest::Config::default();
8-
9-
config.mode = mode.parse().expect("invalid mode");
10-
config.target_rustcflags = Some(String::from(
11-
"\
12-
--edition=2018 \
13-
--extern oauth1_request \
14-
-L test-deps/target/debug/deps \
15-
",
16-
));
17-
config.src_base = format!("tests/{}", mode).into();
7+
let config = compiletest::Config {
8+
mode: mode.parse().expect("invalid mode"),
9+
target_rustcflags: Some(String::from(
10+
"\
11+
--edition=2018 \
12+
--extern oauth1_request \
13+
-L test-deps/target/debug/deps \
14+
",
15+
)),
16+
src_base: format!("tests/{}", mode).into(),
17+
..Default::default()
18+
};
1819

1920
let deps = "test-deps/target/debug/deps";
2021
if fs::metadata(deps).is_ok() {

oauth1-request-derive/tests/pass.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ macro_rules! assert_expand {
5555
$($ty_param: std::fmt::Display,)*
5656
$($($where_ty: $($where_bound)*,)*)*
5757
{
58-
fn expected(&self, auth: Authorizer<Identity>) -> String {
59-
let expand_to: fn(&Self, Authorizer<Identity>) -> _ = $expand_to;
58+
fn expected(&self, auth: Authorizer<'_, Identity>) -> String {
59+
let expand_to: fn(&Self, Authorizer<'_, Identity>) -> _ = $expand_to;
6060
expand_to(self, auth)
6161
}
6262
}
@@ -277,7 +277,7 @@ assert_expand! {
277277
#[oauth1(option = false, fmt = super::fmt_ignore)]
278278
option_false: Option<()>,
279279

280-
#[oauth1(skip_if = std::any::Any::is::<&'static str>)]
280+
#[oauth1(skip_if = <dyn std::any::Any>::is::<&'static str>)]
281281
#[oauth1(fmt = std::fmt::Debug::fmt)]
282282
trait_item: T,
283283

@@ -332,6 +332,7 @@ fn tautology<T>(_: &T) -> bool {
332332
true
333333
}
334334

335+
#[allow(clippy::unnecessary_wraps)]
335336
fn fmt_ignore<T>(_: &T, _: &mut Formatter<'_>) -> fmt::Result {
336337
Ok(())
337338
}

oauth1-request/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ oauth1-request-derive = { version = "0.4", optional = true }
2727

2828
# `hmac-sha1` feature
2929
either = { version = "1.2", optional = true }
30-
hmac = { version = "0.10", optional = true }
30+
hmac = { version = "0.11", optional = true }
3131
sha-1 = { version = "0.9", optional = true }
3232

3333
[dev-dependencies]

oauth1-request/src/serializer/auth.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ fn get_current_timestamp() -> u64 {
282282
use std::time::{SystemTime, UNIX_EPOCH};
283283
match SystemTime::now().duration_since(UNIX_EPOCH) {
284284
Ok(d) => d.as_secs(),
285-
#[cold]
286285
Err(_) => 1,
287286
}
288287
}

0 commit comments

Comments
 (0)