Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c54a2a5
Make mtime of reproducible tarball dependent on git commit
Kobzol Jun 27, 2024
e1999f9
Add support for mtime override to `generate` and `combine` rust-insta…
Kobzol Jun 29, 2024
61963fa
Avoid an ICE reachable through const eval shenanigans
oli-obk Jul 1, 2024
9d5da39
Revert some ICE avoiding logic that is not necessary anymore
oli-obk Jul 1, 2024
a5d3723
Prefer item-local tainting checks over global error count checks
oli-obk Jul 1, 2024
814bfe9
This check should now be unreachable
oli-obk Jul 1, 2024
1680b79
Simplify `CfgEval`.
nnethercote Jun 27, 2024
d6c0b81
Fix a typo in a comment.
nnethercote Jun 27, 2024
f852568
Change `AttrTokenStream::to_tokenstream` to `to_token_trees`.
nnethercote Jun 27, 2024
0cfd247
Rename `TokenStream::new` argument.
nnethercote Jun 27, 2024
7416c20
Just `push` in `AttrTokenStream::to_token_trees`.
nnethercote Jun 27, 2024
36c30a9
Fix comment.
nnethercote Jul 1, 2024
2342770
Flip an if/else in `AttrTokenStream::to_attr_token_stream`.
nnethercote Jul 1, 2024
8b5a7eb
Move things around in `collect_tokens_trailing_token`.
nnethercote Jul 1, 2024
f5b2896
Move more things around in `collect_tokens_trailing_token`.
nnethercote Jul 1, 2024
3d750e2
Shrink parser positions from `usize` to `u32`.
nnethercote Jul 2, 2024
6f60156
Rename `make_token_stream`.
nnethercote Jul 2, 2024
edeebe6
Import `std::{iter,mem}`.
nnethercote Jul 2, 2024
a21ba34
add TyCtxt::as_lang_item, use in new solver
compiler-errors Jun 30, 2024
5a83751
Make fn traits into first-class TraitSolverLangItems to avoid needing…
compiler-errors Jun 30, 2024
64a3bd8
Always preserve user-written comments in assembly
tgross35 Jun 21, 2024
c15a698
Rename the `asm-comments` compiler flag to `verbose-asm`
tgross35 Jun 21, 2024
1a6893e
Add documentation for -Zverbose-asm
tgross35 Jun 21, 2024
9e71c7b
Small `run-make-support` API improvements
GuillaumeGomez Jul 3, 2024
bcbcbff
bootstrap: pass correct struct size to winapi
klensy Jul 3, 2024
8b6435d
Add parse fail test using safe trait/impl trait
spastorino Jul 2, 2024
c74d620
Rollup merge of #126803 - tgross35:verbose-asm, r=Amanieu
matthiaskrgr Jul 3, 2024
444a0ff
Rollup merge of #127050 - Kobzol:reproducibility-git, r=onur-ozkan
matthiaskrgr Jul 3, 2024
02916a3
Rollup merge of #127145 - compiler-errors:as_lang_item, r=lcnr
matthiaskrgr Jul 3, 2024
9b05e7b
Rollup merge of #127202 - oli-obk:do_not_count_errors, r=wesleywiser
matthiaskrgr Jul 3, 2024
7fdb2f5
Rollup merge of #127233 - nnethercote:parser-cleanups, r=petrochenkov
matthiaskrgr Jul 3, 2024
ce991da
Rollup merge of #127248 - spastorino:unsafe-extern-tests, r=compiler-…
matthiaskrgr Jul 3, 2024
06fba4f
Rollup merge of #127264 - GuillaumeGomez:run-make-support-api-improve…
matthiaskrgr Jul 3, 2024
b212cd0
Rollup merge of #127270 - klensy:PROCESS_MEMORY_COUNTERS, r=Kobzol
matthiaskrgr Jul 3, 2024
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
Prev Previous commit
Next Next commit
Change AttrTokenStream::to_tokenstream to to_token_trees.
I.e. change the return type from `TokenStream` to `Vec<TokenTree>`.

Most of the callsites require a `TokenStream`, but the recursive call
used to create `target_tokens` requires a `Vec<TokenTree>`. It's easy
to convert a `Vec<TokenTree>` to a `TokenStream` (just call
`TokenStream::new`) but it's harder to convert a `TokenStream` to a
`Vec<TokenTree>` (either iterate/clone/collect, or use `Lrc::into_inner`
if appropriate).

So this commit changes the return value to simplify that `target_tokens`
call site.
  • Loading branch information
nnethercote committed Jul 2, 2024
commit f852568fa601171f20f924a50478c33fd2661fba
14 changes: 8 additions & 6 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ impl Attribute {

pub fn tokens(&self) -> TokenStream {
match &self.kind {
AttrKind::Normal(normal) => normal
.tokens
.as_ref()
.unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
.to_attr_token_stream()
.to_tokenstream(),
AttrKind::Normal(normal) => TokenStream::new(
normal
.tokens
.as_ref()
.unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
.to_attr_token_stream()
.to_token_trees(),
),
&AttrKind::DocComment(comment_kind, data) => TokenStream::token_alone(
token::DocComment(comment_kind, self.style, data),
self.span,
Expand Down
23 changes: 7 additions & 16 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ impl AttrTokenStream {
AttrTokenStream(Lrc::new(tokens))
}

/// Converts this `AttrTokenStream` to a plain `TokenStream`.
/// Converts this `AttrTokenStream` to a plain `Vec<TokenTree>`.
/// 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.
pub fn to_tokenstream(&self) -> TokenStream {
let trees: Vec<_> = self
.0
pub fn to_token_trees(&self) -> Vec<TokenTree> {
self.0
.iter()
.flat_map(|tree| match &tree {
AttrTokenTree::Token(inner, spacing) => {
Expand All @@ -198,7 +197,7 @@ impl AttrTokenStream {
*span,
*spacing,
*delim,
stream.to_tokenstream()
TokenStream::new(stream.to_token_trees())
),]
.into_iter()
}
Expand All @@ -208,14 +207,7 @@ impl AttrTokenStream {
.partition_point(|attr| matches!(attr.style, crate::AttrStyle::Outer));
let (outer_attrs, inner_attrs) = data.attrs.split_at(idx);

let mut target_tokens: Vec<_> = data
.tokens
.to_attr_token_stream()
.to_tokenstream()
.0
.iter()
.cloned()
.collect();
let mut target_tokens = data.tokens.to_attr_token_stream().to_token_trees();
if !inner_attrs.is_empty() {
let mut found = false;
// Check the last two trees (to account for a trailing semi)
Expand Down Expand Up @@ -260,8 +252,7 @@ impl AttrTokenStream {
flat.into_iter()
}
})
.collect();
TokenStream::new(trees)
.collect()
}
}

Expand Down Expand Up @@ -461,7 +452,7 @@ impl TokenStream {
AttributesData { attrs: attrs.iter().cloned().collect(), tokens: tokens.clone() };
AttrTokenStream::new(vec![AttrTokenTree::Attributes(attr_data)])
};
attr_stream.to_tokenstream()
TokenStream::new(attr_stream.to_token_trees())
}

pub fn from_nonterminal_ast(nt: &Nonterminal) -> TokenStream {
Expand Down