mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
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:
commit
5338f5f1d4
@ -24,7 +24,7 @@ pub use UnsafeSource::*;
|
||||
|
||||
use crate::ptr::P;
|
||||
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::stack::ensure_sufficient_stack;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
@ -91,7 +91,7 @@ pub struct Path {
|
||||
/// The segments in the path: the things separated by `::`.
|
||||
/// Global paths begin with `kw::PathRoot`.
|
||||
pub segments: Vec<PathSegment>,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
impl PartialEq<Symbol> for Path {
|
||||
@ -534,7 +534,7 @@ pub struct Block {
|
||||
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
|
||||
pub rules: BlockCheckMode,
|
||||
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.
|
||||
/// ```compile_fail
|
||||
/// let x = {
|
||||
@ -553,7 +553,7 @@ pub struct Pat {
|
||||
pub id: NodeId,
|
||||
pub kind: PatKind,
|
||||
pub span: Span,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
impl Pat {
|
||||
@ -937,8 +937,8 @@ impl Stmt {
|
||||
/// a trailing semicolon.
|
||||
///
|
||||
/// This only modifies the parsed AST struct, not the attached
|
||||
/// `LazyTokenStream`. The parser is responsible for calling
|
||||
/// `CreateTokenStream::add_trailing_semi` when there is actually
|
||||
/// `LazyAttrTokenStream`. The parser is responsible for calling
|
||||
/// `ToAttrTokenStream::add_trailing_semi` when there is actually
|
||||
/// a semicolon in the tokenstream.
|
||||
pub fn add_trailing_semicolon(mut self) -> Self {
|
||||
self.kind = match self.kind {
|
||||
@ -984,7 +984,7 @@ pub struct MacCallStmt {
|
||||
pub mac: P<MacCall>,
|
||||
pub style: MacStmtStyle,
|
||||
pub attrs: AttrVec,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)]
|
||||
@ -1009,7 +1009,7 @@ pub struct Local {
|
||||
pub kind: LocalKind,
|
||||
pub span: Span,
|
||||
pub attrs: AttrVec,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
@ -1108,7 +1108,7 @@ pub struct Expr {
|
||||
pub kind: ExprKind,
|
||||
pub span: Span,
|
||||
pub attrs: AttrVec,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
impl Expr {
|
||||
@ -1967,7 +1967,7 @@ pub struct Ty {
|
||||
pub id: NodeId,
|
||||
pub kind: TyKind,
|
||||
pub span: Span,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
impl Clone for Ty {
|
||||
@ -2532,7 +2532,7 @@ impl<D: Decoder> Decodable<D> for AttrId {
|
||||
pub struct AttrItem {
|
||||
pub path: Path,
|
||||
pub args: MacArgs,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
/// A list of attributes.
|
||||
@ -2552,7 +2552,7 @@ pub struct Attribute {
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct NormalAttr {
|
||||
pub item: AttrItem,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
@ -2603,7 +2603,7 @@ impl PolyTraitRef {
|
||||
pub struct Visibility {
|
||||
pub kind: VisibilityKind,
|
||||
pub span: Span,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
#[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
|
||||
/// include inner attributes.
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
pub tokens: Option<LazyAttrTokenStream>,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use crate::ptr::P;
|
||||
use crate::token::Nonterminal;
|
||||
use crate::tokenstream::LazyTokenStream;
|
||||
use crate::tokenstream::LazyAttrTokenStream;
|
||||
use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
|
||||
use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
|
||||
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.
|
||||
pub trait HasTokens {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream>;
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>>;
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream>;
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>>;
|
||||
}
|
||||
|
||||
macro_rules! impl_has_tokens {
|
||||
($($T:ty),+ $(,)?) => {
|
||||
$(
|
||||
impl HasTokens for $T {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -147,10 +147,10 @@ macro_rules! impl_has_tokens_none {
|
||||
($($T:ty),+ $(,)?) => {
|
||||
$(
|
||||
impl HasTokens for $T {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
None
|
||||
}
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
|
||||
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<T: AstDeref<Target: HasTokens>> HasTokens for T {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
impl HasTokens for StmtKind {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
match self {
|
||||
StmtKind::Local(local) => local.tokens.as_ref(),
|
||||
StmtKind::Item(item) => item.tokens(),
|
||||
@ -189,7 +189,7 @@ impl HasTokens for StmtKind {
|
||||
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 {
|
||||
StmtKind::Local(local) => Some(&mut local.tokens),
|
||||
StmtKind::Item(item) => item.tokens_mut(),
|
||||
@ -201,16 +201,16 @@ impl HasTokens for StmtKind {
|
||||
}
|
||||
|
||||
impl HasTokens for Stmt {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
impl HasTokens for Attribute {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
match &self.kind {
|
||||
AttrKind::Normal(normal) => normal.tokens.as_ref(),
|
||||
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 {
|
||||
AttrKind::Normal(normal) => &mut normal.tokens,
|
||||
kind @ AttrKind::DocComment(..) => {
|
||||
@ -229,7 +229,7 @@ impl HasTokens for Attribute {
|
||||
}
|
||||
|
||||
impl HasTokens for Nonterminal {
|
||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
match self {
|
||||
Nonterminal::NtItem(item) => item.tokens(),
|
||||
Nonterminal::NtStmt(stmt) => stmt.tokens(),
|
||||
@ -243,7 +243,7 @@ impl HasTokens for Nonterminal {
|
||||
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 {
|
||||
Nonterminal::NtItem(item) => item.tokens_mut(),
|
||||
Nonterminal::NtStmt(stmt) => stmt.tokens_mut(),
|
||||
|
@ -7,9 +7,8 @@ use crate::ast::{MacArgs, MacArgsEq, MacDelimiter, MetaItem, MetaItemKind, Neste
|
||||
use crate::ast::{Path, PathSegment};
|
||||
use crate::ptr::P;
|
||||
use crate::token::{self, CommentKind, Delimiter, Token};
|
||||
use crate::tokenstream::{AttrAnnotatedTokenStream, AttrAnnotatedTokenTree};
|
||||
use crate::tokenstream::{DelimSpan, Spacing, TokenTree};
|
||||
use crate::tokenstream::{LazyTokenStream, TokenStream};
|
||||
use crate::tokenstream::{LazyAttrTokenStream, TokenStream};
|
||||
use crate::util::comments;
|
||||
|
||||
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 {
|
||||
AttrKind::Normal(ref normal) => normal
|
||||
.tokens
|
||||
.as_ref()
|
||||
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
|
||||
.create_token_stream(),
|
||||
AttrKind::DocComment(comment_kind, data) => AttrAnnotatedTokenStream::from((
|
||||
AttrAnnotatedTokenTree::Token(Token::new(
|
||||
token::DocComment(comment_kind, self.style, data),
|
||||
self.span,
|
||||
)),
|
||||
.to_attr_token_stream()
|
||||
.to_tokenstream(),
|
||||
AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
|
||||
Token::new(token::DocComment(comment_kind, self.style, data), self.span),
|
||||
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(
|
||||
item: AttrItem,
|
||||
tokens: Option<LazyTokenStream>,
|
||||
tokens: Option<LazyAttrTokenStream>,
|
||||
style: AttrStyle,
|
||||
span: Span,
|
||||
) -> Attribute {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#![feature(if_let_guard)]
|
||||
#![cfg_attr(bootstrap, feature(label_break_value))]
|
||||
#![feature(let_chains)]
|
||||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(negative_impls)]
|
||||
#![feature(slice_internals)]
|
||||
|
@ -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`.
|
||||
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 {
|
||||
AttrAnnotatedTokenTree::Token(token) => {
|
||||
AttrTokenTree::Token(token, _) => {
|
||||
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(close);
|
||||
visit_attr_annotated_tts(tts, vis);
|
||||
visit_attr_tts(tts, vis);
|
||||
}
|
||||
AttrAnnotatedTokenTree::Attributes(data) => {
|
||||
AttrTokenTree::Attributes(data) => {
|
||||
for attr in &mut *data.attrs {
|
||||
match &mut attr.kind {
|
||||
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>(
|
||||
AttrAnnotatedTokenStream(tts): &mut AttrAnnotatedTokenStream,
|
||||
vis: &mut T,
|
||||
) {
|
||||
pub fn visit_attr_tts<T: MutVisitor>(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) {
|
||||
if T::VISIT_TOKENS && !tts.is_empty() {
|
||||
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 let Some(lazy_tts) = lazy_tts {
|
||||
let mut tts = lazy_tts.create_token_stream();
|
||||
visit_attr_annotated_tts(&mut tts, vis);
|
||||
*lazy_tts = LazyTokenStream::new(tts);
|
||||
let mut tts = lazy_tts.to_attr_token_stream();
|
||||
visit_attr_tts(&mut tts, vis);
|
||||
*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);
|
||||
}
|
||||
|
||||
|
@ -121,12 +121,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CreateTokenStream: sync::Send + sync::Sync {
|
||||
fn create_token_stream(&self) -> AttrAnnotatedTokenStream;
|
||||
pub trait ToAttrTokenStream: sync::Send + sync::Sync {
|
||||
fn to_attr_token_stream(&self) -> AttrTokenStream;
|
||||
}
|
||||
|
||||
impl CreateTokenStream for AttrAnnotatedTokenStream {
|
||||
fn create_token_stream(&self) -> AttrAnnotatedTokenStream {
|
||||
impl ToAttrTokenStream for AttrTokenStream {
|
||||
fn to_attr_token_stream(&self) -> AttrTokenStream {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
@ -135,68 +135,68 @@ impl CreateTokenStream for AttrAnnotatedTokenStream {
|
||||
/// of an actual `TokenStream` until it is needed.
|
||||
/// `Box` is here only to reduce the structure size.
|
||||
#[derive(Clone)]
|
||||
pub struct LazyTokenStream(Lrc<Box<dyn CreateTokenStream>>);
|
||||
pub struct LazyAttrTokenStream(Lrc<Box<dyn ToAttrTokenStream>>);
|
||||
|
||||
impl LazyTokenStream {
|
||||
pub fn new(inner: impl CreateTokenStream + 'static) -> LazyTokenStream {
|
||||
LazyTokenStream(Lrc::new(Box::new(inner)))
|
||||
impl LazyAttrTokenStream {
|
||||
pub fn new(inner: impl ToAttrTokenStream + 'static) -> LazyAttrTokenStream {
|
||||
LazyAttrTokenStream(Lrc::new(Box::new(inner)))
|
||||
}
|
||||
|
||||
pub fn create_token_stream(&self) -> AttrAnnotatedTokenStream {
|
||||
self.0.create_token_stream()
|
||||
pub fn to_attr_token_stream(&self) -> AttrTokenStream {
|
||||
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 {
|
||||
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) {
|
||||
// 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 {
|
||||
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) {
|
||||
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
|
||||
/// during expansion to perform early cfg-expansion, and to process attributes
|
||||
/// during proc-macro invocations.
|
||||
#[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)]
|
||||
pub enum AttrAnnotatedTokenTree {
|
||||
Token(Token),
|
||||
Delimited(DelimSpan, Delimiter, AttrAnnotatedTokenStream),
|
||||
pub enum AttrTokenTree {
|
||||
Token(Token, Spacing),
|
||||
Delimited(DelimSpan, Delimiter, AttrTokenStream),
|
||||
/// Stores the attributes for an attribute target,
|
||||
/// along with the tokens for that attribute target.
|
||||
/// See `AttributesData` for more information
|
||||
Attributes(AttributesData),
|
||||
}
|
||||
|
||||
impl AttrAnnotatedTokenStream {
|
||||
pub fn new(tokens: Vec<(AttrAnnotatedTokenTree, Spacing)>) -> AttrAnnotatedTokenStream {
|
||||
AttrAnnotatedTokenStream(Lrc::new(tokens))
|
||||
impl AttrTokenStream {
|
||||
pub fn new(tokens: Vec<AttrTokenTree>) -> AttrTokenStream {
|
||||
AttrTokenStream(Lrc::new(tokens))
|
||||
}
|
||||
|
||||
/// Converts this `AttrAnnotatedTokenStream` to a plain `TokenStream
|
||||
/// During conversion, `AttrAnnotatedTokenTree::Attributes` get 'flattened'
|
||||
/// Converts this `AttrTokenStream` to a plain `TokenStream`.
|
||||
/// During conversion, `AttrTokenTree::Attributes` get 'flattened'
|
||||
/// back to a `TokenStream` of the form `outer_attr attr_target`.
|
||||
/// If there are inner attributes, they are inserted into the proper
|
||||
/// place in the attribute target tokens.
|
||||
@ -204,31 +204,27 @@ impl AttrAnnotatedTokenStream {
|
||||
let trees: Vec<_> = self
|
||||
.0
|
||||
.iter()
|
||||
.flat_map(|tree| match &tree.0 {
|
||||
AttrAnnotatedTokenTree::Token(inner) => {
|
||||
smallvec![TokenTree::Token(inner.clone(), tree.1)].into_iter()
|
||||
.flat_map(|tree| match &tree {
|
||||
AttrTokenTree::Token(inner, spacing) => {
|
||||
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()),]
|
||||
.into_iter()
|
||||
}
|
||||
AttrAnnotatedTokenTree::Attributes(data) => {
|
||||
AttrTokenTree::Attributes(data) => {
|
||||
let mut outer_attrs = Vec::new();
|
||||
let mut inner_attrs = Vec::new();
|
||||
for attr in &data.attrs {
|
||||
match attr.style {
|
||||
crate::AttrStyle::Outer => {
|
||||
outer_attrs.push(attr);
|
||||
}
|
||||
crate::AttrStyle::Inner => {
|
||||
inner_attrs.push(attr);
|
||||
}
|
||||
crate::AttrStyle::Outer => outer_attrs.push(attr),
|
||||
crate::AttrStyle::Inner => inner_attrs.push(attr),
|
||||
}
|
||||
}
|
||||
|
||||
let mut target_tokens: Vec<_> = data
|
||||
.tokens
|
||||
.create_token_stream()
|
||||
.to_attr_token_stream()
|
||||
.to_tokenstream()
|
||||
.0
|
||||
.iter()
|
||||
@ -239,9 +235,9 @@ impl AttrAnnotatedTokenStream {
|
||||
// Check the last two trees (to account for a trailing semi)
|
||||
for tree in target_tokens.iter_mut().rev().take(2) {
|
||||
if let TokenTree::Delimited(span, delim, delim_tokens) = tree {
|
||||
// Inner attributes are only supported on extern blocks, functions, impls,
|
||||
// and modules. All of these have their inner attributes placed at
|
||||
// the beginning of the rightmost outermost braced group:
|
||||
// Inner attributes are only supported on extern blocks, functions,
|
||||
// impls, and modules. All of these have their inner attributes
|
||||
// placed at the beginning of the rightmost outermost braced group:
|
||||
// e.g. fn foo() { #![my_attr} }
|
||||
//
|
||||
// Therefore, we can insert them back into the right location
|
||||
@ -255,7 +251,7 @@ impl AttrAnnotatedTokenStream {
|
||||
|
||||
let mut builder = TokenStreamBuilder::new();
|
||||
for inner_attr in inner_attrs {
|
||||
builder.push(inner_attr.tokens().to_tokenstream());
|
||||
builder.push(inner_attr.tokens());
|
||||
}
|
||||
builder.push(delim_tokens.clone());
|
||||
*tree = TokenTree::Delimited(*span, *delim, builder.build());
|
||||
@ -273,7 +269,7 @@ impl AttrAnnotatedTokenStream {
|
||||
let mut flat: SmallVec<[_; 1]> = SmallVec::new();
|
||||
for attr in outer_attrs {
|
||||
// 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.into_iter()
|
||||
@ -300,7 +296,7 @@ pub struct AttributesData {
|
||||
pub attrs: AttrVec,
|
||||
/// The underlying tokens for the attribute target that `attrs`
|
||||
/// are applied to
|
||||
pub tokens: LazyTokenStream,
|
||||
pub tokens: LazyAttrTokenStream,
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
|
||||
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()))
|
||||
}
|
||||
|
||||
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.
|
||||
pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream {
|
||||
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 {
|
||||
TokenStream::opt_from_ast(node)
|
||||
.unwrap_or_else(|| panic!("missing tokens for node at {:?}: {:?}", node.span(), node))
|
||||
let Some(tokens) = node.tokens() else {
|
||||
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 {
|
||||
|
@ -86,8 +86,7 @@ impl LocationTable {
|
||||
let (block, &first_index) = self
|
||||
.statements_before_block
|
||||
.iter_enumerated()
|
||||
.filter(|(_, first_index)| **first_index <= point_index)
|
||||
.last()
|
||||
.rfind(|&(_, &first_index)| first_index <= point_index)
|
||||
.unwrap();
|
||||
|
||||
let statement_index = (point_index - first_index) / 2;
|
||||
|
@ -188,14 +188,14 @@ impl CfgEval<'_, '_> {
|
||||
let orig_tokens = annotatable.to_tokens().flattened();
|
||||
|
||||
// Re-parse the tokens, setting the `capture_cfg` flag to save extra information
|
||||
// to the captured `AttrAnnotatedTokenStream` (specifically, we capture
|
||||
// `AttrAnnotatedTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
|
||||
// to the captured `AttrTokenStream` (specifically, we capture
|
||||
// `AttrTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
|
||||
let mut parser =
|
||||
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
|
||||
parser.capture_cfg = true;
|
||||
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.
|
||||
flat_map_annotatable(self, annotatable)
|
||||
}
|
||||
|
@ -1704,7 +1704,7 @@ impl EmitterWriter {
|
||||
{
|
||||
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;
|
||||
|
||||
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_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...
|
||||
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
|
||||
// characters.
|
||||
let sub_len: usize = part
|
||||
.snippet
|
||||
.trim()
|
||||
.chars()
|
||||
.map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1))
|
||||
.sum();
|
||||
let sub_len: usize =
|
||||
if is_whitespace_addition { &part.snippet } else { part.snippet.trim() }
|
||||
.chars()
|
||||
.map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1))
|
||||
.sum();
|
||||
|
||||
let offset: isize = offsets
|
||||
.iter()
|
||||
@ -2130,7 +2137,7 @@ impl EmitterWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum DisplaySuggestion {
|
||||
Underline,
|
||||
Diff,
|
||||
|
@ -150,21 +150,20 @@ pub struct SubstitutionHighlight {
|
||||
|
||||
impl SubstitutionPart {
|
||||
pub fn is_addition(&self, sm: &SourceMap) -> bool {
|
||||
!self.snippet.is_empty()
|
||||
&& sm
|
||||
.span_to_snippet(self.span)
|
||||
.map_or(self.span.is_empty(), |snippet| snippet.trim().is_empty())
|
||||
!self.snippet.is_empty() && !self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
pub fn is_deletion(&self) -> bool {
|
||||
self.snippet.trim().is_empty()
|
||||
pub fn is_deletion(&self, sm: &SourceMap) -> bool {
|
||||
self.snippet.trim().is_empty() && self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
pub fn is_replacement(&self, sm: &SourceMap) -> bool {
|
||||
!self.snippet.is_empty()
|
||||
&& sm
|
||||
.span_to_snippet(self.span)
|
||||
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
|
||||
!self.snippet.is_empty() && self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
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::{LazyTokenStream, TokenTree};
|
||||
use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
|
||||
use rustc_ast::NodeId;
|
||||
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
|
||||
use rustc_attr as attr;
|
||||
@ -259,8 +259,8 @@ impl<'a> StripUnconfigured<'a> {
|
||||
fn try_configure_tokens<T: HasTokens>(&self, node: &mut T) {
|
||||
if self.config_tokens {
|
||||
if let Some(Some(tokens)) = node.tokens_mut() {
|
||||
let attr_annotated_tokens = tokens.create_token_stream();
|
||||
*tokens = LazyTokenStream::new(self.configure_tokens(&attr_annotated_tokens));
|
||||
let attr_stream = tokens.to_attr_token_stream();
|
||||
*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 }
|
||||
}
|
||||
|
||||
/// 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,
|
||||
/// which require that we cfg-expand their entire input.
|
||||
/// Normal cfg-expansion operates on parsed AST nodes via the `configure` method
|
||||
fn configure_tokens(&self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream {
|
||||
fn can_skip(stream: &AttrAnnotatedTokenStream) -> bool {
|
||||
stream.0.iter().all(|(tree, _spacing)| match tree {
|
||||
AttrAnnotatedTokenTree::Attributes(_) => false,
|
||||
AttrAnnotatedTokenTree::Token(_) => true,
|
||||
AttrAnnotatedTokenTree::Delimited(_, _, inner) => can_skip(inner),
|
||||
fn configure_tokens(&self, stream: &AttrTokenStream) -> AttrTokenStream {
|
||||
fn can_skip(stream: &AttrTokenStream) -> bool {
|
||||
stream.0.iter().all(|tree| match tree {
|
||||
AttrTokenTree::Attributes(_) => false,
|
||||
AttrTokenTree::Token(..) => true,
|
||||
AttrTokenTree::Delimited(_, _, inner) => can_skip(inner),
|
||||
})
|
||||
}
|
||||
|
||||
@ -290,36 +290,36 @@ impl<'a> StripUnconfigured<'a> {
|
||||
let trees: Vec<_> = stream
|
||||
.0
|
||||
.iter()
|
||||
.flat_map(|(tree, spacing)| match tree.clone() {
|
||||
AttrAnnotatedTokenTree::Attributes(mut data) => {
|
||||
.flat_map(|tree| match tree.clone() {
|
||||
AttrTokenTree::Attributes(mut data) => {
|
||||
data.attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
|
||||
|
||||
if self.in_cfg(&data.attrs) {
|
||||
data.tokens = LazyTokenStream::new(
|
||||
self.configure_tokens(&data.tokens.create_token_stream()),
|
||||
data.tokens = LazyAttrTokenStream::new(
|
||||
self.configure_tokens(&data.tokens.to_attr_token_stream()),
|
||||
);
|
||||
Some((AttrAnnotatedTokenTree::Attributes(data), *spacing)).into_iter()
|
||||
Some(AttrTokenTree::Attributes(data)).into_iter()
|
||||
} else {
|
||||
None.into_iter()
|
||||
}
|
||||
}
|
||||
AttrAnnotatedTokenTree::Delimited(sp, delim, mut inner) => {
|
||||
AttrTokenTree::Delimited(sp, delim, mut inner) => {
|
||||
inner = self.configure_tokens(&inner);
|
||||
Some((AttrAnnotatedTokenTree::Delimited(sp, delim, inner), *spacing))
|
||||
Some(AttrTokenTree::Delimited(sp, delim, inner))
|
||||
.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!(
|
||||
"Nonterminal should have been flattened at {:?}: {:?}",
|
||||
token.span, nt
|
||||
);
|
||||
}
|
||||
AttrAnnotatedTokenTree::Token(token) => {
|
||||
Some((AttrAnnotatedTokenTree::Token(token), *spacing)).into_iter()
|
||||
AttrTokenTree::Token(token, spacing) => {
|
||||
Some(AttrTokenTree::Token(token, spacing)).into_iter()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
AttrAnnotatedTokenStream::new(trees)
|
||||
AttrTokenStream::new(trees)
|
||||
}
|
||||
|
||||
/// Parse and expand all `cfg_attr` attributes into a list of attributes
|
||||
@ -388,7 +388,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
attr: &Attribute,
|
||||
(item, item_span): (ast::AttrItem, Span),
|
||||
) -> 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)]`
|
||||
// and producing an attribute of the form `#[attr]`. We
|
||||
@ -404,26 +404,26 @@ impl<'a> StripUnconfigured<'a> {
|
||||
};
|
||||
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 {
|
||||
// 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 {
|
||||
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 `[]`
|
||||
// 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),
|
||||
Delimiter::Bracket,
|
||||
item.tokens
|
||||
.as_ref()
|
||||
.unwrap_or_else(|| panic!("Missing tokens for {:?}", item))
|
||||
.create_token_stream(),
|
||||
.to_attr_token_stream(),
|
||||
);
|
||||
trees.push((bracket_group, Spacing::Alone));
|
||||
let tokens = Some(LazyTokenStream::new(AttrAnnotatedTokenStream::new(trees)));
|
||||
trees.push(bracket_group);
|
||||
let tokens = Some(LazyAttrTokenStream::new(AttrTokenStream::new(trees)));
|
||||
let attr = attr::mk_attr_from_item(item, tokens, attr.style, item_span);
|
||||
if attr.has_name(sym::crate_type) {
|
||||
self.sess.parse_sess.buffer_lint(
|
||||
|
@ -576,8 +576,7 @@ impl<'hir> Generics<'hir> {
|
||||
if self.has_where_clause_predicates {
|
||||
self.predicates
|
||||
.iter()
|
||||
.filter(|p| p.in_where_clause())
|
||||
.last()
|
||||
.rfind(|&p| p.in_where_clause())
|
||||
.map_or(end, |p| p.span())
|
||||
.shrink_to_hi()
|
||||
.to(end)
|
||||
|
@ -719,7 +719,7 @@ fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
|
||||
Some(match *ty.kind() {
|
||||
ty::Adt(field_def, field_substs) => {
|
||||
let inner_field_ty = {
|
||||
let first_non_zst_ty = field_def
|
||||
let mut first_non_zst_ty = field_def
|
||||
.variants()
|
||||
.iter()
|
||||
.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"
|
||||
);
|
||||
first_non_zst_ty
|
||||
.last()
|
||||
.next_back()
|
||||
.expect("No non-zst fields in transparent type.")
|
||||
.ty(tcx, field_substs)
|
||||
};
|
||||
|
@ -301,9 +301,9 @@ impl<'a> Parser<'a> {
|
||||
if let Some(attr) = attr {
|
||||
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 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
|
||||
// `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
|
||||
// token stream (the first inner attribute is removed each time we invoke the
|
||||
// corresponding macro).
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken};
|
||||
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{AttrAnnotatedTokenStream, AttributesData, CreateTokenStream};
|
||||
use rustc_ast::tokenstream::{AttrAnnotatedTokenTree, DelimSpan, LazyTokenStream, Spacing};
|
||||
use rustc_ast::tokenstream::{AttrTokenStream, AttributesData, ToAttrTokenStream};
|
||||
use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spacing};
|
||||
use rustc_ast::{self as ast};
|
||||
use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens};
|
||||
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
|
||||
// there is no intermediate collection buffer to clone.
|
||||
#[derive(Clone)]
|
||||
struct LazyTokenStreamImpl {
|
||||
struct LazyAttrTokenStreamImpl {
|
||||
start_token: (Token, Spacing),
|
||||
cursor_snapshot: TokenCursor,
|
||||
num_calls: usize,
|
||||
@ -97,10 +97,10 @@ struct LazyTokenStreamImpl {
|
||||
}
|
||||
|
||||
#[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 {
|
||||
fn create_token_stream(&self) -> AttrAnnotatedTokenStream {
|
||||
impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
|
||||
fn to_attr_token_stream(&self) -> AttrTokenStream {
|
||||
// The token produced by the final call to `{,inlined_}next` was not
|
||||
// actually consumed by the callback. The combination of chaining the
|
||||
// initial token and using `take` produces the desired result - we
|
||||
@ -179,7 +179,7 @@ impl CreateTokenStream for LazyTokenStreamImpl {
|
||||
impl<'a> Parser<'a> {
|
||||
/// Records all tokens consumed by the provided callback,
|
||||
/// 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.
|
||||
///
|
||||
/// 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),
|
||||
// then extend the range of captured tokens to include it, since the parser
|
||||
// was not actually bumped past it. When the `LazyTokenStream` gets converted
|
||||
// into an `AttrAnnotatedTokenStream`, we will create the proper token.
|
||||
// was not actually bumped past it. When the `LazyAttrTokenStream` gets converted
|
||||
// into an `AttrTokenStream`, we will create the proper token.
|
||||
if self.token_cursor.break_last_token {
|
||||
assert_eq!(
|
||||
trailing,
|
||||
@ -316,8 +316,8 @@ impl<'a> Parser<'a> {
|
||||
Box::new([])
|
||||
} else {
|
||||
// Grab any replace ranges that occur *inside* the current AST node.
|
||||
// We will perform the actual replacement when we convert the `LazyTokenStream`
|
||||
// to an `AttrAnnotatedTokenStream`
|
||||
// We will perform the actual replacement when we convert the `LazyAttrTokenStream`
|
||||
// to an `AttrTokenStream`.
|
||||
let start_calls: u32 = cursor_snapshot_next_calls.try_into().unwrap();
|
||||
self.capture_state.replace_ranges[replace_ranges_start..replace_ranges_end]
|
||||
.iter()
|
||||
@ -329,7 +329,7 @@ impl<'a> Parser<'a> {
|
||||
.collect()
|
||||
};
|
||||
|
||||
let tokens = LazyTokenStream::new(LazyTokenStreamImpl {
|
||||
let tokens = LazyAttrTokenStream::new(LazyAttrTokenStreamImpl {
|
||||
start_token,
|
||||
num_calls,
|
||||
cursor_snapshot,
|
||||
@ -392,12 +392,12 @@ impl<'a> Parser<'a> {
|
||||
fn make_token_stream(
|
||||
mut iter: impl Iterator<Item = (FlatToken, Spacing)>,
|
||||
break_last_token: bool,
|
||||
) -> AttrAnnotatedTokenStream {
|
||||
) -> AttrTokenStream {
|
||||
#[derive(Debug)]
|
||||
struct FrameData {
|
||||
// This is `None` for the first frame, `Some` for all others.
|
||||
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 token_and_spacing = iter.next();
|
||||
@ -418,48 +418,47 @@ fn make_token_stream(
|
||||
open_delim, span
|
||||
);
|
||||
let dspan = DelimSpan::from_pair(open_sp, span);
|
||||
let stream = AttrAnnotatedTokenStream::new(frame_data.inner);
|
||||
let delimited = AttrAnnotatedTokenTree::Delimited(dspan, delim, stream);
|
||||
let stream = AttrTokenStream::new(frame_data.inner);
|
||||
let delimited = AttrTokenTree::Delimited(dspan, delim, stream);
|
||||
stack
|
||||
.last_mut()
|
||||
.unwrap_or_else(|| {
|
||||
panic!("Bottom token frame is missing for token: {:?}", token)
|
||||
})
|
||||
.inner
|
||||
.push((delimited, Spacing::Alone));
|
||||
.push(delimited);
|
||||
}
|
||||
FlatToken::Token(token) => stack
|
||||
.last_mut()
|
||||
.expect("Bottom token frame is missing!")
|
||||
.inner
|
||||
.push((AttrAnnotatedTokenTree::Token(token), spacing)),
|
||||
.push(AttrTokenTree::Token(token, spacing)),
|
||||
FlatToken::AttrTarget(data) => stack
|
||||
.last_mut()
|
||||
.expect("Bottom token frame is missing!")
|
||||
.inner
|
||||
.push((AttrAnnotatedTokenTree::Attributes(data), spacing)),
|
||||
.push(AttrTokenTree::Attributes(data)),
|
||||
FlatToken::Empty => {}
|
||||
}
|
||||
token_and_spacing = iter.next();
|
||||
}
|
||||
let mut final_buf = stack.pop().expect("Missing final buf!");
|
||||
if break_last_token {
|
||||
let (last_token, spacing) = final_buf.inner.pop().unwrap();
|
||||
if let AttrAnnotatedTokenTree::Token(last_token) = last_token {
|
||||
let last_token = final_buf.inner.pop().unwrap();
|
||||
if let AttrTokenTree::Token(last_token, spacing) = last_token {
|
||||
let unglued_first = last_token.kind.break_two_token_op().unwrap().0;
|
||||
|
||||
// An 'unglued' token is always two ASCII characters
|
||||
let mut first_span = last_token.span.shrink_to_lo();
|
||||
first_span = first_span.with_hi(first_span.lo() + rustc_span::BytePos(1));
|
||||
|
||||
final_buf.inner.push((
|
||||
AttrAnnotatedTokenTree::Token(Token::new(unglued_first, first_span)),
|
||||
spacing,
|
||||
));
|
||||
final_buf
|
||||
.inner
|
||||
.push(AttrTokenTree::Token(Token::new(unglued_first, first_span), spacing));
|
||||
} else {
|
||||
panic!("Unexpected last token {:?}", last_token)
|
||||
}
|
||||
}
|
||||
assert!(stack.is_empty(), "Stack should be empty: final_buf={:?} stack={:?}", final_buf, stack);
|
||||
AttrAnnotatedTokenStream::new(final_buf.inner)
|
||||
AttrTokenStream::new(final_buf.inner)
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ pub struct ClosureSpans {
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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,
|
||||
/// 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)]
|
||||
pub enum Capturing {
|
||||
/// We aren't performing any capturing - this is the default mode.
|
||||
@ -237,7 +237,7 @@ struct TokenCursor {
|
||||
// the trailing `>>` token. The `break_last_token`
|
||||
// field is used to track this token - it gets
|
||||
// appended to the captured stream when
|
||||
// we evaluate a `LazyTokenStream`
|
||||
// we evaluate a `LazyAttrTokenStream`.
|
||||
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 `LazyTokenStream`. Both delimiter and non-delimited tokens
|
||||
/// A helper struct used when building an `AttrTokenStream` from
|
||||
/// a `LazyAttrTokenStream`. Both delimiter and non-delimited tokens
|
||||
/// are stored as `FlatToken::Token`. A vector of `FlatToken`s
|
||||
/// is then 'parsed' to build up an `AttrAnnotatedTokenStream` with nested
|
||||
/// `AttrAnnotatedTokenTree::Delimited` tokens
|
||||
/// is then 'parsed' to build up an `AttrTokenStream` with nested
|
||||
/// `AttrTokenTree::Delimited` tokens.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum FlatToken {
|
||||
/// A token - this holds both delimiter (e.g. '{' and '}')
|
||||
@ -1476,11 +1476,11 @@ pub enum FlatToken {
|
||||
Token(Token),
|
||||
/// Holds the `AttributesData` for an AST node. The
|
||||
/// `AttributesData` is inserted directly into the
|
||||
/// constructed `AttrAnnotatedTokenStream` as
|
||||
/// an `AttrAnnotatedTokenTree::Attributes`
|
||||
/// constructed `AttrTokenStream` as
|
||||
/// an `AttrTokenTree::Attributes`.
|
||||
AttrTarget(AttributesData),
|
||||
/// 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.
|
||||
Empty,
|
||||
}
|
||||
|
@ -617,9 +617,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||
.filter(|&sp| sp != base_error.span)
|
||||
.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><)
|
||||
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)
|
||||
let last_bound_span = spans.last().cloned().unwrap();
|
||||
let mut multi_span: MultiSpan = spans.clone().into();
|
||||
|
@ -1309,10 +1309,8 @@ pub fn build_session(
|
||||
let warnings_allow = sopts
|
||||
.lint_opts
|
||||
.iter()
|
||||
.filter(|&&(ref key, _)| *key == "warnings")
|
||||
.map(|&(_, ref level)| *level == lint::Allow)
|
||||
.last()
|
||||
.unwrap_or(false);
|
||||
.rfind(|&&(ref key, _)| *key == "warnings")
|
||||
.map_or(false, |&(_, level)| level == 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);
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ pub(crate) mod builtin {
|
||||
/// Concatenates literals into a byte slice.
|
||||
///
|
||||
/// 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:
|
||||
///
|
||||
/// - byte literals (`b'r'`)
|
||||
|
@ -587,7 +587,7 @@ fn generate_macro_def_id_path(
|
||||
}
|
||||
})
|
||||
.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);
|
||||
// We need this to prevent a `panic` when this function is used from intra doc links...
|
||||
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 {
|
||||
once(crate_name.clone()).chain(relative).collect()
|
||||
} else {
|
||||
vec![crate_name.clone(), relative.last().unwrap()]
|
||||
vec![crate_name.clone(), relative.next_back().unwrap()]
|
||||
};
|
||||
if path.len() < 2 {
|
||||
// The minimum we can have is the crate name followed by the macro name. If shorter, then
|
||||
|
@ -206,7 +206,6 @@ a.source,
|
||||
.item-left > a,
|
||||
.out-of-band,
|
||||
span.since,
|
||||
#source-sidebar, #sidebar-toggle,
|
||||
details.rustdoc-toggle > summary::before,
|
||||
.content ul.crate a.crate,
|
||||
a.srclink,
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -6,9 +6,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
|
|
||||
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
|
||||
--> $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
|
||||
|
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
|
||||
|
@ -6,9 +6,8 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
|
||||
|
|
||||
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
|
||||
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13
|
||||
|
@ -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>
|
||||
help: use `dyn`
|
||||
|
|
||||
LL - eq::<dyn, Foo>
|
||||
LL + eq::<dyn, dyn Foo>
|
||||
|
|
||||
LL | eq::<dyn, dyn Foo>
|
||||
| +++
|
||||
|
||||
error[E0107]: missing generics for trait `Foo`
|
||||
--> $DIR/issue-86756.rs:5:15
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -8,9 +8,8 @@ help: use `+= 1` instead
|
||||
|
|
||||
LL | { let tmp = i; i += 1; tmp };
|
||||
| +++++++++++ ~~~~~~~~~~~~~~~
|
||||
LL - i++;
|
||||
LL + i += 1;
|
||||
|
|
||||
LL | i += 1;
|
||||
| ~~~~
|
||||
|
||||
error: Rust has no postfix increment operator
|
||||
--> $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 i++ < 5 {
|
||||
LL + while i += 1 < 5 {
|
||||
|
|
||||
LL | while i += 1 < 5 {
|
||||
| ~~~~
|
||||
|
||||
error: Rust has no postfix increment operator
|
||||
--> $DIR/increment-notfixed.rs:25:8
|
||||
@ -38,9 +36,8 @@ help: use `+= 1` instead
|
||||
|
|
||||
LL | { let tmp_ = tmp; tmp += 1; tmp_ };
|
||||
| ++++++++++++ ~~~~~~~~~~~~~~~~~~
|
||||
LL - tmp++;
|
||||
LL + tmp += 1;
|
||||
|
|
||||
LL | tmp += 1;
|
||||
| ~~~~
|
||||
|
||||
error: Rust has no postfix increment operator
|
||||
--> $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 tmp++ < 5 {
|
||||
LL + while tmp += 1 < 5 {
|
||||
|
|
||||
LL | while tmp += 1 < 5 {
|
||||
| ~~~~
|
||||
|
||||
error: Rust has no postfix increment operator
|
||||
--> $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 - foo.bar.qux++;
|
||||
LL + foo.bar.qux += 1;
|
||||
|
|
||||
LL | foo.bar.qux += 1;
|
||||
| ~~~~
|
||||
|
||||
error: Rust has no postfix increment operator
|
||||
--> $DIR/increment-notfixed.rs:49:10
|
||||
@ -82,9 +77,8 @@ help: use `+= 1` instead
|
||||
|
|
||||
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
|
||||
--> $DIR/increment-notfixed.rs:56:5
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $DIR/trait-object-trait-parens.rs:18:36
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
|
||||
|
@ -7,9 +7,8 @@ LL | demo3!(foo#bar);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo3!(foo#bar);
|
||||
LL + demo3!(foo #bar);
|
||||
|
|
||||
LL | demo3!(foo #bar);
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:17:12
|
||||
@ -20,9 +19,8 @@ LL | demo2!(foo"bar");
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo2!(foo"bar");
|
||||
LL + demo2!(foo "bar");
|
||||
|
|
||||
LL | demo2!(foo "bar");
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:18:12
|
||||
@ -33,9 +31,8 @@ LL | demo2!(foo'b');
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo2!(foo'b');
|
||||
LL + demo2!(foo 'b');
|
||||
|
|
||||
LL | demo2!(foo 'b');
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:20:12
|
||||
@ -46,9 +43,8 @@ LL | demo2!(foo'b);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo2!(foo'b);
|
||||
LL + demo2!(foo 'b);
|
||||
|
|
||||
LL | demo2!(foo 'b);
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:21:12
|
||||
@ -59,9 +55,8 @@ LL | demo3!(foo# bar);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo3!(foo# bar);
|
||||
LL + demo3!(foo # bar);
|
||||
|
|
||||
LL | demo3!(foo # bar);
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:22:12
|
||||
@ -72,9 +67,8 @@ LL | demo4!(foo#! bar);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo4!(foo#! bar);
|
||||
LL + demo4!(foo #! bar);
|
||||
|
|
||||
LL | demo4!(foo #! bar);
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:23:12
|
||||
@ -85,9 +79,8 @@ LL | demo4!(foo## bar);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo4!(foo## bar);
|
||||
LL + demo4!(foo ## bar);
|
||||
|
|
||||
LL | demo4!(foo ## bar);
|
||||
| +
|
||||
|
||||
error: prefix `foo` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:25:12
|
||||
@ -98,9 +91,8 @@ LL | demo4!(foo#bar#);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo4!(foo#bar#);
|
||||
LL + demo4!(foo #bar#);
|
||||
|
|
||||
LL | demo4!(foo #bar#);
|
||||
| +
|
||||
|
||||
error: prefix `bar` is unknown
|
||||
--> $DIR/reserved-prefixes.rs:25:16
|
||||
@ -111,9 +103,8 @@ LL | demo4!(foo#bar#);
|
||||
= note: prefixed identifiers and literals are reserved since Rust 2021
|
||||
help: consider inserting whitespace here
|
||||
|
|
||||
LL - demo4!(foo#bar#);
|
||||
LL + demo4!(foo#bar #);
|
||||
|
|
||||
LL | demo4!(foo#bar #);
|
||||
| +
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
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
|
||||
--> $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>
|
||||
help: use `dyn`
|
||||
|
|
||||
LL - pub struct Foo {
|
||||
LL + dyn pub struct Foo {
|
||||
|
|
||||
LL | dyn pub struct Foo {
|
||||
| +++
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
@ -6,9 +6,8 @@ LL | impl LocalTraitTwo for LocalTraitOne {}
|
||||
|
|
||||
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`
|
||||
|
|
||||
LL | impl<T: LocalTraitOne> LocalTraitTwo for T {}
|
||||
@ -22,9 +21,8 @@ LL | impl fmt::Display for LocalTraitOne {
|
||||
|
|
||||
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
|
||||
--> $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
|
||||
|
|
||||
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
|
||||
--> $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
|
||||
|
|
||||
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`
|
||||
|
|
||||
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
|
||||
|
|
||||
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`
|
||||
|
|
||||
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
|
||||
|
|
||||
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`
|
||||
|
|
||||
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
|
||||
|
|
||||
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>`
|
||||
|
|
||||
LL | impl<T, E, U: GenericTrait<T>> GenericTraitTwo<E> for U {}
|
||||
|
@ -39,9 +39,8 @@ LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
|
||||
|
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
|
||||
|
@ -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>
|
||||
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
|
||||
--> $DIR/not-on-bare-trait.rs:7:8
|
||||
|
@ -2594,7 +2594,7 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
None
|
||||
} else {
|
||||
let sline = line.split("///").last().unwrap_or("");
|
||||
let sline = line.rsplit("///").next().unwrap();
|
||||
let line = sline.trim_start();
|
||||
if line.starts_with("```") {
|
||||
if ignore {
|
||||
|
Loading…
Reference in New Issue
Block a user