diff options
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index fdc9b5ed..4dd52036 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2082,8 +2082,7 @@ impl CodeGenerator for CompInfo { attributes.push(attributes::derives(&derives)) } - if item.annotations().must_use_type() || ctx.must_use_type_by_name(item) - { + if item.must_use(ctx) { attributes.push(attributes::must_use()); } @@ -3054,8 +3053,7 @@ impl CodeGenerator for Enum { attrs.push(attributes::doc(comment)); } - if item.annotations().must_use_type() || ctx.must_use_type_by_name(item) - { + if item.must_use(ctx) { attrs.push(attributes::must_use()); } @@ -3967,26 +3965,12 @@ impl CodeGenerator for Function { if ctx.options().rust_features().must_use_function { let must_use = signature.must_use() || { - let ret_ty = signature.return_type(); - - let resolved_ret = ret_ty + let ret_ty = signature + .return_type() .into_resolver() .through_type_refs() - .through_type_aliases() .resolve(ctx); - - let must_use_resolved_ty = - resolved_ret.annotations().must_use_type() || - ctx.must_use_type_by_name(resolved_ret); - - let ret = ctx.resolve_item(ret_ty); - let must_use_ty = ret.annotations().must_use_type() || - ctx.must_use_type_by_name(ret); - - // If the return type already has #[must_use], the function does not - // need the annotation. This preserves the codegen behavior before - // type aliases with #[must_use] were supported. - !must_use_resolved_ty && must_use_ty + ret_ty.must_use(ctx) }; if must_use { |