1
Fork 0

Auto merge of #101757 - Dylan-DPC:rollup-wkt6oe9, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #101602 (Streamline `AttrAnnotatedTokenStream`)
 - #101690 (Avoid `Iterator::last`)
 - #101700 (A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing)
 - #101745 (Fix typo in concat_bytes documentation)
 - #101748 (rustdoc: remove redundant CSS `#source-sidebar, #sidebar-toggle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-09-13 12:35:55 +00:00
commit 5338f5f1d4
41 changed files with 352 additions and 437 deletions

View file

@ -24,7 +24,7 @@ pub use UnsafeSource::*;
use crate::ptr::P; use crate::ptr::P;
use crate::token::{self, CommentKind, Delimiter}; use crate::token::{self, CommentKind, Delimiter};
use crate::tokenstream::{DelimSpan, LazyTokenStream, TokenStream}; use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
@ -91,7 +91,7 @@ pub struct Path {
/// The segments in the path: the things separated by `::`. /// The segments in the path: the things separated by `::`.
/// Global paths begin with `kw::PathRoot`. /// Global paths begin with `kw::PathRoot`.
pub segments: Vec<PathSegment>, pub segments: Vec<PathSegment>,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
impl PartialEq<Symbol> for Path { impl PartialEq<Symbol> for Path {
@ -534,7 +534,7 @@ pub struct Block {
/// Distinguishes between `unsafe { ... }` and `{ ... }`. /// Distinguishes between `unsafe { ... }` and `{ ... }`.
pub rules: BlockCheckMode, pub rules: BlockCheckMode,
pub span: Span, pub span: Span,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
/// The following *isn't* a parse error, but will cause multiple errors in following stages. /// The following *isn't* a parse error, but will cause multiple errors in following stages.
/// ```compile_fail /// ```compile_fail
/// let x = { /// let x = {
@ -553,7 +553,7 @@ pub struct Pat {
pub id: NodeId, pub id: NodeId,
pub kind: PatKind, pub kind: PatKind,
pub span: Span, pub span: Span,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
impl Pat { impl Pat {
@ -937,8 +937,8 @@ impl Stmt {
/// a trailing semicolon. /// a trailing semicolon.
/// ///
/// This only modifies the parsed AST struct, not the attached /// This only modifies the parsed AST struct, not the attached
/// `LazyTokenStream`. The parser is responsible for calling /// `LazyAttrTokenStream`. The parser is responsible for calling
/// `CreateTokenStream::add_trailing_semi` when there is actually /// `ToAttrTokenStream::add_trailing_semi` when there is actually
/// a semicolon in the tokenstream. /// a semicolon in the tokenstream.
pub fn add_trailing_semicolon(mut self) -> Self { pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind { self.kind = match self.kind {
@ -984,7 +984,7 @@ pub struct MacCallStmt {
pub mac: P<MacCall>, pub mac: P<MacCall>,
pub style: MacStmtStyle, pub style: MacStmtStyle,
pub attrs: AttrVec, pub attrs: AttrVec,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)] #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)]
@ -1009,7 +1009,7 @@ pub struct Local {
pub kind: LocalKind, pub kind: LocalKind,
pub span: Span, pub span: Span,
pub attrs: AttrVec, pub attrs: AttrVec,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
#[derive(Clone, Encodable, Decodable, Debug)] #[derive(Clone, Encodable, Decodable, Debug)]
@ -1108,7 +1108,7 @@ pub struct Expr {
pub kind: ExprKind, pub kind: ExprKind,
pub span: Span, pub span: Span,
pub attrs: AttrVec, pub attrs: AttrVec,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
impl Expr { impl Expr {
@ -1967,7 +1967,7 @@ pub struct Ty {
pub id: NodeId, pub id: NodeId,
pub kind: TyKind, pub kind: TyKind,
pub span: Span, pub span: Span,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
impl Clone for Ty { impl Clone for Ty {
@ -2532,7 +2532,7 @@ impl<D: Decoder> Decodable<D> for AttrId {
pub struct AttrItem { pub struct AttrItem {
pub path: Path, pub path: Path,
pub args: MacArgs, pub args: MacArgs,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
/// A list of attributes. /// A list of attributes.
@ -2552,7 +2552,7 @@ pub struct Attribute {
#[derive(Clone, Encodable, Decodable, Debug)] #[derive(Clone, Encodable, Decodable, Debug)]
pub struct NormalAttr { pub struct NormalAttr {
pub item: AttrItem, pub item: AttrItem,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
#[derive(Clone, Encodable, Decodable, Debug)] #[derive(Clone, Encodable, Decodable, Debug)]
@ -2603,7 +2603,7 @@ impl PolyTraitRef {
pub struct Visibility { pub struct Visibility {
pub kind: VisibilityKind, pub kind: VisibilityKind,
pub span: Span, pub span: Span,
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
#[derive(Clone, Encodable, Decodable, Debug)] #[derive(Clone, Encodable, Decodable, Debug)]
@ -2689,7 +2689,7 @@ pub struct Item<K = ItemKind> {
/// ///
/// Note that the tokens here do not include the outer attributes, but will /// Note that the tokens here do not include the outer attributes, but will
/// include inner attributes. /// include inner attributes.
pub tokens: Option<LazyTokenStream>, pub tokens: Option<LazyAttrTokenStream>,
} }
impl Item { impl Item {

View file

@ -4,7 +4,7 @@
use crate::ptr::P; use crate::ptr::P;
use crate::token::Nonterminal; use crate::token::Nonterminal;
use crate::tokenstream::LazyTokenStream; use crate::tokenstream::LazyAttrTokenStream;
use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant}; use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
use crate::{AssocItem, Expr, ForeignItem, Item, NodeId}; use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility}; use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
@ -124,18 +124,18 @@ impl HasSpan for AttrItem {
/// A trait for AST nodes having (or not having) collected tokens. /// A trait for AST nodes having (or not having) collected tokens.
pub trait HasTokens { pub trait HasTokens {
fn tokens(&self) -> Option<&LazyTokenStream>; fn tokens(&self) -> Option<&LazyAttrTokenStream>;
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>>; fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>>;
} }
macro_rules! impl_has_tokens { macro_rules! impl_has_tokens {
($($T:ty),+ $(,)?) => { ($($T:ty),+ $(,)?) => {
$( $(
impl HasTokens for $T { impl HasTokens for $T {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
self.tokens.as_ref() self.tokens.as_ref()
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
Some(&mut self.tokens) Some(&mut self.tokens)
} }
} }
@ -147,10 +147,10 @@ macro_rules! impl_has_tokens_none {
($($T:ty),+ $(,)?) => { ($($T:ty),+ $(,)?) => {
$( $(
impl HasTokens for $T { impl HasTokens for $T {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
None None
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
None None
} }
} }
@ -162,25 +162,25 @@ impl_has_tokens!(AssocItem, AttrItem, Block, Expr, ForeignItem, Item, Pat, Path,
impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant); impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant);
impl<T: AstDeref<Target: HasTokens>> HasTokens for T { impl<T: AstDeref<Target: HasTokens>> HasTokens for T {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
self.ast_deref().tokens() self.ast_deref().tokens()
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
self.ast_deref_mut().tokens_mut() self.ast_deref_mut().tokens_mut()
} }
} }
impl<T: HasTokens> HasTokens for Option<T> { impl<T: HasTokens> HasTokens for Option<T> {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
self.as_ref().and_then(|inner| inner.tokens()) self.as_ref().and_then(|inner| inner.tokens())
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
self.as_mut().and_then(|inner| inner.tokens_mut()) self.as_mut().and_then(|inner| inner.tokens_mut())
} }
} }
impl HasTokens for StmtKind { impl HasTokens for StmtKind {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
match self { match self {
StmtKind::Local(local) => local.tokens.as_ref(), StmtKind::Local(local) => local.tokens.as_ref(),
StmtKind::Item(item) => item.tokens(), StmtKind::Item(item) => item.tokens(),
@ -189,7 +189,7 @@ impl HasTokens for StmtKind {
StmtKind::MacCall(mac) => mac.tokens.as_ref(), StmtKind::MacCall(mac) => mac.tokens.as_ref(),
} }
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
match self { match self {
StmtKind::Local(local) => Some(&mut local.tokens), StmtKind::Local(local) => Some(&mut local.tokens),
StmtKind::Item(item) => item.tokens_mut(), StmtKind::Item(item) => item.tokens_mut(),
@ -201,16 +201,16 @@ impl HasTokens for StmtKind {
} }
impl HasTokens for Stmt { impl HasTokens for Stmt {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
self.kind.tokens() self.kind.tokens()
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
self.kind.tokens_mut() self.kind.tokens_mut()
} }
} }
impl HasTokens for Attribute { impl HasTokens for Attribute {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
match &self.kind { match &self.kind {
AttrKind::Normal(normal) => normal.tokens.as_ref(), AttrKind::Normal(normal) => normal.tokens.as_ref(),
kind @ AttrKind::DocComment(..) => { kind @ AttrKind::DocComment(..) => {
@ -218,7 +218,7 @@ impl HasTokens for Attribute {
} }
} }
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
Some(match &mut self.kind { Some(match &mut self.kind {
AttrKind::Normal(normal) => &mut normal.tokens, AttrKind::Normal(normal) => &mut normal.tokens,
kind @ AttrKind::DocComment(..) => { kind @ AttrKind::DocComment(..) => {
@ -229,7 +229,7 @@ impl HasTokens for Attribute {
} }
impl HasTokens for Nonterminal { impl HasTokens for Nonterminal {
fn tokens(&self) -> Option<&LazyTokenStream> { fn tokens(&self) -> Option<&LazyAttrTokenStream> {
match self { match self {
Nonterminal::NtItem(item) => item.tokens(), Nonterminal::NtItem(item) => item.tokens(),
Nonterminal::NtStmt(stmt) => stmt.tokens(), Nonterminal::NtStmt(stmt) => stmt.tokens(),
@ -243,7 +243,7 @@ impl HasTokens for Nonterminal {
Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None, Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None,
} }
} }
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> { fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
match self { match self {
Nonterminal::NtItem(item) => item.tokens_mut(), Nonterminal::NtItem(item) => item.tokens_mut(),
Nonterminal::NtStmt(stmt) => stmt.tokens_mut(), Nonterminal::NtStmt(stmt) => stmt.tokens_mut(),

View file

@ -7,9 +7,8 @@ use crate::ast::{MacArgs, MacArgsEq, MacDelimiter, MetaItem, MetaItemKind, Neste
use crate::ast::{Path, PathSegment}; use crate::ast::{Path, PathSegment};
use crate::ptr::P; use crate::ptr::P;
use crate::token::{self, CommentKind, Delimiter, Token}; use crate::token::{self, CommentKind, Delimiter, Token};
use crate::tokenstream::{AttrAnnotatedTokenStream, AttrAnnotatedTokenTree};
use crate::tokenstream::{DelimSpan, Spacing, TokenTree}; use crate::tokenstream::{DelimSpan, Spacing, TokenTree};
use crate::tokenstream::{LazyTokenStream, TokenStream}; use crate::tokenstream::{LazyAttrTokenStream, TokenStream};
use crate::util::comments; use crate::util::comments;
use rustc_index::bit_set::GrowableBitSet; use rustc_index::bit_set::GrowableBitSet;
@ -296,20 +295,18 @@ impl Attribute {
} }
} }
pub fn tokens(&self) -> AttrAnnotatedTokenStream { pub fn tokens(&self) -> TokenStream {
match self.kind { match self.kind {
AttrKind::Normal(ref normal) => normal AttrKind::Normal(ref normal) => normal
.tokens .tokens
.as_ref() .as_ref()
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self)) .unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
.create_token_stream(), .to_attr_token_stream()
AttrKind::DocComment(comment_kind, data) => AttrAnnotatedTokenStream::from(( .to_tokenstream(),
AttrAnnotatedTokenTree::Token(Token::new( AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
token::DocComment(comment_kind, self.style, data), Token::new(token::DocComment(comment_kind, self.style, data), self.span),
self.span,
)),
Spacing::Alone, Spacing::Alone,
)), )]),
} }
} }
} }
@ -356,7 +353,7 @@ pub fn mk_attr(style: AttrStyle, path: Path, args: MacArgs, span: Span) -> Attri
pub fn mk_attr_from_item( pub fn mk_attr_from_item(
item: AttrItem, item: AttrItem,
tokens: Option<LazyTokenStream>, tokens: Option<LazyAttrTokenStream>,
style: AttrStyle, style: AttrStyle,
span: Span, span: Span,
) -> Attribute { ) -> Attribute {

View file

@ -15,6 +15,7 @@
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![cfg_attr(bootstrap, feature(label_break_value))] #![cfg_attr(bootstrap, feature(label_break_value))]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(let_else)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(slice_internals)] #![feature(slice_internals)]

View file

@ -642,17 +642,17 @@ pub fn noop_flat_map_param<T: MutVisitor>(mut param: Param, vis: &mut T) -> Smal
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_attr_annotated_tt<T: MutVisitor>(tt: &mut AttrAnnotatedTokenTree, vis: &mut T) { pub fn visit_attr_tt<T: MutVisitor>(tt: &mut AttrTokenTree, vis: &mut T) {
match tt { match tt {
AttrAnnotatedTokenTree::Token(token) => { AttrTokenTree::Token(token, _) => {
visit_token(token, vis); visit_token(token, vis);
} }
AttrAnnotatedTokenTree::Delimited(DelimSpan { open, close }, _delim, tts) => { AttrTokenTree::Delimited(DelimSpan { open, close }, _delim, tts) => {
vis.visit_span(open); vis.visit_span(open);
vis.visit_span(close); vis.visit_span(close);
visit_attr_annotated_tts(tts, vis); visit_attr_tts(tts, vis);
} }
AttrAnnotatedTokenTree::Attributes(data) => { AttrTokenTree::Attributes(data) => {
for attr in &mut *data.attrs { for attr in &mut *data.attrs {
match &mut attr.kind { match &mut attr.kind {
AttrKind::Normal(normal) => { AttrKind::Normal(normal) => {
@ -690,27 +690,27 @@ pub fn visit_tts<T: MutVisitor>(TokenStream(tts): &mut TokenStream, vis: &mut T)
} }
} }
pub fn visit_attr_annotated_tts<T: MutVisitor>( pub fn visit_attr_tts<T: MutVisitor>(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) {
AttrAnnotatedTokenStream(tts): &mut AttrAnnotatedTokenStream,
vis: &mut T,
) {
if T::VISIT_TOKENS && !tts.is_empty() { if T::VISIT_TOKENS && !tts.is_empty() {
let tts = Lrc::make_mut(tts); let tts = Lrc::make_mut(tts);
visit_vec(tts, |(tree, _is_joint)| visit_attr_annotated_tt(tree, vis)); visit_vec(tts, |tree| visit_attr_tt(tree, vis));
} }
} }
pub fn visit_lazy_tts_opt_mut<T: MutVisitor>(lazy_tts: Option<&mut LazyTokenStream>, vis: &mut T) { pub fn visit_lazy_tts_opt_mut<T: MutVisitor>(
lazy_tts: Option<&mut LazyAttrTokenStream>,
vis: &mut T,
) {
if T::VISIT_TOKENS { if T::VISIT_TOKENS {
if let Some(lazy_tts) = lazy_tts { if let Some(lazy_tts) = lazy_tts {
let mut tts = lazy_tts.create_token_stream(); let mut tts = lazy_tts.to_attr_token_stream();
visit_attr_annotated_tts(&mut tts, vis); visit_attr_tts(&mut tts, vis);
*lazy_tts = LazyTokenStream::new(tts); *lazy_tts = LazyAttrTokenStream::new(tts);
} }
} }
} }
pub fn visit_lazy_tts<T: MutVisitor>(lazy_tts: &mut Option<LazyTokenStream>, vis: &mut T) { pub fn visit_lazy_tts<T: MutVisitor>(lazy_tts: &mut Option<LazyAttrTokenStream>, vis: &mut T) {
visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis); visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis);
} }

View file

@ -121,12 +121,12 @@ where
} }
} }
pub trait CreateTokenStream: sync::Send + sync::Sync { pub trait ToAttrTokenStream: sync::Send + sync::Sync {
fn create_token_stream(&self) -> AttrAnnotatedTokenStream; fn to_attr_token_stream(&self) -> AttrTokenStream;
} }
impl CreateTokenStream for AttrAnnotatedTokenStream { impl ToAttrTokenStream for AttrTokenStream {
fn create_token_stream(&self) -> AttrAnnotatedTokenStream { fn to_attr_token_stream(&self) -> AttrTokenStream {
self.clone() self.clone()
} }
} }
@ -135,68 +135,68 @@ impl CreateTokenStream for AttrAnnotatedTokenStream {
/// of an actual `TokenStream` until it is needed. /// of an actual `TokenStream` until it is needed.
/// `Box` is here only to reduce the structure size. /// `Box` is here only to reduce the structure size.
#[derive(Clone)] #[derive(Clone)]
pub struct LazyTokenStream(Lrc<Box<dyn CreateTokenStream>>); pub struct LazyAttrTokenStream(Lrc<Box<dyn ToAttrTokenStream>>);
impl LazyTokenStream { impl LazyAttrTokenStream {
pub fn new(inner: impl CreateTokenStream + 'static) -> LazyTokenStream { pub fn new(inner: impl ToAttrTokenStream + 'static) -> LazyAttrTokenStream {
LazyTokenStream(Lrc::new(Box::new(inner))) LazyAttrTokenStream(Lrc::new(Box::new(inner)))
} }
pub fn create_token_stream(&self) -> AttrAnnotatedTokenStream { pub fn to_attr_token_stream(&self) -> AttrTokenStream {
self.0.create_token_stream() self.0.to_attr_token_stream()
} }
} }
impl fmt::Debug for LazyTokenStream { impl fmt::Debug for LazyAttrTokenStream {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "LazyTokenStream({:?})", self.create_token_stream()) write!(f, "LazyAttrTokenStream({:?})", self.to_attr_token_stream())
} }
} }
impl<S: Encoder> Encodable<S> for LazyTokenStream { impl<S: Encoder> Encodable<S> for LazyAttrTokenStream {
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
// Used by AST json printing. // Used by AST json printing.
Encodable::encode(&self.create_token_stream(), s); Encodable::encode(&self.to_attr_token_stream(), s);
} }
} }
impl<D: Decoder> Decodable<D> for LazyTokenStream { impl<D: Decoder> Decodable<D> for LazyAttrTokenStream {
fn decode(_d: &mut D) -> Self { fn decode(_d: &mut D) -> Self {
panic!("Attempted to decode LazyTokenStream"); panic!("Attempted to decode LazyAttrTokenStream");
} }
} }
impl<CTX> HashStable<CTX> for LazyTokenStream { impl<CTX> HashStable<CTX> for LazyAttrTokenStream {
fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) { fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) {
panic!("Attempted to compute stable hash for LazyTokenStream"); panic!("Attempted to compute stable hash for LazyAttrTokenStream");
} }
} }
/// A `AttrAnnotatedTokenStream` is similar to a `TokenStream`, but with extra /// An `AttrTokenStream` is similar to a `TokenStream`, but with extra
/// information about the tokens for attribute targets. This is used /// information about the tokens for attribute targets. This is used
/// during expansion to perform early cfg-expansion, and to process attributes /// during expansion to perform early cfg-expansion, and to process attributes
/// during proc-macro invocations. /// during proc-macro invocations.
#[derive(Clone, Debug, Default, Encodable, Decodable)] #[derive(Clone, Debug, Default, Encodable, Decodable)]
pub struct AttrAnnotatedTokenStream(pub Lrc<Vec<(AttrAnnotatedTokenTree, Spacing)>>); pub struct AttrTokenStream(pub Lrc<Vec<AttrTokenTree>>);
/// Like `TokenTree`, but for `AttrAnnotatedTokenStream` /// Like `TokenTree`, but for `AttrTokenStream`.
#[derive(Clone, Debug, Encodable, Decodable)] #[derive(Clone, Debug, Encodable, Decodable)]
pub enum AttrAnnotatedTokenTree { pub enum AttrTokenTree {
Token(Token), Token(Token, Spacing),
Delimited(DelimSpan, Delimiter, AttrAnnotatedTokenStream), Delimited(DelimSpan, Delimiter, AttrTokenStream),
/// Stores the attributes for an attribute target, /// Stores the attributes for an attribute target,
/// along with the tokens for that attribute target. /// along with the tokens for that attribute target.
/// See `AttributesData` for more information /// See `AttributesData` for more information
Attributes(AttributesData), Attributes(AttributesData),
} }
impl AttrAnnotatedTokenStream { impl AttrTokenStream {
pub fn new(tokens: Vec<(AttrAnnotatedTokenTree, Spacing)>) -> AttrAnnotatedTokenStream { pub fn new(tokens: Vec<AttrTokenTree>) -> AttrTokenStream {
AttrAnnotatedTokenStream(Lrc::new(tokens)) AttrTokenStream(Lrc::new(tokens))
} }
/// Converts this `AttrAnnotatedTokenStream` to a plain `TokenStream /// Converts this `AttrTokenStream` to a plain `TokenStream`.
/// During conversion, `AttrAnnotatedTokenTree::Attributes` get 'flattened' /// During conversion, `AttrTokenTree::Attributes` get 'flattened'
/// back to a `TokenStream` of the form `outer_attr attr_target`. /// back to a `TokenStream` of the form `outer_attr attr_target`.
/// If there are inner attributes, they are inserted into the proper /// If there are inner attributes, they are inserted into the proper
/// place in the attribute target tokens. /// place in the attribute target tokens.
@ -204,31 +204,27 @@ impl AttrAnnotatedTokenStream {
let trees: Vec<_> = self let trees: Vec<_> = self
.0 .0
.iter() .iter()
.flat_map(|tree| match &tree.0 { .flat_map(|tree| match &tree {
AttrAnnotatedTokenTree::Token(inner) => { AttrTokenTree::Token(inner, spacing) => {
smallvec![TokenTree::Token(inner.clone(), tree.1)].into_iter() smallvec![TokenTree::Token(inner.clone(), *spacing)].into_iter()
} }
AttrAnnotatedTokenTree::Delimited(span, delim, stream) => { AttrTokenTree::Delimited(span, delim, stream) => {
smallvec![TokenTree::Delimited(*span, *delim, stream.to_tokenstream()),] smallvec![TokenTree::Delimited(*span, *delim, stream.to_tokenstream()),]
.into_iter() .into_iter()
} }
AttrAnnotatedTokenTree::Attributes(data) => { AttrTokenTree::Attributes(data) => {
let mut outer_attrs = Vec::new(); let mut outer_attrs = Vec::new();
let mut inner_attrs = Vec::new(); let mut inner_attrs = Vec::new();
for attr in &data.attrs { for attr in &data.attrs {
match attr.style { match attr.style {
crate::AttrStyle::Outer => { crate::AttrStyle::Outer => outer_attrs.push(attr),
outer_attrs.push(attr); crate::AttrStyle::Inner => inner_attrs.push(attr),
}
crate::AttrStyle::Inner => {
inner_attrs.push(attr);
}
} }
} }
let mut target_tokens: Vec<_> = data let mut target_tokens: Vec<_> = data
.tokens .tokens
.create_token_stream() .to_attr_token_stream()
.to_tokenstream() .to_tokenstream()
.0 .0
.iter() .iter()
@ -239,9 +235,9 @@ impl AttrAnnotatedTokenStream {
// Check the last two trees (to account for a trailing semi) // Check the last two trees (to account for a trailing semi)
for tree in target_tokens.iter_mut().rev().take(2) { for tree in target_tokens.iter_mut().rev().take(2) {
if let TokenTree::Delimited(span, delim, delim_tokens) = tree { if let TokenTree::Delimited(span, delim, delim_tokens) = tree {
// Inner attributes are only supported on extern blocks, functions, impls, // Inner attributes are only supported on extern blocks, functions,
// and modules. All of these have their inner attributes placed at // impls, and modules. All of these have their inner attributes
// the beginning of the rightmost outermost braced group: // placed at the beginning of the rightmost outermost braced group:
// e.g. fn foo() { #![my_attr} } // e.g. fn foo() { #![my_attr} }
// //
// Therefore, we can insert them back into the right location // Therefore, we can insert them back into the right location
@ -255,7 +251,7 @@ impl AttrAnnotatedTokenStream {
let mut builder = TokenStreamBuilder::new(); let mut builder = TokenStreamBuilder::new();
for inner_attr in inner_attrs { for inner_attr in inner_attrs {
builder.push(inner_attr.tokens().to_tokenstream()); builder.push(inner_attr.tokens());
} }
builder.push(delim_tokens.clone()); builder.push(delim_tokens.clone());
*tree = TokenTree::Delimited(*span, *delim, builder.build()); *tree = TokenTree::Delimited(*span, *delim, builder.build());
@ -273,7 +269,7 @@ impl AttrAnnotatedTokenStream {
let mut flat: SmallVec<[_; 1]> = SmallVec::new(); let mut flat: SmallVec<[_; 1]> = SmallVec::new();
for attr in outer_attrs { for attr in outer_attrs {
// FIXME: Make this more efficient // FIXME: Make this more efficient
flat.extend(attr.tokens().to_tokenstream().0.clone().iter().cloned()); flat.extend(attr.tokens().0.clone().iter().cloned());
} }
flat.extend(target_tokens); flat.extend(target_tokens);
flat.into_iter() flat.into_iter()
@ -300,7 +296,7 @@ pub struct AttributesData {
pub attrs: AttrVec, pub attrs: AttrVec,
/// The underlying tokens for the attribute target that `attrs` /// The underlying tokens for the attribute target that `attrs`
/// are applied to /// are applied to
pub tokens: LazyTokenStream, pub tokens: LazyAttrTokenStream,
} }
/// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s. /// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s.
@ -363,12 +359,6 @@ impl TokenStream {
} }
} }
impl From<(AttrAnnotatedTokenTree, Spacing)> for AttrAnnotatedTokenStream {
fn from((tree, spacing): (AttrAnnotatedTokenTree, Spacing)) -> AttrAnnotatedTokenStream {
AttrAnnotatedTokenStream::new(vec![(tree, spacing)])
}
}
impl iter::FromIterator<TokenTree> for TokenStream { impl iter::FromIterator<TokenTree> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self { fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
TokenStream::new(iter.into_iter().collect::<Vec<TokenTree>>()) TokenStream::new(iter.into_iter().collect::<Vec<TokenTree>>())
@ -420,22 +410,6 @@ impl TokenStream {
TokenStream(Lrc::new(self.0.iter().enumerate().map(|(i, tree)| f(i, tree)).collect())) TokenStream(Lrc::new(self.0.iter().enumerate().map(|(i, tree)| f(i, tree)).collect()))
} }
fn opt_from_ast(node: &(impl HasAttrs + HasTokens)) -> Option<TokenStream> {
let tokens = node.tokens()?;
let attrs = node.attrs();
let attr_annotated = if attrs.is_empty() {
tokens.create_token_stream()
} else {
let attr_data =
AttributesData { attrs: attrs.iter().cloned().collect(), tokens: tokens.clone() };
AttrAnnotatedTokenStream::new(vec![(
AttrAnnotatedTokenTree::Attributes(attr_data),
Spacing::Alone,
)])
};
Some(attr_annotated.to_tokenstream())
}
// Create a token stream containing a single token with alone spacing. // Create a token stream containing a single token with alone spacing.
pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream { pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream {
TokenStream::new(vec![TokenTree::token_alone(kind, span)]) TokenStream::new(vec![TokenTree::token_alone(kind, span)])
@ -452,8 +426,18 @@ impl TokenStream {
} }
pub fn from_ast(node: &(impl HasAttrs + HasSpan + HasTokens + fmt::Debug)) -> TokenStream { pub fn from_ast(node: &(impl HasAttrs + HasSpan + HasTokens + fmt::Debug)) -> TokenStream {
TokenStream::opt_from_ast(node) let Some(tokens) = node.tokens() else {
.unwrap_or_else(|| panic!("missing tokens for node at {:?}: {:?}", node.span(), node)) panic!("missing tokens for node at {:?}: {:?}", node.span(), node);
};
let attrs = node.attrs();
let attr_stream = if attrs.is_empty() {
tokens.to_attr_token_stream()
} else {
let attr_data =
AttributesData { attrs: attrs.iter().cloned().collect(), tokens: tokens.clone() };
AttrTokenStream::new(vec![AttrTokenTree::Attributes(attr_data)])
};
attr_stream.to_tokenstream()
} }
pub fn from_nonterminal_ast(nt: &Nonterminal) -> TokenStream { pub fn from_nonterminal_ast(nt: &Nonterminal) -> TokenStream {

View file

@ -86,8 +86,7 @@ impl LocationTable {
let (block, &first_index) = self let (block, &first_index) = self
.statements_before_block .statements_before_block
.iter_enumerated() .iter_enumerated()
.filter(|(_, first_index)| **first_index <= point_index) .rfind(|&(_, &first_index)| first_index <= point_index)
.last()
.unwrap(); .unwrap();
let statement_index = (point_index - first_index) / 2; let statement_index = (point_index - first_index) / 2;

View file

@ -188,14 +188,14 @@ impl CfgEval<'_, '_> {
let orig_tokens = annotatable.to_tokens().flattened(); let orig_tokens = annotatable.to_tokens().flattened();
// Re-parse the tokens, setting the `capture_cfg` flag to save extra information // Re-parse the tokens, setting the `capture_cfg` flag to save extra information
// to the captured `AttrAnnotatedTokenStream` (specifically, we capture // to the captured `AttrTokenStream` (specifically, we capture
// `AttrAnnotatedTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`) // `AttrTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
let mut parser = let mut parser =
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None); rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
parser.capture_cfg = true; parser.capture_cfg = true;
annotatable = parse_annotatable_with(&mut parser); annotatable = parse_annotatable_with(&mut parser);
// Now that we have our re-parsed `AttrAnnotatedTokenStream`, recursively configuring // Now that we have our re-parsed `AttrTokenStream`, recursively configuring
// our attribute target will correctly the tokens as well. // our attribute target will correctly the tokens as well.
flat_map_annotatable(self, annotatable) flat_map_annotatable(self, annotatable)
} }

View file

@ -1704,7 +1704,7 @@ impl EmitterWriter {
{ {
notice_capitalization |= only_capitalization; notice_capitalization |= only_capitalization;
let has_deletion = parts.iter().any(|p| p.is_deletion()); let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
let is_multiline = complete.lines().count() > 1; let is_multiline = complete.lines().count() > 1;
if let Some(span) = span.primary_span() { if let Some(span) = span.primary_span() {
@ -1880,16 +1880,23 @@ impl EmitterWriter {
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display; let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display; let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;
// If this addition is _only_ whitespace, then don't trim it,
// or else we're just not rendering anything.
let is_whitespace_addition = part.snippet.trim().is_empty();
// Do not underline the leading... // Do not underline the leading...
let start = part.snippet.len().saturating_sub(part.snippet.trim_start().len()); let start = if is_whitespace_addition {
0
} else {
part.snippet.len().saturating_sub(part.snippet.trim_start().len())
};
// ...or trailing spaces. Account for substitutions containing unicode // ...or trailing spaces. Account for substitutions containing unicode
// characters. // characters.
let sub_len: usize = part let sub_len: usize =
.snippet if is_whitespace_addition { &part.snippet } else { part.snippet.trim() }
.trim() .chars()
.chars() .map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1))
.map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1)) .sum();
.sum();
let offset: isize = offsets let offset: isize = offsets
.iter() .iter()
@ -2130,7 +2137,7 @@ impl EmitterWriter {
} }
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
enum DisplaySuggestion { enum DisplaySuggestion {
Underline, Underline,
Diff, Diff,

View file

@ -150,21 +150,20 @@ pub struct SubstitutionHighlight {
impl SubstitutionPart { impl SubstitutionPart {
pub fn is_addition(&self, sm: &SourceMap) -> bool { pub fn is_addition(&self, sm: &SourceMap) -> bool {
!self.snippet.is_empty() !self.snippet.is_empty() && !self.replaces_meaningful_content(sm)
&& sm
.span_to_snippet(self.span)
.map_or(self.span.is_empty(), |snippet| snippet.trim().is_empty())
} }
pub fn is_deletion(&self) -> bool { pub fn is_deletion(&self, sm: &SourceMap) -> bool {
self.snippet.trim().is_empty() self.snippet.trim().is_empty() && self.replaces_meaningful_content(sm)
} }
pub fn is_replacement(&self, sm: &SourceMap) -> bool { pub fn is_replacement(&self, sm: &SourceMap) -> bool {
!self.snippet.is_empty() !self.snippet.is_empty() && self.replaces_meaningful_content(sm)
&& sm }
.span_to_snippet(self.span)
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty()) fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {
sm.span_to_snippet(self.span)
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
} }
} }

View file

@ -2,9 +2,9 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{Delimiter, Token, TokenKind}; use rustc_ast::token::{Delimiter, Token, TokenKind};
use rustc_ast::tokenstream::{AttrAnnotatedTokenStream, AttrAnnotatedTokenTree}; use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree};
use rustc_ast::tokenstream::{DelimSpan, Spacing}; use rustc_ast::tokenstream::{DelimSpan, Spacing};
use rustc_ast::tokenstream::{LazyTokenStream, TokenTree}; use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
use rustc_ast::NodeId; use rustc_ast::NodeId;
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem}; use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
use rustc_attr as attr; use rustc_attr as attr;
@ -259,8 +259,8 @@ impl<'a> StripUnconfigured<'a> {
fn try_configure_tokens<T: HasTokens>(&self, node: &mut T) { fn try_configure_tokens<T: HasTokens>(&self, node: &mut T) {
if self.config_tokens { if self.config_tokens {
if let Some(Some(tokens)) = node.tokens_mut() { if let Some(Some(tokens)) = node.tokens_mut() {
let attr_annotated_tokens = tokens.create_token_stream(); let attr_stream = tokens.to_attr_token_stream();
*tokens = LazyTokenStream::new(self.configure_tokens(&attr_annotated_tokens)); *tokens = LazyAttrTokenStream::new(self.configure_tokens(&attr_stream));
} }
} }
} }
@ -270,16 +270,16 @@ impl<'a> StripUnconfigured<'a> {
if self.in_cfg(&attrs) { Some(attrs) } else { None } if self.in_cfg(&attrs) { Some(attrs) } else { None }
} }
/// Performs cfg-expansion on `stream`, producing a new `AttrAnnotatedTokenStream`. /// Performs cfg-expansion on `stream`, producing a new `AttrTokenStream`.
/// This is only used during the invocation of `derive` proc-macros, /// This is only used during the invocation of `derive` proc-macros,
/// which require that we cfg-expand their entire input. /// which require that we cfg-expand their entire input.
/// Normal cfg-expansion operates on parsed AST nodes via the `configure` method /// Normal cfg-expansion operates on parsed AST nodes via the `configure` method
fn configure_tokens(&self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream { fn configure_tokens(&self, stream: &AttrTokenStream) -> AttrTokenStream {
fn can_skip(stream: &AttrAnnotatedTokenStream) -> bool { fn can_skip(stream: &AttrTokenStream) -> bool {
stream.0.iter().all(|(tree, _spacing)| match tree { stream.0.iter().all(|tree| match tree {
AttrAnnotatedTokenTree::Attributes(_) => false, AttrTokenTree::Attributes(_) => false,
AttrAnnotatedTokenTree::Token(_) => true, AttrTokenTree::Token(..) => true,
AttrAnnotatedTokenTree::Delimited(_, _, inner) => can_skip(inner), AttrTokenTree::Delimited(_, _, inner) => can_skip(inner),
}) })
} }
@ -290,36 +290,36 @@ impl<'a> StripUnconfigured<'a> {
let trees: Vec<_> = stream let trees: Vec<_> = stream
.0 .0
.iter() .iter()
.flat_map(|(tree, spacing)| match tree.clone() { .flat_map(|tree| match tree.clone() {
AttrAnnotatedTokenTree::Attributes(mut data) => { AttrTokenTree::Attributes(mut data) => {
data.attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr)); data.attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
if self.in_cfg(&data.attrs) { if self.in_cfg(&data.attrs) {
data.tokens = LazyTokenStream::new( data.tokens = LazyAttrTokenStream::new(
self.configure_tokens(&data.tokens.create_token_stream()), self.configure_tokens(&data.tokens.to_attr_token_stream()),
); );
Some((AttrAnnotatedTokenTree::Attributes(data), *spacing)).into_iter() Some(AttrTokenTree::Attributes(data)).into_iter()
} else { } else {
None.into_iter() None.into_iter()
} }
} }
AttrAnnotatedTokenTree::Delimited(sp, delim, mut inner) => { AttrTokenTree::Delimited(sp, delim, mut inner) => {
inner = self.configure_tokens(&inner); inner = self.configure_tokens(&inner);
Some((AttrAnnotatedTokenTree::Delimited(sp, delim, inner), *spacing)) Some(AttrTokenTree::Delimited(sp, delim, inner))
.into_iter() .into_iter()
} }
AttrAnnotatedTokenTree::Token(ref token) if let TokenKind::Interpolated(ref nt) = token.kind => { AttrTokenTree::Token(ref token, _) if let TokenKind::Interpolated(ref nt) = token.kind => {
panic!( panic!(
"Nonterminal should have been flattened at {:?}: {:?}", "Nonterminal should have been flattened at {:?}: {:?}",
token.span, nt token.span, nt
); );
} }
AttrAnnotatedTokenTree::Token(token) => { AttrTokenTree::Token(token, spacing) => {
Some((AttrAnnotatedTokenTree::Token(token), *spacing)).into_iter() Some(AttrTokenTree::Token(token, spacing)).into_iter()
} }
}) })
.collect(); .collect();
AttrAnnotatedTokenStream::new(trees) AttrTokenStream::new(trees)
} }
/// Parse and expand all `cfg_attr` attributes into a list of attributes /// Parse and expand all `cfg_attr` attributes into a list of attributes
@ -388,7 +388,7 @@ impl<'a> StripUnconfigured<'a> {
attr: &Attribute, attr: &Attribute,
(item, item_span): (ast::AttrItem, Span), (item, item_span): (ast::AttrItem, Span),
) -> Attribute { ) -> Attribute {
let orig_tokens = attr.tokens().to_tokenstream(); let orig_tokens = attr.tokens();
// We are taking an attribute of the form `#[cfg_attr(pred, attr)]` // We are taking an attribute of the form `#[cfg_attr(pred, attr)]`
// and producing an attribute of the form `#[attr]`. We // and producing an attribute of the form `#[attr]`. We
@ -404,26 +404,26 @@ impl<'a> StripUnconfigured<'a> {
}; };
let pound_span = pound_token.span; let pound_span = pound_token.span;
let mut trees = vec![(AttrAnnotatedTokenTree::Token(pound_token), Spacing::Alone)]; let mut trees = vec![AttrTokenTree::Token(pound_token, Spacing::Alone)];
if attr.style == AttrStyle::Inner { if attr.style == AttrStyle::Inner {
// For inner attributes, we do the same thing for the `!` in `#![some_attr]` // For inner attributes, we do the same thing for the `!` in `#![some_attr]`
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = orig_trees.next().unwrap() else { let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = orig_trees.next().unwrap() else {
panic!("Bad tokens for attribute {:?}", attr); panic!("Bad tokens for attribute {:?}", attr);
}; };
trees.push((AttrAnnotatedTokenTree::Token(bang_token), Spacing::Alone)); trees.push(AttrTokenTree::Token(bang_token, Spacing::Alone));
} }
// We don't really have a good span to use for the synthesized `[]` // We don't really have a good span to use for the synthesized `[]`
// in `#[attr]`, so just use the span of the `#` token. // in `#[attr]`, so just use the span of the `#` token.
let bracket_group = AttrAnnotatedTokenTree::Delimited( let bracket_group = AttrTokenTree::Delimited(
DelimSpan::from_single(pound_span), DelimSpan::from_single(pound_span),
Delimiter::Bracket, Delimiter::Bracket,
item.tokens item.tokens
.as_ref() .as_ref()
.unwrap_or_else(|| panic!("Missing tokens for {:?}", item)) .unwrap_or_else(|| panic!("Missing tokens for {:?}", item))
.create_token_stream(), .to_attr_token_stream(),
); );
trees.push((bracket_group, Spacing::Alone)); trees.push(bracket_group);
let tokens = Some(LazyTokenStream::new(AttrAnnotatedTokenStream::new(trees))); let tokens = Some(LazyAttrTokenStream::new(AttrTokenStream::new(trees)));
let attr = attr::mk_attr_from_item(item, tokens, attr.style, item_span); let attr = attr::mk_attr_from_item(item, tokens, attr.style, item_span);
if attr.has_name(sym::crate_type) { if attr.has_name(sym::crate_type) {
self.sess.parse_sess.buffer_lint( self.sess.parse_sess.buffer_lint(

View file

@ -576,8 +576,7 @@ impl<'hir> Generics<'hir> {
if self.has_where_clause_predicates { if self.has_where_clause_predicates {
self.predicates self.predicates
.iter() .iter()
.filter(|p| p.in_where_clause()) .rfind(|&p| p.in_where_clause())
.last()
.map_or(end, |p| p.span()) .map_or(end, |p| p.span())
.shrink_to_hi() .shrink_to_hi()
.to(end) .to(end)

View file

@ -719,7 +719,7 @@ fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
Some(match *ty.kind() { Some(match *ty.kind() {
ty::Adt(field_def, field_substs) => { ty::Adt(field_def, field_substs) => {
let inner_field_ty = { let inner_field_ty = {
let first_non_zst_ty = field_def let mut first_non_zst_ty = field_def
.variants() .variants()
.iter() .iter()
.filter_map(|v| transparent_newtype_field(cx.tcx, v)); .filter_map(|v| transparent_newtype_field(cx.tcx, v));
@ -729,7 +729,7 @@ fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
"Wrong number of fields for transparent type" "Wrong number of fields for transparent type"
); );
first_non_zst_ty first_non_zst_ty
.last() .next_back()
.expect("No non-zst fields in transparent type.") .expect("No non-zst fields in transparent type.")
.ty(tcx, field_substs) .ty(tcx, field_substs)
}; };

View file

@ -301,9 +301,9 @@ impl<'a> Parser<'a> {
if let Some(attr) = attr { if let Some(attr) = attr {
let end_pos: u32 = self.token_cursor.num_next_calls.try_into().unwrap(); let end_pos: u32 = self.token_cursor.num_next_calls.try_into().unwrap();
// If we are currently capturing tokens, mark the location of this inner attribute. // If we are currently capturing tokens, mark the location of this inner attribute.
// If capturing ends up creating a `LazyTokenStream`, we will include // If capturing ends up creating a `LazyAttrTokenStream`, we will include
// this replace range with it, removing the inner attribute from the final // this replace range with it, removing the inner attribute from the final
// `AttrAnnotatedTokenStream`. Inner attributes are stored in the parsed AST note. // `AttrTokenStream`. Inner attributes are stored in the parsed AST note.
// During macro expansion, they are selectively inserted back into the // During macro expansion, they are selectively inserted back into the
// token stream (the first inner attribute is removed each time we invoke the // token stream (the first inner attribute is removed each time we invoke the
// corresponding macro). // corresponding macro).

View file

@ -1,7 +1,7 @@
use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken}; use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken};
use rustc_ast::token::{self, Delimiter, Token, TokenKind}; use rustc_ast::token::{self, Delimiter, Token, TokenKind};
use rustc_ast::tokenstream::{AttrAnnotatedTokenStream, AttributesData, CreateTokenStream}; use rustc_ast::tokenstream::{AttrTokenStream, AttributesData, ToAttrTokenStream};
use rustc_ast::tokenstream::{AttrAnnotatedTokenTree, DelimSpan, LazyTokenStream, Spacing}; use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spacing};
use rustc_ast::{self as ast}; use rustc_ast::{self as ast};
use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens}; use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens};
use rustc_errors::PResult; use rustc_errors::PResult;
@ -88,7 +88,7 @@ fn has_cfg_or_cfg_attr(attrs: &[Attribute]) -> bool {
// This also makes `Parser` very cheap to clone, since // This also makes `Parser` very cheap to clone, since
// there is no intermediate collection buffer to clone. // there is no intermediate collection buffer to clone.
#[derive(Clone)] #[derive(Clone)]
struct LazyTokenStreamImpl { struct LazyAttrTokenStreamImpl {
start_token: (Token, Spacing), start_token: (Token, Spacing),
cursor_snapshot: TokenCursor, cursor_snapshot: TokenCursor,
num_calls: usize, num_calls: usize,
@ -97,10 +97,10 @@ struct LazyTokenStreamImpl {
} }
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(LazyTokenStreamImpl, 144); rustc_data_structures::static_assert_size!(LazyAttrTokenStreamImpl, 144);
impl CreateTokenStream for LazyTokenStreamImpl { impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
fn create_token_stream(&self) -> AttrAnnotatedTokenStream { fn to_attr_token_stream(&self) -> AttrTokenStream {
// The token produced by the final call to `{,inlined_}next` was not // The token produced by the final call to `{,inlined_}next` was not
// actually consumed by the callback. The combination of chaining the // actually consumed by the callback. The combination of chaining the
// initial token and using `take` produces the desired result - we // initial token and using `take` produces the desired result - we
@ -179,7 +179,7 @@ impl CreateTokenStream for LazyTokenStreamImpl {
impl<'a> Parser<'a> { impl<'a> Parser<'a> {
/// Records all tokens consumed by the provided callback, /// Records all tokens consumed by the provided callback,
/// including the current token. These tokens are collected /// including the current token. These tokens are collected
/// into a `LazyTokenStream`, and returned along with the result /// into a `LazyAttrTokenStream`, and returned along with the result
/// of the callback. /// of the callback.
/// ///
/// Note: If your callback consumes an opening delimiter /// Note: If your callback consumes an opening delimiter
@ -297,8 +297,8 @@ impl<'a> Parser<'a> {
// If we 'broke' the last token (e.g. breaking a '>>' token to two '>' tokens), // If we 'broke' the last token (e.g. breaking a '>>' token to two '>' tokens),
// then extend the range of captured tokens to include it, since the parser // then extend the range of captured tokens to include it, since the parser
// was not actually bumped past it. When the `LazyTokenStream` gets converted // was not actually bumped past it. When the `LazyAttrTokenStream` gets converted
// into an `AttrAnnotatedTokenStream`, we will create the proper token. // into an `AttrTokenStream`, we will create the proper token.
if self.token_cursor.break_last_token { if self.token_cursor.break_last_token {
assert_eq!( assert_eq!(
trailing, trailing,
@ -316,8 +316,8 @@ impl<'a> Parser<'a> {
Box::new([]) Box::new([])
} else { } else {
// Grab any replace ranges that occur *inside* the current AST node. // Grab any replace ranges that occur *inside* the current AST node.
// We will perform the actual replacement when we convert the `LazyTokenStream` // We will perform the actual replacement when we convert the `LazyAttrTokenStream`
// to an `AttrAnnotatedTokenStream` // to an `AttrTokenStream`.
let start_calls: u32 = cursor_snapshot_next_calls.try_into().unwrap(); let start_calls: u32 = cursor_snapshot_next_calls.try_into().unwrap();
self.capture_state.replace_ranges[replace_ranges_start..replace_ranges_end] self.capture_state.replace_ranges[replace_ranges_start..replace_ranges_end]
.iter() .iter()
@ -329,7 +329,7 @@ impl<'a> Parser<'a> {
.collect() .collect()
}; };
let tokens = LazyTokenStream::new(LazyTokenStreamImpl { let tokens = LazyAttrTokenStream::new(LazyAttrTokenStreamImpl {
start_token, start_token,
num_calls, num_calls,
cursor_snapshot, cursor_snapshot,
@ -392,12 +392,12 @@ impl<'a> Parser<'a> {
fn make_token_stream( fn make_token_stream(
mut iter: impl Iterator<Item = (FlatToken, Spacing)>, mut iter: impl Iterator<Item = (FlatToken, Spacing)>,
break_last_token: bool, break_last_token: bool,
) -> AttrAnnotatedTokenStream { ) -> AttrTokenStream {
#[derive(Debug)] #[derive(Debug)]
struct FrameData { struct FrameData {
// This is `None` for the first frame, `Some` for all others. // This is `None` for the first frame, `Some` for all others.
open_delim_sp: Option<(Delimiter, Span)>, open_delim_sp: Option<(Delimiter, Span)>,
inner: Vec<(AttrAnnotatedTokenTree, Spacing)>, inner: Vec<AttrTokenTree>,
} }
let mut stack = vec![FrameData { open_delim_sp: None, inner: vec![] }]; let mut stack = vec![FrameData { open_delim_sp: None, inner: vec![] }];
let mut token_and_spacing = iter.next(); let mut token_and_spacing = iter.next();
@ -418,48 +418,47 @@ fn make_token_stream(
open_delim, span open_delim, span
); );
let dspan = DelimSpan::from_pair(open_sp, span); let dspan = DelimSpan::from_pair(open_sp, span);
let stream = AttrAnnotatedTokenStream::new(frame_data.inner); let stream = AttrTokenStream::new(frame_data.inner);
let delimited = AttrAnnotatedTokenTree::Delimited(dspan, delim, stream); let delimited = AttrTokenTree::Delimited(dspan, delim, stream);
stack stack
.last_mut() .last_mut()
.unwrap_or_else(|| { .unwrap_or_else(|| {
panic!("Bottom token frame is missing for token: {:?}", token) panic!("Bottom token frame is missing for token: {:?}", token)
}) })
.inner .inner
.push((delimited, Spacing::Alone)); .push(delimited);
} }
FlatToken::Token(token) => stack FlatToken::Token(token) => stack
.last_mut() .last_mut()
.expect("Bottom token frame is missing!") .expect("Bottom token frame is missing!")
.inner .inner
.push((AttrAnnotatedTokenTree::Token(token), spacing)), .push(AttrTokenTree::Token(token, spacing)),
FlatToken::AttrTarget(data) => stack FlatToken::AttrTarget(data) => stack
.last_mut() .last_mut()
.expect("Bottom token frame is missing!") .expect("Bottom token frame is missing!")
.inner .inner
.push((AttrAnnotatedTokenTree::Attributes(data), spacing)), .push(AttrTokenTree::Attributes(data)),
FlatToken::Empty => {} FlatToken::Empty => {}
} }
token_and_spacing = iter.next(); token_and_spacing = iter.next();
} }
let mut final_buf = stack.pop().expect("Missing final buf!"); let mut final_buf = stack.pop().expect("Missing final buf!");
if break_last_token { if break_last_token {
let (last_token, spacing) = final_buf.inner.pop().unwrap(); let last_token = final_buf.inner.pop().unwrap();
if let AttrAnnotatedTokenTree::Token(last_token) = last_token { if let AttrTokenTree::Token(last_token, spacing) = last_token {
let unglued_first = last_token.kind.break_two_token_op().unwrap().0; let unglued_first = last_token.kind.break_two_token_op().unwrap().0;
// An 'unglued' token is always two ASCII characters // An 'unglued' token is always two ASCII characters
let mut first_span = last_token.span.shrink_to_lo(); let mut first_span = last_token.span.shrink_to_lo();
first_span = first_span.with_hi(first_span.lo() + rustc_span::BytePos(1)); first_span = first_span.with_hi(first_span.lo() + rustc_span::BytePos(1));
final_buf.inner.push(( final_buf
AttrAnnotatedTokenTree::Token(Token::new(unglued_first, first_span)), .inner
spacing, .push(AttrTokenTree::Token(Token::new(unglued_first, first_span), spacing));
));
} else { } else {
panic!("Unexpected last token {:?}", last_token) panic!("Unexpected last token {:?}", last_token)
} }
} }
assert!(stack.is_empty(), "Stack should be empty: final_buf={:?} stack={:?}", final_buf, stack); assert!(stack.is_empty(), "Stack should be empty: final_buf={:?} stack={:?}", final_buf, stack);
AttrAnnotatedTokenStream::new(final_buf.inner) AttrTokenStream::new(final_buf.inner)
} }

View file

@ -170,7 +170,7 @@ pub struct ClosureSpans {
/// attribute, we parse a nested AST node that has `#[cfg]` or `#[cfg_attr]` /// attribute, we parse a nested AST node that has `#[cfg]` or `#[cfg_attr]`
/// In this case, we use a `ReplaceRange` to replace the entire inner AST node /// In this case, we use a `ReplaceRange` to replace the entire inner AST node
/// with `FlatToken::AttrTarget`, allowing us to perform eager cfg-expansion /// with `FlatToken::AttrTarget`, allowing us to perform eager cfg-expansion
/// on an `AttrAnnotatedTokenStream` /// on an `AttrTokenStream`.
/// ///
/// 2. When we parse an inner attribute while collecting tokens. We /// 2. When we parse an inner attribute while collecting tokens. We
/// remove inner attributes from the token stream entirely, and /// remove inner attributes from the token stream entirely, and
@ -183,7 +183,7 @@ pub type ReplaceRange = (Range<u32>, Vec<(FlatToken, Spacing)>);
/// Controls how we capture tokens. Capturing can be expensive, /// Controls how we capture tokens. Capturing can be expensive,
/// so we try to avoid performing capturing in cases where /// so we try to avoid performing capturing in cases where
/// we will never need an `AttrAnnotatedTokenStream` /// we will never need an `AttrTokenStream`.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub enum Capturing { pub enum Capturing {
/// We aren't performing any capturing - this is the default mode. /// We aren't performing any capturing - this is the default mode.
@ -237,7 +237,7 @@ struct TokenCursor {
// the trailing `>>` token. The `break_last_token` // the trailing `>>` token. The `break_last_token`
// field is used to track this token - it gets // field is used to track this token - it gets
// appended to the captured stream when // appended to the captured stream when
// we evaluate a `LazyTokenStream` // we evaluate a `LazyAttrTokenStream`.
break_last_token: bool, break_last_token: bool,
} }
@ -1464,11 +1464,11 @@ pub fn emit_unclosed_delims(unclosed_delims: &mut Vec<UnmatchedBrace>, sess: &Pa
} }
} }
/// A helper struct used when building an `AttrAnnotatedTokenStream` from /// A helper struct used when building an `AttrTokenStream` from
/// a `LazyTokenStream`. Both delimiter and non-delimited tokens /// a `LazyAttrTokenStream`. Both delimiter and non-delimited tokens
/// are stored as `FlatToken::Token`. A vector of `FlatToken`s /// are stored as `FlatToken::Token`. A vector of `FlatToken`s
/// is then 'parsed' to build up an `AttrAnnotatedTokenStream` with nested /// is then 'parsed' to build up an `AttrTokenStream` with nested
/// `AttrAnnotatedTokenTree::Delimited` tokens /// `AttrTokenTree::Delimited` tokens.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum FlatToken { pub enum FlatToken {
/// A token - this holds both delimiter (e.g. '{' and '}') /// A token - this holds both delimiter (e.g. '{' and '}')
@ -1476,11 +1476,11 @@ pub enum FlatToken {
Token(Token), Token(Token),
/// Holds the `AttributesData` for an AST node. The /// Holds the `AttributesData` for an AST node. The
/// `AttributesData` is inserted directly into the /// `AttributesData` is inserted directly into the
/// constructed `AttrAnnotatedTokenStream` as /// constructed `AttrTokenStream` as
/// an `AttrAnnotatedTokenTree::Attributes` /// an `AttrTokenTree::Attributes`.
AttrTarget(AttributesData), AttrTarget(AttributesData),
/// A special 'empty' token that is ignored during the conversion /// A special 'empty' token that is ignored during the conversion
/// to an `AttrAnnotatedTokenStream`. This is used to simplify the /// to an `AttrTokenStream`. This is used to simplify the
/// handling of replace ranges. /// handling of replace ranges.
Empty, Empty,
} }

View file

@ -617,9 +617,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
.filter(|&sp| sp != base_error.span) .filter(|&sp| sp != base_error.span)
.collect(); .collect();
let start_span = bounds.iter().map(|bound| bound.span()).next().unwrap(); let start_span = bounds[0].span();
// `end_span` is the end of the poly trait ref (Foo + 'baz + Bar><) // `end_span` is the end of the poly trait ref (Foo + 'baz + Bar><)
let end_span = bounds.iter().map(|bound| bound.span()).last().unwrap(); let end_span = bounds.last().unwrap().span();
// `last_bound_span` is the last bound of the poly trait ref (Foo + >'baz< + Bar) // `last_bound_span` is the last bound of the poly trait ref (Foo + >'baz< + Bar)
let last_bound_span = spans.last().cloned().unwrap(); let last_bound_span = spans.last().cloned().unwrap();
let mut multi_span: MultiSpan = spans.clone().into(); let mut multi_span: MultiSpan = spans.clone().into();

View file

@ -1309,10 +1309,8 @@ pub fn build_session(
let warnings_allow = sopts let warnings_allow = sopts
.lint_opts .lint_opts
.iter() .iter()
.filter(|&&(ref key, _)| *key == "warnings") .rfind(|&&(ref key, _)| *key == "warnings")
.map(|&(_, ref level)| *level == lint::Allow) .map_or(false, |&(_, level)| level == lint::Allow);
.last()
.unwrap_or(false);
let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow); let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow);
let can_emit_warnings = !(warnings_allow || cap_lints_allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow);

View file

@ -1016,7 +1016,7 @@ pub(crate) mod builtin {
/// Concatenates literals into a byte slice. /// Concatenates literals into a byte slice.
/// ///
/// This macro takes any number of comma-separated literals, and concatenates them all into /// This macro takes any number of comma-separated literals, and concatenates them all into
/// one, yielding an expression of type `&[u8, _]`, which represents all of the literals /// one, yielding an expression of type `&[u8; _]`, which represents all of the literals
/// concatenated left-to-right. The literals passed can be any combination of: /// concatenated left-to-right. The literals passed can be any combination of:
/// ///
/// - byte literals (`b'r'`) /// - byte literals (`b'r'`)

View file

@ -587,7 +587,7 @@ fn generate_macro_def_id_path(
} }
}) })
.collect(); .collect();
let relative = fqp.iter().map(|elem| elem.to_string()); let mut relative = fqp.iter().map(|elem| elem.to_string());
let cstore = CStore::from_tcx(tcx); let cstore = CStore::from_tcx(tcx);
// We need this to prevent a `panic` when this function is used from intra doc links... // We need this to prevent a `panic` when this function is used from intra doc links...
if !cstore.has_crate_data(def_id.krate) { if !cstore.has_crate_data(def_id.krate) {
@ -607,7 +607,7 @@ fn generate_macro_def_id_path(
let mut path = if is_macro_2 { let mut path = if is_macro_2 {
once(crate_name.clone()).chain(relative).collect() once(crate_name.clone()).chain(relative).collect()
} else { } else {
vec![crate_name.clone(), relative.last().unwrap()] vec![crate_name.clone(), relative.next_back().unwrap()]
}; };
if path.len() < 2 { if path.len() < 2 {
// The minimum we can have is the crate name followed by the macro name. If shorter, then // The minimum we can have is the crate name followed by the macro name. If shorter, then

View file

@ -206,7 +206,6 @@ a.source,
.item-left > a, .item-left > a,
.out-of-band, .out-of-band,
span.since, span.since,
#source-sidebar, #sidebar-toggle,
details.rustdoc-toggle > summary::before, details.rustdoc-toggle > summary::before,
.content ul.crate a.crate, .content ul.crate a.crate,
a.srclink, a.srclink,

View file

@ -13,9 +13,8 @@ LL | #[deny(bare_trait_objects)]
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:35 --> $DIR/dyn-2018-edition-lint.rs:4:35
@ -27,9 +26,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:17:14 --> $DIR/dyn-2018-edition-lint.rs:17:14
@ -41,9 +39,8 @@ LL | let _x: &SomeTrait = todo!();
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - let _x: &SomeTrait = todo!(); LL | let _x: &dyn SomeTrait = todo!();
LL + let _x: &dyn SomeTrait = todo!(); | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:17 --> $DIR/dyn-2018-edition-lint.rs:4:17
@ -55,9 +52,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:17 --> $DIR/dyn-2018-edition-lint.rs:4:17
@ -69,9 +65,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:35 --> $DIR/dyn-2018-edition-lint.rs:4:35
@ -83,9 +78,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:35 --> $DIR/dyn-2018-edition-lint.rs:4:35
@ -97,9 +91,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { | +++
|
error: aborting due to 7 previous errors error: aborting due to 7 previous errors

View file

@ -6,9 +6,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { | +++
|
error[E0782]: trait objects must include the `dyn` keyword error[E0782]: trait objects must include the `dyn` keyword
--> $DIR/dyn-2021-edition-error.rs:3:35 --> $DIR/dyn-2021-edition-error.rs:3:35
@ -18,9 +17,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { | +++
|
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -13,9 +13,8 @@ LL | #![deny(bare_trait_objects)]
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - <fmt::Debug>::fmt(self, f) LL | <dyn fmt::Debug>::fmt(self, f)
LL + <dyn fmt::Debug>::fmt(self, f) | +++
|
error: aborting due to previous error error: aborting due to previous error

View file

@ -6,9 +6,8 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - fn ice() -> impl AsRef<Fn(&())> { LL | fn ice() -> impl AsRef<dyn Fn(&())> {
LL + fn ice() -> impl AsRef<dyn Fn(&())> { | +++
|
error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13 --> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13

View file

@ -25,9 +25,8 @@ LL | eq::<dyn, Foo>
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - eq::<dyn, Foo> LL | eq::<dyn, dyn Foo>
LL + eq::<dyn, dyn Foo> | +++
|
error[E0107]: missing generics for trait `Foo` error[E0107]: missing generics for trait `Foo`
--> $DIR/issue-86756.rs:5:15 --> $DIR/issue-86756.rs:5:15

View file

@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/allowed-group-warn-by-default-lint.rs:10:25 --> $DIR/allowed-group-warn-by-default-lint.rs:10:25
@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/allowed-group-warn-by-default-lint.rs:10:25 --> $DIR/allowed-group-warn-by-default-lint.rs:10:25
@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: 3 warnings emitted warning: 3 warnings emitted

View file

@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/cap-lints-allow.rs:8:25 --> $DIR/cap-lints-allow.rs:8:25
@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/cap-lints-allow.rs:8:25 --> $DIR/cap-lints-allow.rs:8:25
@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: 3 warnings emitted warning: 3 warnings emitted

View file

@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25
@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25
@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: 3 warnings emitted warning: 3 warnings emitted

View file

@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-lint-group.rs:10:25 --> $DIR/lint-group-allowed-lint-group.rs:10:25
@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-lint-group.rs:10:25 --> $DIR/lint-group-allowed-lint-group.rs:10:25
@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: 3 warnings emitted warning: 3 warnings emitted

View file

@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25
@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25
@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub fn function(_x: Box<SomeTrait>) {} LL | pub fn function(_x: Box<dyn SomeTrait>) {}
LL + pub fn function(_x: Box<dyn SomeTrait>) {} | +++
|
warning: 3 warnings emitted warning: 3 warnings emitted

View file

@ -8,9 +8,8 @@ help: use `+= 1` instead
| |
LL | { let tmp = i; i += 1; tmp }; LL | { let tmp = i; i += 1; tmp };
| +++++++++++ ~~~~~~~~~~~~~~~ | +++++++++++ ~~~~~~~~~~~~~~~
LL - i++; LL | i += 1;
LL + i += 1; | ~~~~
|
error: Rust has no postfix increment operator error: Rust has no postfix increment operator
--> $DIR/increment-notfixed.rs:17:12 --> $DIR/increment-notfixed.rs:17:12
@ -24,9 +23,8 @@ help: use `+= 1` instead
| |
LL | while { let tmp = i; i += 1; tmp } < 5 { LL | while { let tmp = i; i += 1; tmp } < 5 {
| +++++++++++ ~~~~~~~~~~~~~~~ | +++++++++++ ~~~~~~~~~~~~~~~
LL - while i++ < 5 { LL | while i += 1 < 5 {
LL + while i += 1 < 5 { | ~~~~
|
error: Rust has no postfix increment operator error: Rust has no postfix increment operator
--> $DIR/increment-notfixed.rs:25:8 --> $DIR/increment-notfixed.rs:25:8
@ -38,9 +36,8 @@ help: use `+= 1` instead
| |
LL | { let tmp_ = tmp; tmp += 1; tmp_ }; LL | { let tmp_ = tmp; tmp += 1; tmp_ };
| ++++++++++++ ~~~~~~~~~~~~~~~~~~ | ++++++++++++ ~~~~~~~~~~~~~~~~~~
LL - tmp++; LL | tmp += 1;
LL + tmp += 1; | ~~~~
|
error: Rust has no postfix increment operator error: Rust has no postfix increment operator
--> $DIR/increment-notfixed.rs:31:14 --> $DIR/increment-notfixed.rs:31:14
@ -54,9 +51,8 @@ help: use `+= 1` instead
| |
LL | while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 { LL | while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 {
| ++++++++++++ ~~~~~~~~~~~~~~~~~~ | ++++++++++++ ~~~~~~~~~~~~~~~~~~
LL - while tmp++ < 5 { LL | while tmp += 1 < 5 {
LL + while tmp += 1 < 5 { | ~~~~
|
error: Rust has no postfix increment operator error: Rust has no postfix increment operator
--> $DIR/increment-notfixed.rs:39:16 --> $DIR/increment-notfixed.rs:39:16
@ -68,9 +64,8 @@ help: use `+= 1` instead
| |
LL | { let tmp = foo.bar.qux; foo.bar.qux += 1; tmp }; LL | { let tmp = foo.bar.qux; foo.bar.qux += 1; tmp };
| +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~
LL - foo.bar.qux++; LL | foo.bar.qux += 1;
LL + foo.bar.qux += 1; | ~~~~
|
error: Rust has no postfix increment operator error: Rust has no postfix increment operator
--> $DIR/increment-notfixed.rs:49:10 --> $DIR/increment-notfixed.rs:49:10
@ -82,9 +77,8 @@ help: use `+= 1` instead
| |
LL | { let tmp = s.tmp; s.tmp += 1; tmp }; LL | { let tmp = s.tmp; s.tmp += 1; tmp };
| +++++++++++ ~~~~~~~~~~~~~~~~~~~ | +++++++++++ ~~~~~~~~~~~~~~~~~~~
LL - s.tmp++; LL | s.tmp += 1;
LL + s.tmp += 1; | ~~~~
|
error: Rust has no prefix increment operator error: Rust has no prefix increment operator
--> $DIR/increment-notfixed.rs:56:5 --> $DIR/increment-notfixed.rs:56:5

View file

@ -27,9 +27,8 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; LL | let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>;
LL + let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>; | +++
|
error[E0225]: only auto traits can be used as additional traits in a trait object error[E0225]: only auto traits can be used as additional traits in a trait object
--> $DIR/trait-object-trait-parens.rs:8:35 --> $DIR/trait-object-trait-parens.rs:8:35
@ -52,9 +51,8 @@ LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>; LL | let _: Box<dyn ?Sized + (for<'a> Trait<'a>) + (Obj)>;
LL + let _: Box<dyn ?Sized + (for<'a> Trait<'a>) + (Obj)>; | +++
|
error[E0225]: only auto traits can be used as additional traits in a trait object error[E0225]: only auto traits can be used as additional traits in a trait object
--> $DIR/trait-object-trait-parens.rs:13:47 --> $DIR/trait-object-trait-parens.rs:13:47
@ -77,9 +75,8 @@ LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>; LL | let _: Box<dyn for<'a> Trait<'a> + (Obj) + (?Sized)>;
LL + let _: Box<dyn for<'a> Trait<'a> + (Obj) + (?Sized)>; | +++
|
error[E0225]: only auto traits can be used as additional traits in a trait object error[E0225]: only auto traits can be used as additional traits in a trait object
--> $DIR/trait-object-trait-parens.rs:18:36 --> $DIR/trait-object-trait-parens.rs:18:36

View file

@ -13,9 +13,8 @@ LL | #![warn(rust_2021_prefixes_incompatible_syntax)]
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
| |
LL - m2!(z"hey"); LL | m2!(z "hey");
LL + m2!(z "hey"); | +
|
warning: prefix `prefix` is unknown warning: prefix `prefix` is unknown
--> $DIR/reserved-prefixes-migration.rs:19:9 --> $DIR/reserved-prefixes-migration.rs:19:9
@ -27,9 +26,8 @@ LL | m2!(prefix"hey");
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
| |
LL - m2!(prefix"hey"); LL | m2!(prefix "hey");
LL + m2!(prefix "hey"); | +
|
warning: prefix `hey` is unknown warning: prefix `hey` is unknown
--> $DIR/reserved-prefixes-migration.rs:22:9 --> $DIR/reserved-prefixes-migration.rs:22:9
@ -41,9 +39,8 @@ LL | m3!(hey#123);
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
| |
LL - m3!(hey#123); LL | m3!(hey #123);
LL + m3!(hey #123); | +
|
warning: prefix `hey` is unknown warning: prefix `hey` is unknown
--> $DIR/reserved-prefixes-migration.rs:25:9 --> $DIR/reserved-prefixes-migration.rs:25:9
@ -55,9 +52,8 @@ LL | m3!(hey#hey);
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
| |
LL - m3!(hey#hey); LL | m3!(hey #hey);
LL + m3!(hey #hey); | +
|
warning: prefix `kind` is unknown warning: prefix `kind` is unknown
--> $DIR/reserved-prefixes-migration.rs:35:14 --> $DIR/reserved-prefixes-migration.rs:35:14
@ -69,9 +65,8 @@ LL | #name = #kind#value
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
| |
LL - #name = #kind#value LL | #name = #kind #value
LL + #name = #kind #value | +
|
warning: 5 warnings emitted warning: 5 warnings emitted

View file

@ -7,9 +7,8 @@ LL | demo3!(foo#bar);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo3!(foo#bar); LL | demo3!(foo #bar);
LL + demo3!(foo #bar); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:17:12 --> $DIR/reserved-prefixes.rs:17:12
@ -20,9 +19,8 @@ LL | demo2!(foo"bar");
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo2!(foo"bar"); LL | demo2!(foo "bar");
LL + demo2!(foo "bar"); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:18:12 --> $DIR/reserved-prefixes.rs:18:12
@ -33,9 +31,8 @@ LL | demo2!(foo'b');
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo2!(foo'b'); LL | demo2!(foo 'b');
LL + demo2!(foo 'b'); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:20:12 --> $DIR/reserved-prefixes.rs:20:12
@ -46,9 +43,8 @@ LL | demo2!(foo'b);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo2!(foo'b); LL | demo2!(foo 'b);
LL + demo2!(foo 'b); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:21:12 --> $DIR/reserved-prefixes.rs:21:12
@ -59,9 +55,8 @@ LL | demo3!(foo# bar);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo3!(foo# bar); LL | demo3!(foo # bar);
LL + demo3!(foo # bar); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:22:12 --> $DIR/reserved-prefixes.rs:22:12
@ -72,9 +67,8 @@ LL | demo4!(foo#! bar);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo4!(foo#! bar); LL | demo4!(foo #! bar);
LL + demo4!(foo #! bar); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:23:12 --> $DIR/reserved-prefixes.rs:23:12
@ -85,9 +79,8 @@ LL | demo4!(foo## bar);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo4!(foo## bar); LL | demo4!(foo ## bar);
LL + demo4!(foo ## bar); | +
|
error: prefix `foo` is unknown error: prefix `foo` is unknown
--> $DIR/reserved-prefixes.rs:25:12 --> $DIR/reserved-prefixes.rs:25:12
@ -98,9 +91,8 @@ LL | demo4!(foo#bar#);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo4!(foo#bar#); LL | demo4!(foo #bar#);
LL + demo4!(foo #bar#); | +
|
error: prefix `bar` is unknown error: prefix `bar` is unknown
--> $DIR/reserved-prefixes.rs:25:16 --> $DIR/reserved-prefixes.rs:25:16
@ -111,9 +103,8 @@ LL | demo4!(foo#bar#);
= note: prefixed identifiers and literals are reserved since Rust 2021 = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here help: consider inserting whitespace here
| |
LL - demo4!(foo#bar#); LL | demo4!(foo#bar #);
LL + demo4!(foo#bar #); | +
|
error: aborting due to 9 previous errors error: aborting due to 9 previous errors

View file

@ -13,9 +13,8 @@ LL | #![deny(bare_trait_objects)]
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - bar: Box<Bar>, LL | bar: Box<dyn Bar>,
LL + bar: Box<dyn Bar>, | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:18:1 --> $DIR/issue-61963.rs:18:1
@ -27,9 +26,8 @@ LL | pub struct Foo {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub struct Foo { LL | dyn pub struct Foo {
LL + dyn pub struct Foo { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:28:14 --> $DIR/issue-61963.rs:28:14
@ -41,9 +39,8 @@ LL | bar: Box<Bar>,
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - bar: Box<Bar>, LL | bar: Box<dyn Bar>,
LL + bar: Box<dyn Bar>, | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:28:14 --> $DIR/issue-61963.rs:28:14
@ -55,9 +52,8 @@ LL | bar: Box<Bar>,
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - bar: Box<Bar>, LL | bar: Box<dyn Bar>,
LL + bar: Box<dyn Bar>, | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:18:1 --> $DIR/issue-61963.rs:18:1
@ -69,9 +65,8 @@ LL | pub struct Foo {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub struct Foo { LL | dyn pub struct Foo {
LL + dyn pub struct Foo { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:18:1 --> $DIR/issue-61963.rs:18:1
@ -83,9 +78,8 @@ LL | pub struct Foo {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub struct Foo { LL | dyn pub struct Foo {
LL + dyn pub struct Foo { | +++
|
error: trait objects without an explicit `dyn` are deprecated error: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-61963.rs:18:1 --> $DIR/issue-61963.rs:18:1
@ -97,9 +91,8 @@ LL | pub struct Foo {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - pub struct Foo { LL | dyn pub struct Foo {
LL + dyn pub struct Foo { | +++
|
error: aborting due to 7 previous errors error: aborting due to 7 previous errors

View file

@ -6,9 +6,8 @@ LL | impl LocalTraitTwo for LocalTraitOne {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl LocalTraitTwo for LocalTraitOne {} LL | impl LocalTraitTwo for dyn LocalTraitOne {}
LL + impl LocalTraitTwo for dyn LocalTraitOne {} | +++
|
help: alternatively use a blanket implementation to implement `LocalTraitTwo` for all types that also implement `LocalTraitOne` help: alternatively use a blanket implementation to implement `LocalTraitTwo` for all types that also implement `LocalTraitOne`
| |
LL | impl<T: LocalTraitOne> LocalTraitTwo for T {} LL | impl<T: LocalTraitOne> LocalTraitTwo for T {}
@ -22,9 +21,8 @@ LL | impl fmt::Display for LocalTraitOne {
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl fmt::Display for LocalTraitOne { LL | impl fmt::Display for dyn LocalTraitOne {
LL + impl fmt::Display for dyn LocalTraitOne { | +++
|
error[E0782]: trait objects must include the `dyn` keyword error[E0782]: trait objects must include the `dyn` keyword
--> $DIR/suggest-blanket-impl-local-trait.rs:26:23 --> $DIR/suggest-blanket-impl-local-trait.rs:26:23
@ -34,9 +32,8 @@ LL | impl fmt::Display for LocalTraitTwo + Send {
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl fmt::Display for LocalTraitTwo + Send { LL | impl fmt::Display for dyn LocalTraitTwo + Send {
LL + impl fmt::Display for dyn LocalTraitTwo + Send { | +++
|
error[E0782]: trait objects must include the `dyn` keyword error[E0782]: trait objects must include the `dyn` keyword
--> $DIR/suggest-blanket-impl-local-trait.rs:34:24 --> $DIR/suggest-blanket-impl-local-trait.rs:34:24
@ -46,9 +43,8 @@ LL | impl LocalTraitOne for fmt::Display {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl LocalTraitOne for fmt::Display {} LL | impl LocalTraitOne for dyn fmt::Display {}
LL + impl LocalTraitOne for dyn fmt::Display {} | +++
|
help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display` help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display`
| |
LL | impl<T: fmt::Display> LocalTraitOne for T {} LL | impl<T: fmt::Display> LocalTraitOne for T {}
@ -62,9 +58,8 @@ LL | impl LocalTraitOne for fmt::Display + Send {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl LocalTraitOne for fmt::Display + Send {} LL | impl LocalTraitOne for dyn fmt::Display + Send {}
LL + impl LocalTraitOne for dyn fmt::Display + Send {} | +++
|
help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display + Send` help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display + Send`
| |
LL | impl<T: fmt::Display + Send> LocalTraitOne for T {} LL | impl<T: fmt::Display + Send> LocalTraitOne for T {}
@ -78,9 +73,8 @@ LL | impl<E> GenericTrait<E> for LocalTraitOne {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl<E> GenericTrait<E> for LocalTraitOne {} LL | impl<E> GenericTrait<E> for dyn LocalTraitOne {}
LL + impl<E> GenericTrait<E> for dyn LocalTraitOne {} | +++
|
help: alternatively use a blanket implementation to implement `GenericTrait<E>` for all types that also implement `LocalTraitOne` help: alternatively use a blanket implementation to implement `GenericTrait<E>` for all types that also implement `LocalTraitOne`
| |
LL | impl<E, T: LocalTraitOne> GenericTrait<E> for T {} LL | impl<E, T: LocalTraitOne> GenericTrait<E> for T {}
@ -94,9 +88,8 @@ LL | impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {} LL | impl<T, E> GenericTraitTwo<E> for dyn GenericTrait<T> {}
LL + impl<T, E> GenericTraitTwo<E> for dyn GenericTrait<T> {} | +++
|
help: alternatively use a blanket implementation to implement `GenericTraitTwo<E>` for all types that also implement `GenericTrait<T>` help: alternatively use a blanket implementation to implement `GenericTraitTwo<E>` for all types that also implement `GenericTrait<T>`
| |
LL | impl<T, E, U: GenericTrait<T>> GenericTraitTwo<E> for U {} LL | impl<T, E, U: GenericTrait<T>> GenericTraitTwo<E> for U {}

View file

@ -39,9 +39,8 @@ LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
| |
help: add `dyn` keyword before this trait help: add `dyn` keyword before this trait
| |
LL - impl<'a, T> Struct<T> for Trait<'a, T> {} LL | impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
LL + impl<'a, T> Struct<T> for dyn Trait<'a, T> {} | +++
|
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -42,9 +42,8 @@ LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - impl<'a, T> Struct<T> for Trait<'a, T> {} LL | impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
LL + impl<'a, T> Struct<T> for dyn Trait<'a, T> {} | +++
|
error: aborting due to 3 previous errors; 1 warning emitted error: aborting due to 3 previous errors; 1 warning emitted

View file

@ -9,9 +9,8 @@ LL | fn foo(_x: Foo + Send) {
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn` help: use `dyn`
| |
LL - fn foo(_x: Foo + Send) { LL | fn foo(_x: dyn Foo + Send) {
LL + fn foo(_x: dyn Foo + Send) { | +++
|
error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time
--> $DIR/not-on-bare-trait.rs:7:8 --> $DIR/not-on-bare-trait.rs:7:8

View file

@ -2594,7 +2594,7 @@ impl<'test> TestCx<'test> {
} }
None None
} else { } else {
let sline = line.split("///").last().unwrap_or(""); let sline = line.rsplit("///").next().unwrap();
let line = sline.trim_start(); let line = sline.trim_start();
if line.starts_with("```") { if line.starts_with("```") {
if ignore { if ignore {