Skip to content

Conversation

sbillig
Copy link
Collaborator

@sbillig sbillig commented Aug 19, 2025

struct Foo<T = i32> {
  inner: T
}

trait Add<T: Self> {
  type Output = Self
  fn add(self, _ other: T) -> Self::Output
}

I also moved the type alias analysis into DefAnalyzer, where the other item definitions are analyzed. This fixes some missing type alias diagnostics.

@sbillig sbillig requested a review from Copilot August 19, 2025 22:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for generic parameter defaults in structs, traits, type aliases, and functions. It includes validation for proper syntax (defaults must be trailing, no forward references) and implements automatic completion of missing type arguments with defaults.

  • Adds parser support for = Type syntax in generic parameter lists
  • Implements default type substitution when resolving types with missing arguments
  • Moves type alias analysis into DefAnalyzer for consistent diagnostic handling

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/parser/src/parser/param.rs Adds parsing support for generic parameter defaults
crates/parser/src/ast/param.rs Adds default_ty() method to TypeGenericParam AST node
crates/hir/src/hir_def/params.rs Extends TypeGenericParam with default_ty field
crates/hir/src/lower/params.rs Updates HIR lowering to handle default types
crates/hir-analysis/src/ty/ty_lower.rs Implements default type completion logic
crates/hir-analysis/src/ty/def_analysis.rs Adds validation for default generic parameters
crates/hir-analysis/src/ty/diagnostics.rs Adds new diagnostic types for default generic validation
crates/hir-analysis/src/name_resolution/path_resolver.rs Updates type resolution to use defaults
Various test files Test cases for default generic functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@micahscopes micahscopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@micahscopes micahscopes merged commit 4330dd5 into argotorg:master Aug 25, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants