Bug 1817900 - Update proc-macro2 to 1.0.51. r=emilio,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D170449
This commit is contained in:
Mike Hommey 2023-02-23 01:17:32 +00:00
parent 30d2d77ab4
commit 52d1694944
11 changed files with 102 additions and 106 deletions

4
Cargo.lock generated
View File

@ -4305,9 +4305,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.49"
version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
dependencies = [
"unicode-ident",
]

View File

@ -1850,6 +1850,11 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "1.0.43 -> 1.0.49"
[[audits.proc-macro2]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "1.0.49 -> 1.0.51"
[[audits.profiling]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"0e97188d4acfad75ff86e59b28f9b393e29058e716252c552335add042bbf7f1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"32cbd395594db59ecc43d7866cfa2663f3687bb7df631781d60ae83200dae8a8","build.rs":"275f7a9ee0b9eff972124951de544ae17ee3e698a4e89b0f0393b334344f5e30","src/detection.rs":"ed9a5f9a979ab01247d7a68eeb1afa3c13209334c5bfff0f9289cb07e5bb4e8b","src/fallback.rs":"a9e6fa159d6a111a231fa9367d54859103e9d49f6662397baea951b5f3e7e983","src/lib.rs":"28eecf6d91a6c0a82096bfa4a872ba81bcc0a9ca043920f465951412de06e7de","src/marker.rs":"344a8394f06a1d43355b514920e7e3c0c6dce507be767e3a590bbe3552edd110","src/parse.rs":"637a9fe6e3e21c36fa411b70674f617743fe0129787c17a559e78f86418d0da4","src/rcvec.rs":"49b6784c6ca5f32573cd8a83758b485d8acbfa126e5fb516ae439e429ef4c144","src/wrapper.rs":"8ea825cdac628570719a258419fcffd1c9d2ca1ca5e2fbbbf283dd9cc6695910","tests/comments.rs":"31115b3a56c83d93eef2fb4c9566bf4543e302560732986161b98aef504785ed","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"cb6d776eba6a238d726b0f531883adf41957e06f2717ee8a069821c81e7081d6","tests/test.rs":"d7f21088314d1df25447fdc0a32feffae26d4d637e3ce68e23c0190060cb5652","tests/test_fmt.rs":"9357769945784354909259084ec8b34d2aa52081dd3967cac6dae3a5e3df3bc0"},"package":"57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"}
{"files":{"Cargo.toml":"7d4723ca4eea6d781e7e67c85a4f3537723b89e6c8e1b843e9f3a090d6c02d00","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"32cbd395594db59ecc43d7866cfa2663f3687bb7df631781d60ae83200dae8a8","build.rs":"275f7a9ee0b9eff972124951de544ae17ee3e698a4e89b0f0393b334344f5e30","src/detection.rs":"ed9a5f9a979ab01247d7a68eeb1afa3c13209334c5bfff0f9289cb07e5bb4e8b","src/fallback.rs":"b0b98566421529c309f4310565f24fa27608078c03c84e07a65f5aa1c0df2ae8","src/lib.rs":"4ba3c39bb516c6acbcfc5cfb45888ca79c93953768ac6a45bb2fb6f342f24874","src/location.rs":"f55d2e61f1bb1af65e14ed04c9e91eb1ddbf8430e8c05f2048d1cd538d27368e","src/marker.rs":"344a8394f06a1d43355b514920e7e3c0c6dce507be767e3a590bbe3552edd110","src/parse.rs":"06bd29cf594bb5d5cfff9b3371ce6a3367a13788354135e51e8b5ff195d06481","src/rcvec.rs":"49b6784c6ca5f32573cd8a83758b485d8acbfa126e5fb516ae439e429ef4c144","src/wrapper.rs":"6932058819a5c31c1765e6294f1a8279ab4ea1807de21a488c869fdfe13bf9d5","tests/comments.rs":"31115b3a56c83d93eef2fb4c9566bf4543e302560732986161b98aef504785ed","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"cb6d776eba6a238d726b0f531883adf41957e06f2717ee8a069821c81e7081d6","tests/test.rs":"cf3c944f1c4a09c326b1e639f70c173f0d93d916fb50c085542e44fad691eea7","tests/test_fmt.rs":"9357769945784354909259084ec8b34d2aa52081dd3967cac6dae3a5e3df3bc0"},"package":"5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"}

