]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #86757 - JohnTitor:rollup-acevhz7, r=JohnTitor
authorbors <bors@rust-lang.org>
Thu, 1 Jul 2021 01:08:46 +0000 (01:08 +0000)
committerbors <bors@rust-lang.org>
Thu, 1 Jul 2021 01:08:46 +0000 (01:08 +0000)
Rollup of 8 pull requests

Successful merges:

 - #85504 (the foundation owns rust trademarks)
 - #85520 (Fix typo and improve documentation for E0632)
 - #86680 (Improve error for missing -Z with debugging option)
 - #86728 (Check node kind to avoid ICE in `check_expr_return()`)
 - #86740 (copy rust-lld as ld in dist)
 - #86746 (Fix rustdoc query type filter)
 - #86750 (Test cross-crate usage of `feature(const_trait_impl)`)
 - #86755 (alloc: `RawVec<T, A>::shrink` can be in `no_global_oom_handling`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

30 files changed:
README.md
compiler/rustc_driver/src/lib.rs
compiler/rustc_error_codes/src/error_codes.rs
compiler/rustc_error_codes/src/error_codes/E0632.md [new file with mode: 0644]
compiler/rustc_lint/src/builtin.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_typeck/src/check/expr.rs
library/alloc/src/raw_vec.rs
src/bootstrap/dist.rs
src/librustdoc/html/static/search.js
src/test/rustdoc-js-std/typed-query.js [new file with mode: 0644]
src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr
src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr
src/test/ui/impl-trait/issues/universal-issue-48703.stderr
src/test/ui/impl-trait/issues/universal-turbofish-in-method-issue-50950.stderr
src/test/ui/invalid-compile-flags/codegen-option-without-group.rs [new file with mode: 0644]
src/test/ui/invalid-compile-flags/codegen-option-without-group.stderr [new file with mode: 0644]
src/test/ui/invalid-compile-flags/debug-option-without-group.rs [new file with mode: 0644]
src/test/ui/invalid-compile-flags/debug-option-without-group.stderr [new file with mode: 0644]
src/test/ui/return/issue-86188-return-not-in-fn-body.rs
src/test/ui/return/issue-86188-return-not-in-fn-body.stderr
src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs [new file with mode: 0644]
src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.rs [new file with mode: 0644]
src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.stderr [new file with mode: 0644]
src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.rs [new file with mode: 0644]
src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.stderr [new file with mode: 0644]
src/test/ui/synthetic-param.stderr
src/test/ui/typeck/issue-86721-return-expr-ice.rev1.stderr [new file with mode: 0644]
src/test/ui/typeck/issue-86721-return-expr-ice.rev2.stderr [new file with mode: 0644]
src/test/ui/typeck/issue-86721-return-expr-ice.rs [new file with mode: 0644]

index cf75f4184a1c96a0eab4def408ee84a76594759d..32fab9fc25de558febac046ab9b8f705e4fcd0d7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -272,15 +272,14 @@ See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
 
 ## Trademark
 
-The Rust programming language is an open source, community project governed
-by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”),
-which owns and protects the Rust and Cargo trademarks and logos
-(the “Rust Trademarks”).
+[The Rust Foundation][rust-foundation] owns and protects the Rust and Cargo
+trademarks and logos (the “Rust Trademarks”).
 
 If you want to use these names or brands, please read the [media guide][media-guide].
 
 Third-party logos may be subject to third-party copyrights and trademarks. See
 [Licenses][policies-licenses] for details.
 
+[rust-foundation]: https://foundation.rust-lang.org/
 [media-guide]: https://www.rust-lang.org/policies/media-guide
 [policies-licenses]: https://www.rust-lang.org/policies/licenses
index 20f1e192a618b6e8cbb307be65ed22ca2fb18dc8..d41779e8b3a7e9ea40f3de5767b7b1632e990136 100644 (file)
@@ -29,7 +29,7 @@
 use rustc_save_analysis as save;
 use rustc_save_analysis::DumpHandler;
 use rustc_serialize::json::{self, ToJson};
-use rustc_session::config::nightly_options;
+use rustc_session::config::{nightly_options, CG_OPTIONS, DB_OPTIONS};
 use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
 use rustc_session::getopts;
 use rustc_session::lint::{Lint, LintId};
