8000 Rollup of 13 pull requests by tmandry · Pull Request #65548 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 13 pull requests #65548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f04ea6c
Document JSON message output.
ehuss Sep 30, 2019
3b0fd82
Disable Go and OCaml bindings when building LLVM
tmiasko Oct 8, 2019
77f0aaf
Add more coherence tests
weiznich Oct 12, 2019
70b136d
Use a `BitSet` in `LexicalResolver::iterate_until_fixed_point()`.
nnethercote Oct 15, 2019
d51fee0
Inline and remove `iterate_until_fixed_point()`.
nnethercote Oct 16, 2019
42c0236
Use a sharded dep node to dep node index map
Zoxc Jun 13, 2019
d1db077
Add long error explanation for E0575
GuillaumeGomez Oct 12, 2019
21d9258
Update ui tests
GuillaumeGomez Oct 12, 2019
83e97c6
properly document panics in div_euclid and rem_euclid
tspiteri Oct 17, 2019
4cd9276
Add long error explanation for E0584
GuillaumeGomez Oct 17, 2019
f647c06
Update ui tests
GuillaumeGomez Oct 17, 2019
71b0049
Plugins deprecation: don’t suggest simply removing the attribute
SimonSapin Oct 17, 2019
a4d9492
add option to ping llvm ice-breakers to triagebot
nikomatsakis Oct 17, 2019
4e6efe4
reorder fmt docs for more clarity
RalfJung Oct 17, 2019
5487994
Update triagebot.toml
nikomatsakis Oct 17, 2019
c0b7e76
example for padding any format
RalfJung Oct 17, 2019
db94656
Update backtrace to 0.3.40
tmandry Oct 17, 2019
d0eaf60
Remove two no-op `into()` calls.
nnethercote Oct 15, 2019
a6eef29
Make `TokenStream::from_iter` less general and more efficient.
nnethercote Oct 13, 2019
212ae58
Change `Lit::tokens()` to `Lit::token_tree()`.
nnethercote Oct 14, 2019
e4ec4a6
Change `MetaItem::tokens()` to `MetaItem::token_trees_and_joints()`.
nnethercote Oct 14, 2019
cb41fb6
Rollup merge of #64925 - ehuss:document-json, r=Mark-Simulacrum
tmandry Oct 18, 2019
d913212
Rollup merge of #65201 - tmiasko:no-bindings, r=rkruppe
tmandry Oct 18, 2019
a8ae1eb
Rollup merge of #65334 - GuillaumeGomez:long-err-explanation-E0575, r…
tmandry Oct 18, 2019
ce4349e
Rollup merge of #65417 - weiznich:more_coherence_tests, r=nikomatsakis
tmandry Oct 18, 2019
0a866a3
Rollup merge of #65455 - nnethercote:avoid-unnecessary-TokenTree-to-T…
tmandry Oct 18, 2019
7a49208
Rollup merge of #65472 - Zoxc:sharded-dep-graph-2, r=nikomatsakis
tmandry Oct 18, 2019
8cb6225
Rollup merge of #65480 - nnethercote:rm-iterate_until_fixed_size, r=n…
tmandry Oct 18, 2019
f1d4ce4
Rollup merge of #65493 - GuillaumeGomez:long-err-explanation-E0584, r…
tmandry Oct 18, 2019
0c6b6ad
Rollup merge of #65496 - tspiteri:euc-div-panic, r=KodrAus
tmandry Oct 18, 2019
570bc27
Rollup merge of #65498 - SimonSapin:plugin-help, r=Centril
tmandry Oct 18, 2019
8ccea93
Rollup merge of #65508 - rust-lang:llvm-icebreakers-ping-1, r=simulacrum
tmandry Oct 18, 2019
0e49753
Rollup merge of #65513 - RalfJung:fmt, r=Mark-Simulacrum
tmandry Oct 18, 2019
772a8d2
Rollup merge of #65531 - tmandry:bump-backtrace, r=cramertj
tmandry Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions src/libsyntax/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::ptr::P;
use crate::sess::ParseSess;
use crate::symbol::{sym, Symbol};
use crate::ThinVec;
use crate::tokenstream::{TokenStream, TokenTree, DelimSpan};
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
use crate::GLOBALS;

use log::debug;
Expand Down Expand Up @@ -463,7 +463,7 @@ pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: Symbol) -> Option
}

