-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Complete diagnostics in ty lowering groundwork and serve a first diagnostic 🎉 #18541
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| //! A desugared representation of paths like `crate::foo` or `<Type as Trait>::bar`. | ||
| mod lower; | ||
| #[cfg(test)] | ||
| mod tests; | ||
|
|
||
| use std::{ | ||
| fmt::{self, Display}, | ||
|
|
@@ -19,6 +21,8 @@ use syntax::ast; | |
|
|
||
| pub use hir_expand::mod_path::{path, ModPath, PathKind}; | ||
|
|
||
| pub use lower::hir_segment_to_ast_segment; | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum ImportAlias { | ||
| /// Unnamed alias, as in `use Foo as _;` | ||
|
|
@@ -230,7 +234,7 @@ impl Path { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
| pub struct PathSegment<'a> { | ||
| pub name: &'a Name, | ||
| pub args_and_bindings: Option<&'a GenericArgs>, | ||
|
|
@@ -274,6 +278,12 @@ impl<'a> PathSegments<'a> { | |
| generic_args: self.generic_args.map(|it| it.get(..len).unwrap_or(it)), | ||
| } | ||
| } | ||
| pub fn strip_last(&self) -> PathSegments<'a> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was wondering what this kind of function is usually called, given everything but the |
||
| PathSegments { | ||
| segments: self.segments.split_last().map_or(&[], |it| it.1), | ||
| generic_args: self.generic_args.map(|it| it.split_last().map_or(&[][..], |it| it.1)), | ||
| } | ||
| } | ||
| pub fn iter(&self) -> impl Iterator<Item = PathSegment<'a>> { | ||
| self.segments | ||
| .iter() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could shrink it by another 8 bytes now if we made these wide boxes thin boxes, something to keep in mind