Skip to content

Commit 5f7b56b

Browse files
committed
Fix clippy warnings
1 parent 2009187 commit 5f7b56b

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

+216
-213
lines changed

binding-generator/src/class.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
236236
}
237237
}
238238

239-
pub fn bases(&self) -> Cow<[Class<'tu, 'ge>]> {
239+
pub fn bases(&self) -> Cow<'_, [Class<'tu, 'ge>]> {
240240
match self {
241241
&Self::Clang { entity, gen_env, .. } => {
242242
let mut out = vec![];
@@ -640,16 +640,16 @@ impl Element for Class<'_, '_> {
640640
}
641641
}
642642

643-
fn doc_comment(&self) -> Cow<str> {
643+
fn doc_comment(&self) -> Cow<'_, str> {
644644
match self {
645645
&Self::Clang { entity, .. } => strip_doxygen_comment_markers(&entity.get_comment().unwrap_or_default()).into(),
646646
Self::Desc(_) => "".into(),
647647
}
648648
}
649649

650-
fn cpp_namespace(&self) -> Cow<str> {
650+
fn cpp_namespace(&self) -> Cow<'_, str> {
651651
#[inline(always)]
652-
fn inner(cpp_fullname: &str) -> Cow<str> {
652+
fn inner(cpp_fullname: &str) -> Cow<'_, str> {
653653
cpp_fullname.namespace().into()
654654
}
655655

@@ -663,7 +663,7 @@ impl Element for Class<'_, '_> {
663663
}
664664
}
665665

666-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
666+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
667667
match self {
668668
Self::Clang {
669669
custom_fullname: Some(cpp_fullname),

binding-generator/src/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ impl Element for Const<'_> {
9898
DefaultElement::is_public(self.entity)
9999
}
100100

101-
fn doc_comment(&self) -> Cow<str> {
101+
fn doc_comment(&self) -> Cow<'_, str> {
102102
strip_doxygen_comment_markers(&self.entity.get_comment().unwrap_or_default()).into()
103103
}
104104

105-
fn cpp_namespace(&self) -> Cow<str> {
105+
fn cpp_namespace(&self) -> Cow<'_, str> {
106106
DefaultElement::cpp_namespace(self.entity).into()
107107
}
108108

109-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
109+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
110110
DefaultElement::cpp_name(self, self.entity(), style)
111111
}
112112
}

binding-generator/src/element.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ pub trait Element: fmt::Debug {
128128

129129
fn is_public(&self) -> bool;
130130

131-
fn doc_comment(&self) -> Cow<str>;
131+
fn doc_comment(&self) -> Cow<'_, str>;
132132

133-
fn cpp_namespace(&self) -> Cow<str>;
133+
fn cpp_namespace(&self) -> Cow<'_, str>;
134134

135-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str>;
135+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str>;
136136
}
137137

138138
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

binding-generator/src/entity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ impl Element for Entity<'_> {
2323
DefaultElement::is_public(self.entity())
2424
}
2525

26-
fn doc_comment(&self) -> Cow<str> {
26+
fn doc_comment(&self) -> Cow<'_, str> {
2727
strip_doxygen_comment_markers(&self.get_comment().unwrap_or_default()).into()
2828
}
2929

30-
fn cpp_namespace(&self) -> Cow<str> {
30+
fn cpp_namespace(&self) -> Cow<'_, str> {
3131
DefaultElement::cpp_namespace(self.entity()).into()
3232
}
3333

34-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
34+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
3535
DefaultElement::cpp_name(self, self.entity(), style)
3636
}
3737
}

binding-generator/src/enumeration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ impl Element for Enum<'_> {
8080
DefaultElement::is_public(self.entity)
8181
}
8282

83-
fn doc_comment(&self) -> Cow<str> {
83+
fn doc_comment(&self) -> Cow<'_, str> {
8484
strip_doxygen_comment_markers(&self.entity.get_comment().unwrap_or_default()).into()
8585
}
8686

