Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crates/hir/src/semantics/source_to_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//! The `GetDeclaredType` takes `Syntax` as input, and returns `Symbol` as
//! output. First, it retrieves a `Symbol` for parent `Syntax`:
//!
//! * https://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp/Compilation/SyntaxTreeSemanticModel.cs,1423
//! * <https://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp/Compilation/SyntaxTreeSemanticModel.cs,1423>
//!
//! Then, it iterates parent symbol's children, looking for one which has the
//! same text span as the original node:
Expand Down
3 changes: 1 addition & 2 deletions crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
//!
//! Splitting is implemented in the [`Constructor::split`] function. We don't do splitting for
//! or-patterns; instead we just try the alternatives one-by-one. For details on splitting
//! wildcards, see [`SplitWildcard`]; for integer ranges, see [`SplitIntRange`]; for slices, see
//! [`SplitVarLenSlice`].
//! wildcards, see [`SplitWildcard`]; for integer ranges, see [`SplitIntRange`].

use std::{
cmp::{max, min},
Expand Down
4 changes: 2 additions & 2 deletions crates/ide_db/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ pub fn visit_file_defs(
///
/// Note that, by default, rust-analyzer tests **do not** include core or std
/// libraries. If you are writing tests for functionality using [`FamousDefs`],
/// you'd want to include [minicore](test_utils::MiniCore) declaration at the
/// start of your tests:
/// you'd want to include minicore (see `test_utils::MiniCore`) declaration at
/// the start of your tests:
///
/// ```
/// //- minicore: iterator, ord, derive
Expand Down
6 changes: 3 additions & 3 deletions crates/parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! each submodule starts with `use super::*` import and exports
//! "public" productions via `pub(super)`.
//!
//! See docs for `Parser` to learn about API, available to the grammar,
//! and see docs for `Event` to learn how this actually manages to
//! produce parse trees.
//! See docs for [`Parser`](super::parser::Parser) to learn about API,
//! available to the grammar, and see docs for [`Event`](super::event::Event)
//! to learn how this actually manages to produce parse trees.
//!
//! Code in this module also contains inline tests, which start with
//! `// test name-of-the-test` comment and look like this:
Expand Down
18 changes: 15 additions & 3 deletions crates/parser/src/grammar/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,26 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
// match 92 {
// 0 ... 100 => (),
// 101 ..= 200 => (),
// 200 .. 301=> (),
// 200 .. 301 => (),
// 302 .. => (),
// }
// }

// FIXME: support half_open_range_patterns (`..=2`),
// exclusive_range_pattern (`..5`) with missing lhs
for &range_op in [T![...], T![..=], T![..]].iter() {
if p.at(range_op) {
let m = lhs.precede(p);
p.bump(range_op);
atom_pat(p, recovery_set);

// `0 .. =>` or `let 0 .. =`
// ^ ^
if p.at(T![=]) {
// test half_open_range_pat
// fn f() { let 0 .. = 1u32; }
} else {
atom_pat(p, recovery_set);
}
m.complete(p, RANGE_PAT);
return;
}
Expand All @@ -84,7 +96,7 @@ const PAT_RECOVERY_SET: TokenSet =
TokenSet::new(&[T![let], T![if], T![while], T![loop], T![match], T![')'], T![,], T![=]]);

fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
let m = match p.nth(0) {
let m = match p.current() {
T![box] => box_pat(p),
T![ref] | T![mut] => ident_pat(p, true),
T![const] => const_block_pat(p),
Expand Down
17 changes: 10 additions & 7 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
//! The Rust parser.
//!
//! The parser doesn't know about concrete representation of tokens and syntax
//! trees. Abstract `TokenSource` and `TreeSink` traits are used instead. As a
//! consequence, this crates does not contain a lexer.
//! trees. Abstract [`TokenSource`] and [`TreeSink`] traits are used instead.
//! As a consequence, this crate does not contain a lexer.
//!
//! The `Parser` struct from the `parser` module is a cursor into the sequence
//! of tokens. Parsing routines use `Parser` to inspect current state and
//! advance the parsing.
//! The [`Parser`] struct from the [`parser`] module is a cursor into the
//! sequence of tokens. Parsing routines use [`Parser`] to inspect current
//! state and advance the parsing.
//!
//! The actual parsing happens in the `grammar` module.
//! The actual parsing happens in the [`grammar`] module.
//!
//! Tests for this crate live in `syntax` crate.
//! Tests for this crate live in the `syntax` crate.
//!
//! [`Parser`]: crate::parser::Parser

#![allow(rustdoc::private_intra_doc_links)]
#[macro_use]
mod token_set;
#[macro_use]
Expand Down
7 changes: 4 additions & 3 deletions crates/parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
/// `Parser` struct provides the low-level API for
/// navigating through the stream of tokens and
/// constructing the parse tree. The actual parsing
/// happens in the `grammar` module.
/// happens in the [`grammar`](super::grammar) module.
///
/// However, the result of this `Parser` is not a real
/// tree, but rather a flat stream of events of the form
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'t> Parser<'t> {
}
}

/// See `Parser::start`.
/// See [`Parser::start`].
pub(crate) struct Marker {
pos: u32,
bomb: DropBomb,
Expand Down Expand Up @@ -320,7 +320,8 @@ impl CompletedMarker {
/// node `A`, then complete it, and then after parsing the
/// whole `A`, decide that it should have started some node
/// `B` before starting `A`. `precede` allows to do exactly
/// that. See also docs about `forward_parent` in `Event::Start`.
/// that. See also docs about
/// [`Event::Start::forward_parent`](crate::event::Event::Start::forward_parent).
///
/// Given completed events `[START, FINISH]` and its corresponding
/// `CompletedMarker(pos: 0, _)`.
Expand Down
4 changes: 2 additions & 2 deletions crates/syntax/src/ast/node_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ pub enum AttrKind {
}

impl AttrKind {
/// Returns `true` if the attr_kind is [`Inner`].
/// Returns `true` if the attr_kind is [`Inner`](Self::Inner).
pub fn is_inner(&self) -> bool {
matches!(self, Self::Inner)
}

/// Returns `true` if the attr_kind is [`Outer`].
/// Returns `true` if the attr_kind is [`Outer`](Self::Outer).
pub fn is_outer(&self) -> bool {
matches!(self, Self::Outer)
}
Expand Down
50 changes: 33 additions & 17 deletions crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOURCE_FILE@0..112
FN@0..111
SOURCE_FILE@0..135
FN@0..134
[email protected] "fn"
[email protected] " "
[email protected]
Expand All @@ -8,16 +8,16 @@ [email protected]
[email protected] "("
[email protected] ")"
[email protected] " "
BLOCK_EXPR@10..111
BLOCK_EXPR@10..134
[email protected] "{"
[email protected] "\n "
MATCH_EXPR@16..109
MATCH_EXPR@16..132
[email protected] "match"
[email protected] " "
[email protected]
[email protected] "92"
[email protected] " "
MATCH_ARM_LIST@25..109
MATCH_ARM_LIST@25..132
[email protected] "{"
[email protected] "\n "
[email protected]
Expand Down Expand Up @@ -58,7 +58,7 @@ [email protected]
[email protected] ")"
[email protected] ","
[email protected] "\n "
MATCH_ARM@87..103
MATCH_ARM@87..104
[email protected]
[email protected]
[email protected]
Expand All @@ -69,14 +69,30 @@ [email protected]
[email protected]
[email protected]
[email protected] "301"
[email protected] "=>"
[email protected] " "
[email protected]
[email protected] "("
[email protected] ")"
[email protected] ","
[email protected] "\n "
[email protected] "}"
[email protected] "\n"
[email protected] "}"
[email protected] "\n"
[email protected] " "
[email protected] "=>"
[email protected] " "
[email protected]
[email protected] "("
[email protected] ")"
[email protected] ","
[email protected] "\n "
[email protected]
[email protected]
[email protected]
[email protected]
[email protected] "302"
[email protected] " "
[email protected] ".."
[email protected] " "
[email protected] "=>"
[email protected] " "
[email protected]
[email protected] "("
[email protected] ")"
[email protected] ","
[email protected] "\n "
[email protected] "}"
[email protected] "\n"
[email protected] "}"
[email protected] "\n"
3 changes: 2 additions & 1 deletion crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fn main() {
match 92 {
0 ... 100 => (),
101 ..= 200 => (),
200 .. 301=> (),
200 .. 301 => (),
302 .. => (),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn f() { let 0 .. = 1u32; }