Skip to content

Commit 97fb5da

Browse files
bors[bot]matklad
andauthored
Merge #5592
5592: Rename TypeParamList -> GenericParamList r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents ee00679 + 28ef4c3 commit 97fb5da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+155
-154
lines changed

crates/ra_assists/src/handlers/generate_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl FunctionTemplate {
104104
struct FunctionBuilder {
105105
target: GeneratedFunctionTarget,
106106
fn_name: ast::Name,
107-
type_params: Option<ast::TypeParamList>,
107+
type_params: Option<ast::GenericParamList>,
108108
params: ast::ParamList,
109109
file: FileId,
110110
needs_pub: bool,
@@ -200,7 +200,7 @@ fn fn_args(
200200
ctx: &AssistContext,
201201
target_module: hir::Module,
202202
call: &ast::CallExpr,
203-
) -> Option<(Option<ast::TypeParamList>, ast::ParamList)> {
203+
) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
204204
let mut arg_names = Vec::new();
205205
let mut arg_types = Vec::new();
206206
for arg in call.arg_list()?.args() {

crates/ra_assists/src/handlers/generate_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner};
1+
use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
22
use stdx::{format_to, SepBy};
33

44
use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()
3131
format!("Generate impl for `{}`", name),
3232
target,
3333
|edit| {
34-
let type_params = nominal.type_param_list();
34+
let type_params = nominal.generic_param_list();
3535
let start_offset = nominal.syntax().text_range().end();
3636
let mut buf = String::new();
3737
buf.push_str("\n\nimpl");

crates/ra_assists/src/handlers/generate_new.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use hir::Adt;
22
use ra_syntax::{
33
ast::{
4-
self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner,
4+
self, AstNode, GenericParamsOwner, NameOwner, StructKind, TypeAscriptionOwner,
5+
VisibilityOwner,
56
},
67
T,
78
};
@@ -91,7 +92,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
9192
// Generates the surrounding `impl Type { <code> }` including type and lifetime
9293
// parameters
9394
fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
94-
let type_params = strukt.type_param_list();
95+
let type_params = strukt.generic_param_list();
9596
let mut buf = String::with_capacity(code.len());
9697
buf.push_str("\n\nimpl");
9798
if let Some(type_params) = &type_params {

crates/ra_assists/src/handlers/introduce_named_lifetime.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ra_syntax::{
2-
ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner},
2+
ast::{self, GenericParamsOwner, NameOwner, TypeAscriptionOwner},
33
AstNode, SyntaxKind, TextRange, TextSize,
44
};
55
use rustc_hash::FxHashSet;
@@ -54,7 +54,7 @@ fn generate_fn_def_assist(
5454
lifetime_loc: TextRange,
5555
) -> Option<()> {
5656
let param_list: ast::ParamList = fn_def.param_list()?;
57-
let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?;
57+
let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?;
5858
let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end();
5959
let self_param =
6060
// use the self if it's a reference and has no explicit lifetime
@@ -96,7 +96,7 @@ fn generate_impl_def_assist(
9696
impl_def: &ast::ImplDef,
9797
lifetime_loc: TextRange,
9898
) -> Option<()> {
99-
let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?;
99+
let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?;
100100
let end_of_impl_kw = impl_def.impl_token()?.text_range().end();
101101
acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| {
102102
add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param);
@@ -107,7 +107,7 @@ fn generate_impl_def_assist(
107107
/// Given a type parameter list, generate a unique lifetime parameter name
108108
/// which is not in the list
109109
fn generate_unique_lifetime_param_name(
110-
existing_type_param_list: &Option<ast::TypeParamList>,
110+
existing_type_param_list: &Option<ast::GenericParamList>,
111111
) -> Option<char> {
112112
match existing_type_param_list {
113113
Some(type_params) => {
@@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name(
123123

124124
/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise
125125
/// add new type params brackets with the lifetime parameter at `new_type_params_loc`.
126-
fn add_lifetime_param<TypeParamsOwner: ast::TypeParamsOwner>(
126+
fn add_lifetime_param<TypeParamsOwner: ast::GenericParamsOwner>(
127127
type_params_owner: &TypeParamsOwner,
128128
builder: &mut AssistBuilder,
129129
new_type_params_loc: TextSize,
130130
new_lifetime_param: char,
131131
) {
132-
match type_params_owner.type_param_list() {
132+
match type_params_owner.generic_param_list() {
133133
// add the new lifetime parameter to an existing type param list
134134
Some(type_params) => {
135135
builder.insert(

crates/ra_assists/src/handlers/move_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
2323
// }
2424
// ```
2525
pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26-
let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?;
26+
let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
2727

2828
let mut type_params = type_param_list.type_params();
2929
if type_params.all(|p| p.type_bound_list().is_none()) {

crates/ra_hir_def/src/generics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use hir_expand::{
1212
use ra_arena::{map::ArenaMap, Arena};
1313
use ra_db::FileId;
1414
use ra_prof::profile;
15-
use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
15+
use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
1616

1717
use crate::{
1818
body::LowerCtx,
@@ -205,9 +205,9 @@ impl GenericParams {
205205
&mut self,
206206
lower_ctx: &LowerCtx,
207207
sm: &mut SourceMap,
208-
node: &dyn TypeParamsOwner,
208+
node: &dyn GenericParamsOwner,
209209
) {
210-
if let Some(params) = node.type_param_list() {
210+
if let Some(params) = node.generic_param_list() {
211211
self.fill_params(lower_ctx, sm, params)
212212
}
213213
if let Some(where_clause) = node.where_clause() {
@@ -232,7 +232,7 @@ impl GenericParams {
232232
&mut self,
233233
lower_ctx: &LowerCtx,
234234
sm: &mut SourceMap,
235-
params: ast::TypeParamList,
235+
params: ast::GenericParamList,
236236
) {
237237
for type_param in params.type_params() {
238238
let name = type_param.name().map_or_else(Name::missing, |it| it.as_name());

crates/ra_hir_def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,10 @@ impl Ctx {
568568
fn lower_generic_params_and_inner_items(
569569
&mut self,
570570
owner: GenericsOwner<'_>,
571-
node: &impl ast::TypeParamsOwner,
571+
node: &impl ast::GenericParamsOwner,
572572
) -> GenericParamsId {
573573
// Generics are part of item headers and may contain inner items we need to collect.
574-
if let Some(params) = node.type_param_list() {
574+
if let Some(params) = node.generic_param_list() {
575575
self.collect_inner_items(params.syntax());
576576
}
577577
if let Some(clause) = node.where_clause() {
@@ -584,7 +584,7 @@ impl Ctx {
584584
fn lower_generic_params(
585585
&mut self,
586586
owner: GenericsOwner<'_>,
587-
node: &impl ast::TypeParamsOwner,
587+
node: &impl ast::GenericParamsOwner,
588588
) -> GenericParamsId {
589589
let mut sm = &mut ArenaMap::default();
590590
let mut generics = GenericParams::default();

crates/ra_hir_expand/src/builtin_derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use log::debug;
44

55
use ra_parser::FragmentKind;
66
use ra_syntax::{
7-
ast::{self, AstNode, ModuleItemOwner, NameOwner, TypeParamsOwner},
7+
ast::{self, AstNode, GenericParamsOwner, ModuleItemOwner, NameOwner},
88
match_ast,
99
};
1010

@@ -72,9 +72,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
7272
let node = item.syntax();
7373
let (name, params) = match_ast! {
7474
match node {
75-
ast::StructDef(it) => (it.name(), it.type_param_list()),
76-
ast::EnumDef(it) => (it.name(), it.type_param_list()),
77-
ast::UnionDef(it) => (it.name(), it.type_param_list()),
75+
ast::StructDef(it) => (it.name(), it.generic_param_list()),
76+
ast::EnumDef(it) => (it.name(), it.generic_param_list()),
77+
ast::UnionDef(it) => (it.name(), it.generic_param_list()),
7878
_ => {
7979
debug!("unexpected node is {:?}", node);
8080
return Err(mbe::ExpandError::ConversionError)

crates/ra_ide/src/display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod navigation_target;
55
mod short_label;
66

77
use ra_syntax::{
8-
ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner},
8+
ast::{self, AstNode, AttrsOwner, GenericParamsOwner, NameOwner},
99
SyntaxKind::{ATTR, COMMENT},
1010
};
1111

@@ -37,7 +37,7 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String {
3737
if let Some(name) = node.name() {
3838
format_to!(buf, "fn {}", name)
3939
}
40-
if let Some(type_params) = node.type_param_list() {
40+
if let Some(type_params) = node.generic_param_list() {
4141
format_to!(buf, "{}", type_params);
4242
}
4343
if let Some(param_list) = node.param_list() {

crates/ra_ide/src/extend_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn try_extend_selection(
4444
RECORD_FIELD_LIST,
4545
ENUM_VARIANT_LIST,
4646
USE_TREE_LIST,
47-
TYPE_PARAM_LIST,
47+
GENERIC_PARAM_LIST,
4848
TYPE_ARG_LIST,
4949
TYPE_BOUND_LIST,
5050
PARAM_LIST,

0 commit comments

Comments
 (0)