@@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
     for option in config::rustc_optgroups() {
         (option.apply)(&mut options);
     }
-    let matches = options
-        .parse(args)
-        .unwrap_or_else(|f| early_error(ErrorOutputType::default(), &f.to_string()));
+    let matches = options.parse(args).unwrap_or_else(|e| {
+        let msg = match e {
+            getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
+                .iter()
+                .map(|&(name, ..)| ('C', name))
+                .chain(DB_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
+                .find(|&(_, name)| *opt == name.replace("_", "-"))
+                .map(|(flag, _)| format!("{}. Did you mean `-{} {}`?", e, flag, opt)),
+            _ => None,
+        };
+        early_error(ErrorOutputType::default(), &msg.unwrap_or_else(|| e.to_string()));
+    });
 
     // For all options we just parsed, we check a few aspects:
     //
index ff7a2344e69537543e5eb6ed2a6263216e3713ca..df162f8dce0267456005a54055e3dd31e2127d88 100644 (file)
 E0627: include_str!("./error_codes/E0627.md"),
 E0628: include_str!("./error_codes/E0628.md"),
 E0631: include_str!("./error_codes/E0631.md"),
+E0632: include_str!("./error_codes/E0632.md"),
 E0633: include_str!("./error_codes/E0633.md"),
 E0634: include_str!("./error_codes/E0634.md"),
 E0635: include_str!("./error_codes/E0635.md"),
 //  E0629, // missing 'feature' (rustc_const_unstable)
 //  E0630, // rustc_const_unstable attribute must be paired with stable/unstable
            // attribute
-    E0632, // cannot provide explicit generic arguments when `impl Trait` is
-           // used in argument position
     E0640, // infer outlives requirements
 //  E0645, // trait aliases not finished
     E0667, // `impl Trait` in projections
diff --git a/compiler/rustc_error_codes/src/error_codes/E0632.md b/compiler/rustc_error_codes/src/error_codes/E0632.md
new file mode 100644 (file)
index 0000000..40840e8
--- /dev/null
@@ -0,0 +1,25 @@
+An explicit generic argument was provided when calling a function that
+uses `impl Trait` in argument position.
+
+Erroneous code example:
+
+```compile_fail,E0632
+fn foo<T: Copy>(a: T, b: impl Clone) {}
+
+foo::<i32>(0i32, "abc".to_string());
+```
+
+Either all generic arguments should be inferred at the call site, or
+the function definition should use an explicit generic type parameter
+instead of `impl Trait`. Example:
+
+```
+fn foo<T: Copy>(a: T, b: impl Clone) {}
+fn bar<T: Copy, U: Clone>(a: T, b: U) {}
+
+foo(0i32, "abc".to_string());
+
+bar::<i32, String>(0i32, "abc".to_string());
+bar::<_, _>(0i32, "abc".to_string());
+bar(0i32, "abc".to_string());
+```
index d7d0c978ca42d61cea5e61be400bfe7a898765c1..65695fc03de82d07f630f88c77300b7d77b24522 100644 (file)
@@ -1084,7 +1084,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
     ///
     /// ### Explanation
     ///
-    /// An function with generics must have its symbol mangled to accommodate
+    /// A function with generics must have its symbol mangled to accommodate
     /// the generic parameter. The [`no_mangle` attribute] has no effect in
     /// this situation, and should be removed.
     ///
index 76007398000415fa8c772be9e21e2d14b49e6579..4231db620b012df76738bf907a5e8b19fb9d732c 100644 (file)
@@ -1223,7 +1223,12 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) {
                 let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
                     FnData {
                         asyncness: sig.header.asyncness,
-                        constness: sig.header.constness,
+                        // Can be inside `impl const Trait`, so using sig.header.constness is not reliable
+                        constness: if self.tcx.is_const_fn_raw(def_id) {
+                            hir::Constness::Const
+                        } else {
+                            hir::Constness::NotConst
+                        },
                         param_names: self.encode_fn_param_names_for_body(body),
                     }
                 } else {
index f69839bf85903336884458c77c03171ff8836081..cfe1d1c6871f092ab4a048c829b758f859f034b4 100644 (file)
@@ -682,9 +682,23 @@ fn check_expr_return(
             };
 
             let encl_item_id = self.tcx.hir().get_parent_item(expr.hir_id);
-            let encl_item = self.tcx.hir().expect_item(encl_item_id);
 
-            if let hir::ItemKind::Fn(..) = encl_item.kind {
+            if let Some(hir::Node::Item(hir::Item {
+                kind: hir::ItemKind::Fn(..),
+                span: encl_fn_span,
+                ..
+            }))
+            | Some(hir::Node::TraitItem(hir::TraitItem {
+                kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)),
+                span: encl_fn_span,
+                ..
+            }))
+            | Some(hir::Node::ImplItem(hir::ImplItem {
+                kind: hir::ImplItemKind::Fn(..),
+                span: encl_fn_span,
+                ..
+            })) = self.tcx.hir().find(encl_item_id)
+            {
                 // We are inside a function body, so reporting "return statement
                 // outside of function body" needs an explanation.
 
@@ -698,7 +712,7 @@ fn check_expr_return(
                 let encl_body = self.tcx.hir().body(encl_body_id);
 
                 err.encl_body_span = Some(encl_body.value.span);
-                err.encl_fn_span = Some(encl_item.span);
+                err.encl_fn_span = Some(*encl_fn_span);
             }
 
             self.tcx.sess.emit_err(err);
index 2e2c9b76bd4ba6a1d74d73f6935b8961adfaad8f..d11d4031f77548e92e3b61dfe22eaffff3b03efa 100644 (file)
@@ -463,7 +463,6 @@ fn grow_exact(&mut self, len: usize, additional: usize) -> Result<(), TryReserve
         Ok(())
     }
 
