about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-07-26 10:04:02 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-03-11 12:05:02 +0000
commitcb044d4d7b6d4b9f944a648b38c790e6fadae9b8 (patch)
tree9069069734c9c8e6e674dcfb2c992fc56b1b2a00
parenteac092fb41d1949129deda31dc60b20b33b279b6 (diff)
downloadrust-cb044d4d7b6d4b9f944a648b38c790e6fadae9b8.tar.gz
rust-cb044d4d7b6d4b9f944a648b38c790e6fadae9b8.zip
Implement `#[define_opaque]` attribute for functions.
-rw-r--r--clippy_utils/src/ast_utils/mod.rs6
-rw-r--r--tests/ui/crashes/ice-10972-tait.rs10
-rw-r--r--tests/ui/implied_bounds_in_impls.fixed1
-rw-r--r--tests/ui/implied_bounds_in_impls.rs1
-rw-r--r--tests/ui/missing_const_for_fn/cant_be_const.rs1
-rw-r--r--tests/ui/new_ret_no_self_overflow.rs1
-rw-r--r--tests/ui/new_ret_no_self_overflow.stderr2
7 files changed, 11 insertions, 11 deletions
diff --git a/clippy_utils/src/ast_utils/mod.rs b/clippy_utils/src/ast_utils/mod.rs
index 4f024ecaf29..707312a97f3 100644
--- a/clippy_utils/src/ast_utils/mod.rs
+++ b/clippy_utils/src/ast_utils/mod.rs
@@ -364,6 +364,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
                 generics: lg,
                 contract: lc,
                 body: lb,
+                define_opaque: _,
             }),
             Fn(box ast::Fn {
                 defaultness: rd,
@@ -371,6 +372,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
                 generics: rg,
                 contract: rc,
                 body: rb,
+                define_opaque: _,
             }),
         ) => {
             eq_defaultness(*ld, *rd)
@@ -502,6 +504,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
                 generics: lg,
                 contract: lc,
                 body: lb,
+                define_opaque: _,
             }),
             Fn(box ast::Fn {
                 defaultness: rd,
@@ -509,6 +512,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
                 generics: rg,
                 contract: rc,
                 body: rb,
+                define_opaque: _,
             }),
         ) => {
             eq_defaultness(*ld, *rd)
@@ -567,6 +571,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
                 generics: lg,
                 contract: lc,
                 body: lb,
+                define_opaque: _,
             }),
             Fn(box ast::Fn {
                 defaultness: rd,
@@ -574,6 +579,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
                 generics: rg,
                 contract: rc,
                 body: rb,
+                define_opaque: _,
             }),
         ) => {
             eq_defaultness(*ld, *rd)
diff --git a/tests/ui/crashes/ice-10972-tait.rs b/tests/ui/crashes/ice-10972-tait.rs
deleted file mode 100644
index 11ddbfc3a04..00000000000
--- a/tests/ui/crashes/ice-10972-tait.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//@ check-pass
-// ICE: #10972
-// asked to assemble constituent types of unexpected type: Binder(Foo, [])
-#![feature(type_alias_impl_trait)]
-
-use std::fmt::Debug;
-type Foo = impl Debug;
-const FOO2: Foo = 22_u32;
-
-pub fn main() {}
diff --git a/tests/ui/implied_bounds_in_impls.fixed b/tests/ui/implied_bounds_in_impls.fixed
index bac7af59491..4fe3fa4eab5 100644
--- a/tests/ui/implied_bounds_in_impls.fixed
+++ b/tests/ui/implied_bounds_in_impls.fixed
@@ -192,6 +192,7 @@ impl Atpit for () {
 
 type Tait = impl DerefMut;
 //~^ implied_bounds_in_impls
+#[define_opaque(Tait)]
 fn define() -> Tait {
     &mut [] as &mut [()]
 }
diff --git a/tests/ui/implied_bounds_in_impls.rs b/tests/ui/implied_bounds_in_impls.rs
index 2014cd46ada..6cc824db110 100644
--- a/tests/ui/implied_bounds_in_impls.rs
+++ b/tests/ui/implied_bounds_in_impls.rs
@@ -192,6 +192,7 @@ impl Atpit for () {
 
 type Tait = impl Deref + DerefMut;
 //~^ implied_bounds_in_impls
+#[define_opaque(Tait)]
 fn define() -> Tait {
     &mut [] as &mut [()]
 }
diff --git a/tests/ui/missing_const_for_fn/cant_be_const.rs b/tests/ui/missing_const_for_fn/cant_be_const.rs
index aef5eb5b890..bd6339b7870 100644
--- a/tests/ui/missing_const_for_fn/cant_be_const.rs
+++ b/tests/ui/missing_const_for_fn/cant_be_const.rs
@@ -207,6 +207,7 @@ mod msrv {
 mod with_ty_alias {
     type Foo = impl std::fmt::Debug;
 
+    #[define_opaque(Foo)]
     fn foo(_: Foo) {
         let _: Foo = 1;
     }
diff --git a/tests/ui/new_ret_no_self_overflow.rs b/tests/ui/new_ret_no_self_overflow.rs
index 8a85c566227..f317674bc1a 100644
--- a/tests/ui/new_ret_no_self_overflow.rs
+++ b/tests/ui/new_ret_no_self_overflow.rs
@@ -17,6 +17,7 @@ mod issue10041 {
     struct Bomb2;
 
     impl Bomb2 {
+        #[define_opaque(X)]
         pub fn new() -> X {
             //~^ ERROR: overflow evaluating the requirement
             0i32
diff --git a/tests/ui/new_ret_no_self_overflow.stderr b/tests/ui/new_ret_no_self_overflow.stderr
index 77c1b64ebc8..8ecd0437e7d 100644
--- a/tests/ui/new_ret_no_self_overflow.stderr
+++ b/tests/ui/new_ret_no_self_overflow.stderr
@@ -1,5 +1,5 @@
 error[E0275]: overflow evaluating the requirement `<i32 as std::ops::Add>::Output == issue10041::X`
-  --> tests/ui/new_ret_no_self_overflow.rs:20:25
+  --> tests/ui/new_ret_no_self_overflow.rs:21:25
    |
 LL |         pub fn new() -> X {
    |                         ^