From fa029400d57d662513be80d3dd1c7826f517f680 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Apr 2021 16:08:29 -0700 Subject: [PATCH 01/10] rustc: Add a new `wasm` ABI This commit implements the idea of a new ABI for the WebAssembly target, one called `"wasm"`. This ABI is entirely of my own invention and has no current precedent, but I think that the addition of this ABI might help solve a number of issues with the WebAssembly targets. When `wasm32-unknown-unknown` was first added to Rust I naively "implemented an abi" for the target. I then went to write `wasm-bindgen` which accidentally relied on details of this ABI. Turns out the ABI definition didn't match C, which is causing issues for C/Rust interop. Currently the compiler has a "wasm32 bindgen compat" ABI which is the original implementation I added, and it's purely there for, well, `wasm-bindgen`. Another issue with the WebAssembly target is that it's not clear to me when and if the default C ABI will change to account for WebAssembly's multi-value feature (a feature that allows functions to return multiple values). Even if this does happen, though, it seems like the C ABI will be guided based on the performance of WebAssembly code and will likely not match even what the current wasm-bindgen-compat ABI is today. This leaves a hole in Rust's expressivity in binding WebAssembly where given a particular import type, Rust may not be able to import that signature with an updated C ABI for multi-value. To fix these issues I had the idea of a new ABI for WebAssembly, one called `wasm`. The definition of this ABI is "what you write maps straight to wasm". The goal here is that whatever you write down in the parameter list or in the return values goes straight into the function's signature in the WebAssembly file. This special ABI is for intentionally matching the ABI of an imported function from the environment or exporting a function with the right signature. With the addition of a new ABI, this enables rustc to: * Eventually remove the "wasm-bindgen compat hack". Once this ABI is stable wasm-bindgen can switch to using it everywhere. Afterwards the wasm32-unknown-unknown target can have its default ABI updated to match C. * Expose the ability to precisely match an ABI signature for a WebAssembly function, regardless of what the C ABI that clang chooses turns out to be. * Continue to evolve the definition of the default C ABI to match what clang does on all targets, since the purpose of that ABI will be explicitly matching C rather than generating particular function imports/exports. Naturally this is implemented as an unstable feature initially, but it would be nice for this to get stabilized (if it works) in the near-ish future to remove the wasm32-unknown-unknown incompatibility with the C ABI. Doing this, however, requires the feature to be on stable because wasm-bindgen works with stable Rust. --- compiler/rustc_ast_passes/src/feature_gate.rs | 8 + compiler/rustc_codegen_llvm/src/attributes.rs | 44 ++-- compiler/rustc_feature/src/active.rs | 3 + compiler/rustc_middle/src/ty/layout.rs | 2 + compiler/rustc_mir_build/src/build/mod.rs | 1 + compiler/rustc_span/src/symbol.rs | 1 + compiler/rustc_target/src/abi/call/mod.rs | 18 +- .../src/abi/call/{wasm32.rs => wasm.rs} | 27 ++- .../src/abi/call/wasm32_bindgen_compat.rs | 29 --- compiler/rustc_target/src/abi/call/wasm64.rs | 58 ------ compiler/rustc_target/src/spec/abi.rs | 15 +- compiler/rustc_target/src/spec/mod.rs | 22 ++ .../src/spec/wasm32_unknown_unknown.rs | 12 ++ src/test/run-make/wasm-abi/Makefile | 7 + src/test/run-make/wasm-abi/foo.js | 22 ++ src/test/run-make/wasm-abi/foo.rs | 87 ++++++++ src/test/ui/codemap_tests/unicode.stderr | 2 +- src/test/ui/feature-gates/feature-gate-abi.rs | 25 ++- .../ui/feature-gates/feature-gate-abi.stderr | 195 ++++++++++++------ .../ui/feature-gates/feature-gate-wasm_abi.rs | 7 + .../feature-gate-wasm_abi.stderr | 12 ++ src/test/ui/parser/issue-8537.stderr | 2 +- 22 files changed, 403 insertions(+), 196 deletions(-) rename compiler/rustc_target/src/abi/call/{wasm32.rs => wasm.rs} (66%) delete mode 100644 compiler/rustc_target/src/abi/call/wasm32_bindgen_compat.rs delete mode 100644 compiler/rustc_target/src/abi/call/wasm64.rs create mode 100644 src/test/run-make/wasm-abi/Makefile create mode 100644 src/test/run-make/wasm-abi/foo.js create mode 100644 src/test/run-make/wasm-abi/foo.rs create mode 100644 src/test/ui/feature-gates/feature-gate-wasm_abi.rs create mode 100644 src/test/ui/feature-gates/feature-gate-wasm_abi.stderr diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 3724438cc6ed2..87c4bfae1af23 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -196,6 +196,14 @@ impl<'a> PostExpansionVisitor<'a> { "thiscall-unwind ABI is experimental and subject to change" ); } + "wasm" => { + gate_feature_post!( + &self, + wasm_abi, + span, + "wasm ABI is experimental and subject to change" + ); + } abi => self .sess .parse_sess diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index e06c1c825f6eb..9e5e2b1039efe 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -13,6 +13,7 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::config::OptLevel; use rustc_session::Session; +use rustc_target::spec::abi::Abi; use rustc_target::spec::{SanitizerSet, StackProbeType}; use crate::attributes; @@ -293,7 +294,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: // The target doesn't care; the subtarget reads our attribute. apply_tune_cpu_attr(cx, llfn); - let function_features = codegen_fn_attrs + let mut function_features = codegen_fn_attrs .target_features .iter() .map(|f| { @@ -305,23 +306,10 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: InstructionSetAttr::ArmT32 => "+thumb-mode".to_string(), })) .collect::>(); - if !function_features.is_empty() { - let mut global_features = llvm_util::llvm_global_features(cx.tcx.sess); - global_features.extend(function_features.into_iter()); - let features = global_features.join(","); - let val = CString::new(features).unwrap(); - llvm::AddFunctionAttrStringValue( - llfn, - llvm::AttributePlace::Function, - cstr!("target-features"), - &val, - ); - } - // Note that currently the `wasm-import-module` doesn't do anything, but - // eventually LLVM 7 should read this and ferry the appropriate import - // module to the output file. if cx.tcx.sess.target.is_like_wasm { + // If this function is an import from the environment but the wasm + // import has a specific module/name, apply them here. if let Some(module) = wasm_import_module(cx.tcx, instance.def_id()) { llvm::AddFunctionAttrStringValue( llfn, @@ -340,6 +328,30 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: &name, ); } + + // The `"wasm"` abi on wasm targets automatically enables the + // `+multivalue` feature because the purpose of the wasm abi is to match + // the WebAssembly specification, which has this feature. This won't be + // needed when LLVM enables this `multivalue` feature by default. + if !cx.tcx.is_closure(instance.def_id()) { + let abi = cx.tcx.fn_sig(instance.def_id()).abi(); + if abi == Abi::Wasm { + function_features.push("+multivalue".to_string()); + } + } + } + + if !function_features.is_empty() { + let mut global_features = llvm_util::llvm_global_features(cx.tcx.sess); + global_features.extend(function_features.into_iter()); + let features = global_features.join(","); + let val = CString::new(features).unwrap(); + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + cstr!("target-features"), + &val, + ); } } diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 93de4891ec7d2..1a91eb600a91b 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -645,6 +645,9 @@ declare_features! ( /// Allows using `#[repr(align(...))]` on function items (active, fn_align, "1.53.0", Some(82232), None), + /// Allows `extern "wasm" fn` + (active, wasm_abi, "1.53.0", Some(83788), None), + // ------------------------------------------------------------------------- // feature-group-end: actual feature gates // ------------------------------------------------------------------------- diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index e7bbdc3ccebdf..c2e9dba6c8e8a 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2630,6 +2630,7 @@ fn fn_can_unwind( | AvrInterrupt | AvrNonBlockingInterrupt | CCmseNonSecureCall + | Wasm | RustIntrinsic | PlatformIntrinsic | Unadjusted => false, @@ -2712,6 +2713,7 @@ where AmdGpuKernel => Conv::AmdGpuKernel, AvrInterrupt => Conv::AvrInterrupt, AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt, + Wasm => Conv::C, // These API constants ought to be more specific... Cdecl => Conv::C, diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index c90f94c6d63fb..3a189e6b33dda 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -609,6 +609,7 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo | AvrInterrupt | AvrNonBlockingInterrupt | CCmseNonSecureCall + | Wasm | RustIntrinsic | PlatformIntrinsic | Unadjusted => true, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 54fea5515946f..4b55494a0843b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1296,6 +1296,7 @@ symbols! { vreg_low16, warn, wasm, + wasm_abi, wasm_import_module, wasm_target_feature, while_let, diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 395235399ea86..d9d7d467d9294 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -18,9 +18,7 @@ mod riscv; mod s390x; mod sparc; mod sparc64; -mod wasm32; -mod wasm32_bindgen_compat; -mod wasm64; +mod wasm; mod x86; mod x86_64; mod x86_win64; @@ -648,12 +646,14 @@ impl<'a, Ty> FnAbi<'a, Ty> { "nvptx64" => nvptx64::compute_abi_info(self), "hexagon" => hexagon::compute_abi_info(self), "riscv32" | "riscv64" => riscv::compute_abi_info(cx, self), - "wasm32" => match cx.target_spec().os.as_str() { - "emscripten" | "wasi" => wasm32::compute_abi_info(cx, self), - _ => wasm32_bindgen_compat::compute_abi_info(self), - }, - "asmjs" => wasm32::compute_abi_info(cx, self), - "wasm64" => wasm64::compute_abi_info(cx, self), + "wasm32" | "wasm64" => { + if cx.target_spec().adjust_abi(abi) == spec::abi::Abi::Wasm { + wasm::compute_wasm_abi_info(self) + } else { + wasm::compute_c_abi_info(cx, self) + } + } + "asmjs" => wasm::compute_c_abi_info(cx, self), a => return Err(format!("unrecognized arch \"{}\" in target specification", a)), } diff --git a/compiler/rustc_target/src/abi/call/wasm32.rs b/compiler/rustc_target/src/abi/call/wasm.rs similarity index 66% rename from compiler/rustc_target/src/abi/call/wasm32.rs rename to compiler/rustc_target/src/abi/call/wasm.rs index ff2c0e9bb6fcc..bf2c08bb1662d 100644 --- a/compiler/rustc_target/src/abi/call/wasm32.rs +++ b/compiler/rustc_target/src/abi/call/wasm.rs @@ -40,7 +40,8 @@ where } } -pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) +/// The purpose of this ABI is to match the C ABI (aka clang) exactly. +pub fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) where Ty: TyAndLayoutMethods<'a, C> + Copy, C: LayoutOf> + HasDataLayout, @@ -56,3 +57,27 @@ where classify_arg(cx, arg); } } + +/// The purpose of this ABI is for matching the WebAssembly standard. This +/// intentionally diverges from the C ABI and is specifically crafted to take +/// advantage of LLVM's support of multiple returns in WebAssembly. +pub fn compute_wasm_abi_info(fn_abi: &mut FnAbi<'_, Ty>) { + if !fn_abi.ret.is_ignore() { + classify_ret(&mut fn_abi.ret); + } + + for arg in &mut fn_abi.args { + if arg.is_ignore() { + continue; + } + classify_arg(arg); + } + + fn classify_ret(ret: &mut ArgAbi<'_, Ty>) { + ret.extend_integer_width_to(32); + } + + fn classify_arg(arg: &mut ArgAbi<'_, Ty>) { + arg.extend_integer_width_to(32); + } +} diff --git a/compiler/rustc_target/src/abi/call/wasm32_bindgen_compat.rs b/compiler/rustc_target/src/abi/call/wasm32_bindgen_compat.rs deleted file mode 100644 index 59571fd9d4821..0000000000000 --- a/compiler/rustc_target/src/abi/call/wasm32_bindgen_compat.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is not and has never been a correct C ABI for WebAssembly, but -// for a long time this was the C ABI that Rust used. wasm-bindgen -// depends on ABI details for this ABI and is incompatible with the -// correct C ABI, so this ABI is being kept around until wasm-bindgen -// can be fixed to work with the correct ABI. See #63649 for further -// discussion. - -use crate::abi::call::{ArgAbi, FnAbi}; - -fn classify_ret(ret: &mut ArgAbi<'_, Ty>) { - ret.extend_integer_width_to(32); -} - -fn classify_arg(arg: &mut ArgAbi<'_, Ty>) { - arg.extend_integer_width_to(32); -} - -pub fn compute_abi_info(fn_abi: &mut FnAbi<'_, Ty>) { - if !fn_abi.ret.is_ignore() { - classify_ret(&mut fn_abi.ret); - } - - for arg in &mut fn_abi.args { - if arg.is_ignore() { - continue; - } - classify_arg(arg); - } -} diff --git a/compiler/rustc_target/src/abi/call/wasm64.rs b/compiler/rustc_target/src/abi/call/wasm64.rs deleted file mode 100644 index 46d670d168949..0000000000000 --- a/compiler/rustc_target/src/abi/call/wasm64.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::abi::call::{ArgAbi, FnAbi, Uniform}; -use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods}; - -fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool -where - Ty: TyAndLayoutMethods<'a, C> + Copy, - C: LayoutOf> + HasDataLayout, -{ - if val.layout.is_aggregate() { - if let Some(unit) = val.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) { - let size = val.layout.size; - if unit.size == size { - val.cast_to(Uniform { unit, total: size }); - return true; - } - } - } - false -} - -fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>) -where - Ty: TyAndLayoutMethods<'a, C> + Copy, - C: LayoutOf> + HasDataLayout, -{ - ret.extend_integer_width_to(64); - if ret.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, ret) { - ret.make_indirect(); - } -} - -fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -where - Ty: TyAndLayoutMethods<'a, C> + Copy, - C: LayoutOf> + HasDataLayout, -{ - arg.extend_integer_width_to(64); - if arg.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, arg) { - arg.make_indirect_byval(); - } -} - -pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) -where - Ty: TyAndLayoutMethods<'a, C> + Copy, - C: LayoutOf> + HasDataLayout, -{ - if !fn_abi.ret.is_ignore() { - classify_ret(cx, &mut fn_abi.ret); - } - - for arg in &mut fn_abi.args { - if arg.is_ignore() { - continue; - } - classify_arg(cx, arg); - } -} diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs index 17eb33b8f2eaa..a026a623f7866 100644 --- a/compiler/rustc_target/src/spec/abi.rs +++ b/compiler/rustc_target/src/spec/abi.rs @@ -34,6 +34,7 @@ pub enum Abi { AvrInterrupt, AvrNonBlockingInterrupt, CCmseNonSecureCall, + Wasm, // Multiplatform / generic ABIs System { unwind: bool }, @@ -83,6 +84,7 @@ const AbiDatas: &[AbiData] = &[ generic: false, }, AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call", generic: false }, + AbiData { abi: Abi::Wasm, name: "wasm", generic: false }, // Cross-platform ABIs AbiData { abi: Abi::System { unwind: false }, name: "system", generic: true }, AbiData { abi: Abi::System { unwind: true }, name: "system-unwind", generic: true }, @@ -131,13 +133,14 @@ impl Abi { AvrInterrupt => 18, AvrNonBlockingInterrupt => 19, CCmseNonSecureCall => 20, + Wasm => 21, // Cross-platform ABIs - System { unwind: false } => 21, - System { unwind: true } => 22, - RustIntrinsic => 23, - RustCall => 24, - PlatformIntrinsic => 25, - Unadjusted => 26, + System { unwind: false } => 22, + System { unwind: true } => 23, + RustIntrinsic => 24, + RustCall => 25, + PlatformIntrinsic => 26, + Unadjusted => 27, }; debug_assert!( AbiDatas diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 801cdd3ebe924..57b0a36e009ef 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1254,6 +1254,9 @@ pub struct TargetOptions { /// enabled can generated on this target, but the necessary supporting libraries are not /// distributed with the target, the sanitizer should still appear in this list for the target. pub supported_sanitizers: SanitizerSet, + + /// If present it's a default value to use for adjusting the C ABI. + pub default_adjusted_cabi: Option, } impl Default for TargetOptions { @@ -1357,6 +1360,7 @@ impl Default for TargetOptions { has_thumb_interworking: false, split_debuginfo: SplitDebuginfo::Off, supported_sanitizers: SanitizerSet::empty(), + default_adjusted_cabi: None, } } } @@ -1408,6 +1412,9 @@ impl Target { Abi::C { unwind: false } } } + + Abi::C { unwind } => self.default_adjusted_cabi.unwrap_or(Abi::C { unwind }), + abi => abi, } } @@ -1742,6 +1749,16 @@ impl Target { } } } ); + ($key_name:ident, Option) => ( { + let name = (stringify!($key_name)).replace("_", "-"); + obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| { + match lookup_abi(s) { + Some(abi) => base.$key_name = Some(abi), + _ => return Some(Err(format!("'{}' is not a valid value for abi", s))), + } + Some(Ok(())) + })).unwrap_or(Ok(())) + } ); } if let Some(s) = obj.find("target-endian").and_then(Json::as_string) { @@ -1841,6 +1858,7 @@ impl Target { key!(has_thumb_interworking, bool); key!(split_debuginfo, SplitDebuginfo)?; key!(supported_sanitizers, SanitizerSet)?; + key!(default_adjusted_cabi, Option)?; // NB: The old name is deprecated, but support for it is retained for // compatibility. @@ -2081,6 +2099,10 @@ impl ToJson for Target { target_option_val!(split_debuginfo); target_option_val!(supported_sanitizers); + if let Some(abi) = self.default_adjusted_cabi { + d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json()); + } + if default.unsupported_abis != self.unsupported_abis { d.insert( "unsupported-abis".to_string(), diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs index 0a88ee426297b..834c4dbfc05f6 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs @@ -12,11 +12,23 @@ use super::wasm_base; use super::{LinkerFlavor, LldFlavor, Target}; +use crate::spec::abi::Abi; pub fn target() -> Target { let mut options = wasm_base::options(); options.os = "unknown".to_string(); options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm); + + // This is a default for backwards-compatibility with the original + // definition of this target oh-so-long-ago. Once the "wasm" ABI is + // stable and the wasm-bindgen project has switched to using it then there's + // no need for this and it can be removed. + // + // Currently this is the reason that this target's ABI is mismatched with + // clang's ABI. This means that, in the limit, you can't merge C and Rust + // code on this target due to this ABI mismatch. + options.default_adjusted_cabi = Some(Abi::Wasm); + let clang_args = options.pre_link_args.entry(LinkerFlavor::Gcc).or_default(); // Make sure clang uses LLD as its linker and is configured appropriately diff --git a/src/test/run-make/wasm-abi/Makefile b/src/test/run-make/wasm-abi/Makefile new file mode 100644 index 0000000000000..61fc4e8f57fb8 --- /dev/null +++ b/src/test/run-make/wasm-abi/Makefile @@ -0,0 +1,7 @@ +-include ../../run-make-fulldeps/tools.mk + +# only-wasm32-bare + +all: + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(NODE) foo.js $(TMPDIR)/foo.wasm diff --git a/src/test/run-make/wasm-abi/foo.js b/src/test/run-make/wasm-abi/foo.js new file mode 100644 index 0000000000000..9e9a65401af81 --- /dev/null +++ b/src/test/run-make/wasm-abi/foo.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +const m = new WebAssembly.Module(buffer); +const i = new WebAssembly.Instance(m, { + host: { + two_i32: () => [100, 101], + two_i64: () => [102n, 103n], + two_f32: () => [104, 105], + two_f64: () => [106, 107], + mishmash: () => [108, 109, 110, 111n, 112, 113], + } +}); + +assert.deepEqual(i.exports.return_two_i32(), [1, 2]) +assert.deepEqual(i.exports.return_two_i64(), [3, 4]) +assert.deepEqual(i.exports.return_two_f32(), [5, 6]) +assert.deepEqual(i.exports.return_two_f64(), [7, 8]) +assert.deepEqual(i.exports.return_mishmash(), [9, 10, 11, 12, 13, 14]) +i.exports.call_imports(); diff --git a/src/test/run-make/wasm-abi/foo.rs b/src/test/run-make/wasm-abi/foo.rs new file mode 100644 index 0000000000000..0678eb3ff51ae --- /dev/null +++ b/src/test/run-make/wasm-abi/foo.rs @@ -0,0 +1,87 @@ +#![crate_type = "cdylib"] +#![deny(warnings)] +#![feature(wasm_abi)] + +#[repr(C)] +#[derive(PartialEq, Debug)] +pub struct TwoI32 { + pub a: i32, + pub b: i32, +} + +#[no_mangle] +pub extern "wasm" fn return_two_i32() -> TwoI32 { + TwoI32 { a: 1, b: 2 } +} + +#[repr(C)] +#[derive(PartialEq, Debug)] +pub struct TwoI64 { + pub a: i64, + pub b: i64, +} + +#[no_mangle] +pub extern "wasm" fn return_two_i64() -> TwoI64 { + TwoI64 { a: 3, b: 4 } +} + +#[repr(C)] +#[derive(PartialEq, Debug)] +pub struct TwoF32 { + pub a: f32, + pub b: f32, +} + +#[no_mangle] +pub extern "wasm" fn return_two_f32() -> TwoF32 { + TwoF32 { a: 5., b: 6. } +} + +#[repr(C)] +#[derive(PartialEq, Debug)] +pub struct TwoF64 { + pub a: f64, + pub b: f64, +} + +#[no_mangle] +pub extern "wasm" fn return_two_f64() -> TwoF64 { + TwoF64 { a: 7., b: 8. } +} + +#[repr(C)] +#[derive(PartialEq, Debug)] +pub struct Mishmash { + pub a: f64, + pub b: f32, + pub c: i32, + pub d: i64, + pub e: TwoI32, +} + +#[no_mangle] +pub extern "wasm" fn return_mishmash() -> Mishmash { + Mishmash { a: 9., b: 10., c: 11, d: 12, e: TwoI32 { a: 13, b: 14 } } +} + +#[link(wasm_import_module = "host")] +extern "wasm" { + fn two_i32() -> TwoI32; + fn two_i64() -> TwoI64; + fn two_f32() -> TwoF32; + fn two_f64() -> TwoF64; + fn mishmash() -> Mishmash; +} + +#[no_mangle] +pub unsafe extern "C" fn call_imports() { + assert_eq!(two_i32(), TwoI32 { a: 100, b: 101 }); + assert_eq!(two_i64(), TwoI64 { a: 102, b: 103 }); + assert_eq!(two_f32(), TwoF32 { a: 104., b: 105. }); + assert_eq!(two_f64(), TwoF64 { a: 106., b: 107. }); + assert_eq!( + mishmash(), + Mishmash { a: 108., b: 109., c: 110, d: 111, e: TwoI32 { a: 112, b: 113 } } + ); +} diff --git a/src/test/ui/codemap_tests/unicode.stderr b/src/test/ui/codemap_tests/unicode.stderr index b7ba4fa46d92b..357dd25389ecb 100644 --- a/src/test/ui/codemap_tests/unicode.stderr +++ b/src/test/ui/codemap_tests/unicode.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `路濫狼á́́` LL | extern "路濫狼á́́" fn foo() {} | ^^^^^^^^^ invalid ABI | - = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-abi.rs b/src/test/ui/feature-gates/feature-gate-abi.rs index 3883106a3af95..49cf2e158edfc 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.rs +++ b/src/test/ui/feature-gates/feature-gate-abi.rs @@ -10,9 +10,9 @@ // Functions extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change -//~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental -//~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "vectorcall" fn f3() {} //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change extern "msp430-interrupt" fn f5() {} //~ ERROR msp430-interrupt ABI is experimental @@ -21,13 +21,14 @@ extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn f8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn f9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" fn f10() {} //~ ERROR efiapi ABI is experimental and subject to change +extern "wasm" fn f11() {} //~ ERROR wasm ABI is experimental and subject to change // Methods in trait definition trait Tr { extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "vectorcall" fn m3(); //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change extern "msp430-interrupt" fn m5(); //~ ERROR msp430-interrupt ABI is experimental @@ -36,6 +37,7 @@ trait Tr { extern "thiscall" fn m8(); //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn m9(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" fn m10(); //~ ERROR efiapi ABI is experimental and subject to change + extern "wasm" fn m11() {} //~ ERROR wasm ABI is experimental and subject to change extern "vectorcall" fn dm3() {} //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change @@ -45,6 +47,7 @@ trait Tr { extern "thiscall" fn dm8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn dm9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" fn dm10() {} //~ ERROR efiapi ABI is experimental and subject to change + extern "wasm" fn dm11() {} //~ ERROR wasm ABI is experimental and subject to change } struct S; @@ -52,9 +55,9 @@ struct S; // Methods in trait impl impl Tr for S { extern "rust-intrinsic" fn m1() {} //~ ERROR intrinsics are subject to change - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "vectorcall" fn m3() {} //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change extern "msp430-interrupt" fn m5() {} //~ ERROR msp430-interrupt ABI is experimental @@ -63,14 +66,15 @@ impl Tr for S { extern "thiscall" fn m8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn m9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" fn m10() {} //~ ERROR efiapi ABI is experimental and subject to change + extern "wasm" fn m11() {} //~ ERROR wasm ABI is experimental and subject to change } // Methods in inherent impl impl S { extern "rust-intrinsic" fn im1() {} //~ ERROR intrinsics are subject to change - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental - //~^ ERROR intrinsic must be in + //~^ ERROR intrinsic must be in extern "vectorcall" fn im3() {} //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change extern "msp430-interrupt" fn im5() {} //~ ERROR msp430-interrupt ABI is experimental @@ -79,6 +83,7 @@ impl S { extern "thiscall" fn im8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn im9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" fn im10() {} //~ ERROR efiapi ABI is experimental and subject to change + extern "wasm" fn im11() {} //~ ERROR wasm ABI is experimental and subject to change } // Function pointer types @@ -87,11 +92,12 @@ type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are ex type A3 = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental and subject to change type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change type A5 = extern "msp430-interrupt" fn(); //~ ERROR msp430-interrupt ABI is experimental -type A6 = extern "ptx-kernel" fn (); //~ ERROR PTX ABIs are experimental and subject to change +type A6 = extern "ptx-kernel" fn(); //~ ERROR PTX ABIs are experimental and subject to change type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental type A8 = extern "thiscall" fn(); //~ ERROR thiscall is experimental and subject to change type A9 = extern "amdgpu-kernel" fn(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change type A10 = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental and subject to change +type A11 = extern "wasm" fn(); //~ ERROR wasm ABI is experimental and subject to change // Foreign modules extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change @@ -104,5 +110,6 @@ extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change extern "efiapi" {} //~ ERROR efiapi ABI is experimental and subject to change +extern "wasm" {} //~ ERROR wasm ABI is experimental and subject to change fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index eeeb349c66277..078d21ad36f90 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -85,8 +85,17 @@ LL | extern "efiapi" fn f10() {} = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:24:8 + | +LL | extern "wasm" fn f11() {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:27:12 + --> $DIR/feature-gate-abi.rs:28:12 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^ @@ -94,7 +103,7 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:29:12 + --> $DIR/feature-gate-abi.rs:30:12 | LL | extern "platform-intrinsic" fn m2(); | ^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +112,7 @@ LL | extern "platform-intrinsic" fn m2(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:31:12 + --> $DIR/feature-gate-abi.rs:32:12 | LL | extern "vectorcall" fn m3(); | ^^^^^^^^^^^^ @@ -111,7 +120,7 @@ LL | extern "vectorcall" fn m3(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:32:12 + --> $DIR/feature-gate-abi.rs:33:12 | LL | extern "rust-call" fn m4(_: ()); | ^^^^^^^^^^^ @@ -120,7 +129,7 @@ LL | extern "rust-call" fn m4(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:33:12 + --> $DIR/feature-gate-abi.rs:34:12 | LL | extern "msp430-interrupt" fn m5(); | ^^^^^^^^^^^^^^^^^^ @@ -129,7 +138,7 @@ LL | extern "msp430-interrupt" fn m5(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:34:12 + --> $DIR/feature-gate-abi.rs:35:12 | LL | extern "ptx-kernel" fn m6(); | ^^^^^^^^^^^^ @@ -138,7 +147,7 @@ LL | extern "ptx-kernel" fn m6(); = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:35:12 + --> $DIR/feature-gate-abi.rs:36:12 | LL | extern "x86-interrupt" fn m7(); | ^^^^^^^^^^^^^^^ @@ -147,7 +156,7 @@ LL | extern "x86-interrupt" fn m7(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:36:12 + --> $DIR/feature-gate-abi.rs:37:12 | LL | extern "thiscall" fn m8(); | ^^^^^^^^^^ @@ -155,7 +164,7 @@ LL | extern "thiscall" fn m8(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:37:12 + --> $DIR/feature-gate-abi.rs:38:12 | LL | extern "amdgpu-kernel" fn m9(); | ^^^^^^^^^^^^^^^ @@ -164,7 +173,7 @@ LL | extern "amdgpu-kernel" fn m9(); = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:38:12 + --> $DIR/feature-gate-abi.rs:39:12 | LL | extern "efiapi" fn m10(); | ^^^^^^^^ @@ -172,16 +181,25 @@ LL | extern "efiapi" fn m10(); = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: wasm ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:40:12 | +LL | extern "wasm" fn m11() {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-abi.rs:42:12 + | LL | extern "vectorcall" fn dm3() {} | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:41:12 + --> $DIR/feature-gate-abi.rs:43:12 | LL | extern "rust-call" fn dm4(_: ()) {} | ^^^^^^^^^^^ @@ -190,7 +208,7 @@ LL | extern "rust-call" fn dm4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:42:12 + --> $DIR/feature-gate-abi.rs:44:12 | LL | extern "msp430-interrupt" fn dm5() {} | ^^^^^^^^^^^^^^^^^^ @@ -199,7 +217,7 @@ LL | extern "msp430-interrupt" fn dm5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:43:12 + --> $DIR/feature-gate-abi.rs:45:12 | LL | extern "ptx-kernel" fn dm6() {} | ^^^^^^^^^^^^ @@ -208,7 +226,7 @@ LL | extern "ptx-kernel" fn dm6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:44:12 + --> $DIR/feature-gate-abi.rs:46:12 | LL | extern "x86-interrupt" fn dm7() {} | ^^^^^^^^^^^^^^^ @@ -217,7 +235,7 @@ LL | extern "x86-interrupt" fn dm7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:45:12 + --> $DIR/feature-gate-abi.rs:47:12 | LL | extern "thiscall" fn dm8() {} | ^^^^^^^^^^ @@ -225,7 +243,7 @@ LL | extern "thiscall" fn dm8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:46:12 + --> $DIR/feature-gate-abi.rs:48:12 | LL | extern "amdgpu-kernel" fn dm9() {} | ^^^^^^^^^^^^^^^ @@ -234,7 +252,7 @@ LL | extern "amdgpu-kernel" fn dm9() {} = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:47:12 + --> $DIR/feature-gate-abi.rs:49:12 | LL | extern "efiapi" fn dm10() {} | ^^^^^^^^ @@ -242,8 +260,17 @@ LL | extern "efiapi" fn dm10() {} = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:50:12 + | +LL | extern "wasm" fn dm11() {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:54:12 + --> $DIR/feature-gate-abi.rs:57:12 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^ @@ -251,7 +278,7 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:56:12 + --> $DIR/feature-gate-abi.rs:59:12 | LL | extern "platform-intrinsic" fn m2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -260,7 +287,7 @@ LL | extern "platform-intrinsic" fn m2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:58:12 + --> $DIR/feature-gate-abi.rs:61:12 | LL | extern "vectorcall" fn m3() {} | ^^^^^^^^^^^^ @@ -268,7 +295,7 @@ LL | extern "vectorcall" fn m3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:59:12 + --> $DIR/feature-gate-abi.rs:62:12 | LL | extern "rust-call" fn m4(_: ()) {} | ^^^^^^^^^^^ @@ -277,7 +304,7 @@ LL | extern "rust-call" fn m4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:60:12 + --> $DIR/feature-gate-abi.rs:63:12 | LL | extern "msp430-interrupt" fn m5() {} | ^^^^^^^^^^^^^^^^^^ @@ -286,7 +313,7 @@ LL | extern "msp430-interrupt" fn m5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:61:12 + --> $DIR/feature-gate-abi.rs:64:12 | LL | extern "ptx-kernel" fn m6() {} | ^^^^^^^^^^^^ @@ -295,7 +322,7 @@ LL | extern "ptx-kernel" fn m6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:62:12 + --> $DIR/feature-gate-abi.rs:65:12 | LL | extern "x86-interrupt" fn m7() {} | ^^^^^^^^^^^^^^^ @@ -304,7 +331,7 @@ LL | extern "x86-interrupt" fn m7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:63:12 + --> $DIR/feature-gate-abi.rs:66:12 | LL | extern "thiscall" fn m8() {} | ^^^^^^^^^^ @@ -312,7 +339,7 @@ LL | extern "thiscall" fn m8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:64:12 + --> $DIR/feature-gate-abi.rs:67:12 | LL | extern "amdgpu-kernel" fn m9() {} | ^^^^^^^^^^^^^^^ @@ -321,7 +348,7 @@ LL | extern "amdgpu-kernel" fn m9() {} = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:65:12 + --> $DIR/feature-gate-abi.rs:68:12 | LL | extern "efiapi" fn m10() {} | ^^^^^^^^ @@ -329,8 +356,17 @@ LL | extern "efiapi" fn m10() {} = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:69:12 + | +LL | extern "wasm" fn m11() {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:70:12 + --> $DIR/feature-gate-abi.rs:74:12 | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^ @@ -338,7 +374,7 @@ LL | extern "rust-intrinsic" fn im1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:72:12 + --> $DIR/feature-gate-abi.rs:76:12 | LL | extern "platform-intrinsic" fn im2() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -347,7 +383,7 @@ LL | extern "platform-intrinsic" fn im2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:74:12 + --> $DIR/feature-gate-abi.rs:78:12 | LL | extern "vectorcall" fn im3() {} | ^^^^^^^^^^^^ @@ -355,7 +391,7 @@ LL | extern "vectorcall" fn im3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:75:12 + --> $DIR/feature-gate-abi.rs:79:12 | LL | extern "rust-call" fn im4(_: ()) {} | ^^^^^^^^^^^ @@ -364,7 +400,7 @@ LL | extern "rust-call" fn im4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:76:12 + --> $DIR/feature-gate-abi.rs:80:12 | LL | extern "msp430-interrupt" fn im5() {} | ^^^^^^^^^^^^^^^^^^ @@ -373,7 +409,7 @@ LL | extern "msp430-interrupt" fn im5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:77:12 + --> $DIR/feature-gate-abi.rs:81:12 | LL | extern "ptx-kernel" fn im6() {} | ^^^^^^^^^^^^ @@ -382,7 +418,7 @@ LL | extern "ptx-kernel" fn im6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:78:12 + --> $DIR/feature-gate-abi.rs:82:12 | LL | extern "x86-interrupt" fn im7() {} | ^^^^^^^^^^^^^^^ @@ -391,7 +427,7 @@ LL | extern "x86-interrupt" fn im7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:79:12 + --> $DIR/feature-gate-abi.rs:83:12 | LL | extern "thiscall" fn im8() {} | ^^^^^^^^^^ @@ -399,7 +435,7 @@ LL | extern "thiscall" fn im8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:80:12 + --> $DIR/feature-gate-abi.rs:84:12 | LL | extern "amdgpu-kernel" fn im9() {} | ^^^^^^^^^^^^^^^ @@ -408,7 +444,7 @@ LL | extern "amdgpu-kernel" fn im9() {} = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:81:12 + --> $DIR/feature-gate-abi.rs:85:12 | LL | extern "efiapi" fn im10() {} | ^^^^^^^^ @@ -416,8 +452,17 @@ LL | extern "efiapi" fn im10() {} = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:86:12 + | +LL | extern "wasm" fn im11() {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:85:18 + --> $DIR/feature-gate-abi.rs:90:18 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -425,7 +470,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:86:18 + --> $DIR/feature-gate-abi.rs:91:18 | LL | type A2 = extern "platform-intrinsic" fn(); | ^^^^^^^^^^^^^^^^^^^^ @@ -434,7 +479,7 @@ LL | type A2 = extern "platform-intrinsic" fn(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:87:18 + --> $DIR/feature-gate-abi.rs:92:18 | LL | type A3 = extern "vectorcall" fn(); | ^^^^^^^^^^^^ @@ -442,7 +487,7 @@ LL | type A3 = extern "vectorcall" fn(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:88:18 + --> $DIR/feature-gate-abi.rs:93:18 | LL | type A4 = extern "rust-call" fn(_: ()); | ^^^^^^^^^^^ @@ -451,7 +496,7 @@ LL | type A4 = extern "rust-call" fn(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:89:18 + --> $DIR/feature-gate-abi.rs:94:18 | LL | type A5 = extern "msp430-interrupt" fn(); | ^^^^^^^^^^^^^^^^^^ @@ -460,16 +505,16 @@ LL | type A5 = extern "msp430-interrupt" fn(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:90:18 + --> $DIR/feature-gate-abi.rs:95:18 | -LL | type A6 = extern "ptx-kernel" fn (); +LL | type A6 = extern "ptx-kernel" fn(); | ^^^^^^^^^^^^ | = note: see issue #38788 for more information = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:91:18 + --> $DIR/feature-gate-abi.rs:96:18 | LL | type A7 = extern "x86-interrupt" fn(); | ^^^^^^^^^^^^^^^ @@ -478,7 +523,7 @@ LL | type A7 = extern "x86-interrupt" fn(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:92:18 + --> $DIR/feature-gate-abi.rs:97:18 | LL | type A8 = extern "thiscall" fn(); | ^^^^^^^^^^ @@ -486,7 +531,7 @@ LL | type A8 = extern "thiscall" fn(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:93:18 + --> $DIR/feature-gate-abi.rs:98:18 | LL | type A9 = extern "amdgpu-kernel" fn(); | ^^^^^^^^^^^^^^^ @@ -495,7 +540,7 @@ LL | type A9 = extern "amdgpu-kernel" fn(); = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:94:19 + --> $DIR/feature-gate-abi.rs:99:19 | LL | type A10 = extern "efiapi" fn(); | ^^^^^^^^ @@ -503,8 +548,17 @@ LL | type A10 = extern "efiapi" fn(); = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:100:19 + | +LL | type A11 = extern "wasm" fn(); + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:97:8 + --> $DIR/feature-gate-abi.rs:103:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -512,7 +566,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:98:8 + --> $DIR/feature-gate-abi.rs:104:8 | LL | extern "platform-intrinsic" {} | ^^^^^^^^^^^^^^^^^^^^ @@ -521,7 +575,7 @@ LL | extern "platform-intrinsic" {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:99:8 + --> $DIR/feature-gate-abi.rs:105:8 | LL | extern "vectorcall" {} | ^^^^^^^^^^^^ @@ -529,7 +583,7 @@ LL | extern "vectorcall" {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:100:8 + --> $DIR/feature-gate-abi.rs:106:8 | LL | extern "rust-call" {} | ^^^^^^^^^^^ @@ -538,7 +592,7 @@ LL | extern "rust-call" {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:101:8 + --> $DIR/feature-gate-abi.rs:107:8 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^ @@ -547,7 +601,7 @@ LL | extern "msp430-interrupt" {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:102:8 + --> $DIR/feature-gate-abi.rs:108:8 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^ @@ -556,7 +610,7 @@ LL | extern "ptx-kernel" {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:103:8 + --> $DIR/feature-gate-abi.rs:109:8 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^ @@ -565,7 +619,7 @@ LL | extern "x86-interrupt" {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:104:8 + --> $DIR/feature-gate-abi.rs:110:8 | LL | extern "thiscall" {} | ^^^^^^^^^^ @@ -573,7 +627,7 @@ LL | extern "thiscall" {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:105:8 + --> $DIR/feature-gate-abi.rs:111:8 | LL | extern "amdgpu-kernel" {} | ^^^^^^^^^^^^^^^ @@ -582,7 +636,7 @@ LL | extern "amdgpu-kernel" {} = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:106:8 + --> $DIR/feature-gate-abi.rs:112:8 | LL | extern "efiapi" {} | ^^^^^^^^ @@ -590,14 +644,23 @@ LL | extern "efiapi" {} = note: see issue #65815 for more information = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:113:8 + | +LL | extern "wasm" {} + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:27:32 + --> $DIR/feature-gate-abi.rs:28:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:29:36 + --> $DIR/feature-gate-abi.rs:30:36 | LL | extern "platform-intrinsic" fn m2(); | ^^ @@ -615,29 +678,29 @@ LL | extern "platform-intrinsic" fn f2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:54:37 + --> $DIR/feature-gate-abi.rs:57:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:56:41 + --> $DIR/feature-gate-abi.rs:59:41 | LL | extern "platform-intrinsic" fn m2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:70:38 + --> $DIR/feature-gate-abi.rs:74:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:72:42 + --> $DIR/feature-gate-abi.rs:76:42 | LL | extern "platform-intrinsic" fn im2() {} | ^^ -error: aborting due to 76 previous errors +error: aborting due to 83 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-wasm_abi.rs b/src/test/ui/feature-gates/feature-gate-wasm_abi.rs new file mode 100644 index 0000000000000..8c8de0763658e --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-wasm_abi.rs @@ -0,0 +1,7 @@ +extern "wasm" fn foo() { + //~^ ERROR: wasm ABI is experimental and subject to change +} + +fn main() { + foo(); +} diff --git a/src/test/ui/feature-gates/feature-gate-wasm_abi.stderr b/src/test/ui/feature-gates/feature-gate-wasm_abi.stderr new file mode 100644 index 0000000000000..c4113fd6af979 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-wasm_abi.stderr @@ -0,0 +1,12 @@ +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:1:8 + | +LL | extern "wasm" fn foo() { + | ^^^^^^ + | + = note: see issue #83788 for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/parser/issue-8537.stderr b/src/test/ui/parser/issue-8537.stderr index 85e2b77d867b9..5a29ce2221fc2 100644 --- a/src/test/ui/parser/issue-8537.stderr +++ b/src/test/ui/parser/issue-8537.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `invalid-ab_isize` LL | "invalid-ab_isize" | ^^^^^^^^^^^^^^^^^^ invalid ABI | - = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error From ffd7094f1d0f0a619b6d40d7f4705cbb04005e20 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 24 Feb 2021 16:16:49 -0500 Subject: [PATCH 02/10] Fix handling of `--output-format json` flag - Don't treat it as deprecated on stable and beta channels. Before, it would give confusing and incorrect output: ``` warning: the 'output-format' flag is considered deprecated | = warning: see issue #44136 for more information error: json output format isn't supported for doc generation ``` Both of those are wrong: output-format isn't deprecated, and json output is supported. - Require -Z unstable-options for `--output-format json` Previously, it was allowed by default on nightly, which made it hard to realize the flag wouldn't be accepted on beta or stable. Note that this still allows `--output-format html`, which has been stable since 1.0. - Remove unnecessary double-checking of the feature gate when parsing the output format - Add custom run-make test since compiletest passes -Zunstable-options by default --- src/librustdoc/config.rs | 27 +++++++++---------- .../run-make/unstable-flag-required/Makefile | 4 +++ .../run-make/unstable-flag-required/README.md | 3 +++ .../output-format-json.stderr | 2 ++ src/test/run-make/unstable-flag-required/x.rs | 1 + .../rustdoc-ui/output-format-html-stable.rs | 4 +++ src/tools/compiletest/src/runtest.rs | 2 +- 7 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 src/test/run-make/unstable-flag-required/Makefile create mode 100644 src/test/run-make/unstable-flag-required/README.md create mode 100644 src/test/run-make/unstable-flag-required/output-format-json.stderr create mode 100644 src/test/run-make/unstable-flag-required/x.rs create mode 100644 src/test/rustdoc-ui/output-format-html-stable.rs diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 821675bb9f542..2433f75c18962 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -379,6 +379,17 @@ impl Options { } } + // check for `--output-format=json` + if !matches!(matches.opt_str("output-format").as_deref(), None | Some("html")) + && !matches.opt_present("show-coverage") + && !nightly_options::is_unstable_enabled(matches) + { + rustc_session::early_error( + error_format, + "the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578)", + ); + } + let to_check = matches.opt_strs("check-theme"); if !to_check.is_empty() { let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes()); @@ -575,13 +586,7 @@ impl Options { let output_format = match matches.opt_str("output-format") { Some(s) => match OutputFormat::try_from(s.as_str()) { Ok(out_fmt) => { - if out_fmt.is_json() - && !(show_coverage || nightly_options::match_is_nightly_build(matches)) - { - diag.struct_err("json output format isn't supported for doc generation") - .emit(); - return Err(1); - } else if !out_fmt.is_json() && show_coverage { + if !out_fmt.is_json() && show_coverage { diag.struct_err( "html output format isn't supported for the --show-coverage option", ) @@ -703,16 +708,10 @@ impl Options { /// Prints deprecation warnings for deprecated options fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) { - let deprecated_flags = ["input-format", "output-format", "no-defaults", "passes"]; + let deprecated_flags = ["input-format", "no-defaults", "passes"]; for flag in deprecated_flags.iter() { if matches.opt_present(flag) { - if *flag == "output-format" - && (matches.opt_present("show-coverage") - || nightly_options::match_is_nightly_build(matches)) - { - continue; - } let mut err = diag.struct_warn(&format!("the `{}` flag is deprecated", flag)); err.note( "see issue #44136 \ diff --git a/src/test/run-make/unstable-flag-required/Makefile b/src/test/run-make/unstable-flag-required/Makefile new file mode 100644 index 0000000000000..b8769d5f69051 --- /dev/null +++ b/src/test/run-make/unstable-flag-required/Makefile @@ -0,0 +1,4 @@ +-include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr diff --git a/src/test/run-make/unstable-flag-required/README.md b/src/test/run-make/unstable-flag-required/README.md new file mode 100644 index 0000000000000..e5251fdf9b5d9 --- /dev/null +++ b/src/test/run-make/unstable-flag-required/README.md @@ -0,0 +1,3 @@ +This is a collection of tests that verify `--unstable-options` is required. +It should eventually be removed in favor of UI tests once compiletest stops +passing --unstable-options by default (#82639). diff --git a/src/test/run-make/unstable-flag-required/output-format-json.stderr b/src/test/run-make/unstable-flag-required/output-format-json.stderr new file mode 100644 index 0000000000000..fb4079beb2799 --- /dev/null +++ b/src/test/run-make/unstable-flag-required/output-format-json.stderr @@ -0,0 +1,2 @@ +error: the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578) + diff --git a/src/test/run-make/unstable-flag-required/x.rs b/src/test/run-make/unstable-flag-required/x.rs new file mode 100644 index 0000000000000..5df7576133a68 --- /dev/null +++ b/src/test/run-make/unstable-flag-required/x.rs @@ -0,0 +1 @@ +// nothing to see here diff --git a/src/test/rustdoc-ui/output-format-html-stable.rs b/src/test/rustdoc-ui/output-format-html-stable.rs new file mode 100644 index 0000000000000..fa0362640bb8f --- /dev/null +++ b/src/test/rustdoc-ui/output-format-html-stable.rs @@ -0,0 +1,4 @@ +// compile-flags: --output-format html +// check-pass +// This tests that `--output-format html` is accepted without `-Z unstable-options`, +// since it has been stable since 1.0. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index c2684bb4af3f6..7c8cd699fe0e7 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1600,7 +1600,7 @@ impl<'test> TestCx<'test> { .args(&self.props.compile_flags); if self.config.mode == RustdocJson { - rustdoc.arg("--output-format").arg("json"); + rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options"); } if let Some(ref linker) = self.config.linker { From d326c218efaa598e35ede0ef0607ac8e4eb9fea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 30 Mar 2021 10:01:22 -0700 Subject: [PATCH 03/10] Suggest Pin/Box/Arc for more cases --- .../rustc_typeck/src/check/method/suggest.rs | 105 +++++++++--------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 72eff009473a1..02fe8312c4c1f 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -987,59 +987,60 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let mut alt_rcvr_sugg = false; if let SelfSource::MethodCall(rcvr) = source { - info!(?span, ?item_name, ?rcvr_ty, ?rcvr); - if let ty::Adt(..) = rcvr_ty.kind() { - // Try alternative arbitrary self types that could fulfill this call. - // FIXME: probe for all types that *could* be arbitrary self-types, not - // just this list. - for (rcvr_ty, post) in &[ - (rcvr_ty, ""), - (self.tcx.mk_mut_ref(&ty::ReErased, rcvr_ty), "&mut "), - (self.tcx.mk_imm_ref(&ty::ReErased, rcvr_ty), "&"), + debug!(?span, ?item_name, ?rcvr_ty, ?rcvr); + // Try alternative arbitrary self types that could fulfill this call. + // FIXME: probe for all types that *could* be arbitrary self-types, not + // just this list. + for (rcvr_ty, post) in &[ + (rcvr_ty, ""), + (self.tcx.mk_mut_ref(&ty::ReErased, rcvr_ty), "&mut "), + (self.tcx.mk_imm_ref(&ty::ReErased, rcvr_ty), "&"), + ] { + for (rcvr_ty, pre) in &[ + (self.tcx.mk_lang_item(rcvr_ty, LangItem::OwnedBox), "Box::new"), + (self.tcx.mk_lang_item(rcvr_ty, LangItem::Pin), "Pin::new"), + (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Arc), "Arc::new"), + (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Rc), "Rc::new"), ] { - for (rcvr_ty, pre) in &[ - (self.tcx.mk_lang_item(rcvr_ty, LangItem::OwnedBox), "Box::new"), - (self.tcx.mk_lang_item(rcvr_ty, LangItem::Pin), "Pin::new"), - (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Arc), "Arc::new"), - (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Rc), "Rc::new"), - ] { - if let Some(new_rcvr_t) = *rcvr_ty { - if let Ok(pick) = self.lookup_probe( - span, - item_name, - new_rcvr_t, - rcvr, - crate::check::method::probe::ProbeScope::AllTraits, - ) { - debug!("try_alt_rcvr: pick candidate {:?}", pick); - // Make sure the method is defined for the *actual* receiver: - // we don't want to treat `Box` as a receiver if - // it only works because of an autoderef to `&self` - if pick.autoderefs == 0 - // We don't want to suggest a container type when the missing method is - // `.clone()`, otherwise we'd suggest `Arc::new(foo).clone()`, which is - // far from what the user really wants. - && Some(pick.item.container.id()) != self.tcx.lang_items().clone_trait() - { - err.span_label( - pick.item.ident.span, - &format!( - "the method is available for `{}` here", - new_rcvr_t - ), - ); - err.multipart_suggestion( - "consider wrapping the receiver expression with the \ - appropriate type", - vec![ - (rcvr.span.shrink_to_lo(), format!("{}({}", pre, post)), - (rcvr.span.shrink_to_hi(), ")".to_string()), - ], - Applicability::MaybeIncorrect, - ); - // We don't care about the other suggestions. - alt_rcvr_sugg = true; - } + if let Some(new_rcvr_t) = *rcvr_ty { + if let Ok(pick) = self.lookup_probe( + span, + item_name, + new_rcvr_t, + rcvr, + crate::check::method::probe::ProbeScope::AllTraits, + ) { + debug!("try_alt_rcvr: pick candidate {:?}", pick); + let did = Some(pick.item.container.id()); + // We don't want to suggest a container type when the missing + // method is `.clone()` or `.deref()` otherwise we'd suggest + // `Arc::new(foo).clone()`, which is far from what the user wants. + let skip = [ + self.tcx.lang_items().clone_trait(), + self.tcx.lang_items().deref_trait(), + self.tcx.lang_items().deref_mut_trait(), + self.tcx.lang_items().drop_trait(), + ] + .contains(&did); + // Make sure the method is defined for the *actual* receiver: we don't + // want to treat `Box` as a receiver if it only works because of + // an autoderef to `&self` + if pick.autoderefs == 0 && !skip { + err.span_label( + pick.item.ident.span, + &format!("the method is available for `{}` here", new_rcvr_t), + ); + err.multipart_suggestion( + "consider wrapping the receiver expression with the \ + appropriate type", + vec![ + (rcvr.span.shrink_to_lo(), format!("{}({}", pre, post)), + (rcvr.span.shrink_to_hi(), ")".to_string()), + ], + Applicability::MaybeIncorrect, + ); + // We don't care about the other suggestions. + alt_rcvr_sugg = true; } } } From 8bc558197862268f080e5df621e89f519a52950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 30 Mar 2021 13:37:30 -0700 Subject: [PATCH 04/10] Point at `impl` and type defs introducing requirements on E0277 --- compiler/rustc_middle/src/ty/mod.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 38 +++++++++++- .../associated-types/impl-wf-cycle-1.stderr | 18 +++++- .../associated-types/impl-wf-cycle-2.stderr | 12 +++- .../ui/associated-types/issue-44153.stderr | 6 +- .../ui/associated-types/issue-65774-1.stderr | 6 +- .../issue-72590-type-error-sized.stderr | 6 +- .../ui/async-await/pin-needed-to-poll-2.rs | 48 +++++++++++++++ .../async-await/pin-needed-to-poll-2.stderr | 16 +++++ src/test/ui/block-result/issue-22645.stderr | 6 +- .../builtin-superkinds-in-metadata.stderr | 6 +- .../ui/did_you_mean/recursion_limit.stderr | 60 +++++++++++++++---- src/test/ui/dst/dst-bad-deep.stderr | 12 +++- src/test/ui/error-codes/E0275.stderr | 6 +- src/test/ui/error-codes/E0277-2.stderr | 18 +++++- .../ui/extern/extern-types-unsized.stderr | 24 ++++++-- .../feature-gate-trivial_bounds.stderr | 6 +- src/test/ui/hrtb/issue-62203-hrtb-ice.stderr | 6 +- src/test/ui/issues/issue-18400.stderr | 6 +- src/test/ui/issues/issue-20413.stderr | 60 +++++++++++++++---- src/test/ui/issues/issue-22872.stderr | 6 +- src/test/ui/issues/issue-23122-2.stderr | 6 +- src/test/ui/issues/issue-38821.stderr | 6 +- src/test/ui/issues/issue-39970.stderr | 6 +- src/test/ui/issues/issue-40827.stderr | 24 ++++++-- src/test/ui/issues/issue-5883.stderr | 6 +- src/test/ui/issues/issue-7013.stderr | 6 +- .../kindck/kindck-impl-type-params-2.stderr | 6 +- .../ui/kindck/kindck-impl-type-params.stderr | 36 +++++++++-- .../kindck-inherited-copy-bound.curr.stderr | 6 +- ...copy-bound.object_safe_for_dispatch.stderr | 6 +- src/test/ui/mut/mutable-enum-indirect.stderr | 6 +- src/test/ui/no-send-res-ports.stderr | 12 +++- src/test/ui/no_send-enum.stderr | 6 +- src/test/ui/no_share-enum.stderr | 6 +- src/test/ui/phantom-auto-trait.stderr | 30 ++++++++-- .../recursion/recursive-requirements.stderr | 18 +++++- .../ui/specialization/issue-38091-2.stderr | 6 +- src/test/ui/specialization/issue-39448.stderr | 12 +++- src/test/ui/substs-ppaux.normal.stderr | 6 +- src/test/ui/substs-ppaux.verbose.stderr | 6 +- .../ui/traits/cycle-cache-err-60010.stderr | 18 +++++- .../ui/traits/inductive-overflow/lifetime.rs | 3 +- .../traits/inductive-overflow/lifetime.stderr | 6 +- .../inductive-overflow/simultaneous.stderr | 6 +- .../inductive-overflow/supertrait.stderr | 6 +- .../negated-auto-traits-error.stderr | 12 +++- .../ui/traits/suggest-where-clause.stderr | 6 +- ...ck-default-trait-impl-negation-sync.stderr | 12 +++- .../typeck/typeck-unsafe-always-share.stderr | 6 +- .../issue-50940-with-feature.stderr | 6 +- .../ui/unsized-locals/unsized-exprs.stderr | 12 +++- src/test/ui/unsized/unsized-enum2.stderr | 24 ++++++-- src/test/ui/unsized/unsized-struct.stderr | 6 +- src/test/ui/unsized3.stderr | 24 ++++++-- 55 files changed, 621 insertions(+), 110 deletions(-) create mode 100644 src/test/ui/async-await/pin-needed-to-poll-2.rs create mode 100644 src/test/ui/async-await/pin-needed-to-poll-2.stderr diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 6574c9382604b..414e1979c949a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1598,7 +1598,7 @@ impl<'tcx> TyCtxt<'tcx> { .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value()) } - fn item_name_from_hir(self, def_id: DefId) -> Option { + pub fn item_name_from_hir(self, def_id: DefId) -> Option { self.hir().get_if_local(def_id).and_then(|node| node.ident()) } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 2b8c8d3697384..edbef02df45e7 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2070,7 +2070,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // Don't print the tuple of capture types if !is_upvar_tys_infer_tuple { - err.note(&format!("required because it appears within the type `{}`", ty)); + let msg = format!("required because it appears within the type `{}`", ty); + match ty.kind() { + ty::Adt(def, _) => match self.tcx.item_name_from_hir(def.did) { + Some(ident) => err.span_note(ident.span, &msg), + None => err.note(&msg), + }, + _ => err.note(&msg), + }; } obligated_types.push(ty); @@ -2092,11 +2099,36 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ObligationCauseCode::ImplDerivedObligation(ref data) => { let mut parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_ref); let parent_def_id = parent_trait_ref.def_id(); - err.note(&format!( + let msg = format!( "required because of the requirements on the impl of `{}` for `{}`", parent_trait_ref.print_only_trait_path(), parent_trait_ref.skip_binder().self_ty() - )); + ); + let mut candidates = vec![]; + self.tcx.for_each_relevant_impl( + parent_def_id, + parent_trait_ref.self_ty().skip_binder(), + |impl_def_id| { + candidates.push(impl_def_id); + }, + ); + match &candidates[..] { + [def_id] => match self.tcx.hir().get_if_local(*def_id) { + Some(Node::Item(hir::Item { + kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }), + .. + })) => { + let mut spans = Vec::with_capacity(2); + if let Some(trait_ref) = of_trait { + spans.push(trait_ref.path.span); + } + spans.push(self_ty.span); + err.span_note(spans, &msg) + } + _ => err.note(&msg), + }, + _ => err.note(&msg), + }; let mut parent_predicate = parent_trait_ref.without_const().to_predicate(tcx); let mut data = data; diff --git a/src/test/ui/associated-types/impl-wf-cycle-1.stderr b/src/test/ui/associated-types/impl-wf-cycle-1.stderr index 82328048c99a3..1d8d2b0149d21 100644 --- a/src/test/ui/associated-types/impl-wf-cycle-1.stderr +++ b/src/test/ui/associated-types/impl-wf-cycle-1.stderr @@ -10,7 +10,11 @@ LL | | LL | | } | |_^ | - = note: required because of the requirements on the impl of `Grault` for `(T,)` +note: required because of the requirements on the impl of `Grault` for `(T,)` + --> $DIR/impl-wf-cycle-1.rs:15:17 + | +LL | impl Grault for (T,) + | ^^^^^^ ^^^^ = note: 1 redundant requirements hidden = note: required because of the requirements on the impl of `Grault` for `(T,)` @@ -20,7 +24,11 @@ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` LL | type A = (); | ^^^^^^^^^^^^ | - = note: required because of the requirements on the impl of `Grault` for `(T,)` +note: required because of the requirements on the impl of `Grault` for `(T,)` + --> $DIR/impl-wf-cycle-1.rs:15:17 + | +LL | impl Grault for (T,) + | ^^^^^^ ^^^^ = note: 1 redundant requirements hidden = note: required because of the requirements on the impl of `Grault` for `(T,)` @@ -30,7 +38,11 @@ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` LL | type B = bool; | ^^^^^^^^^^^^^^ | - = note: required because of the requirements on the impl of `Grault` for `(T,)` +note: required because of the requirements on the impl of `Grault` for `(T,)` + --> $DIR/impl-wf-cycle-1.rs:15:17 + | +LL | impl Grault for (T,) + | ^^^^^^ ^^^^ = note: 1 redundant requirements hidden = note: required because of the requirements on the impl of `Grault` for `(T,)` diff --git a/src/test/ui/associated-types/impl-wf-cycle-2.stderr b/src/test/ui/associated-types/impl-wf-cycle-2.stderr index 5cd18a33adf37..a17e63f28fe91 100644 --- a/src/test/ui/associated-types/impl-wf-cycle-2.stderr +++ b/src/test/ui/associated-types/impl-wf-cycle-2.stderr @@ -10,7 +10,11 @@ LL | | LL | | } | |_^ | - = note: required because of the requirements on the impl of `Grault` for `(T,)` +note: required because of the requirements on the impl of `Grault` for `(T,)` + --> $DIR/impl-wf-cycle-2.rs:7:17 + | +LL | impl Grault for (T,) + | ^^^^^^ ^^^^ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` --> $DIR/impl-wf-cycle-2.rs:11:5 @@ -18,7 +22,11 @@ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` LL | type A = (); | ^^^^^^^^^^^^ | - = note: required because of the requirements on the impl of `Grault` for `(T,)` +note: required because of the requirements on the impl of `Grault` for `(T,)` + --> $DIR/impl-wf-cycle-2.rs:7:17 + | +LL | impl Grault for (T,) + | ^^^^^^ ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-44153.stderr b/src/test/ui/associated-types/issue-44153.stderr index cafc8ec52ca76..b7db5d385829c 100644 --- a/src/test/ui/associated-types/issue-44153.stderr +++ b/src/test/ui/associated-types/issue-44153.stderr @@ -7,7 +7,11 @@ LL | fn visit() {} LL | <() as Visit>::visit(); | ^^^^^^^^^^^^^^^^^^^^ expected `&()`, found `()` | - = note: required because of the requirements on the impl of `Visit` for `()` +note: required because of the requirements on the impl of `Visit` for `()` + --> $DIR/issue-44153.rs:13:10 + | +LL | impl<'a> Visit for () where + | ^^^^^ ^^ error: aborting due to previous error diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index f644eb5a1f478..fc020e40b5ad2 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -13,7 +13,11 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied LL | let closure = |config: &mut ::MpuConfig| writer.my_write(&config); | ^^^^^^^ the trait `MyDisplay` is not implemented for `T` | - = note: required because of the requirements on the impl of `MyDisplay` for `&mut T` +note: required because of the requirements on the impl of `MyDisplay` for `&mut T` + --> $DIR/issue-65774-1.rs:5:24 + | +LL | impl<'a, T: MyDisplay> MyDisplay for &'a mut T { } + | ^^^^^^^^^ ^^^^^^^^^ = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/issue-72590-type-error-sized.stderr b/src/test/ui/async-await/issue-72590-type-error-sized.stderr index 0f90a4c336c57..50dfeffde7cf0 100644 --- a/src/test/ui/async-await/issue-72590-type-error-sized.stderr +++ b/src/test/ui/async-await/issue-72590-type-error-sized.stderr @@ -17,7 +17,11 @@ LL | async fn frob(self) {} | ^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `Sized` is not implemented for `str` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/issue-72590-type-error-sized.rs:5:8 + | +LL | struct Foo { + | ^^^ = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | diff --git a/src/test/ui/async-await/pin-needed-to-poll-2.rs b/src/test/ui/async-await/pin-needed-to-poll-2.rs new file mode 100644 index 0000000000000..6ce70336d0c63 --- /dev/null +++ b/src/test/ui/async-await/pin-needed-to-poll-2.rs @@ -0,0 +1,48 @@ +use std::{ + future::Future, + pin::Pin, + marker::Unpin, + task::{Context, Poll}, +}; + +struct Sleep(std::marker::PhantomPinned); + +impl Future for Sleep { + type Output = (); + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + Poll::Ready(()) + } +} + +impl Drop for Sleep { + fn drop(&mut self) {} +} + +fn sleep() -> Sleep { + Sleep(std::marker::PhantomPinned) +} + + +struct MyFuture { + sleep: Sleep, +} + +impl MyFuture { + fn new() -> Self { + Self { + sleep: sleep(), + } + } +} + +impl Future for MyFuture { + type Output = (); + + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + Pin::new(&mut self.sleep).poll(cx) + //~^ ERROR `PhantomPinned` cannot be unpinned + } +} + +fn main() {} diff --git a/src/test/ui/async-await/pin-needed-to-poll-2.stderr b/src/test/ui/async-await/pin-needed-to-poll-2.stderr new file mode 100644 index 0000000000000..31007cb40285e --- /dev/null +++ b/src/test/ui/async-await/pin-needed-to-poll-2.stderr @@ -0,0 +1,16 @@ +error[E0277]: `PhantomPinned` cannot be unpinned + --> $DIR/pin-needed-to-poll-2.rs:43:9 + | +LL | Pin::new(&mut self.sleep).poll(cx) + | ^^^^^^^^ within `Sleep`, the trait `Unpin` is not implemented for `PhantomPinned` + | +note: required because it appears within the type `Sleep` + --> $DIR/pin-needed-to-poll-2.rs:8:8 + | +LL | struct Sleep(std::marker::PhantomPinned); + | ^^^^^ + = note: required by `Pin::