-    #[cfg(not(no_global_oom_handling))]
     fn shrink(&mut self, amount: usize) -> Result<(), TryReserveError> {
         assert!(amount <= self.capacity(), "Tried to shrink to a larger capacity");
 
index 19895baf08f162ff92e2bc95b82800dab5becf75..92853378e588133460a3fa33bc229c46df2e760c 100644 (file)
@@ -400,12 +400,12 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
 
             // Copy over lld if it's there
             if builder.config.lld_enabled {
-                let exe = exe("rust-lld", compiler.host);
-                builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
+                let rust_lld = exe("rust-lld", compiler.host);
+                builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
                 // for `-Z gcc-ld=lld`
                 let gcc_lld_dir = dst_dir.join("gcc-ld");
                 t!(fs::create_dir(&gcc_lld_dir));
-                builder.copy(&src_dir.join(&exe), &gcc_lld_dir.join(&exe));
+                builder.copy(&src_dir.join(&rust_lld), &gcc_lld_dir.join(exe("ld", compiler.host)));
             }
 
             // Copy over llvm-dwp if it's there
index 0aebb0e9d65889f48f92ea0f4920c6402758b116..f6343e4c3d246c4496cbda98b8cb0ef2168db7ca 100644 (file)
@@ -801,7 +801,8 @@ window.initSearch = function(rawSearchIndex) {
                     results_returned[fullId].lev =
                         Math.min(results_returned[fullId].lev, returned);
                 }
-                if (index !== -1 || lev <= MAX_LEV_DISTANCE) {
+                if (typePassesFilter(typeFilter, ty.ty) &&
+                        (index !== -1 || lev <= MAX_LEV_DISTANCE)) {
                     if (index !== -1 && paths.length < 2) {
                         lev = 0;
                     }
diff --git a/src/test/rustdoc-js-std/typed-query.js b/src/test/rustdoc-js-std/typed-query.js
new file mode 100644 (file)
index 0000000..f656aa7
--- /dev/null
@@ -0,0 +1,12 @@
+// exact-check
+
+const QUERY = 'macro:print';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'print' },
+        { 'path': 'std', 'name': 'eprint' },
+        { 'path': 'std', 'name': 'println' },
+        { 'path': 'std', 'name': 'eprintln' },
+    ],
+};
index 26b965901a4c4d061f6d526f4918bbf20e480ace..ebc8f458f79c78788d7bbb346069a311123e32af 100644 (file)
@@ -6,3 +6,4 @@ LL |     assert_eq!(f::<4usize>(Usizable), 20usize);
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0632`.
index 26b965901a4c4d061f6d526f4918bbf20e480ace..ebc8f458f79c78788d7bbb346069a311123e32af 100644 (file)
@@ -6,3 +6,4 @@ LL |     assert_eq!(f::<4usize>(Usizable), 20usize);
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0632`.
index 8f05ab3c4940c30e22f0f170108907dbeb31e65e..6800b37b5b175aaaee409116c67c9acefa9a4848 100644 (file)
@@ -6,3 +6,4 @@ LL |     foo::<String>('a');
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0632`.
index c980e9463e48ae383b377412b67cfaac37976414..db66d461095993f8fb9f5b3ad9a5c711dcadb30f 100644 (file)
@@ -8,3 +8,4 @@ LL |     evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0632`.
diff --git a/src/test/ui/invalid-compile-flags/codegen-option-without-group.rs b/src/test/ui/invalid-compile-flags/codegen-option-without-group.rs
new file mode 100644 (file)
index 0000000..7bbf47a
--- /dev/null
@@ -0,0 +1 @@
+// compile-flags: --llvm-args
diff --git a/src/test/ui/invalid-compile-flags/codegen-option-without-group.stderr b/src/test/ui/invalid-compile-flags/codegen-option-without-group.stderr
new file mode 100644 (file)
index 0000000..c5a0c29
--- /dev/null
@@ -0,0 +1,2 @@
+error: Unrecognized option: 'llvm-args'. Did you mean `-C llvm-args`?
+
diff --git a/src/test/ui/invalid-compile-flags/debug-option-without-group.rs b/src/test/ui/invalid-compile-flags/debug-option-without-group.rs
new file mode 100644 (file)
index 0000000..86e40c1
--- /dev/null
@@ -0,0 +1 @@
+// compile-flags: --unpretty=hir
diff --git a/src/test/ui/invalid-compile-flags/debug-option-without-group.stderr b/src/test/ui/invalid-compile-flags/debug-option-without-group.stderr
new file mode 100644 (file)
index 0000000..0e57e31
--- /dev/null
@@ -0,0 +1,2 @@
+error: Unrecognized option: 'unpretty'. Did you mean `-Z unpretty`?
+
index 23cc9f0512ca1f1185549fdbe87cdc551fecee73..4f076fa0693839cafcfbd01ecc7285ea9cc26ba0 100644 (file)
     }]
 };
 