87-
fn cpp_namespace(&self) -> Cow<str> {
87+
fn cpp_namespace(&self) -> Cow<'_, str> {
8888
if let Some(custom_fullname) = &self.custom_fullname {
8989
custom_fullname.namespace().into()
9090
} else {
9191
DefaultElement::cpp_namespace(self.entity).into()
9292
}
9393
}
9494

95-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
95+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
9696
if let Some(custom_fullname) = self.custom_fullname.as_deref() {
9797
custom_fullname.cpp_name_from_fullname(style).into()
9898
} else {

binding-generator/src/field.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tu, 'ge> Field<'tu, 'ge> {
8282
}
8383
}
8484

85-
pub fn type_ref(&self) -> Cow<TypeRef<'tu, 'ge>> {
85+
pub fn type_ref(&self) -> Cow<'_, TypeRef<'tu, 'ge>> {
8686
match self {
8787
Self::Clang {
8888
entity,
@@ -139,7 +139,7 @@ impl<'tu, 'ge> Field<'tu, 'ge> {
139139
}
140140
}
141141

142-
pub fn default_value(&self) -> Option<Cow<str>> {
142+
pub fn default_value(&self) -> Option<Cow<'_, str>> {
143143
match self {
144144
&Self::Clang { entity, .. } => {
145145
// fixme: clang-2.0.0 contains a bug that causes rust-1.78.0+ to panic when calling .tokenize()
@@ -246,21 +246,21 @@ impl Element for Field<'_, '_> {
246246
}
247247
}
248248

249-
fn doc_comment(&self) -> Cow<str> {
249+
fn doc_comment(&self) -> Cow<'_, str> {
250250
match self {
251251
Field::Clang { entity, .. } => strip_doxygen_comment_markers(&entity.get_comment().unwrap_or_default()).into(),
252252
Field::Desc(_) => "".into(),
253253
}
254254
}
255255

256-
fn cpp_namespace(&self) -> Cow<str> {
256+
fn cpp_namespace(&self) -> Cow<'_, str> {
257257
match self {
258258
&Self::Clang { entity, .. } => DefaultElement::cpp_namespace(entity).into(),
259259
Self::Desc(desc) => desc.cpp_fullname.namespace().into(),
260260
}
261261
}
262262

263-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
263+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
264264
match self {
265265
&Self::Clang { entity, .. } => DefaultElement::cpp_name(self, entity, style),
266266
Self::Desc(desc) => desc.cpp_fullname.cpp_name_from_fullname(style).into(),

binding-generator/src/func.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
271271
}
272272
}
273273

274-
pub fn kind(&self) -> Cow<FuncKind<'tu, 'ge>> {
274+
pub fn kind(&self) -> Cow<'_, FuncKind<'tu, 'ge>> {
275275
match self {
276276
&Self::Clang { entity, gen_env, .. } => {
277277
const OPERATOR: &str = "operator";
@@ -352,7 +352,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
352352

353353
/// Like [Self::doc_comment], but processes `@overload` and `@copybrief` directives if possible by copying the corresponding
354354
/// doccomment
355-
pub fn doc_comment_overloaded(&self) -> Cow<str> {
355+
pub fn doc_comment_overloaded(&self) -> Cow<'_, str> {
356356
let mut out = self.doc_comment();
357357
match self {
358358
Func::Clang { gen_env, .. } => {
@@ -443,7 +443,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
443443
}
444444
}
445445

446-
pub fn return_type_ref(&self) -> Cow<TypeRef<'tu, 'ge>> {
446+
pub fn return_type_ref(&self) -> Cow<'_, TypeRef<'tu, 'ge>> {
447447
match self {
448448
&Self::Clang { entity, gen_env, .. } => {
449449
let mut out = match self.kind().as_ref() {
@@ -515,7 +515,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
515515
}
516516
}
517517

518-
pub fn arguments(&self) -> Cow<[Field<'tu, 'ge>]> {
518+
pub fn arguments(&self) -> Cow<'_, [Field<'tu, 'ge>]> {
519519
match self {
520520
&Self::Clang { entity, gen_env, .. } => {
521521
let arg_overrides = gen_env.settings.arg_override.get(&mut self.matcher());
@@ -603,7 +603,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
603603
out
604604
}
605605

606-
pub fn matcher(&self) -> FuncMatchProperties {
606+
pub fn matcher(&self) -> FuncMatchProperties<'_> {
607607
FuncMatchProperties::new(self, self.cpp_name(CppNameStyle::Reference))
608608
}
609609

@@ -689,14 +689,14 @@ impl Element for Func<'_, '_> {
689689
}
690690
}
691691

692-
fn doc_comment(&self) -> Cow<str> {
692+
fn doc_comment(&self) -> Cow<'_, str> {
693693
match self {
694694
&Self::Clang { entity, .. } => strip_doxygen_comment_markers(&entity.get_comment().unwrap_or_default()).into(),
695695
Self::Desc(desc) => desc.doc_comment.as_ref().into(),
696696
}
697697
}
698698

699-
fn cpp_namespace(&self) -> Cow<str> {
699+
fn cpp_namespace(&self) -> Cow<'_, str> {
700700
match self {
701701
&Self::Clang { entity, .. } => DefaultElement::cpp_namespace(entity).into(),
702702
Self::Desc(desc) => self.kind().map_borrowed(|kind| match kind {
@@ -712,7 +712,7 @@ impl Element for Func<'_, '_> {
712712
}
713713
}
714714

715-
fn cpp_name(&self, style: CppNameStyle) -> Cow<str> {
715+
fn cpp_name(&self, style: CppNameStyle) -> Cow<'_, str> {
716716
let decl_name = match self {
717717
&Self::Clang { entity, gen_env, .. } => {
718718
if matches!(entity.get_kind(), EntityKind::ConversionFunction) {

binding-generator/src/func/func_matcher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'f> FuncMatchProperties<'f> {
4646
})
4747
}
4848

49-
pub fn arg_names(&mut self) -> &[Cow<str>] {
49+
pub fn arg_names(&mut self) -> &[Cow<'_, str>] {
5050
self
5151
.arg_names
5252
.get_or_insert_with(|| {
@@ -69,7 +69,7 @@ impl<'f> FuncMatchProperties<'f> {
6969
.as_slice()
7070
}
7171

72-
pub fn arg_types(&mut self) -> &[Cow<str>] {
72+
pub fn arg_types(&mut self) -> &[Cow<'_, str>] {
7373
self
7474
.arg_types
7575
.get_or_insert_with(|| match &self.func {
@@ -172,7 +172,7 @@ impl<'l, RES> FuncMatcher<'l, RES> {
172172
}
173173
}
174174

175-
pub fn finish_usage_tracking(&mut self) -> HashSet<UsageTracker> {
175+
pub fn finish_usage_tracking(&mut self) -> HashSet<UsageTracker<'_>> {
176176
if let Some(out) = self.usage_tracking.take() {
177177
if let Ok(usage_tracking) = out.into_inner() {
178178
if !usage_tracking.is_empty() {

binding-generator/src/function.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ impl Element for Function<'_, '_> {
4747
true
4848
}
4949

50-
fn doc_comment(&self) -> Cow<str> {
50+
fn doc_comment(&self) -> Cow<'_, str> {
5151
"".into()
5252
}
5353

54-
fn cpp_namespace(&self) -> Cow<str> {
54+
fn cpp_namespace(&self) -> Cow<'_, str> {
5555
"<unset>".into()
5656
}
5757

58-
fn cpp_name(&self, _style: CppNameStyle) -> Cow<str> {
58+
fn cpp_name(&self, _style: CppNameStyle) -> Cow<'_, str> {
5959
let args = self
6060
.arguments()
6161
.iter()

binding-generator/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl Settings {
163163
self.func_unsafe.start_usage_tracking();
164164
}
165165

166-
pub fn finish_usage_tracking(&mut self) -> HashMap<&'static str, HashSet<UsageTracker>> {
166+
pub fn finish_usage_tracking(&mut self) -> HashMap<&'static str, HashSet<UsageTracker<'_>>> {
167167
HashMap::from([
168168
("ARG_OVERRIDE", self.arg_override.finish_usage_tracking()),
169169
("RETURN_OVERRIDE", self.return_override.finish_usage_tracking()),

0 commit comments

Comments
 (0)