impl MetaItem {
fn tokens(&self) -> TokenStream {
fn token_trees_and_joints(&self) -> Vec<TreeAndJoint> {
let mut idents = vec![];
let mut last_pos = BytePos(0 as u32);
for (i, segment) in self.path.segments.iter().enumerate() {
Expand All @@ -477,8 +477,8 @@ impl MetaItem {
idents.push(TokenTree::Token(Token::from_ast_ident(segment.ident)).into());
last_pos = segment.ident.span.hi();
}
self.kind.tokens(self.span).append_to_tree_and_joint_vec(&mut idents);
TokenStream::new(idents)
idents.extend(self.kind.token_trees_and_joints(self.span));
idents
}

fn from_tokens<I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItem>
Expand Down Expand Up @@ -537,31 +537,41 @@ impl MetaItem {
}

impl MetaItemKind {
pub fn tokens(&self, span: Span) -> TokenStream {
pub fn token_trees_and_joints(&self, span: Span) -> Vec<TreeAndJoint> {
match *self {
MetaItemKind::Word => TokenStream::default(),
MetaItemKind::Word => vec![],
MetaItemKind::NameValue(ref lit) => {
let mut vec = vec![TokenTree::token(token::Eq, span).into()];
lit.tokens().append_to_tree_and_joint_vec(&mut vec);
TokenStream::new(vec)
vec![
TokenTree::token(token::Eq, span).into(),
lit.token_tree().into(),
]
}
MetaItemKind::List(ref list) => {
let mut tokens = Vec::new();
for (i, item) in list.iter().enumerate() {
if i > 0 {
tokens.push(TokenTree::token(token::Comma, span).into());
}
item.tokens().append_to_tree_and_joint_vec(&mut tokens);
tokens.extend(item.token_trees_and_joints())
}
TokenTree::Delimited(
DelimSpan::from_single(span),
token::Paren,
TokenStream::new(tokens).into(),
).into()
vec![
TokenTree::Delimited(
DelimSpan::from_single(span),
token::Paren,
TokenStream::new(tokens).into(),
).into()
]
}
}
}

// Premature conversions of `TokenTree`s to `TokenStream`s can hurt
// performance. Do not use this function if `token_trees_and_joints()` can
// be used instead.
pub fn tokens(&self, span: Span) -> TokenStream {
TokenStream::new(self.token_trees_and_joints(span))
}

fn from_tokens<I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItemKind>
where I: Iterator<Item = TokenTree>,
{
Expand Down Expand Up @@ -603,10 +613,10 @@ impl NestedMetaItem {
}
}

fn tokens(&self) -> TokenStream {
fn token_trees_and_joints(&self) -> Vec<TreeAndJoint> {
match *self {
NestedMetaItem::MetaItem(ref item) => item.tokens(),
NestedMetaItem::Literal(ref lit) => lit.tokens(),
NestedMetaItem::MetaItem(ref item) => item.token_trees_and_joints(),
NestedMetaItem::Literal(ref lit) => vec![lit.token_tree().into()],
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/parse/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::ast::{self, Lit, LitKind};
use crate::parse::token::{self, Token};
use crate::symbol::{kw, sym, Symbol};
use crate::tokenstream::{TokenStream, TokenTree};
use crate::tokenstream::TokenTree;

use log::debug;
use rustc_data_structures::sync::Lrc;
Expand Down Expand Up @@ -216,13 +216,13 @@ impl Lit {
Lit { token: kind.to_lit_token(), kind, span }
}

/// Losslessly convert an AST literal into a token stream.
crate fn tokens(&self) -> TokenStream {
/// Losslessly convert an AST literal into a token tree.
crate fn token_tree(&self) -> TokenTree {
let token = match self.token.kind {
token::Bool => token::Ident(self.token.symbol, false),
_ => token::Literal(self.token),
};
TokenTree::token(token, self.span).into()
TokenTree::token(token, self.span)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ impl TokenCursor {
token::NoDelim,
&if doc_comment_style(&name.as_str()) == AttrStyle::Inner {
[TokenTree::token(token::Pound, sp), TokenTree::token(token::Not, sp), body]
.iter().cloned().collect::<TokenStream>().into()
.iter().cloned().collect::<TokenStream>()
} else {
[TokenTree::token(token::Pound, sp), body]
.iter().cloned().collect::<TokenStream>().into()
.iter().cloned().collect::<TokenStream>()
},
)));

Expand Down
9 changes: 4 additions & 5 deletions src/libsyntax/parse/parser/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::tokenstream::{TokenStream, TokenTree};
use crate::source_map::Span;

use log::debug;
use smallvec::smallvec;

#[derive(Debug)]
enum InnerAttributeParsePolicy<'a> {
Expand Down Expand Up @@ -193,15 +192,15 @@ impl<'a> Parser<'a> {
is_interpolated_expr = true;
}
}
let tokens = if is_interpolated_expr {
let token_tree = if is_interpolated_expr {
// We need to accept arbitrary interpolated expressions to continue
// supporting things like `doc = $expr` that work on stable.
// Non-literal interpolated expressions are rejected after expansion.
self.parse_token_tree().into()
self.parse_token_tree()
} else {
self.parse_unsuffixed_lit()?.tokens()
self.parse_unsuffixed_lit()?.token_tree()
};
TokenStream::from_streams(smallvec![eq.into(), tokens])
TokenStream::new(vec![eq.into(), token_tree.into()])
} else {
TokenStream::default()
};
Expand Down
10 changes: 3 additions & 7 deletions src/libsyntax/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ impl From<TokenTree> for TreeAndJoint {
}
}

impl<T: Into<TokenStream>> iter::FromIterator<T> for TokenStream {
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
TokenStream::from_streams(iter.into_iter().map(Into::into).collect::<SmallVec<_>>())
impl iter::FromIterator<TokenTree> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
TokenStream::new(iter.into_iter().map(Into::into).collect::<Vec<TreeAndJoint>>())
}
}

Expand Down Expand Up @@ -271,10 +271,6 @@ impl TokenStream {
}
}

pub fn append_to_tree_and_joint_vec(self, vec: &mut Vec<TreeAndJoint>) {
vec.extend(self.0.iter().cloned());
}

pub fn trees(&self) -> Cursor {
self.clone().into_trees()
}
Expand Down
0