+struct S {}
+trait Tr {
+    fn foo();
+    fn bar() {
+    //~^ NOTE: ...not the enclosing function body
+        [(); return];
+        //~^ ERROR: return statement outside of function body [E0572]
+        //~| NOTE: the return is part of this body...
+    }
+}
+impl Tr for S {
+    fn foo() {
+    //~^ NOTE: ...not the enclosing function body
+        [(); return];
+        //~^ ERROR: return statement outside of function body [E0572]
+        //~| NOTE: the return is part of this body...
+    }
+}
+
 fn main() {
 //~^ NOTE: ...not the enclosing function body
     [(); return || {
index 9275cb91dd3564fa79d61ddd55ba67f86b5ccff9..d7eeb3a729099c5ca5d5c6628e93aefd1f4492d2 100644 (file)
@@ -9,7 +9,31 @@ LL | |     }]
    | |_____^
 
 error[E0572]: return statement outside of function body
-  --> $DIR/issue-86188-return-not-in-fn-body.rs:17:10
+  --> $DIR/issue-86188-return-not-in-fn-body.rs:20:14
+   |
+LL | /     fn bar() {
+LL | |
+LL | |         [(); return];
+   | |              ^^^^^^ the return is part of this body...
+LL | |
+LL | |
+LL | |     }
+   | |_____- ...not the enclosing function body
+
+error[E0572]: return statement outside of function body
+  --> $DIR/issue-86188-return-not-in-fn-body.rs:28:14
+   |
+LL | /     fn foo() {
+LL | |
+LL | |         [(); return];
+   | |              ^^^^^^ the return is part of this body...
+LL | |
+LL | |
+LL | |     }
+   | |_____- ...not the enclosing function body
+
+error[E0572]: return statement outside of function body
+  --> $DIR/issue-86188-return-not-in-fn-body.rs:36:10
    |
 LL |  / fn main() {
 LL |  |
@@ -23,6 +47,6 @@ LL | ||     }];
 LL |  | }
    |  |_- ...not the enclosing function body
 