View File

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.31"
name = "proc-macro2"
version = "1.0.49"
version = "1.0.51"
authors = [
"David Tolnay <dtolnay@gmail.com>",
"Alex Crichton <alex@alexcrichton.com>",

View File

@ -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.

View File

@ -1,3 +1,5 @@
#[cfg(span_locations)]
use crate::location::LineColumn;
use crate::parse::{self, Cursor};
use crate::rcvec::{RcVec, RcVecBuilder, RcVecIntoIter, RcVecMut};
use crate::{Delimiter, Spacing, TokenTree};
@ -232,7 +234,7 @@ impl Debug for TokenStream {
#[cfg(use_proc_macro)]
impl From<proc_macro::TokenStream> for TokenStream {
fn from(inner: proc_macro::TokenStream) -> TokenStream {
fn from(inner: proc_macro::TokenStream) -> Self {
inner
.to_string()
.parse()
@ -242,7 +244,7 @@ impl From<proc_macro::TokenStream> for TokenStream {
#[cfg(use_proc_macro)]
impl From<TokenStream> for proc_macro::TokenStream {
fn from(inner: TokenStream) -> proc_macro::TokenStream {
fn from(inner: TokenStream) -> Self {
inner
.to_string()
.parse()
@ -251,7 +253,7 @@ impl From<TokenStream> for proc_macro::TokenStream {
}
impl From<TokenTree> for TokenStream {
fn from(tree: TokenTree) -> TokenStream {
fn from(tree: TokenTree) -> Self {
let mut stream = RcVecBuilder::new();
push_token_from_proc_macro(stream.as_mut(), tree);
TokenStream {
@ -332,12 +334,6 @@ impl Debug for SourceFile {
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct LineColumn {
pub line: usize,
pub column: usize,
}
#[cfg(span_locations)]
thread_local! {
static SOURCE_MAP: RefCell<SourceMap> = RefCell::new(SourceMap {

View File

@ -86,7 +86,7 @@
//! a different thread.
// Proc-macro2 types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.49")]
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.51")]
#![cfg_attr(
any(proc_macro_span, super_unstable),
feature(proc_macro_span, proc_macro_span_shrink)
@ -139,6 +139,9 @@ use crate::fallback as imp;
#[cfg(wrap_proc_macro)]
mod imp;
#[cfg(span_locations)]
mod location;
use crate::marker::Marker;
use core::cmp::Ordering;
use core::fmt::{self, Debug, Display};
@ -150,6 +153,9 @@ use std::error::Error;
#[cfg(procmacro2_semver_exempt)]
use std::path::PathBuf;
#[cfg(span_locations)]
pub use crate::location::LineColumn;
/// An abstract stream of tokens, or more concretely a sequence of token trees.
///
/// This type provides interfaces for iterating over token trees and for
@ -225,14 +231,14 @@ impl FromStr for TokenStream {
#[cfg(use_proc_macro)]
impl From<proc_macro::TokenStream> for TokenStream {
fn from(inner: proc_macro::TokenStream) -> TokenStream {
fn from(inner: proc_macro::TokenStream) -> Self {
TokenStream::_new(inner.into())
}
}
#[cfg(use_proc_macro)]
impl From<TokenStream> for proc_macro::TokenStream {
fn from(inner: TokenStream) -> proc_macro::TokenStream {
fn from(inner: TokenStream) -> Self {
inner.inner.into()
}
}
@ -356,37 +362,6 @@ impl Debug for SourceFile {
}
}
/// A line-column pair representing the start or end of a `Span`.
///
/// This type is semver exempt and not exposed by default.
#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct LineColumn {
/// The 1-indexed line in the source file on which the span starts or ends
/// (inclusive).
pub line: usize,
/// The 0-indexed column (in UTF-8 characters) in the source file on which
/// the span starts or ends (inclusive).
pub column: usize,
}
#[cfg(span_locations)]
impl Ord for LineColumn {
fn cmp(&self, other: &Self) -> Ordering {
self.line
.cmp(&other.line)
.then(self.column.cmp(&other.column))
}
}
#[cfg(span_locations)]
impl PartialOrd for LineColumn {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
/// A region of source code, along with macro expansion information.
#[derive(Copy, Clone)]
pub struct Span {
@ -492,8 +467,7 @@ impl Span {
#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
pub fn start(&self) -> LineColumn {
let imp::LineColumn { line, column } = self.inner.start();
LineColumn { line, column }
self.inner.start()
}
/// Get the ending line/column in the source file for this span.
@ -508,8 +482,7 @@ impl Span {
#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
pub fn end(&self) -> LineColumn {
let imp::LineColumn { line, column } = self.inner.end();
LineColumn { line, column }
self.inner.end()
}
/// Creates an empty span pointing to directly before this span.
@ -601,25 +574,25 @@ impl TokenTree {
}
impl From<Group> for TokenTree {
fn from(g: Group) -> TokenTree {
fn from(g: Group) -> Self {
TokenTree::Group(g)
}
}
impl From<Ident> for TokenTree {
fn from(g: Ident) -> TokenTree {
fn from(g: Ident) -> Self {
TokenTree::Ident(g)
}
}
impl From<Punct> for TokenTree {
fn from(g: Punct) -> TokenTree {
fn from(g: Punct) -> Self {
TokenTree::Punct(g)
}
}
impl From<Literal> for TokenTree {
fn from(g: Literal) -> TokenTree {
fn from(g: Literal) -> Self {
TokenTree::Literal(g)
}
}

View File

@ -0,0 +1,29 @@
use core::cmp::Ordering;
/// A line-column pair representing the start or end of a `Span`.
///
/// This type is semver exempt and not exposed by default.
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct LineColumn {
/// The 1-indexed line in the source file on which the span starts or ends
/// (inclusive).
pub line: usize,
/// The 0-indexed column (in UTF-8 characters) in the source file on which
/// the span starts or ends (inclusive).
pub column: usize,
}
impl Ord for LineColumn {
fn cmp(&self, other: &Self) -> Ordering {
self.line
.cmp(&other.line)
.then(self.column.cmp(&other.column))
}
}
impl PartialOrd for LineColumn {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

View File

@ -472,6 +472,10 @@ fn raw_string(input: Cursor) -> Result<Cursor, Reject> {
_ => return Err(Reject),
}
}
if n > 255 {
// https://github.com/rust-lang/rust/pull/95251
return Err(Reject);
}
while let Some((i, ch)) = chars.next() {
match ch {
'"' if input.rest[i + 1..].starts_with(&input.rest[..n]) => {

View File

@ -1,4 +1,6 @@
use crate::detection::inside_proc_macro;
#[cfg(span_locations)]
use crate::location::LineColumn;
use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
use core::fmt::{self, Debug, Display};
use core::iter::FromIterator;
@ -129,13 +131,13 @@ impl Display for TokenStream {
}
impl From<proc_macro::TokenStream> for TokenStream {
fn from(inner: proc_macro::TokenStream) -> TokenStream {
fn from(inner: proc_macro::TokenStream) -> Self {
TokenStream::Compiler(DeferredTokenStream::new(inner))
}
}
impl From<TokenStream> for proc_macro::TokenStream {
fn from(inner: TokenStream) -> proc_macro::TokenStream {
fn from(inner: TokenStream) -> Self {
match inner {
TokenStream::Compiler(inner) => inner.into_token_stream(),
TokenStream::Fallback(inner) => inner.to_string().parse().unwrap(),
@ -144,7 +146,7 @@ impl From<TokenStream> for proc_macro::TokenStream {
}
impl From<fallback::TokenStream> for TokenStream {
fn from(inner: fallback::TokenStream) -> TokenStream {
fn from(inner: fallback::TokenStream) -> Self {
TokenStream::Fallback(inner)
}
}
@ -168,7 +170,7 @@ fn into_compiler_token(token: TokenTree) -> proc_macro::TokenTree {
}
impl From<TokenTree> for TokenStream {
fn from(token: TokenTree) -> TokenStream {
fn from(token: TokenTree) -> Self {
if inside_proc_macro() {
TokenStream::Compiler(DeferredTokenStream::new(into_compiler_token(token).into()))
} else {
@ -261,13 +263,13 @@ impl LexError {
}
impl From<proc_macro::LexError> for LexError {
fn from(e: proc_macro::LexError) -> LexError {
fn from(e: proc_macro::LexError) -> Self {
LexError::Compiler(e)
}
}
impl From<fallback::LexError> for LexError {
fn from(e: fallback::LexError) -> LexError {
fn from(e: fallback::LexError) -> Self {
LexError::Fallback(e)
}
}
@ -389,12 +391,6 @@ impl Debug for SourceFile {
}
}
#[cfg(any(super_unstable, feature = "span-locations"))]
pub(crate) struct LineColumn {
pub line: usize,
pub column: usize,
}
#[derive(Copy, Clone)]
pub(crate) enum Span {
Compiler(proc_macro::Span),
@ -471,7 +467,7 @@ impl Span {
}
}
#[cfg(any(super_unstable, feature = "span-locations"))]
#[cfg(span_locations)]
pub fn start(&self) -> LineColumn {
match self {
#[cfg(proc_macro_span)]
@ -481,14 +477,11 @@ impl Span {
}
#[cfg(not(proc_macro_span))]
Span::Compiler(_) => LineColumn { line: 0, column: 0 },
Span::Fallback(s) => {
let fallback::LineColumn { line, column } = s.start();
LineColumn { line, column }
}
Span::Fallback(s) => s.start(),
}
}
#[cfg(any(super_unstable, feature = "span-locations"))]
#[cfg(span_locations)]
pub fn end(&self) -> LineColumn {
match self {
#[cfg(proc_macro_span)]
@ -498,10 +491,7 @@ impl Span {
}
#[cfg(not(proc_macro_span))]
Span::Compiler(_) => LineColumn { line: 0, column: 0 },
Span::Fallback(s) => {
let fallback::LineColumn { line, column } = s.end();
LineColumn { line, column }
}
Span::Fallback(s) => s.end(),
}
}
@ -549,13 +539,13 @@ impl Span {
}
impl From<proc_macro::Span> for crate::Span {
fn from(proc_span: proc_macro::Span) -> crate::Span {
fn from(proc_span: proc_macro::Span) -> Self {
crate::Span::_new(Span::Compiler(proc_span))
}
}
impl From<fallback::Span> for Span {
fn from(inner: fallback::Span) -> Span {
fn from(inner: fallback::Span) -> Self {
Span::Fallback(inner)
}
}
@ -939,7 +929,7 @@ impl Literal {
}
impl From<fallback::Literal> for Literal {
fn from(s: fallback::Literal) -> Literal {
fn from(s: fallback::Literal) -> Self {
Literal::Fallback(s)
}
}

View File

@ -1,6 +1,11 @@
#![allow(clippy::assertions_on_result_states, clippy::non_ascii_literal)]
#![allow(
clippy::assertions_on_result_states,
clippy::items_after_statements,
clippy::non_ascii_literal
)]
use proc_macro2::{Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
use std::iter;
use std::panic;
use std::str::{self, FromStr};
@ -114,6 +119,25 @@ fn literal_string() {
#[test]
fn literal_raw_string() {
"r\"\r\n\"".parse::<TokenStream>().unwrap();
fn raw_string_literal_with_hashes(n: usize) -> String {
let mut literal = String::new();
literal.push('r');
literal.extend(iter::repeat('#').take(n));
literal.push('"');
literal.push('"');
literal.extend(iter::repeat('#').take(n));
literal
}
raw_string_literal_with_hashes(255)
.parse::<TokenStream>()
.unwrap();
// https://github.com/rust-lang/rust/pull/95251
raw_string_literal_with_hashes(256)
.parse::<TokenStream>()
.unwrap_err();
}
#[test]