::new` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/block-result/issue-22645.stderr b/src/test/ui/block-result/issue-22645.stderr index 6649e67a5093c..397bdac60513e 100644 --- a/src/test/ui/block-result/issue-22645.stderr +++ b/src/test/ui/block-result/issue-22645.stderr @@ -6,7 +6,11 @@ LL | b + 3 | = help: the following implementations were found: - = note: required because of the requirements on the impl of `Add<{integer}>` for `Bob` +note: required because of the requirements on the impl of `Add<{integer}>` for `Bob` + --> $DIR/issue-22645.rs:8:19 + | +LL | impl Add for Bob { + | ^^^^^^^^^ ^^^ error[E0308]: mismatched types --> $DIR/issue-22645.rs:15:3 diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr index 133508d39c105..0d1d747272d18 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr @@ -9,7 +9,11 @@ LL | impl RequiresRequiresShareAndSend for X { } LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } | ---- required by this bound in `RequiresRequiresShareAndSend` | - = note: required because it appears within the type `X` +note: required because it appears within the type `X` + --> $DIR/builtin-superkinds-in-metadata.rs:9:8 + | +LL | struct X(T); + | ^ help: consider further restricting this bound | LL | impl RequiresRequiresShareAndSend for X { } diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index c5b42416eac4a..2d52172a6fa53 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -8,16 +8,56 @@ LL | is_send::(); | ^^^^^^^^^^^^ | = help: consider adding a `#![recursion_limit="20"]` attribute to your crate (`recursion_limit`) - = note: required because it appears within the type `J` - = note: required because it appears within the type `I` - = note: required because it appears within the type `H` - = note: required because it appears within the type `G` - = note: required because it appears within the type `F` - = note: required because it appears within the type `E` - = note: required because it appears within the type `D` - = note: required because it appears within the type `C` - = note: required because it appears within the type `B` - = note: required because it appears within the type `A` +note: required because it appears within the type `J` + --> $DIR/recursion_limit.rs:24:9 + | +LL | link! { J, K } + | ^ +note: required because it appears within the type `I` + --> $DIR/recursion_limit.rs:23:9 + | +LL | link! { I, J } + | ^ +note: required because it appears within the type `H` + --> $DIR/recursion_limit.rs:22:9 + | +LL | link! { H, I } + | ^ +note: required because it appears within the type `G` + --> $DIR/recursion_limit.rs:21:9 + | +LL | link! { G, H } + | ^ +note: required because it appears within the type `F` + --> $DIR/recursion_limit.rs:20:9 + | +LL | link! { F, G } + | ^ +note: required because it appears within the type `E` + --> $DIR/recursion_limit.rs:19:9 + | +LL | link! { E, F } + | ^ +note: required because it appears within the type `D` + --> $DIR/recursion_limit.rs:18:9 + | +LL | link! { D, E } + | ^ +note: required because it appears within the type `C` + --> $DIR/recursion_limit.rs:17:9 + | +LL | link! { C, D } + | ^ +note: required because it appears within the type `B` + --> $DIR/recursion_limit.rs:16:9 + | +LL | link! { B, C } + | ^ +note: required because it appears within the type `A` + --> $DIR/recursion_limit.rs:15:9 + | +LL | link! { A, B } + | ^ error: aborting due to previous error diff --git a/src/test/ui/dst/dst-bad-deep.stderr b/src/test/ui/dst/dst-bad-deep.stderr index ea6b2390478ba..71e57b3e062b4 100644 --- a/src/test/ui/dst/dst-bad-deep.stderr +++ b/src/test/ui/dst/dst-bad-deep.stderr @@ -5,8 +5,16 @@ LL | let h: &Fat> = &Fat { ptr: *g }; | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Fat>`, the trait `Sized` is not implemented for `[isize]` - = note: required because it appears within the type `Fat<[isize]>` - = note: required because it appears within the type `Fat>` +note: required because it appears within the type `Fat<[isize]>` + --> $DIR/dst-bad-deep.rs:6:8 + | +LL | struct Fat { + | ^^^ +note: required because it appears within the type `Fat>` + --> $DIR/dst-bad-deep.rs:6:8 + | +LL | struct Fat { + | ^^^ = note: structs must have a statically known size to be initialized error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index 46966f22b6d1e..390c1e3e8ea4a 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -8,7 +8,11 @@ LL | impl Foo for T where Bar: Foo {} | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`E0275`) - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/E0275.rs:5:9 + | +LL | impl Foo for T where Bar: Foo {} + | ^^^ ^ = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `Bar` diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr index a0ab1641ca7c6..afd0e032dc3b3 100644 --- a/src/test/ui/error-codes/E0277-2.stderr +++ b/src/test/ui/error-codes/E0277-2.stderr @@ -8,9 +8,21 @@ LL | is_send::(); | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely | = help: within `Foo`, the trait `Send` is not implemented for `*const u8` - = note: required because it appears within the type `Baz` - = note: required because it appears within the type `Bar` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Baz` + --> $DIR/E0277-2.rs:9:8 + | +LL | struct Baz { + | ^^^ +note: required because it appears within the type `Bar` + --> $DIR/E0277-2.rs:5:8 + | +LL | struct Bar { + | ^^^ +note: required because it appears within the type `Foo` + --> $DIR/E0277-2.rs:1:8 + | +LL | struct Foo { + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 278db45655720..72e4be51822e2 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -23,7 +23,11 @@ LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `Sized` is not implemented for `A` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/extern-types-unsized.rs:9:8 + | +LL | struct Foo { + | ^^^ help: consider relaxing the implicit `Sized` restriction | LL | fn assert_sized() {} @@ -39,7 +43,11 @@ LL | assert_sized::>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar`, the trait `Sized` is not implemented for `A` - = note: required because it appears within the type `Bar` +note: required because it appears within the type `Bar` + --> $DIR/extern-types-unsized.rs:14:8 + | +LL | struct Bar { + | ^^^ help: consider relaxing the implicit `Sized` restriction | LL | fn assert_sized() {} @@ -55,8 +63,16 @@ LL | assert_sized::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar>`, the trait `Sized` is not implemented for `A` - = note: required because it appears within the type `Bar` - = note: required because it appears within the type `Bar>` +note: required because it appears within the type `Bar` + --> $DIR/extern-types-unsized.rs:14:8 + | +LL | struct Bar { + | ^^^ +note: required because it appears within the type `Bar>` + --> $DIR/extern-types-unsized.rs:14:8 + | +LL | struct Bar { + | ^^^ help: consider relaxing the implicit `Sized` restriction | LL | fn assert_sized() {} diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index f3fa641209563..78904b383f49a 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -107,7 +107,11 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: within `Dst<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)` - = note: required because it appears within the type `Dst<(dyn A + 'static)>` +note: required because it appears within the type `Dst<(dyn A + 'static)>` + --> $DIR/feature-gate-trivial_bounds.rs:48:8 + | +LL | struct Dst { + | ^^^ = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index 2342a4f6e172a..7b81beeed4167 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -15,7 +15,11 @@ error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42 LL | let v = Unit2.m( | ^ expected struct `Unit4`, found struct `Unit3` | - = note: required because of the requirements on the impl of `for<'r> T0<'r, (>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>` +note: required because of the requirements on the impl of `for<'r> T0<'r, (>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>` + --> $DIR/issue-62203-hrtb-ice.rs:17:16 + | +LL | impl<'a, A, T> T0<'a, A> for L + | ^^^^^^^^^ ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-18400.stderr b/src/test/ui/issues/issue-18400.stderr index 3bd9c656e8bd5..92d53088442e6 100644 --- a/src/test/ui/issues/issue-18400.stderr +++ b/src/test/ui/issues/issue-18400.stderr @@ -5,7 +5,11 @@ LL | 0.contains(bits); | ^^^^^^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_18400`) - = note: required because of the requirements on the impl of `Set<&[_]>` for `{integer}` +note: required because of the requirements on the impl of `Set<&[_]>` for `{integer}` + --> $DIR/issue-18400.rs:6:16 + | +LL | impl<'a, T, S> Set<&'a [T]> for S where + | ^^^^^^^^^^^^ ^ = note: 128 redundant requirements hidden = note: required because of the requirements on the impl of `Set<&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[_]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]>` for `{integer}` diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index b167bb77b5101..7fb1e3f2bba4f 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -16,7 +16,11 @@ LL | impl Foo for T where NoData: Foo { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Foo` for `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Foo` for `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:8:9 + | +LL | impl Foo for T where NoData: Foo { + | ^^^ ^ = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `NoData` @@ -30,8 +34,16 @@ LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` @@ -45,8 +57,16 @@ LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` @@ -60,7 +80,11 @@ LL | impl Foo for T where NoData: Foo { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Foo` for `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Foo` for `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:8:9 + | +LL | impl Foo for T where NoData: Foo { + | ^^^ ^ = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `NoData` @@ -74,8 +98,16 @@ LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` @@ -89,8 +121,16 @@ LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`) - = note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` diff --git a/src/test/ui/issues/issue-22872.stderr b/src/test/ui/issues/issue-22872.stderr index c65a97d999998..fd3db9546991c 100644 --- a/src/test/ui/issues/issue-22872.stderr +++ b/src/test/ui/issues/issue-22872.stderr @@ -5,7 +5,11 @@ LL | let _: Box Wrap<'b>> = Box::new(Wrapper(process)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `

>::Item` is not an iterator | = help: the trait `Iterator` is not implemented for `

>::Item` - = note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper

` +note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper

` + --> $DIR/issue-22872.rs:7:13 + | +LL | impl<'b, P> Wrap<'b> for Wrapper

+ | ^^^^^^^^ ^^^^^^^^^^ = note: required for the cast to the object type `dyn for<'b> Wrap<'b>` help: consider further restricting the associated type | diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index ce3bffe602ca0..5008a499986d4 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -5,7 +5,11 @@ LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) - = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` +note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` + --> $DIR/issue-23122-2.rs:8:15 + | +LL | impl Next for GetNext { + | ^^^^ ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38821.stderr b/src/test/ui/issues/issue-38821.stderr index e355094261de1..296efab7512f1 100644 --- a/src/test/ui/issues/issue-38821.stderr +++ b/src/test/ui/issues/issue-38821.stderr @@ -4,7 +4,11 @@ error[E0277]: the trait bound `::SqlType: NotNull` is not sat LL | #[derive(Debug, Copy, Clone)] | ^^^^ the trait `NotNull` is not implemented for `::SqlType` | - = note: required because of the requirements on the impl of `IntoNullable` for `::SqlType` +note: required because of the requirements on the impl of `IntoNullable` for `::SqlType` + --> $DIR/issue-38821.rs:9:18 + | +LL | impl IntoNullable for T { + | ^^^^^^^^^^^^ ^ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39970.stderr b/src/test/ui/issues/issue-39970.stderr index 8ecde9d1e68e1..2a0693a581c31 100644 --- a/src/test/ui/issues/issue-39970.stderr +++ b/src/test/ui/issues/issue-39970.stderr @@ -7,7 +7,11 @@ LL | fn visit() {} LL | <() as Visit>::visit(); | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()` | - = note: required because of the requirements on the impl of `Visit` for `()` +note: required because of the requirements on the impl of `Visit` for `()` + --> $DIR/issue-39970.rs:13:6 + | +LL | impl Visit for () where + | ^^^^^ ^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40827.stderr b/src/test/ui/issues/issue-40827.stderr index 95cacbc32ab69..38c3af935c564 100644 --- a/src/test/ui/issues/issue-40827.stderr +++ b/src/test/ui/issues/issue-40827.stderr @@ -8,9 +8,17 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `Rc` cannot be shared between threads safely | = help: within `Bar`, the trait `Sync` is not implemented for `Rc` - = note: required because it appears within the type `Bar` +note: required because it appears within the type `Bar` + --> $DIR/issue-40827.rs:6:6 + | +LL | enum Bar { + | ^^^ = note: required because of the requirements on the impl of `Send` for `Arc` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/issue-40827.rs:4:8 + | +LL | struct Foo(Arc); + | ^^^ error[E0277]: `Rc` cannot be sent between threads safely --> $DIR/issue-40827.rs:14:5 @@ -22,9 +30,17 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `Rc` cannot be sent between threads safely | = help: within `Bar`, the trait `Send` is not implemented for `Rc` - = note: required because it appears within the type `Bar` +note: required because it appears within the type `Bar` + --> $DIR/issue-40827.rs:6:6 + | +LL | enum Bar { + | ^^^ = note: required because of the requirements on the impl of `Send` for `Arc` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/issue-40827.rs:4:8 + | +LL | struct Foo(Arc); + | ^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 5798733e04be0..48879eb798f06 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -21,7 +21,11 @@ LL | Struct { r: r } | --------------- this returned value is of type `Struct` | = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` - = note: required because it appears within the type `Struct` +note: required because it appears within the type `Struct` + --> $DIR/issue-5883.rs:3:8 + | +LL | struct Struct { + | ^^^^^^ = note: the return type of a function must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-7013.stderr b/src/test/ui/issues/issue-7013.stderr index 5f3156a540271..98ed67507b1d8 100644 --- a/src/test/ui/issues/issue-7013.stderr +++ b/src/test/ui/issues/issue-7013.stderr @@ -6,7 +6,11 @@ LL | let a = A {v: box B{v: None} as Box}; | = help: within `B`, the trait `Send` is not implemented for `Rc>` = note: required because it appears within the type `Option>>` - = note: required because it appears within the type `B` +note: required because it appears within the type `B` + --> $DIR/issue-7013.rs:10:8 + | +LL | struct B { + | ^ = note: required for the cast to the object type `dyn Foo + Send` error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-impl-type-params-2.stderr b/src/test/ui/kindck/kindck-impl-type-params-2.stderr index 7e0f6e0b2de91..c635ebdbb7f46 100644 --- a/src/test/ui/kindck/kindck-impl-type-params-2.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params-2.stderr @@ -7,7 +7,11 @@ LL | fn take_param(foo: &T) { } LL | take_param(&x); | ^^ the trait `Copy` is not implemented for `Box<{integer}>` | - = note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` +note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` + --> $DIR/kindck-impl-type-params-2.rs:6:14 + | +LL | impl Foo for T { + | ^^^ ^ error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 472a6bcafa273..241fe367fd339 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -4,7 +4,11 @@ error[E0277]: `T` cannot be sent between threads safely LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -17,7 +21,11 @@ error[E0277]: the trait bound `T: Copy` is not satisfied LL | let a = &t as &dyn Gettable; | ^^ the trait `Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -30,7 +38,11 @@ error[E0277]: `T` cannot be sent between threads safely LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -43,7 +55,11 @@ error[E0277]: the trait bound `T: Copy` is not satisfied LL | let a: &dyn Gettable = &t; | ^^ the trait `Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -64,7 +80,11 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `Foo: Copy` is not satisfied @@ -73,7 +93,11 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error: aborting due to 7 previous errors diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr index 64e56f8c79043..86eaca83f2040 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -7,7 +7,11 @@ LL | fn take_param(foo: &T) { } LL | take_param(&x); | ^^ the trait `Copy` is not implemented for `Box<{integer}>` | - = note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` +note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` + --> $DIR/kindck-inherited-copy-bound.rs:14:14 + | +LL | impl Foo for T { + | ^^^ ^ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:28:19 diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr index 57f7551fd4018..49c5cd40b589a 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr @@ -7,7 +7,11 @@ LL | fn take_param(foo: &T) { } LL | take_param(&x); | ^^ the trait `Copy` is not implemented for `Box<{integer}>` | - = note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` +note: required because of the requirements on the impl of `Foo` for `Box<{integer}>` + --> $DIR/kindck-inherited-copy-bound.rs:14:14 + | +LL | impl Foo for T { + | ^^^ ^ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:28:13 diff --git a/src/test/ui/mut/mutable-enum-indirect.stderr b/src/test/ui/mut/mutable-enum-indirect.stderr index 3be6acb41a947..5b26f94115ac9 100644 --- a/src/test/ui/mut/mutable-enum-indirect.stderr +++ b/src/test/ui/mut/mutable-enum-indirect.stderr @@ -8,7 +8,11 @@ LL | bar(&x); | ^^^ `NoSync` cannot be shared between threads safely | = help: within `&Foo`, the trait `Sync` is not implemented for `NoSync` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/mutable-enum-indirect.rs:11:6 + | +LL | enum Foo { A(NoSync) } + | ^^^ = note: required because it appears within the type `&Foo` error: aborting due to previous error diff --git a/src/test/ui/no-send-res-ports.stderr b/src/test/ui/no-send-res-ports.stderr index ef7fb4ad7b266..2ee32029b40dc 100644 --- a/src/test/ui/no-send-res-ports.stderr +++ b/src/test/ui/no-send-res-ports.stderr @@ -17,8 +17,16 @@ LL | F: Send + 'static, | ---- required by this bound in `spawn` | = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]`, the trait `Send` is not implemented for `Rc<()>` - = note: required because it appears within the type `Port<()>` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Port<()>` + --> $DIR/no-send-res-ports.rs:5:8 + | +LL | struct Port(Rc); + | ^^^^ +note: required because it appears within the type `Foo` + --> $DIR/no-send-res-ports.rs:9:12 + | +LL | struct Foo { + | ^^^ = note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]` error: aborting due to previous error diff --git a/src/test/ui/no_send-enum.stderr b/src/test/ui/no_send-enum.stderr index b617fe410fa9b..9d755839d37c1 100644 --- a/src/test/ui/no_send-enum.stderr +++ b/src/test/ui/no_send-enum.stderr @@ -8,7 +8,11 @@ LL | bar(x); | ^^^ `NoSend` cannot be sent between threads safely | = help: within `Foo`, the trait `Send` is not implemented for `NoSend` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/no_send-enum.rs:8:6 + | +LL | enum Foo { + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/no_share-enum.stderr b/src/test/ui/no_share-enum.stderr index 4a93edc100ec6..a8ab69200ecf1 100644 --- a/src/test/ui/no_share-enum.stderr +++ b/src/test/ui/no_share-enum.stderr @@ -8,7 +8,11 @@ LL | bar(x); | ^^^ `NoSync` cannot be shared between threads safely | = help: within `Foo`, the trait `Sync` is not implemented for `NoSync` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/no_share-enum.rs:8:6 + | +LL | enum Foo { A(NoSync) } + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/phantom-auto-trait.stderr b/src/test/ui/phantom-auto-trait.stderr index 5a2ad637e4204..de13176ddc2a5 100644 --- a/src/test/ui/phantom-auto-trait.stderr +++ b/src/test/ui/phantom-auto-trait.stderr @@ -7,9 +7,17 @@ LL | fn is_zen(_: T) {} LL | is_zen(x) | ^ `T` cannot be shared between threads safely | - = note: required because of the requirements on the impl of `Zen` for `&T` +note: required because of the requirements on the impl of `Zen` for `&T` + --> $DIR/phantom-auto-trait.rs:10:24 + | +LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} + | ^^^ ^^^^^ = note: required because it appears within the type `PhantomData<&T>` - = note: required because it appears within the type `Guard<'_, T>` +note: required because it appears within the type `Guard<'_, T>` + --> $DIR/phantom-auto-trait.rs:12:8 + | +LL | struct Guard<'a, T: 'a> { + | ^^^^^ help: consider restricting type parameter `T` | LL | fn not_sync(x: Guard) { @@ -24,10 +32,22 @@ LL | fn is_zen(_: T) {} LL | is_zen(x) | ^ `T` cannot be shared between threads safely | - = note: required because of the requirements on the impl of `Zen` for `&T` +note: required because of the requirements on the impl of `Zen` for `&T` + --> $DIR/phantom-auto-trait.rs:10:24 + | +LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} + | ^^^ ^^^^^ = note: required because it appears within the type `PhantomData<&T>` - = note: required because it appears within the type `Guard<'_, T>` - = note: required because it appears within the type `Nested>` +note: required because it appears within the type `Guard<'_, T>` + --> $DIR/phantom-auto-trait.rs:12:8 + | +LL | struct Guard<'a, T: 'a> { + | ^^^^^ +note: required because it appears within the type `Nested>` + --> $DIR/phantom-auto-trait.rs:16:8 + | +LL | struct Nested(T); + | ^^^^^^ help: consider restricting type parameter `T` | LL | fn nested_not_sync(x: Nested>) { diff --git a/src/test/ui/recursion/recursive-requirements.stderr b/src/test/ui/recursion/recursive-requirements.stderr index 6c0be0f7f8d77..0518cc507b50b 100644 --- a/src/test/ui/recursion/recursive-requirements.stderr +++ b/src/test/ui/recursion/recursive-requirements.stderr @@ -8,7 +8,11 @@ LL | let _: AssertSync = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Bar` cannot be shared between threads safely | = help: within `Foo`, the trait `Sync` is not implemented for `*const Bar` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/recursive-requirements.rs:5:12 + | +LL | pub struct Foo { + | ^^^ error[E0277]: `*const Foo` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:16:12 @@ -20,9 +24,17 @@ LL | let _: AssertSync = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Foo` cannot be shared between threads safely | = help: within `Foo`, the trait `Sync` is not implemented for `*const Foo` - = note: required because it appears within the type `Bar` +note: required because it appears within the type `Bar` + --> $DIR/recursive-requirements.rs:10:12 + | +LL | pub struct Bar { + | ^^^ = note: required because it appears within the type `PhantomData` - = note: required because it appears within the type `Foo` +note: required because it appears within the type `Foo` + --> $DIR/recursive-requirements.rs:5:12 + | +LL | pub struct Foo { + | ^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/specialization/issue-38091-2.stderr b/src/test/ui/specialization/issue-38091-2.stderr index bd5ed498d92ca..a93f27ff051fc 100644 --- a/src/test/ui/specialization/issue-38091-2.stderr +++ b/src/test/ui/specialization/issue-38091-2.stderr @@ -10,7 +10,11 @@ LL | #![feature(specialization)] error[E0275]: overflow evaluating the requirement `i32: Check` | - = note: required because of the requirements on the impl of `Iterate` for `i32` +note: required because of the requirements on the impl of `Iterate` for `i32` + --> $DIR/issue-38091-2.rs:11:13 + | +LL | impl<'a, T> Iterate<'a> for T + | ^^^^^^^^^^^ ^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/specialization/issue-39448.stderr b/src/test/ui/specialization/issue-39448.stderr index 98e49b1bab3b7..c4fc44c737ec1 100644 --- a/src/test/ui/specialization/issue-39448.stderr +++ b/src/test/ui/specialization/issue-39448.stderr @@ -14,8 +14,16 @@ error[E0275]: overflow evaluating the requirement `T: FromA` LL | x.foo(y.to()).to() | ^^ | - = note: required because of the requirements on the impl of `FromA` for `T` - = note: required because of the requirements on the impl of `ToA` for `U` +note: required because of the requirements on the impl of `FromA` for `T` + --> $DIR/issue-39448.rs:24:29 + | +LL | impl> FromA for U { + | ^^^^^^^^ ^ +note: required because of the requirements on the impl of `ToA` for `U` + --> $DIR/issue-39448.rs:34:12 + | +LL | impl ToA for T + | ^^^^^^ ^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index 89be3d29e0cff..5bbf4225812b6 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -80,7 +80,11 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str` +note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str` + --> $DIR/substs-ppaux.rs:11:17 + | +LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} + | ^^^^^^^^^^^^^^ ^ error: aborting due to 5 previous errors diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index e37d087fcc958..20d7655337448 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -80,7 +80,11 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str` +note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str` + --> $DIR/substs-ppaux.rs:11:17 + | +LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} + | ^^^^^^^^^^^^^^ ^ error: aborting due to 5 previous errors diff --git a/src/test/ui/traits/cycle-cache-err-60010.stderr b/src/test/ui/traits/cycle-cache-err-60010.stderr index b2702d977f8b6..40386f706132b 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.stderr +++ b/src/test/ui/traits/cycle-cache-err-60010.stderr @@ -10,9 +10,21 @@ LL | SourceDatabase::parse(db); = note: required because it appears within the type `*const SalsaStorage` = note: required because it appears within the type `Unique` = note: required because it appears within the type `Box` - = note: required because it appears within the type `Runtime` - = note: required because it appears within the type `RootDatabase` - = note: required because of the requirements on the impl of `SourceDatabase` for `RootDatabase` +note: required because it appears within the type `Runtime` + --> $DIR/cycle-cache-err-60010.rs:23:8 + | +LL | struct Runtime { + | ^^^^^^^ +note: required because it appears within the type `RootDatabase` + --> $DIR/cycle-cache-err-60010.rs:20:8 + | +LL | struct RootDatabase { + | ^^^^^^^^^^^^ +note: required because of the requirements on the impl of `SourceDatabase` for `RootDatabase` + --> $DIR/cycle-cache-err-60010.rs:43:9 + | +LL | impl SourceDatabase for T + | ^^^^^^^^^^^^^^ ^ error: aborting due to previous error diff --git a/src/test/ui/traits/inductive-overflow/lifetime.rs b/src/test/ui/traits/inductive-overflow/lifetime.rs index 205d50a2ed9ce..e23dfa57cd0d4 100644 --- a/src/test/ui/traits/inductive-overflow/lifetime.rs +++ b/src/test/ui/traits/inductive-overflow/lifetime.rs @@ -16,7 +16,7 @@ struct C<'a>(&'a ()); struct X(T::P); impl NotAuto for Box {} -impl NotAuto for X where T::P: NotAuto {} +impl NotAuto for X where T::P: NotAuto {} //~ NOTE: required impl<'a> NotAuto for C<'a> {} fn is_send() {} @@ -26,5 +26,4 @@ fn main() { // Should only be a few notes. is_send::>>(); //~^ ERROR overflow evaluating - //~| NOTE: required } diff --git a/src/test/ui/traits/inductive-overflow/lifetime.stderr b/src/test/ui/traits/inductive-overflow/lifetime.stderr index 659f9e26e3e62..752154b35cabe 100644 --- a/src/test/ui/traits/inductive-overflow/lifetime.stderr +++ b/src/test/ui/traits/inductive-overflow/lifetime.stderr @@ -7,7 +7,11 @@ LL | fn is_send() {} LL | is_send::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: required because of the requirements on the impl of `NotAuto` for `X>` +note: required because of the requirements on the impl of `NotAuto` for `X>` + --> $DIR/lifetime.rs:19:12 + | +LL | impl NotAuto for X where T::P: NotAuto {} + | ^^^^^^^ ^^^^ error: aborting due to previous error diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.stderr b/src/test/ui/traits/inductive-overflow/simultaneous.stderr index 88e0631eeb27a..94a255fcb84de 100644 --- a/src/test/ui/traits/inductive-overflow/simultaneous.stderr +++ b/src/test/ui/traits/inductive-overflow/simultaneous.stderr @@ -7,7 +7,11 @@ LL | fn is_ee(t: T) { LL | is_ee(4); | ^^^^^ | - = note: required because of the requirements on the impl of `Combo` for `{integer}` +note: required because of the requirements on the impl of `Combo` for `{integer}` + --> $DIR/simultaneous.rs:11:34 + | +LL | impl Combo for T {} + | ^^^^^ ^ error: aborting due to previous error diff --git a/src/test/ui/traits/inductive-overflow/supertrait.stderr b/src/test/ui/traits/inductive-overflow/supertrait.stderr index dfb967601e987..5ed1c2cc2da6f 100644 --- a/src/test/ui/traits/inductive-overflow/supertrait.stderr +++ b/src/test/ui/traits/inductive-overflow/supertrait.stderr @@ -7,7 +7,11 @@ LL | fn copy(x: T) -> (T, T) { (x, x) } LL | let (a, b) = copy(NoClone); | ^^^^ | - = note: required because of the requirements on the impl of `Magic` for `NoClone` +note: required because of the requirements on the impl of `Magic` for `NoClone` + --> $DIR/supertrait.rs:5:16 + | +LL | impl Magic for T {} + | ^^^^^ ^ error: aborting due to previous error diff --git a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr index 83b1b83d1939d..4f7d1be793891 100644 --- a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -69,7 +69,11 @@ LL | is_send(Box::new(Outer2(TestType))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely | = help: within `Outer2`, the trait `Send` is not implemented for `dummy3::TestType` - = note: required because it appears within the type `Outer2` +note: required because it appears within the type `Outer2` + --> $DIR/negated-auto-traits-error.rs:12:8 + | +LL | struct Outer2(T); + | ^^^^^^ = note: required because of the requirements on the impl of `Send` for `Unique>` = note: required because it appears within the type `Box>` @@ -86,7 +90,11 @@ LL | is_sync(Outer2(TestType)); | help: consider borrowing here: `&Outer2(TestType)` | = note: the trait bound `main::TestType: Sync` is not satisfied - = note: required because of the requirements on the impl of `Sync` for `Outer2` +note: required because of the requirements on the impl of `Sync` for `Outer2` + --> $DIR/negated-auto-traits-error.rs:14:22 + | +LL | unsafe impl Sync for Outer2 {} + | ^^^^ ^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/traits/suggest-where-clause.stderr b/src/test/ui/traits/suggest-where-clause.stderr index efab64205f3af..025706480821d 100644 --- a/src/test/ui/traits/suggest-where-clause.stderr +++ b/src/test/ui/traits/suggest-where-clause.stderr @@ -26,7 +26,11 @@ LL | mem::size_of::>(); LL | pub const fn size_of() -> usize { | - required by this bound in `std::mem::size_of` | - = note: required because it appears within the type `Misc` +note: required because it appears within the type `Misc` + --> $DIR/suggest-where-clause.rs:3:8 + | +LL | struct Misc(T); + | ^^^^ error[E0277]: the trait bound `u64: From` is not satisfied --> $DIR/suggest-where-clause.rs:15:5 diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index 1f21e12597001..a9b49ee32630b 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -19,7 +19,11 @@ LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell` cannot be shared between threads safely | = help: within `MyTypeWUnsafe`, the trait `Sync` is not implemented for `UnsafeCell` - = note: required because it appears within the type `MyTypeWUnsafe` +note: required because it appears within the type `MyTypeWUnsafe` + --> $DIR/typeck-default-trait-impl-negation-sync.rs:21:8 + | +LL | struct MyTypeWUnsafe { + | ^^^^^^^^^^^^^ error[E0277]: `Managed` cannot be shared between threads safely --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:5 @@ -31,7 +35,11 @@ LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely | = help: within `MyTypeManaged`, the trait `Sync` is not implemented for `Managed` - = note: required because it appears within the type `MyTypeManaged` +note: required because it appears within the type `MyTypeManaged` + --> $DIR/typeck-default-trait-impl-negation-sync.rs:25:8 + | +LL | struct MyTypeManaged { + | ^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/typeck-unsafe-always-share.stderr b/src/test/ui/typeck/typeck-unsafe-always-share.stderr index 2a6ae736d7a8d..91585e78d4b93 100644 --- a/src/test/ui/typeck/typeck-unsafe-always-share.stderr +++ b/src/test/ui/typeck/typeck-unsafe-always-share.stderr @@ -30,7 +30,11 @@ LL | test(ms); | ^^^^ `UnsafeCell` cannot be shared between threads safely | = help: within `MySync`, the trait `Sync` is not implemented for `UnsafeCell` - = note: required because it appears within the type `MySync` +note: required because it appears within the type `MySync` + --> $DIR/typeck-unsafe-always-share.rs:8:8 + | +LL | struct MySync { + | ^^^^^^ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/typeck-unsafe-always-share.rs:30:10 diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr index 1b1a584a01ff1..4523d41b60060 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr @@ -14,7 +14,11 @@ LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: within `A`, the trait `Sized` is not implemented for `str` - = note: required because it appears within the type `A` +note: required because it appears within the type `A` + --> $DIR/issue-50940-with-feature.rs:5:12 + | +LL | struct A(X); + | ^ = note: the return type of a function must have a statically known size error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/unsized-locals/unsized-exprs.stderr b/src/test/ui/unsized-locals/unsized-exprs.stderr index 9fb401aec2cfa..a7f57e3fd1566 100644 --- a/src/test/ui/unsized-locals/unsized-exprs.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs.stderr @@ -15,7 +15,11 @@ LL | udrop::>(A { 0: *foo() }); | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `Sized` is not implemented for `[u8]` - = note: required because it appears within the type `A<[u8]>` +note: required because it appears within the type `A<[u8]>` + --> $DIR/unsized-exprs.rs:3:8 + | +LL | struct A(X); + | ^ = note: structs must have a statically known size to be initialized error[E0277]: the size for values of type `[u8]` cannot be known at compilation time @@ -25,7 +29,11 @@ LL | udrop::>(A(*foo())); | ^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `Sized` is not implemented for `[u8]` - = note: required because it appears within the type `A<[u8]>` +note: required because it appears within the type `A<[u8]>` + --> $DIR/unsized-exprs.rs:3:8 + | +LL | struct A(X); + | ^ = note: the return type of a function must have a statically known size error: aborting due to 3 previous errors diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 79f690e8d1a83..1b6c85858159d 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -301,7 +301,11 @@ LL | VI(Path1), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path1`, the trait `Sized` is not implemented for `(dyn PathHelper1 + 'static)` - = note: required because it appears within the type `Path1` +note: required because it appears within the type `Path1` + --> $DIR/unsized-enum2.rs:16:8 + | +LL | struct Path1(dyn PathHelper1); + | ^^^^^ = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -320,7 +324,11 @@ LL | VJ{x: Path2}, | ^^^^^ doesn't have a size known at compile-time | = help: within `Path2`, the trait `Sized` is not implemented for `(dyn PathHelper2 + 'static)` - = note: required because it appears within the type `Path2` +note: required because it appears within the type `Path2` + --> $DIR/unsized-enum2.rs:17:8 + | +LL | struct Path2(dyn PathHelper2); + | ^^^^^ = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -339,7 +347,11 @@ LL | VK(isize, Path3), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path3`, the trait `Sized` is not implemented for `(dyn PathHelper3 + 'static)` - = note: required because it appears within the type `Path3` +note: required because it appears within the type `Path3` + --> $DIR/unsized-enum2.rs:18:8 + | +LL | struct Path3(dyn PathHelper3); + | ^^^^^ = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -358,7 +370,11 @@ LL | VL{u: isize, x: Path4}, | ^^^^^ doesn't have a size known at compile-time | = help: within `Path4`, the trait `Sized` is not implemented for `(dyn PathHelper4 + 'static)` - = note: required because it appears within the type `Path4` +note: required because it appears within the type `Path4` + --> $DIR/unsized-enum2.rs:19:8 + | +LL | struct Path4(dyn PathHelper4); + | ^^^^^ = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 52cf1cbb81d7f..e38375bff46cf 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -28,7 +28,11 @@ LL | fn bar2() { is_sized::>() } | | | this type parameter needs to be `std::marker::Sized` | - = note: required because it appears within the type `Bar` +note: required because it appears within the type `Bar` + --> $DIR/unsized-struct.rs:11:8 + | +LL | struct Bar { data: T } + | ^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index ddddae4eaba57..bd36008aca044 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -41,7 +41,11 @@ LL | fn f8(x1: &S, x2: &S) { LL | f5(x1); | ^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `S` +note: required because it appears within the type `S` + --> $DIR/unsized3.rs:28:8 + | +LL | struct S { + | ^ help: consider relaxing the implicit `Sized` restriction | LL | fn f5(x: &Y) {} @@ -55,7 +59,11 @@ LL | fn f9(x1: Box>) { LL | f5(&(*x1, 34)); | ^^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `S` +note: required because it appears within the type `S` + --> $DIR/unsized3.rs:28:8 + | +LL | struct S { + | ^ = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -66,7 +74,11 @@ LL | fn f10(x1: Box>) { LL | f5(&(32, *x1)); | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `S` +note: required because it appears within the type `S` + --> $DIR/unsized3.rs:28:8 + | +LL | struct S { + | ^ = note: required because it appears within the type `({integer}, S)` = note: tuples must have a statically known size to be initialized @@ -81,7 +93,11 @@ LL | fn f10(x1: Box>) { LL | f5(&(32, *x1)); | ^^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `S` +note: required because it appears within the type `S` + --> $DIR/unsized3.rs:28:8 + | +LL | struct S { + | ^ = note: required because it appears within the type `({integer}, S)` help: consider relaxing the implicit `Sized` restriction | From dc711660377685d057ac37431143e2511ba7065f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 30 Mar 2021 13:51:08 -0700 Subject: [PATCH 05/10] Always mention `Box::pin` when dealing with `!Unpin` --- library/core/src/marker.rs | 2 +- src/test/ui/async-await/pin-needed-to-poll-2.stderr | 1 + src/test/ui/generator/static-not-unpin.stderr | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 85e0e7200875d..fb957348bebd3 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -765,7 +765,7 @@ unsafe impl Freeze for &mut T {} /// [`pin` module]: crate::pin #[stable(feature = "pin", since = "1.33.0")] #[rustc_on_unimplemented( - on(_Self = "std::future::Future", note = "consider using `Box::pin`",), + note = "consider using `Box::pin`", message = "`{Self}` cannot be unpinned" )] #[lang = "unpin"] diff --git a/src/test/ui/async-await/pin-needed-to-poll-2.stderr b/src/test/ui/async-await/pin-needed-to-poll-2.stderr index 31007cb40285e..c4d21de8aaf75 100644 --- a/src/test/ui/async-await/pin-needed-to-poll-2.stderr +++ b/src/test/ui/async-await/pin-needed-to-poll-2.stderr @@ -4,6 +4,7 @@ error[E0277]: `PhantomPinned` cannot be unpinned LL | Pin::new(&mut self.sleep).poll(cx) | ^^^^^^^^ within `Sleep`, the trait `Unpin` is not implemented for `PhantomPinned` | + = note: consider using `Box::pin` note: required because it appears within the type `Sleep` --> $DIR/pin-needed-to-poll-2.rs:8:8 | diff --git a/src/test/ui/generator/static-not-unpin.stderr b/src/test/ui/generator/static-not-unpin.stderr index 881064d2f8418..74ac53a7f9407 100644 --- a/src/test/ui/generator/static-not-unpin.stderr +++ b/src/test/ui/generator/static-not-unpin.stderr @@ -6,6 +6,8 @@ LL | fn assert_unpin(_: T) { ... LL | assert_unpin(generator); | ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]` + | + = note: consider using `Box::pin` error: aborting due to previous error From 2375b8ae7e57c7fc068a43138bd3da8c670c8c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 31 Mar 2021 12:10:24 -0700 Subject: [PATCH 06/10] review comments --- compiler/rustc_middle/src/ty/mod.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 414e1979c949a..6574c9382604b 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1598,7 +1598,7 @@ impl<'tcx> TyCtxt<'tcx> { .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value()) } - pub fn item_name_from_hir(self, def_id: DefId) -> Option { + fn item_name_from_hir(self, def_id: DefId) -> Option { self.hir().get_if_local(def_id).and_then(|node| node.ident()) } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index edbef02df45e7..68e7accd34b3c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2072,7 +2072,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if !is_upvar_tys_infer_tuple { let msg = format!("required because it appears within the type `{}`", ty); match ty.kind() { - ty::Adt(def, _) => match self.tcx.item_name_from_hir(def.did) { + ty::Adt(def, _) => match self.tcx.opt_item_name(def.did) { Some(ident) => err.span_note(ident.span, &msg), None => err.note(&msg), }, From 60c7f37f7ca755db24a414c66a919aab8ae7a9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 31 Mar 2021 16:53:26 -0700 Subject: [PATCH 07/10] Add spans to E0277 for impl/trait type/fn obligation disparity --- .../src/traits/error_reporting/suggestions.rs | 63 +++++++++++++++---- .../generic-associated-types/impl_bounds.rs | 3 + .../impl_bounds.stderr | 55 +++++++++++----- 3 files changed, 96 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 68e7accd34b3c..6a4d41ffc1ac9 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2179,19 +2179,60 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ) }); } - ObligationCauseCode::CompareImplMethodObligation { .. } => { - err.note(&format!( - "the requirement `{}` appears on the impl method but not on the corresponding \ - trait method", - predicate - )); + ObligationCauseCode::CompareImplMethodObligation { + item_name, + trait_item_def_id, + .. + } => { + let msg = format!( + "the requirement `{}` appears on the impl method `{}` but not on the \ + corresponding trait method", + predicate, item_name, + ); + let sp = self + .tcx + .opt_item_name(trait_item_def_id) + .map(|i| i.span) + .unwrap_or_else(|| self.tcx.def_span(trait_item_def_id)); + let mut assoc_span: MultiSpan = sp.into(); + assoc_span.push_span_label( + sp, + format!("this trait method doesn't have the requirement `{}`", predicate), + ); + if let Some(ident) = self + .tcx + .opt_associated_item(trait_item_def_id) + .and_then(|i| self.tcx.opt_item_name(i.container.id())) + { + assoc_span.push_span_label(ident.span, "in this trait".into()); + } + err.span_note(assoc_span, &msg); } - ObligationCauseCode::CompareImplTypeObligation { .. } => { - err.note(&format!( - "the requirement `{}` appears on the associated impl type but not on the \ + ObligationCauseCode::CompareImplTypeObligation { + item_name, trait_item_def_id, .. + } => { + let msg = format!( + "the requirement `{}` appears on the associated impl type `{}` but not on the \ corresponding associated trait type", - predicate - )); + predicate, item_name, + ); + let sp = self.tcx.def_span(trait_item_def_id); + let mut assoc_span: MultiSpan = sp.into(); + assoc_span.push_span_label( + sp, + format!( + "this trait associated type doesn't have the requirement `{}`", + predicate, + ), + ); + if let Some(ident) = self + .tcx + .opt_associated_item(trait_item_def_id) + .and_then(|i| self.tcx.opt_item_name(i.container.id())) + { + assoc_span.push_span_label(ident.span, "in this trait".into()); + } + err.span_note(assoc_span, &msg); } ObligationCauseCode::CompareImplConstObligation => { err.note(&format!( diff --git a/src/test/ui/generic-associated-types/impl_bounds.rs b/src/test/ui/generic-associated-types/impl_bounds.rs index 089a214667ea2..50e1c50644e35 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.rs +++ b/src/test/ui/generic-associated-types/impl_bounds.rs @@ -6,6 +6,7 @@ trait Foo { type A<'a> where Self: 'a; type B<'a, 'b> where 'a: 'b; type C where Self: Clone; + fn d() where Self: Clone; } #[derive(Copy, Clone)] @@ -19,6 +20,8 @@ impl Foo for Fooy { //~| ERROR lifetime bound not satisfied type C where Self: Copy = String; //~^ ERROR the trait bound `T: Copy` is not satisfied + fn d() where Self: Copy {} + //~^ ERROR the trait bound `T: Copy` is not satisfied } fn main() {} diff --git a/src/test/ui/generic-associated-types/impl_bounds.stderr b/src/test/ui/generic-associated-types/impl_bounds.stderr index e3d3de8bf9417..afa43b5693e10 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.stderr +++ b/src/test/ui/generic-associated-types/impl_bounds.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/impl_bounds.rs:15:5 + --> $DIR/impl_bounds.rs:16:5 | LL | type A<'a> where Self: 'static = (&'a ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,53 +8,80 @@ LL | type A<'a> where Self: 'static = (&'a ()); = note: ...so that the type `Fooy` will meet its required lifetime bounds error[E0478]: lifetime bound not satisfied - --> $DIR/impl_bounds.rs:17:5 + --> $DIR/impl_bounds.rs:18:5 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: lifetime parameter instantiated with the lifetime `'b` as defined on the associated item at 17:16 - --> $DIR/impl_bounds.rs:17:16 +note: lifetime parameter instantiated with the lifetime `'b` as defined on the associated item at 18:16 + --> $DIR/impl_bounds.rs:18:16 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^ -note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 17:12 - --> $DIR/impl_bounds.rs:17:12 +note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 18:12 + --> $DIR/impl_bounds.rs:18:12 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^ error[E0478]: lifetime bound not satisfied - --> $DIR/impl_bounds.rs:17:5 + --> $DIR/impl_bounds.rs:18:5 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: lifetime parameter instantiated with the lifetime `'a` as defined on the associated item at 17:12 - --> $DIR/impl_bounds.rs:17:12 +note: lifetime parameter instantiated with the lifetime `'a` as defined on the associated item at 18:12 + --> $DIR/impl_bounds.rs:18:12 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^ -note: but lifetime parameter must outlive the lifetime `'b` as defined on the associated item at 17:16 - --> $DIR/impl_bounds.rs:17:16 +note: but lifetime parameter must outlive the lifetime `'b` as defined on the associated item at 18:16 + --> $DIR/impl_bounds.rs:18:16 | LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ^^ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/impl_bounds.rs:20:5 + --> $DIR/impl_bounds.rs:21:5 | LL | type C where Self: Copy = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` | = note: required because of the requirements on the impl of `Copy` for `Fooy` - = note: the requirement `Fooy: Copy` appears on the associated impl type but not on the corresponding associated trait type +note: the requirement `Fooy: Copy` appears on the associated impl type `C` but not on the corresponding associated trait type + --> $DIR/impl_bounds.rs:8:5 + | +LL | trait Foo { + | --- in this trait +... +LL | type C where Self: Clone; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ this trait associated type doesn't have the requirement `Fooy: Copy` +help: consider restricting type parameter `T` + | +LL | impl Foo for Fooy { + | ^^^^^^ + +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/impl_bounds.rs:23:5 + | +LL | fn d() where Self: Copy {} + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` + | + = note: required because of the requirements on the impl of `Copy` for `Fooy` +note: the requirement `Fooy: Copy` appears on the impl method `d` but not on the corresponding trait method + --> $DIR/impl_bounds.rs:9:8 + | +LL | trait Foo { + | --- in this trait +... +LL | fn d() where Self: Clone; + | ^ this trait method doesn't have the requirement `Fooy: Copy` help: consider restricting type parameter `T` | LL | impl Foo for Fooy { | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0277, E0310, E0478. For more information about an error, try `rustc --explain E0277`. From 6e77bcbbcd3b92c535c5d272f9508c55ffaa121e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 7 Apr 2021 13:30:37 +0200 Subject: [PATCH 08/10] Add Debug implementation for hir::intravisit::FnKind --- compiler/rustc_hir/src/intravisit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index d766a68e19455..16b38bcf42cff 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -98,7 +98,7 @@ where } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum FnKind<'a> { /// `#[xxx] pub async/const/extern "Abi" fn foo()` ItemFn(Ident, &'a Generics<'a>, FnHeader, &'a Visibility<'a>), From 64e6288b8bd78dd8b0addbd0a599e393e2209b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Apr 2021 08:31:38 -0700 Subject: [PATCH 09/10] rebase and update tests --- .../impl_bounds.stderr | 4 +-- ...ction-mismatch-in-impl-where-clause.stderr | 6 +++- .../kindck/kindck-impl-type-params.nll.stderr | 36 +++++++++++++++---- src/test/ui/rfc1623.nll.stderr | 6 +++- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/test/ui/generic-associated-types/impl_bounds.stderr b/src/test/ui/generic-associated-types/impl_bounds.stderr index afa43b5693e10..58bcb13e68ebd 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.stderr +++ b/src/test/ui/generic-associated-types/impl_bounds.stderr @@ -58,8 +58,8 @@ LL | type C where Self: Clone; | ^^^^^^^^^^^^^^^^^^^^^^^^^ this trait associated type doesn't have the requirement `Fooy: Copy` help: consider restricting type parameter `T` | -LL | impl Foo for Fooy { - | ^^^^^^ +LL | impl Foo for Fooy { + | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/impl_bounds.rs:23:5 diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr index d1956a9afb809..54eb5a96c9d81 100644 --- a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr +++ b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr @@ -4,7 +4,11 @@ error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()` LL | fn test() -> impl Test { | ^^^^^^^^^ expected `()`, found `u8` | - = note: required because of the requirements on the impl of `Test` for `()` +note: required because of the requirements on the impl of `Test` for `()` + --> $DIR/projection-mismatch-in-impl-where-clause.rs:11:9 + | +LL | impl Test for T where T: Super {} + | ^^^^ ^ error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index e9002ec36f43d..035501009bda4 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -4,7 +4,11 @@ error[E0277]: `T` cannot be sent between threads safely LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -17,7 +21,11 @@ error[E0277]: the trait bound `T: Copy` is not satisfied LL | let a = &t as &dyn Gettable; | ^^ the trait `Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -30,7 +38,11 @@ error[E0277]: `T` cannot be sent between threads safely LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -43,7 +55,11 @@ error[E0277]: the trait bound `T: Copy` is not satisfied LL | let a: &dyn Gettable = &t; | ^^ the trait `Copy` is not implemented for `T` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` help: consider restricting type parameter `T` | @@ -56,7 +72,11 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `Foo: Copy` is not satisfied @@ -65,7 +85,11 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | - = note: required because of the requirements on the impl of `Gettable` for `S` +note: required because of the requirements on the impl of `Gettable` for `S` + --> $DIR/kindck-impl-type-params.rs:14:32 + | +LL | impl Gettable for S {} + | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error: aborting due to 6 previous errors diff --git a/src/test/ui/rfc1623.nll.stderr b/src/test/ui/rfc1623.nll.stderr index b5dd0c9d2a6c8..a3d94679434d1 100644 --- a/src/test/ui/rfc1623.nll.stderr +++ b/src/test/ui/rfc1623.nll.stderr @@ -11,7 +11,11 @@ LL | | }; | = help: within `&SomeStruct`, the trait `Sync` is not implemented for `dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>` = note: required because it appears within the type `&dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>` - = note: required because it appears within the type `SomeStruct` +note: required because it appears within the type `SomeStruct` + --> $DIR/rfc1623.rs:11:8 + | +LL | struct SomeStruct<'x, 'y, 'z: 'x> { + | ^^^^^^^^^^ = note: required because it appears within the type `&SomeStruct` = note: shared static variables must have a type that implements `Sync` From 934a30a8fd756d6b1b9f2453ca24097c3c8e2157 Mon Sep 17 00:00:00 2001 From: pierwill Date: Wed, 7 Apr 2021 11:45:27 -0500 Subject: [PATCH 10/10] Fix outdated crate names in `rustc_interface::callbacks` --- compiler/rustc_interface/src/callbacks.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs index 7fa1a3eb0f591..3b852b8ccf9d0 100644 --- a/compiler/rustc_interface/src/callbacks.rs +++ b/compiler/rustc_interface/src/callbacks.rs @@ -1,6 +1,6 @@ //! Throughout the compiler tree, there are several places which want to have //! access to state or queries while being inside crates that are dependencies -//! of librustc_middle. To facilitate this, we have the +//! of `rustc_middle`. To facilitate this, we have the //! `rustc_data_structures::AtomicRef` type, which allows us to setup a global //! static which can then be set in this file at program startup. //! @@ -13,8 +13,8 @@ use rustc_errors::{Diagnostic, TRACK_DIAGNOSTICS}; use rustc_middle::ty::tls; use std::fmt; -/// This is a callback from librustc_ast as it cannot access the implicit state -/// in librustc_middle otherwise. +/// This is a callback from `rustc_ast` as it cannot access the implicit state +/// in `rustc_middle` otherwise. fn span_debug(span: rustc_span::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { tls::with_opt(|tcx| { if let Some(tcx) = tcx { @@ -25,8 +25,8 @@ fn span_debug(span: rustc_span::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result }) } -/// This is a callback from librustc_ast as it cannot access the implicit state -/// in librustc_middle otherwise. It is used to when diagnostic messages are +/// This is a callback from `rustc_ast` as it cannot access the implicit state +/// in `rustc_middle` otherwise. It is used to when diagnostic messages are /// emitted and stores them in the current query, if there is one. fn track_diagnostic(diagnostic: &Diagnostic) { tls::with_context_opt(|icx| { @@ -39,8 +39,8 @@ fn track_diagnostic(diagnostic: &Diagnostic) { }) } -/// This is a callback from librustc_hir as it cannot access the implicit state -/// in librustc_middle otherwise. +/// This is a callback from `rustc_hir` as it cannot access the implicit state +/// in `rustc_middle` otherwise. fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "DefId({}:{}", def_id.krate, def_id.index.index())?; tls::with_opt(|opt_tcx| {