-error: aborting due to 2 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0572`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs
new file mode 100644 (file)
index 0000000..4285eaf
--- /dev/null
@@ -0,0 +1,22 @@
+#![feature(const_trait_impl)]
+#![allow(incomplete_features)]
+
+pub trait MyTrait {
+    fn func(self);
+}
+
+pub struct NonConst;
+
+impl MyTrait for NonConst {
+    fn func(self) {
+
+    }
+}
+
+pub struct Const;
+
+impl const MyTrait for Const {
+    fn func(self) {
+
+    }
+}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.rs b/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.rs
new file mode 100644 (file)
index 0000000..abd11d8
--- /dev/null
@@ -0,0 +1,18 @@
+// aux-build: cross-crate.rs
+extern crate cross_crate;
+
+use cross_crate::*;
+
+fn non_const_context() {
+    NonConst.func();
+    Const.func();
+}
+
+const fn const_context() {
+    NonConst.func();
+    //~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+    Const.func();
+    //~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-disabled.stderr
new file mode 100644 (file)
index 0000000..b86583b
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+  --> $DIR/cross-crate-feature-disabled.rs:12:5
+   |
+LL |     NonConst.func();
+   |     ^^^^^^^^^^^^^^^
+
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+  --> $DIR/cross-crate-feature-disabled.rs:14:5
+   |
+LL |     Const.func();
+   |     ^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0015`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.rs b/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.rs
new file mode 100644 (file)
index 0000000..b79ccc7
--- /dev/null
@@ -0,0 +1,20 @@
+#![feature(const_trait_impl)]
+#![allow(incomplete_features)]
+
+// aux-build: cross-crate.rs
+extern crate cross_crate;
+
+use cross_crate::*;
+
+fn non_const_context() {
+    NonConst.func();
+    Const.func();
+}
+
+const fn const_context() {
+    NonConst.func();
+    //~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+    Const.func();
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate-feature-enabled.stderr
new file mode 100644 (file)
index 0000000..a544c0d
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+  --> $DIR/cross-crate-feature-enabled.rs:15:5
+   |
+LL |     NonConst.func();
+   |     ^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0015`.
index 951d7edb7f523ec14cbd3ad24f921b9d963fe8a5..101132d05fa0eb98f6a5d0f05e45d20800f5a2b4 100644 (file)
@@ -18,3 +18,4 @@ LL |     Bar::<i8>::func::<u8>(42);
 
 error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0632`.
diff --git a/src/test/ui/typeck/issue-86721-return-expr-ice.rev1.stderr b/src/test/ui/typeck/issue-86721-return-expr-ice.rev1.stderr
new file mode 100644 (file)
index 0000000..b1111fc
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0572]: return statement outside of function body
+  --> $DIR/issue-86721-return-expr-ice.rs:9:22
+   |
+LL |     const U: usize = return;
+   |                      ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0572`.
diff --git a/src/test/ui/typeck/issue-86721-return-expr-ice.rev2.stderr b/src/test/ui/typeck/issue-86721-return-expr-ice.rev2.stderr
new file mode 100644 (file)
index 0000000..f489ae2
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0572]: return statement outside of function body
+  --> $DIR/issue-86721-return-expr-ice.rs:15:20
+   |
+LL |     fn foo(a: [(); return]);
+   |                    ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0572`.
diff --git a/src/test/ui/typeck/issue-86721-return-expr-ice.rs b/src/test/ui/typeck/issue-86721-return-expr-ice.rs
new file mode 100644 (file)
index 0000000..cd7135f
--- /dev/null
@@ -0,0 +1,17 @@
+// Regression test for the ICE described in #86721.
+
+// revisions: rev1 rev2
+#![cfg_attr(any(), rev1, rev2)]
+#![crate_type="lib"]
+
+#[cfg(any(rev1))]
+trait T {
+    const U: usize = return;
+    //[rev1]~^ ERROR: return statement outside of function body [E0572]
+}
+
+#[cfg(any(rev2))]
+trait T2 {
+    fn foo(a: [(); return]);
+    //[rev2]~^ ERROR: return statement outside of function body [E0572]
+}