From 7529bc592a3f20aec10aadb39afd9d4c582d7541 Mon Sep 17 00:00:00 2001 From: Daniel Paoliello Date: Wed, 26 Apr 2023 11:38:39 -0700 Subject: [PATCH] Update to comply with legal review (#11) --- .github/workflows/build-and-test.yml | 11 ++++++--- CONTRIBUTING.md | 14 ++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- LICENSE | 34 ++++++++++++++-------------- README.md | 2 +- build.ps1 | 17 ++++++++++++++ src/collect.rs | 3 +++ src/error.rs | 3 +++ src/lib.rs | 3 +++ src/set_len_on_drop.rs | 3 +++ src/tests.rs | 3 +++ 12 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d7370fd..eea2860 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -31,11 +31,16 @@ jobs: - name: Checkout uses: actions/checkout@v3 + # no_global_oom_handling is currently broken in 1.69: https://github.com/rust-lang/rust/pull/110649 + # So use 1.68 until it gets fixed. - name: Update Rust toolchain - run: rustup update + run: rustup install 1.68 - - name: Add the rust-src component - run: rustup component add rust-src --toolchain stable-${{ matrix.target }} + - name: Set 1.68 as the default + run: rustup default 1.68 + + - name: Add required components + run: rustup component add rust-src clippy rustfmt rust-docs --toolchain 1.68-${{ matrix.target }} - name: Run build script shell: pwsh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c97e7ed --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,14 @@ +# Contributing + +This project welcomes contributions and suggestions. Most contributions require you to +agree to a Contributor License Agreement (CLA) declaring that you have the right to, +and actually do, grant us the rights to use your contribution. For details, visit +https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need +to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the +instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 1e3f99a..5af0b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "fallible_vec" -version = "0.3.0" +version = "0.3.1" dependencies = [ "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index 3db69c6..aa9a066 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fallible_vec" description = "Fallible allocation functions for the Rust standard library's `Vec` type." -version = "0.3.0" +version = "0.3.1" edition = "2021" license-file = "LICENSE" repository = "https://github.com/microsoft/rust_fallible_vec" diff --git a/LICENSE b/LICENSE index 9e841e7..b2f52a2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ - MIT License +Copyright (c) Microsoft Corporation. - Copyright (c) Microsoft Corporation. +MIT License - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index cb79c50..7018d41 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ in its CI. Comparing `fallible_vec` to [`fallible_collections`](https://crates.io/crates/fallible_collections): -| | `fallible_vec` v0.1.0 | `fallible_collections` v0.4.7 | +| | `fallible_vec` v0.3.1 | `fallible_collections` v0.4.7 | |-------------------------------------------|:---------------------:|:-----------------------------:| | Supports `no_std` | X | X | | Supports `#[cfg(no_global_oom_handling)]` | X | | diff --git a/build.ps1 b/build.ps1 index 0340bfd..19c0370 100644 --- a/build.ps1 +++ b/build.ps1 @@ -47,6 +47,23 @@ function Invoke-WithEnvironment([System.Collections.IDictionary] $Environment, [ } } +# Verify that all sources files have the copyright header. +[string[]] $copyrightHeader = @("// Copyright (c) Microsoft Corporation.", "// Licensed under the MIT license.") +[bool] $hadMissingCopyright = $false +foreach ($file in (Get-ChildItem -Path (Join-Path $PSScriptRoot 'src') -Filter '*.rs' -Recurse)) { + $contents = Get-Content -Path $file -TotalCount $copyrightHeader.Length + if ($null -ne (Compare-Object -ReferenceObject $copyrightHeader -DifferenceObject $contents)) { + $hadMissingCopyright = $true + $fileName = $file.FullName + Write-Error "'$fileName' is missing the copyright header." -ErrorAction Continue + } +} +if ($hadMissingCopyright) { + $mergedCopyrightHeader = $copyrightHeader | Join-String -Separator "`n" + Write-Error "One or more files was missing the copyright header. To fix this, add the copyright header to any non-compliant files:`n$mergedCopyrightHeader" + exit 1 +} + Invoke-WithEnvironment ` -Environment @{ # Enable unstable features on stable toolchain. diff --git a/src/collect.rs b/src/collect.rs index 5181abe..766c926 100644 --- a/src/collect.rs +++ b/src/collect.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + use crate::FallibleVec; use crate::TryReserveError; use alloc::vec::Vec; diff --git a/src/error.rs b/src/error.rs index d8ed80e..d439638 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + use core::alloc::Layout; #[allow(dead_code)] diff --git a/src/lib.rs b/src/lib.rs index c4c82d3..ac2c5a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + //! Fallible allocation functions for the Rust standard library's [`alloc::vec::Vec`] //! type. //! diff --git a/src/set_len_on_drop.rs b/src/set_len_on_drop.rs index 456e180..2df3d79 100644 --- a/src/set_len_on_drop.rs +++ b/src/set_len_on_drop.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + // Forked from the Rust Standard Library: library/alloc/src/vec/set_len_on_drop.rs use alloc::vec::Vec; diff --git a/src/tests.rs b/src/tests.rs index f4bdd6b..4d67c5c 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + use crate::*; use alloc::{alloc::Global, vec::Vec}; use core::sync::atomic::{AtomicI32, Ordering};