diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2023-02-17 18:37:56 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-02-17 18:37:56 +0000 |
commit | 1575776e467d34f62f073df15ac360e7b34e79dc (patch) | |
tree | 1fe3a1a202f1e496aded2d8132b70daf34d23035 | |
parent | d1e278783925f7c7c4c7c8bb19bf533868ac3849 (diff) | |
parent | 354449b52bc258df5bbbb74f7ea659f934869c80 (diff) | |
download | no-panic-1575776e467d34f62f073df15ac360e7b34e79dc.tar.gz |
Upgrade no-panic to 0.1.19 am: d9a874ce84 am: 751f09fb6f am: 354449b52b
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/no-panic/+/2441079
Change-Id: Id0d20db9a32bbe26d5ac1a148c2889db8bae4ea9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 26 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | LICENSE-APACHE | 25 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | src/lib.rs | 19 | ||||
-rw-r--r-- | tests/compiletest/mod.rs | 6 | ||||
-rw-r--r-- | tests/test.rs | 15 | ||||
-rw-r--r-- | tests/ui/async-fn.rs | 10 | ||||
-rw-r--r-- | tests/ui/async-fn.stderr | 7 |
12 files changed, 85 insertions, 37 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 16425b1..3ae0a43 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "6790aa92c3e97abf48a08f8c0667ef2479467075" + "sha1": "67d07dbfd0a40f088de60cf0347f67fc373a2a44" }, "path_in_vcs": "" }
\ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca85f49..2f7af61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,13 @@ env: RUSTFLAGS: -Dwarnings jobs: + pre_ci: + uses: dtolnay/.github/.github/workflows/pre_ci.yml@master + test: name: Rust ${{matrix.rust}} + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest strategy: fail-fast: false @@ -27,8 +32,29 @@ jobs: toolchain: ${{matrix.rust}} - run: cargo test + xplat: + name: ${{matrix.name}} + needs: pre_ci + if: needs.pre_ci.outputs.continue + runs-on: ${{matrix.os}}-latest + strategy: + fail-fast: false + matrix: + include: + - name: macOS + os: macos + - name: Windows + os: windows + timeout-minutes: 45 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - run: cargo test + msrv: name: Rust 1.31.0 + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest timeout-minutes: 45 steps: @@ -41,7 +41,7 @@ rust_proc_macro { name: "libno_panic", crate_name: "no_panic", cargo_env_compat: true, - cargo_pkg_version: "0.1.17", + cargo_pkg_version: "0.1.19", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.31" name = "no-panic" -version = "0.1.17" +version = "0.1.19" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Attribute macro to require that the compiler prove a function can't ever panic." documentation = "https://docs.rs/no-panic" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 6823f9c..3a7a13f 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "no-panic" -version = "0.1.17" +version = "0.1.19" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Attribute macro to require that the compiler prove a function can't ever panic." documentation = "https://docs.rs/no-panic" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 16fe87b..1b5ec8b 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. @@ -11,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/no-panic/no-panic-0.1.17.crate" + value: "https://static.crates.io/crates/no-panic/no-panic-0.1.19.crate" } - version: "0.1.17" + version: "0.1.19" license_type: NOTICE last_upgrade_date { year: 2023 month: 2 - day: 3 + day: 16 } } @@ -126,8 +126,8 @@ extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::quote; -use syn::parse::{Nothing, Result}; -use syn::{parse_quote, Attribute, FnArg, Ident, ItemFn, PatType, ReturnType}; +use syn::parse::{Error, Nothing, Result}; +use syn::{parse_quote, Attribute, FnArg, Ident, ItemFn, Pat, PatType, ReturnType}; #[proc_macro_attribute] pub fn no_panic(args: TokenStream, input: TokenStream) -> TokenStream { @@ -146,6 +146,12 @@ pub fn no_panic(args: TokenStream, input: TokenStream) -> TokenStream { fn parse(args: TokenStream2, input: TokenStream2) -> Result<ItemFn> { let function: ItemFn = syn::parse2(input)?; let _: Nothing = syn::parse2::<Nothing>(args)?; + if function.sig.asyncness.is_some() { + return Err(Error::new( + Span::call_site(), + "no_panic attribute on async fn is not supported", + )); + } Ok(function) } @@ -156,12 +162,17 @@ fn expand_no_panic(mut function: ItemFn) -> TokenStream2 { for (i, input) in function.sig.inputs.iter_mut().enumerate() { let numbered = Ident::new(&format!("__arg{}", i), Span::call_site()); match input { - FnArg::Typed(PatType { pat, .. }) => { + FnArg::Typed(PatType { pat, .. }) + if match pat.as_ref() { + Pat::Ident(pat) => pat.ident != "self", + _ => true, + } => + { arg_pat.push(quote!(#pat)); arg_val.push(quote!(#numbered)); *pat = parse_quote!(mut #numbered); } - FnArg::Receiver(_) => { + FnArg::Typed(_) | FnArg::Receiver(_) => { move_self = Some(quote! { if false { loop {} diff --git a/tests/compiletest/mod.rs b/tests/compiletest/mod.rs index f4e26c1..cc3632d 100644 --- a/tests/compiletest/mod.rs +++ b/tests/compiletest/mod.rs @@ -34,7 +34,11 @@ pub fn contains_panic(name: &str, code: &str) -> bool { .arg("--out-dir") .arg(tempdir.path()) .arg("--extern") - .arg("no_panic=target/debug/libno_panic.so") + .arg(format!( + "no_panic=target/debug/{prefix}no_panic.{extension}", + prefix = std::env::consts::DLL_PREFIX, + extension = std::env::consts::DLL_EXTENSION, + )) .status() .expect("failed to execute rustc"); assert!(status.success()); diff --git a/tests/test.rs b/tests/test.rs index b14d92b..f6505ba 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -178,6 +178,21 @@ assert_no_panic! { println!("{}", s.get_mut()); } } + + mod test_self_with_std_pin { + use std::pin::Pin; + + pub struct S; + + impl S { + #[no_panic] + fn f(mut self: Pin<&mut Self>) { + let _ = self.as_mut(); + } + } + + fn main() {} + } } assert_link_error! { diff --git a/tests/ui/async-fn.rs b/tests/ui/async-fn.rs new file mode 100644 index 0000000..65deada --- /dev/null +++ b/tests/ui/async-fn.rs @@ -0,0 +1,10 @@ +use no_panic::no_panic; + +#[no_panic] +async fn f() { + g().await; +} + +async fn g() {} + +fn main() {} diff --git a/tests/ui/async-fn.stderr b/tests/ui/async-fn.stderr new file mode 100644 index 0000000..ad06ecc --- /dev/null +++ b/tests/ui/async-fn.stderr @@ -0,0 +1,7 @@ +error: no_panic attribute on async fn is not supported + --> tests/ui/async-fn.rs:3:1 + | +3 | #[no_panic] + | ^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `no_panic` (in Nightly builds, run with -Z macro-backtrace for more info) |