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
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ pub fn check_generic_arg_count_for_call(
IsMethodCall::Yes => GenericArgPosition::MethodCall,
IsMethodCall::No => GenericArgPosition::Value,
};
let has_self = generics.parent.is_none() && generics.has_self;
check_generic_arg_count(cx, def_id, seg, generics, gen_pos, has_self)
check_generic_arg_count(cx, def_id, seg, generics, gen_pos, generics.has_own_self())
}

/// Checks that the correct number of generic arguments have been provided.
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl<'tcx> Generics {
args: &'a [ty::GenericArg<'tcx>],
) -> &'a [ty::GenericArg<'tcx>] {
let mut own_params = self.parent_count..self.count();
if self.has_self && self.parent.is_none() {
if self.has_own_self() {
own_params.start = 1;
}

Expand Down Expand Up @@ -316,7 +316,7 @@ impl<'tcx> Generics {
args: &'tcx [ty::GenericArg<'tcx>],
) -> &'tcx [ty::GenericArg<'tcx>] {
let own = &args[self.parent_count..][..self.own_params.len()];
if self.has_self && self.parent.is_none() { &own[1..] } else { own }
if self.has_own_self() { &own[1..] } else { own }
}

/// Returns true if a concrete type is specified after a default type.
Expand Down Expand Up @@ -350,6 +350,10 @@ impl<'tcx> Generics {
pub fn is_own_empty(&'tcx self) -> bool {
self.own_params.is_empty()
}

pub fn has_own_self(&'tcx self) -> bool {
self.has_self && self.parent.is_none()
}
}

/// Bounds on generics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
.iter()
.position(|&arg| self.generic_arg_contains_target(arg))
{
if generics.parent.is_none() && generics.has_self {
if generics.has_own_self() {
argument_index += 1;
}
let args = self.tecx.resolve_vars_if_possible(args);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
// to align the arguments and parameters for the iteration below and to enable us to correctly
// instantiate the generic parameter default later.
let generics = cx.tcx.generics_of(owner);
let args = if !has_self && generics.parent.is_none() && generics.has_self {
let args = if !has_self && generics.has_own_self() {
has_self = true;
[cx.tcx.types.trait_object_dummy_self.into()]
.into_iter()
Expand Down
Loading