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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0b4289f
Variants::Single: do not use invalid VariantIdx for uninhabited enums
RalfJung Dec 1, 2024
8868d06
make no-variant types a dedicated Variants variant
RalfJung Dec 1, 2024
0f7b743
add comment explaining why ty_and_layout_field is not used
RalfJung Dec 2, 2024
b53a3b6
fix outdated comment
RalfJung Dec 7, 2024
7eb0d84
refactor: replace &PathBuf with &Path to enhance generality
Integral-Tech Dec 17, 2024
a676872
Clarify the match ergonomics 2024 migration lint's output
dianne Dec 16, 2024
70b8527
Correctly check the edition of subpatterns in the pattern migration 2…
dianne Dec 17, 2024
77e9051
Improve the pattern migration 2024 migration lint's message
dianne Dec 17, 2024
a105cd6
Use field init shorthand where possible
joshtriplett Dec 17, 2024
28c6d0b
Add the edition guide link from the match 2024 migration lint to the …
dianne Dec 17, 2024
0bf6e82
Change the lookahead in `MacroParser::new`.
nnethercote Dec 11, 2024
3575e79
Simplify `RefTokenTreeCursor::look_ahead`.
nnethercote Dec 11, 2024
809975c
Rename `RefTokenTreeCursor`.
nnethercote Dec 11, 2024
c82d586
Remove `Peekable<TokenStreamIter>` uses.
nnethercote Dec 11, 2024
fd83954
Factor out repeated code from `eat_dollar`.
nnethercote Dec 11, 2024
39305bf
Fix `x build --stage 1 std` when using cg_cranelift as the default ba…
jyn514 Dec 17, 2024
2903356
Overhaul `TokenTreeCursor`.
nnethercote Dec 10, 2024
4977640
Fix const conditions for RPITITs
compiler-errors Dec 5, 2024
8a85bdc
Remove a comment that shouldn't have been committed.
nnethercote Dec 18, 2024
895ed81
Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk
jieyouxu Dec 18, 2024
5c3829f
Rollup merge of #133926 - compiler-errors:const-conditions, r=lcnr
jieyouxu Dec 18, 2024
50ffc60
Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spast…
jieyouxu Dec 18, 2024
06081aa
Rollup merge of #134394 - dianne:clarify-pat-2024-migration, r=compil…
jieyouxu Dec 18, 2024
f0637ac
Rollup merge of #134420 - Integral-Tech:pathbuf-refactor, r=compiler-…
jieyouxu Dec 18, 2024
71744d3
Rollup merge of #134443 - joshtriplett:use-field-init-shorthand, r=lq…
jieyouxu Dec 18, 2024
3bcaddd
Rollup merge of #134444 - jyn514:cranelift-std, r=bjorn3
jieyouxu Dec 18, 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
Simplify RefTokenTreeCursor::look_ahead.
It's only ever used with a lookahead of 0, so this commit removes the
lookahead and renames it `peek`.
  • Loading branch information
nnethercote committed Dec 17, 2024
commit 3575e7943b4d4a47c30716c50884d4ceee1b7dcd
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ impl<'t> RefTokenTreeCursor<'t> {
RefTokenTreeCursor { stream, index: 0 }
}

pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
self.stream.0.get(self.index + n)
pub fn peek(&self) -> Option<&TokenTree> {
self.stream.0.get(self.index)
}
}

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl MetaVarExpr {
}
};
result.push(element);
if iter.look_ahead(0).is_none() {
if iter.peek().is_none() {
break;
}
if !try_eat_comma(&mut iter) {
Expand Down Expand Up @@ -166,7 +166,7 @@ fn parse_count<'psess>(
eat_dollar(iter, psess, span)?;
let ident = parse_ident(iter, psess, span)?;
let depth = if try_eat_comma(iter) {
if iter.look_ahead(0).is_none() {
if iter.peek().is_none() {
return Err(psess.dcx().struct_span_err(
span,
"`count` followed by a comma must have an associated index indicating its depth",
Expand Down Expand Up @@ -252,7 +252,7 @@ fn parse_token<'psess, 't>(
/// Tries to move the iterator forward returning `true` if there is a comma. If not, then the
/// iterator is not modified and the result is `false`.
fn try_eat_comma(iter: &mut RefTokenTreeCursor<'_>) -> bool {
if let Some(TokenTree::Token(Token { kind: token::Comma, .. }, _)) = iter.look_ahead(0) {
if let Some(TokenTree::Token(Token { kind: token::Comma, .. }, _)) = iter.peek() {
let _ = iter.next();
return true;
}
Expand All @@ -262,7 +262,7 @@ fn try_eat_comma(iter: &mut RefTokenTreeCursor<'_>) -> bool {
/// Tries to move the iterator forward returning `true` if there is a dollar sign. If not, then the
/// iterator is not modified and the result is `false`.
fn try_eat_dollar(iter: &mut RefTokenTreeCursor<'_>) -> bool {
if let Some(TokenTree::Token(Token { kind: token::Dollar, .. }, _)) = iter.look_ahead(0) {
if let Some(TokenTree::Token(Token { kind: token::Dollar, .. }, _)) = iter.peek() {
let _ = iter.next();
return true;
}
Expand All @@ -275,7 +275,7 @@ fn eat_dollar<'psess>(
psess: &'psess ParseSess,
span: Span,
) -> PResult<'psess, ()> {
if let Some(TokenTree::Token(Token { kind: token::Dollar, .. }, _)) = iter.look_ahead(0) {
if let Some(TokenTree::Token(Token { kind: token::Dollar, .. }, _)) = iter.peek() {
let _ = iter.next();
return Ok(());
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
while let Some(curr) = cursor.next() {
if !prev_is_dollar
&& let Some(span) = is_crate_keyword(curr)
&& let Some(next) = cursor.look_ahead(0)
&& let Some(next) = cursor.peek()
&& is_token(next, &TokenKind::PathSep)
{
return Some(span);
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustfmt/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ impl<'a> MacroParser<'a> {
// (`(` ... `)` `=>` `{` ... `}`)*
fn parse(&mut self) -> Option<Macro> {
let mut branches = vec![];
while self.toks.look_ahead(0).is_some() {
while self.toks.peek().is_some() {
branches.push(self.parse_branch()?);
}

Expand Down Expand Up @@ -1237,7 +1237,7 @@ impl<'a> MacroParser<'a> {
span,
},
_,
)) = self.toks.look_ahead(0)
)) = self.toks.peek()
{
hi = span.hi();
self.toks.next();
Expand Down