authorbors <bors@rust-lang.org> 2026-05-15 21:40:32 UTC
committerbors <bors@rust-lang.org> 2026-05-15 21:40:32 UTC
log35143615544ede08a47947901cd4a6b7c5ecd450
tree67582655799137eb9235dcea23d8908100a2f135
parentd7f14d3d89c39b2c12ed4b9864a0eb2c205d20bc
parentd1da72ad21d0cccee1c52a67d1b23ab736112881

Auto merge of #156617 - JonathanBrouwer:rollup-M30TGcY, r=JonathanBrouwer

Rollup of 12 pull requests Successful merges: - rust-lang/rust#148788 (Unconstrained parameter fix) - rust-lang/rust#156319 (Require EIIs to be defined when we compile a rust dylib) - rust-lang/rust#156452 (Implement pinned drop sugar) - rust-lang/rust#156554 (Allow user-provided `llvm_args` to override target spec arguments) - rust-lang/rust#156571 (Disable `main_needs_argc_argv` for Wasm) - rust-lang/rust#156600 (Make const param default test reproduce original ICE) - rust-lang/rust#156493 (actually run the temp_dir doctest) - rust-lang/rust#156556 (Require UTF-8 in `Utf8Pattern::StringPattern`) - rust-lang/rust#156565 (delegation: emit error when self type is not specified and accessed) - rust-lang/rust#156586 (Use DropCtxt::new_block and new_block_with_statements systematically.) - rust-lang/rust#156587 (Correctly handle associated items in rustdoc macro expansion) - rust-lang/rust#156604 (coverage: Reduce and clarify the context-mismatch test case)

85 files changed, 1860 insertions(+), 395 deletions(-)

compiler/rustc_ast/src/ast.rs+13
......@@ -3867,6 +3867,19 @@ pub struct Fn {
38673867 pub eii_impls: ThinVec<EiiImpl>,
38683868}
38693869
3870impl Fn {
3871 pub fn is_pin_drop_sugar(&self) -> bool {
3872 self.ident.name == sym::drop
3873 && self
3874 .sig
3875 .decl
3876 .inputs
3877 .first()
3878 .and_then(|param| param.to_self())
3879 .is_some_and(|eself| matches!(eself.node, SelfKind::Pinned(None, Mutability::Mut)))
3880 }
3881}
3882
38703883#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
38713884pub struct EiiImpl {
38723885 pub node_id: NodeId,
compiler/rustc_ast_lowering/src/item.rs+56-17
......@@ -1192,6 +1192,52 @@ impl<'hir> LoweringContext<'_, 'hir> {
11921192 })
11931193 }
11941194
1195 fn resolve_pin_drop_sugar_impl_item(
1196 &self,
1197 i: &AssocItem,
1198 ident: Ident,
1199 span: Span,
1200 ) -> (Ident, Result<DefId, ErrorGuaranteed>) {
1201 let trait_item_def_id = self
1202 .get_partial_res(i.id)
1203 .and_then(|r| r.expect_full_res().opt_def_id())
1204 .ok_or_else(|| {
1205 self.dcx().span_delayed_bug(span, "could not resolve trait item being implemented")
1206 });
1207
1208 let is_pin_drop_sugar = match &i.kind {
1209 AssocItemKind::Fn(fn_kind) => fn_kind.is_pin_drop_sugar(),
1210 _ => false,
1211 };
1212 let def_id = match trait_item_def_id {
1213 Ok(def_id) => def_id,
1214 Err(guar) => return (ident, Err(guar)),
1215 };
1216 if !is_pin_drop_sugar {
1217 return (ident, Ok(def_id));
1218 }
1219
1220 let is_drop_pin_drop = self
1221 .tcx
1222 .lang_items()
1223 .drop_trait()
1224 .is_some_and(|drop_trait| self.tcx.parent(def_id) == drop_trait);
1225 if is_drop_pin_drop {
1226 // Associated item collection still derives the impl item's name from HIR.
1227 return (Ident::new(sym::pin_drop, ident.span), Ok(def_id));
1228 }
1229
1230 let guar = self
1231 .dcx()
1232 .struct_span_err(
1233 i.span,
1234 "method `drop` with `&pin mut self` is only supported for the `Drop` trait",
1235 )
1236 .with_span_label(i.span, "not a `Drop::pin_drop` implementation")
1237 .emit();
1238 (ident, Err(guar))
1239 }
1240
11951241 fn lower_impl_item(
11961242 &mut self,
11971243 i: &AssocItem,
......@@ -1309,26 +1355,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
13091355 };
13101356
13111357 let span = self.lower_span(i.span);
1358 let (effective_ident, impl_kind) = if is_in_trait_impl {
1359 let (effective_ident, trait_item_def_id) =
1360 self.resolve_pin_drop_sugar_impl_item(i, ident, span);
1361 (effective_ident, ImplItemImplKind::Trait { defaultness, trait_item_def_id })
1362 } else {
1363 (ident, ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) })
1364 };
1365
13121366 let item = hir::ImplItem {
13131367 owner_id: hir_id.expect_owner(),
1314 ident: self.lower_ident(ident),
1368 ident: self.lower_ident(effective_ident),
13151369 generics,
1316 impl_kind: if is_in_trait_impl {
1317 ImplItemImplKind::Trait {
1318 defaultness,
1319 trait_item_def_id: self
1320 .get_partial_res(i.id)
1321 .and_then(|r| r.expect_full_res().opt_def_id())
1322 .ok_or_else(|| {
1323 self.dcx().span_delayed_bug(
1324 span,
1325 "could not resolve trait item being implemented",
1326 )
1327 }),
1328 }
1329 } else {
1330 ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) }
1331 },
1370 impl_kind,
13321371 kind,
13331372 span,
13341373 has_delayed_lints: !self.delayed_lints.is_empty(),
compiler/rustc_codegen_llvm/src/llvm_util.rs+4-1
......@@ -66,7 +66,10 @@ unsafe fn configure_llvm(sess: &Session) {
6666
6767 let cg_opts = sess.opts.cg.llvm_args.iter().map(AsRef::as_ref);
6868 let tg_opts = sess.target.llvm_args.iter().map(AsRef::as_ref);
69 let sess_args = cg_opts.chain(tg_opts);
69 // Target-spec args are passed to LLVM before user `-Cllvm-args`. LLVM's
70 // `cl::opt` parser is last-wins, so this lets `-Cllvm-args=...` override
71 // a value already set in the target spec (e.g. `-wasm-use-legacy-eh`).
72 let sess_args = tg_opts.chain(cg_opts);
7073
7174 let user_specified_args: FxHashSet<_> =
7275 sess_args.clone().map(|s| llvm_arg_to_arg_name(s)).filter(|s| !s.is_empty()).collect();
compiler/rustc_hir/src/hir.rs+87
......@@ -1088,6 +1088,93 @@ impl<'hir> Generics<'hir> {
10881088 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
10891089 }
10901090 }
1091
1092 /// Computes the span representing the removal of a generic parameter at `param_index`.
1093 ///
1094 /// This function identifies the correct slice of source code to delete so that the
1095 /// remaining generic list remains syntactically valid (handling commas and brackets).
1096 ///
1097 /// ### Examples
1098 ///
1099 /// 1. **With a following parameter:** (Includes the trailing comma)
1100 /// - Input: `<T, U>` (index 0)
1101 /// - Produces span for: `T, `
1102 ///
1103 /// 2. **With a previous parameter:** (Includes the leading comma and bounds)
1104 /// - Input: `<T: Clone, U>` (index 1)
1105 /// - Produces span for: `, U`
1106 ///
1107 /// 3. **The only parameter:** (Includes the angle brackets)
1108 /// - Input: `<T>` (index 0)
1109 /// - Produces span for: `<T>`
1110 ///
1111 /// 4. **Parameter with where-clause bounds:**
1112 /// - Input: `fn foo<T, U>() where T: Copy` (index 0)
1113 /// - Produces span for: `T, ` (The where-clause remains for other logic to handle).
1114 pub fn span_for_param_removal(&self, param_index: usize) -> Span {
1115 if param_index >= self.params.len() {
1116 return self.span.shrink_to_hi();
1117 }
1118
1119 let is_param_explicit = |par: &&GenericParam<'_>| match par.kind {
1120 GenericParamKind::Type { .. }
1121 | GenericParamKind::Const { .. }
1122 | GenericParamKind::Lifetime { kind: LifetimeParamKind::Explicit } => true,
1123 _ => false,
1124 };
1125
1126 // Find the span of the type parameter.
1127 if let Some(next) = self.params[param_index + 1..].iter().find(is_param_explicit) {
1128 self.params[param_index].span.until(next.span)
1129 } else if let Some(prev) = self.params[..param_index].iter().rfind(is_param_explicit) {
1130 let mut prev_span = prev.span;
1131 // Consider the span of the bounds with the previous generic parameter when there is.
1132 if let Some(prev_bounds_span) = self.span_for_param_bounds(prev) {
1133 prev_span = prev_span.to(prev_bounds_span);
1134 }
1135
1136 // Consider the span of the bounds with the current generic parameter when there is.
1137 prev_span.shrink_to_hi().to(
1138 if let Some(cur_bounds_span) = self.span_for_param_bounds(&self.params[param_index])
1139 {
1140 cur_bounds_span
1141 } else {
1142 self.params[param_index].span
1143 },
1144 )
1145 } else {
1146 // Remove also angle brackets <> when there is just ONE generic parameter.
1147 self.span
1148 }
1149 }
1150
1151 /// Returns the span of the `WherePredicate` associated with the given `GenericParam`, if any.
1152 ///
1153 /// This looks specifically for predicates in the `where` clause that were generated
1154 /// from the parameter definition (e.g., `T` in `where T: Bound`).
1155 ///
1156 /// ### Example
1157 ///
1158 /// - Input: `param` representing `T`
1159 /// - Context: `where T: Clone + Default, U: Copy`
1160 /// - Returns: Span of `T: Clone + Default`
1161 fn span_for_param_bounds(&self, param: &GenericParam<'hir>) -> Option<Span> {
1162 self.predicates
1163 .iter()
1164 .find(|pred| {
1165 if let WherePredicateKind::BoundPredicate(WhereBoundPredicate {
1166 origin: PredicateOrigin::GenericParam,
1167 bounded_ty,
1168 ..
1169 }) = pred.kind
1170 {
1171 bounded_ty.span == param.span
1172 } else {
1173 false
1174 }
1175 })
1176 .map(|pred| pred.span)
1177 }
10911178}
10921179
10931180/// A single predicate in a where-clause.
compiler/rustc_hir_analysis/src/delegation.rs+7
......@@ -14,6 +14,7 @@ use rustc_middle::ty::{
1414use rustc_span::{ErrorGuaranteed, Span, kw};
1515
1616use crate::collect::ItemCtxt;
17use crate::errors::DelegationSelfTypeNotSpecified;
1718use crate::hir_ty_lowering::HirTyLowerer;
1819
1920type RemapTable = FxHashMap<u32, u32>;
......@@ -284,6 +285,12 @@ fn get_delegation_self_ty_or_err(tcx: TyCtxt<'_>, delegation_id: LocalDefId) ->
284285 ctx.lower_ty(tcx.hir_node(id).expect_ty())
285286 })
286287 .unwrap_or_else(|| {
288 // It is possible to attempt to get self type when it is used in signature
289 // (i.e., `fn default() -> Self`), so emit error here in addition to possible
290 // `mismatched types` error (see #156388).
291 let err = DelegationSelfTypeNotSpecified { span: tcx.def_span(delegation_id) };
292 tcx.dcx().emit_err(err);
293
287294 Ty::new_error_with_message(
288295 tcx,
289296 tcx.def_span(delegation_id),
compiler/rustc_hir_analysis/src/errors.rs+10
......@@ -15,6 +15,8 @@ pub(crate) mod wrong_number_of_generic_args;
1515mod precise_captures;
1616pub(crate) use precise_captures::*;
1717
18pub(crate) mod remove_or_use_generic;
19
1820#[derive(Diagnostic)]
1921#[diag("ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`")]
2022pub(crate) struct AmbiguousAssocItem<'a> {
......@@ -1670,6 +1672,14 @@ pub(crate) struct UnsupportedDelegation<'a> {
16701672 pub callee_span: Span,
16711673}
16721674
1675#[derive(Diagnostic)]
1676#[diag("delegation self type is not specified")]
1677#[help("consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`")]
1678pub(crate) struct DelegationSelfTypeNotSpecified {
1679 #[primary_span]
1680 pub span: Span,
1681}
1682
16731683#[derive(Diagnostic)]
16741684#[diag("method should be `async` or return a future, but it is synchronous")]
16751685pub(crate) struct MethodShouldReturnFuture {
compiler/rustc_hir_analysis/src/errors/remove_or_use_generic.rs created+211
......@@ -0,0 +1,211 @@
1use std::ops::ControlFlow;
2
3use rustc_errors::{Applicability, Diag};
4use rustc_hir::def::DefKind;
5use rustc_hir::def_id::{DefId, LocalDefId};
6use rustc_hir::intravisit::{self, Visitor, walk_lifetime};
7use rustc_hir::{GenericArg, HirId, LifetimeKind, Path, QPath, TyKind};
8use rustc_middle::hir::nested_filter::All;
9use rustc_middle::ty::{GenericParamDef, GenericParamDefKind, TyCtxt};
10
11use crate::hir::def::Res;
12
13/// Use a Visitor to find usages of the type or lifetime parameter
14struct ParamUsageVisitor<'tcx> {
15 tcx: TyCtxt<'tcx>,
16 /// The `DefId` of the generic parameter we are looking for.
17 param_def_id: DefId,
18 found: bool,
19}
20
21impl<'tcx> Visitor<'tcx> for ParamUsageVisitor<'tcx> {
22 type NestedFilter = All;
23
24 fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
25 self.tcx
26 }
27
28 type Result = ControlFlow<()>;
29
30 fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) -> Self::Result {
31 if let Some(res_def_id) = path.res.opt_def_id() {
32 if res_def_id == self.param_def_id {
33 self.found = true;
34 return ControlFlow::Break(());
35 }
36 }
37 intravisit::walk_path(self, path)
38 }
39
40 fn visit_lifetime(&mut self, lifetime: &'tcx rustc_hir::Lifetime) -> Self::Result {
41 if let LifetimeKind::Param(id) = lifetime.kind {
42 if let Some(local_def_id) = self.param_def_id.as_local() {
43 if id == local_def_id {
44 self.found = true;
45 return ControlFlow::Break(());
46 }
47 }
48 }
49 walk_lifetime(self, lifetime)
50 }
51}
52
53/// Adds a suggestion to a diagnostic to either remove an unused generic parameter, or use it.
54///
55/// # Examples
56///
57/// - `impl<T> Struct { ... }` where `T` is unused -> suggests removing `T` or using it.
58/// - `impl<T> Struct { // T used in here }` where `T` is used in the body but not in the self type -> suggests adding `T` to the self type and struct definition.
59/// - `impl<T> Struct { ... }` where the struct has a generic parameter with a default -> suggests adding `T` to the self type.
60pub(crate) fn suggest_to_remove_or_use_generic(
61 tcx: TyCtxt<'_>,
62 diag: &mut Diag<'_>,
63 impl_def_id: LocalDefId,
64 param: &GenericParamDef,
65 is_lifetime: bool,
66) {
67 let node = tcx.hir_node_by_def_id(impl_def_id);
68 let hir_impl = node.expect_item().expect_impl();
69
70 let Some((index, _)) = hir_impl
71 .generics
72 .params
73 .iter()
74 .enumerate()
75 .find(|(_, par)| par.def_id.to_def_id() == param.def_id)
76 else {
77 return;
78 };
79
80 // Get the Struct/ADT definition ID from the self type
81 let struct_def_id = if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind
82 && let Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, def_id) = path.res
83 {
84 def_id
85 } else {
86 return;
87 };
88
89 // Count how many generic parameters are defined in the struct definition
90 let generics = tcx.generics_of(struct_def_id);
91 let total_params = generics
92 .own_params
93 .iter()
94 .filter(|p| {
95 if is_lifetime {
96 matches!(p.kind, GenericParamDefKind::Lifetime)
97 } else {
98 matches!(p.kind, GenericParamDefKind::Type { .. })
99 }
100 })
101 .count();
102
103 // Count how many arguments are currently provided in the impl
104 let mut provided_params = 0;
105 let mut last_segment_args = None;
106
107 if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind
108 && let Some(seg) = path.segments.last()
109 && let Some(args) = seg.args
110 {
111 last_segment_args = Some(args);
112 provided_params = args
113 .args
114 .iter()
115 .filter(|arg| match arg {
116 GenericArg::Lifetime(_) => is_lifetime,
117 GenericArg::Type(_) => !is_lifetime,
118 _ => false,
119 })
120 .count();
121 }
122
123 let mut visitor = ParamUsageVisitor { tcx, param_def_id: param.def_id, found: false };
124 for item_ref in hir_impl.items {
125 let _ = visitor.visit_impl_item_ref(item_ref);
126 if visitor.found {
127 break;
128 }
129 }
130 let is_param_used = visitor.found;
131
132 let mut suggestions = vec![];
133
134 // Option A: Remove (Only if not used in body)
135 if !is_param_used {
136 suggestions.push((hir_impl.generics.span_for_param_removal(index), String::new()));
137 }
138
139 // Option B: Suggest adding only if there's an available parameter in the struct definition
140 // or the parameter is already used somewhere, then we suggest adding to the impl struct and the struct definition
141 if provided_params < total_params || is_param_used {
142 if let Some(args) = last_segment_args {
143 // Struct already has <...>, append to it
144 suggestions.push((args.span().unwrap().shrink_to_hi(), format!(", {}", param.name)));
145 } else if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind {
146 // Struct has no <...> yet, add it
147 let seg = path.segments.last().unwrap();
148 suggestions.push((seg.ident.span.shrink_to_hi(), format!("<{}>", param.name)));
149 }
150 if is_param_used {
151 // If the parameter is used in the body, we also want to suggest adding it to the struct definition if it's not already there
152 let struct_span = tcx.def_span(struct_def_id);
153 let last_param_span = if let Some(local_def_id) = struct_def_id.as_local() {
154 let hir_struct = tcx.hir_node_by_def_id(local_def_id).expect_item().expect_struct();
155 hir_struct.1.params.last().map(|param| param.span)
156 } else {
157 let generics = tcx.generics_of(struct_def_id);
158 generics.own_params.last().map(|param| tcx.def_span(param.def_id))
159 };
160
161 if let Some(last_param_span) = last_param_span {
162 suggestions.push((last_param_span.shrink_to_hi(), format!(", {}", param.name)));
163 } else {
164 suggestions.push((struct_span.shrink_to_hi(), format!("<{}>", param.name)));
165 }
166 }
167 }
168
169 if suggestions.is_empty() {
170 return;
171 }
172
173 let parameter_type = if is_lifetime { "lifetime" } else { "type" };
174 if is_param_used {
175 let msg = format!(
176 "use the {} parameter `{}` in the `{}` type and use it in the type definition",
177 parameter_type,
178 param.name,
179 tcx.def_path_str(struct_def_id)
180 );
181 diag.multipart_suggestion(
182 msg,
183 vec![
184 (suggestions[0].0, suggestions[0].1.clone()),
185 (suggestions[1].0, suggestions[1].1.clone()),
186 ],
187 Applicability::MaybeIncorrect,
188 );
189 } else {
190 let msg = if suggestions.len() == 2 {
191 format!("either remove the unused {} parameter `{}`", parameter_type, param.name)
192 } else {
193 format!("remove the unused {} parameter `{}`", parameter_type, param.name)
194 };
195 diag.span_suggestion(
196 suggestions[0].0,
197 msg,
198 suggestions[0].1.clone(),
199 Applicability::MaybeIncorrect,
200 );
201 if suggestions.len() == 2 {
202 let msg = format!("or use it");
203 diag.span_suggestion(
204 suggestions[1].0,
205 msg,
206 suggestions[1].1.clone(),
207 Applicability::MaybeIncorrect,
208 );
209 }
210 };
211}
compiler/rustc_hir_analysis/src/impl_wf_check.rs+3
......@@ -21,6 +21,7 @@ use rustc_span::{ErrorGuaranteed, kw};
2121
2222use crate::constrained_generic_params as cgp;
2323use crate::errors::UnconstrainedGenericParameter;
24use crate::errors::remove_or_use_generic::suggest_to_remove_or_use_generic;
2425
2526mod min_specialization;
2627
......@@ -177,6 +178,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
177178 );
178179 }
179180 }
181 suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, param, true);
180182 res = Err(diag.emit());
181183 }
182184 }
......@@ -242,6 +244,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained(
242244 const_param_note2: const_param_note,
243245 });
244246 diag.code(E0207);
247 suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, &param, false);
245248 res = Err(diag.emit());
246249 }
247250 }
compiler/rustc_mir_transform/src/elaborate_drop.rs+103-165
......@@ -207,6 +207,7 @@ where
207207 // We keep async drop unexpanded to poll-loop here, to expand it later, at StateTransform -
208208 // into states expand.
209209 // call_destructor_only - to call only AsyncDrop::drop, not full async_drop_in_place glue
210 #[instrument(level = "debug", skip(self), ret)]
210211 fn build_async_drop(
211212 &mut self,
212213 place: Place<'tcx>,
......@@ -221,14 +222,8 @@ where
221222 let span = self.source_info.span;
222223
223224 let pin_obj_bb = bb.unwrap_or_else(|| {
224 self.elaborator.patch().new_block(BasicBlockData::new(
225 Some(Terminator {
226 // Temporary terminator, will be replaced by patch
227 source_info: self.source_info,
228 kind: TerminatorKind::Return,
229 }),
230 false,
231 ))
225 // Temporary terminator, will be replaced by patch
226 self.new_block(unwind, TerminatorKind::Return)
232227 });
233228
234229 let (fut_ty, drop_fn_def_id, trait_args) = if call_destructor_only {
......@@ -565,6 +560,7 @@ where
565560 .collect()
566561 }
567562
563 #[instrument(level = "debug", skip(self), ret)]
568564 fn drop_subpath(
569565 &mut self,
570566 place: Place<'tcx>,
......@@ -574,8 +570,6 @@ where
574570 dropline: Option<BasicBlock>,
575571 ) -> BasicBlock {
576572 if let Some(path) = path {
577 debug!("drop_subpath: for std field {:?}", place);
578
579573 DropCtxt {
580574 elaborator: self.elaborator,
581575 source_info: self.source_info,
......@@ -587,8 +581,6 @@ where
587581 }
588582 .elaborated_drop_block()
589583 } else {
590 debug!("drop_subpath: for rest field {:?}", place);
591
592584 DropCtxt {
593585 elaborator: self.elaborator,
594586 source_info: self.source_info,
......@@ -596,8 +588,7 @@ where
596588 succ,
597589 unwind,
598590 dropline,
599 // Using `self.path` here to condition the drop on
600 // our own drop flag.
591 // Using `self.path` here to condition the drop on our own drop flag.
601592 path: self.path,
602593 }
603594 .complete_drop(succ, unwind)
......@@ -614,6 +605,7 @@ where
614605 /// `dropline_ladder` is a similar list of steps in reverse order,
615606 /// which is called if the matching step of the drop glue will contain async drop
616607 /// (expanded later to Yield) and the containing coroutine will be dropped at this point.
608 #[instrument(level = "debug", skip(self), ret)]
617609 fn drop_halfladder(
618610 &mut self,
619611 unwind_ladder: &[Unwind],
......@@ -679,6 +671,7 @@ where
679671 ///
680672 /// NOTE: this does not clear the master drop flag, so you need
681673 /// to point succ/unwind on a `drop_ladder_bottom`.
674 #[instrument(level = "debug", skip(self), ret)]
682675 fn drop_ladder(
683676 &mut self,
684677 fields: Vec<(Place<'tcx>, Option<D::Path>)>,
......@@ -686,7 +679,6 @@ where
686679 unwind: Unwind,
687680 dropline: Option<BasicBlock>,
688681 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
689 debug!("drop_ladder({:?}, {:?})", self, fields);
690682 assert!(
691683 if unwind.is_cleanup() { dropline.is_none() } else { true },
692684 "Dropline is set for cleanup drop ladder"
......@@ -723,9 +715,8 @@ where
723715 )
724716 }
725717
718 #[instrument(level = "debug", skip(self), ret)]
726719 fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
727 debug!("open_drop_for_tuple({:?}, {:?})", self, tys);
728
729720 let fields = tys
730721 .iter()
731722 .enumerate()
......@@ -769,18 +760,14 @@ where
769760
770761 let do_drop_bb = self.drop_subpath(interior, interior_path, succ, unwind, dropline);
771762
772 let setup_bbd = BasicBlockData::new_stmts(
763 self.new_block_with_statements(
764 unwind,
773765 vec![self.assign(
774766 Place::from(ptr_local),
775767 Rvalue::Cast(CastKind::Transmute, Operand::Copy(nonnull_place), ptr_ty),
776768 )],
777 Some(Terminator {
778 kind: TerminatorKind::Goto { target: do_drop_bb },
779 source_info: self.source_info,
780 }),
781 unwind.is_cleanup(),
782 );
783 self.elaborator.patch().new_block(setup_bbd)
769 TerminatorKind::Goto { target: do_drop_bb },
770 )
784771 }
785772
786773 #[instrument(level = "debug", ret)]
......@@ -790,17 +777,11 @@ where
790777 args: GenericArgsRef<'tcx>,
791778 ) -> BasicBlock {
792779 if adt.variants().is_empty() {
793 return self.elaborator.patch().new_block(BasicBlockData::new(
794 Some(Terminator {
795 source_info: self.source_info,
796 kind: TerminatorKind::Unreachable,
797 }),
798 self.unwind.is_cleanup(),
799 ));
780 return self.new_block(self.unwind, TerminatorKind::Unreachable);
800781 }
801782
802783 let skip_contents = adt.is_union() || adt.is_manually_drop();
803 let contents_drop = if skip_contents {
784 let (contents_succ, contents_unwind, contents_dropline) = if skip_contents {
804785 if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() {
805786 // the top-level drop flag is usually cleared by open_drop_for_adt_contents
806787 // types with destructors would still need an empty drop ladder to clear it
......@@ -819,21 +800,19 @@ where
819800 if adt.has_dtor(self.tcx()) {
820801 let destructor_block = if adt.is_box() {
821802 // we need to drop the inside of the box before running the destructor
822 let succ = self.destructor_call_block_sync((contents_drop.0, contents_drop.1));
823 let unwind = contents_drop
824 .1
825 .map(|unwind| self.destructor_call_block_sync((unwind, Unwind::InCleanup)));
826 let dropline = contents_drop
827 .2
828 .map(|dropline| self.destructor_call_block_sync((dropline, contents_drop.1)));
803 let succ = self.destructor_call_block_sync(contents_succ, contents_unwind);
804 let unwind = contents_unwind
805 .map(|unwind| self.destructor_call_block_sync(unwind, Unwind::InCleanup));
806 let dropline = contents_dropline
807 .map(|dropline| self.destructor_call_block_sync(dropline, contents_unwind));
829808 self.open_drop_for_box_contents(adt, args, succ, unwind, dropline)
830809 } else {
831 self.destructor_call_block(contents_drop)
810 self.destructor_call_block(contents_succ, contents_unwind, contents_dropline)
832811 };
833812
834 self.drop_flag_test_block(destructor_block, contents_drop.0, contents_drop.1)
813 self.drop_flag_test_block(destructor_block, contents_succ, contents_unwind)
835814 } else {
836 contents_drop.0
815 contents_succ
837816 }
838817 }
839818
......@@ -976,26 +955,22 @@ where
976955 let discr_ty = adt.repr().discr_type().to_ty(self.tcx());
977956 let discr = Place::from(self.new_temp(discr_ty));
978957 let discr_rv = Rvalue::Discriminant(self.place);
979 let switch_block = BasicBlockData::new_stmts(
958 let switch_block = self.new_block_with_statements(
959 unwind,
980960 vec![self.assign(discr, discr_rv)],
981 Some(Terminator {
982 source_info: self.source_info,
983 kind: TerminatorKind::SwitchInt {
984 discr: Operand::Move(discr),
985 targets: SwitchTargets::new(
986 values.iter().copied().zip(blocks.iter().copied()),
987 *blocks.last().unwrap(),
988 ),
989 },
990 }),
991 unwind.is_cleanup(),
961 TerminatorKind::SwitchInt {
962 discr: Operand::Move(discr),
963 targets: SwitchTargets::new(
964 values.iter().copied().zip(blocks.iter().copied()),
965 *blocks.last().unwrap(),
966 ),
967 },
992968 );
993 let switch_block = self.elaborator.patch().new_block(switch_block);
994969 self.drop_flag_test_block(switch_block, succ, unwind)
995970 }
996971
997 fn destructor_call_block_sync(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock {
998 debug!("destructor_call_block_sync({:?}, {:?})", self, succ);
972 #[instrument(level = "debug", skip(self), ret)]
973 fn destructor_call_block_sync(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
999974 let tcx = self.tcx();
1000975 let drop_trait = tcx.require_lang_item(LangItem::Drop, DUMMY_SP);
1001976 let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
......@@ -1005,7 +980,8 @@ where
1005980 let ref_place = self.new_temp(ref_ty);
1006981 let unit_temp = Place::from(self.new_temp(tcx.types.unit));
1007982
1008 let result = BasicBlockData::new_stmts(
983 self.new_block_with_statements(
984 unwind,
1009985 vec![self.assign(
1010986 Place::from(ref_place),
1011987 Rvalue::Ref(
......@@ -1014,40 +990,31 @@ where
1014990 self.place,
1015991 ),
1016992 )],
1017 Some(Terminator {
1018 kind: TerminatorKind::Call {
1019 func: Operand::function_handle(
1020 tcx,
1021 drop_fn,
1022 [ty.into()],
1023 self.source_info.span,
1024 ),
1025 args: [Spanned { node: Operand::Move(Place::from(ref_place)), span: DUMMY_SP }]
1026 .into(),
1027 destination: unit_temp,
1028 target: Some(succ),
1029 unwind: unwind.into_action(),
1030 call_source: CallSource::Misc,
1031 fn_span: self.source_info.span,
1032 },
1033 source_info: self.source_info,
1034 }),
1035 unwind.is_cleanup(),
1036 );
1037
1038 self.elaborator.patch().new_block(result)
993 TerminatorKind::Call {
994 func: Operand::function_handle(tcx, drop_fn, [ty.into()], self.source_info.span),
995 args: [Spanned { node: Operand::Move(Place::from(ref_place)), span: DUMMY_SP }]
996 .into(),
997 destination: unit_temp,
998 target: Some(succ),
999 unwind: unwind.into_action(),
1000 call_source: CallSource::Misc,
1001 fn_span: self.source_info.span,
1002 },
1003 )
10391004 }
10401005
1006 #[instrument(level = "debug", skip(self), ret)]
10411007 fn destructor_call_block(
10421008 &mut self,
1043 (succ, unwind, dropline): (BasicBlock, Unwind, Option<BasicBlock>),
1009 succ: BasicBlock,
1010 unwind: Unwind,
1011 dropline: Option<BasicBlock>,
10441012 ) -> BasicBlock {
1045 debug!("destructor_call_block({:?}, {:?})", self, succ);
10461013 let ty = self.place_ty(self.place);
10471014 if !unwind.is_cleanup() && self.check_if_can_async_drop(ty, true) {
10481015 self.build_async_drop(self.place, ty, None, succ, unwind, dropline, true)
10491016 } else {
1050 self.destructor_call_block_sync((succ, unwind))
1017 self.destructor_call_block_sync(succ, unwind)
10511018 }
10521019 }
10531020
......@@ -1080,7 +1047,8 @@ where
10801047 let can_go = Place::from(self.new_temp(tcx.types.bool));
10811048 let one = self.constant_usize(1);
10821049
1083 let drop_block = BasicBlockData::new_stmts(
1050 let drop_block = self.new_block_with_statements(
1051 unwind,
10841052 vec![
10851053 self.assign(
10861054 ptr,
......@@ -1091,27 +1059,18 @@ where
10911059 Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))),
10921060 ),
10931061 ],
1094 Some(Terminator {
1095 source_info: self.source_info,
1096 // this gets overwritten by drop elaboration.
1097 kind: TerminatorKind::Unreachable,
1098 }),
1099 unwind.is_cleanup(),
1062 // this gets overwritten by drop elaboration.
1063 TerminatorKind::Unreachable,
11001064 );
1101 let drop_block = self.elaborator.patch().new_block(drop_block);
11021065
1103 let loop_block = BasicBlockData::new_stmts(
1066 let loop_block = self.new_block_with_statements(
1067 unwind,
11041068 vec![self.assign(
11051069 can_go,
11061070 Rvalue::BinaryOp(BinOp::Eq, Box::new((copy(Place::from(cur)), copy(len.into())))),
11071071 )],
1108 Some(Terminator {
1109 source_info: self.source_info,
1110 kind: TerminatorKind::if_(move_(can_go), succ, drop_block),
1111 }),
1112 unwind.is_cleanup(),
1072 TerminatorKind::if_(move_(can_go), succ, drop_block),
11131073 );
1114 let loop_block = self.elaborator.patch().new_block(loop_block);
11151074
11161075 let place = tcx.mk_place_deref(ptr);
11171076 if !unwind.is_cleanup() && self.check_if_can_async_drop(ety, false) {
......@@ -1140,13 +1099,13 @@ where
11401099 loop_block
11411100 }
11421101
1102 #[instrument(level = "debug", skip(self), ret)]
11431103 fn open_drop_for_array(
11441104 &mut self,
11451105 array_ty: Ty<'tcx>,
11461106 ety: Ty<'tcx>,
11471107 opt_size: Option<u64>,
11481108 ) -> BasicBlock {
1149 debug!("open_drop_for_array({:?}, {:?}, {:?})", array_ty, ety, opt_size);
11501109 let tcx = self.tcx();
11511110
11521111 if let Some(size) = opt_size {
......@@ -1215,7 +1174,15 @@ where
12151174 let slice_ptr_ty = Ty::new_mut_ptr(tcx, slice_ty);
12161175 let slice_ptr = self.new_temp(slice_ptr_ty);
12171176
1218 let mut delegate_block = BasicBlockData::new_stmts(
1177 let array_place = mem::replace(
1178 &mut self.place,
1179 Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx),
1180 );
1181 let slice_block = self.drop_loop_trio_for_slice(ety);
1182 self.place = array_place;
1183
1184 self.new_block_with_statements(
1185 self.unwind,
12191186 vec![
12201187 self.assign(Place::from(array_ptr), Rvalue::RawPtr(RawPtrKind::Mut, self.place)),
12211188 self.assign(
......@@ -1230,28 +1197,14 @@ where
12301197 ),
12311198 ),
12321199 ],
1233 None,
1234 self.unwind.is_cleanup(),
1235 );
1236
1237 let array_place = mem::replace(
1238 &mut self.place,
1239 Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx),
1240 );
1241 let slice_block = self.drop_loop_trio_for_slice(ety);
1242 self.place = array_place;
1243
1244 delegate_block.terminator = Some(Terminator {
1245 source_info: self.source_info,
1246 kind: TerminatorKind::Goto { target: slice_block },
1247 });
1248 self.elaborator.patch().new_block(delegate_block)
1200 TerminatorKind::Goto { target: slice_block },
1201 )
12491202 }
12501203
12511204 /// Creates a trio of drop-loops of `place`, which drops its contents, even
12521205 /// in the case of 1 panic or in the case of coroutine drop
1206 #[instrument(level = "debug", skip(self), ret)]
12531207 fn drop_loop_trio_for_slice(&mut self, ety: Ty<'tcx>) -> BasicBlock {
1254 debug!("drop_loop_trio_for_slice({:?})", ety);
12551208 let tcx = self.tcx();
12561209 let len = self.new_temp(tcx.types.usize);
12571210 let cur = self.new_temp(tcx.types.usize);
......@@ -1274,7 +1227,8 @@ where
12741227 };
12751228
12761229 let zero = self.constant_usize(0);
1277 let block = BasicBlockData::new_stmts(
1230 let drop_block = self.new_block_with_statements(
1231 unwind,
12781232 vec![
12791233 self.assign(
12801234 len.into(),
......@@ -1285,14 +1239,9 @@ where
12851239 ),
12861240 self.assign(cur.into(), Rvalue::Use(zero, WithRetag::Yes)),
12871241 ],
1288 Some(Terminator {
1289 source_info: self.source_info,
1290 kind: TerminatorKind::Goto { target: loop_block },
1291 }),
1292 unwind.is_cleanup(),
1242 TerminatorKind::Goto { target: loop_block },
12931243 );
12941244
1295 let drop_block = self.elaborator.patch().new_block(block);
12961245 // FIXME(#34708): handle partially-dropped array/slice elements.
12971246 let reset_block = self.drop_flag_reset_block(DropFlagMode::Deep, drop_block, unwind);
12981247 self.drop_flag_test_block(reset_block, self.succ, unwind)
......@@ -1336,37 +1285,28 @@ where
13361285 self.source_info.span,
13371286 "open drop for unsafe binder shouldn't be encountered",
13381287 );
1339 self.elaborator.patch().new_block(BasicBlockData::new(
1340 Some(Terminator {
1341 source_info: self.source_info,
1342 kind: TerminatorKind::Unreachable,
1343 }),
1344 self.unwind.is_cleanup(),
1345 ))
1288 self.new_block(self.unwind, TerminatorKind::Unreachable)
13461289 }
13471290
13481291 _ => span_bug!(self.source_info.span, "open drop from non-ADT `{:?}`", ty),
13491292 }
13501293 }
13511294
1295 #[instrument(level = "debug", skip(self), ret)]
13521296 fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
1353 debug!("complete_drop(succ={:?}, unwind={:?})", succ, unwind);
1354
13551297 let drop_block = self.drop_block(succ, unwind);
1356
13571298 self.drop_flag_test_block(drop_block, succ, unwind)
13581299 }
13591300
13601301 /// Creates a block that resets the drop flag. If `mode` is deep, all children drop flags will
13611302 /// also be cleared.
1303 #[instrument(level = "debug", skip(self), ret)]
13621304 fn drop_flag_reset_block(
13631305 &mut self,
13641306 mode: DropFlagMode,
13651307 succ: BasicBlock,
13661308 unwind: Unwind,
13671309 ) -> BasicBlock {
1368 debug!("drop_flag_reset_block({:?},{:?})", self, mode);
1369
13701310 if unwind.is_cleanup() {
13711311 // The drop flag isn't read again on the unwind path, so don't
13721312 // bother setting it.
......@@ -1378,25 +1318,23 @@ where
13781318 block
13791319 }
13801320
1321 #[instrument(level = "debug", skip(self), ret)]
13811322 fn elaborated_drop_block(&mut self) -> BasicBlock {
1382 debug!("elaborated_drop_block({:?})", self);
1383 let blk = self.drop_block_simple(self.succ, self.unwind);
1323 let blk = self.new_block(
1324 self.unwind,
1325 TerminatorKind::Drop {
1326 place: self.place,
1327 target: self.succ,
1328 unwind: self.unwind.into_action(),
1329 replace: false,
1330 drop: self.dropline,
1331 async_fut: None,
1332 },
1333 );
13841334 self.elaborate_drop(blk);
13851335 blk
13861336 }
13871337
1388 fn drop_block_simple(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
1389 let block = TerminatorKind::Drop {
1390 place: self.place,
1391 target,
1392 unwind: unwind.into_action(),
1393 replace: false,
1394 drop: self.dropline,
1395 async_fut: None,
1396 };
1397 self.new_block(unwind, block)
1398 }
1399
14001338 fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
14011339 let drop_ty = self.place_ty(self.place);
14021340 if !unwind.is_cleanup() && self.check_if_can_async_drop(drop_ty, false) {
......@@ -1410,15 +1348,17 @@ where
14101348 false,
14111349 )
14121350 } else {
1413 let block = TerminatorKind::Drop {
1414 place: self.place,
1415 target,
1416 unwind: unwind.into_action(),
1417 replace: false,
1418 drop: None,
1419 async_fut: None,
1420 };
1421 self.new_block(unwind, block)
1351 self.new_block(
1352 unwind,
1353 TerminatorKind::Drop {
1354 place: self.place,
1355 target,
1356 unwind: unwind.into_action(),
1357 replace: false,
1358 drop: None,
1359 async_fut: None,
1360 },
1361 )
14221362 }
14231363 }
14241364
......@@ -1432,6 +1372,7 @@ where
14321372 /// Depending on the required `DropStyle`, this might be a generated block with an `if`
14331373 /// terminator (for dynamic/open drops), or it might be `on_set` or `on_unset` itself, in case
14341374 /// the drop can be statically determined.
1375 #[instrument(level = "debug", skip(self), ret)]
14351376 fn drop_flag_test_block(
14361377 &mut self,
14371378 on_set: BasicBlock,
......@@ -1439,11 +1380,6 @@ where
14391380 unwind: Unwind,
14401381 ) -> BasicBlock {
14411382 let style = self.elaborator.drop_style(self.path, DropFlagMode::Shallow);
1442 debug!(
1443 "drop_flag_test_block({:?},{:?},{:?},{:?}) - {:?}",
1444 self, on_set, on_unset, unwind, style
1445 );
1446
14471383 match style {
14481384 DropStyle::Dead => on_unset,
14491385 DropStyle::Static => on_set,
......@@ -1455,6 +1391,7 @@ where
14551391 }
14561392 }
14571393
1394 #[instrument(level = "trace", skip(self), ret)]
14581395 fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock {
14591396 self.elaborator.patch().new_block(BasicBlockData::new(
14601397 Some(Terminator { source_info: self.source_info, kind: k }),
......@@ -1462,6 +1399,7 @@ where
14621399 ))
14631400 }
14641401
1402 #[instrument(level = "trace", skip(self, statements), ret)]
14651403 fn new_block_with_statements(
14661404 &mut self,
14671405 unwind: Unwind,
compiler/rustc_passes/src/eii.rs+2-2
......@@ -18,8 +18,8 @@ enum CheckingMode {
1818}
1919
2020fn get_checking_mode(tcx: TyCtxt<'_>) -> CheckingMode {
21 // if any of the crate types is not rlib or dylib, we must check for existence.
22 if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib | CrateType::Dylib)) {
21 // if any of the crate types is not rlib, we must check for existence.
22 if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib)) {
2323 CheckingMode::CheckExistence
2424 } else {
2525 CheckingMode::CheckDuplicates
compiler/rustc_resolve/src/late.rs+14-3
......@@ -3612,6 +3612,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
36123612 this.check_trait_item(
36133613 item.id,
36143614 *ident,
3615 *ident,
36153616 &item.kind,
36163617 ValueNS,
36173618 item.span,
......@@ -3656,7 +3657,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
36563657 );
36573658 self.resolve_define_opaques(define_opaque);
36583659 }
3659 AssocItemKind::Fn(Fn { ident, generics, define_opaque, .. }) => {
3660 AssocItemKind::Fn(fn_kind @ Fn { ident, generics, define_opaque, .. }) => {
36603661 debug!("resolve_implementation AssocItemKind::Fn");
36613662 // We also need a new scope for the impl item type parameters.
36623663 self.with_generic_param_rib(
......@@ -3666,10 +3667,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
36663667 LifetimeBinderKind::Function,
36673668 generics.span,
36683669 |this| {
3670 let effective_ident = if is_in_trait_impl && fn_kind.is_pin_drop_sugar() {
3671 Ident::new(sym::pin_drop, ident.span)
3672 } else {
3673 *ident
3674 };
36693675 // If this is a trait impl, ensure the method
36703676 // exists in trait
36713677 this.check_trait_item(
36723678 item.id,
3679 effective_ident,
36733680 *ident,
36743681 &item.kind,
36753682 ValueNS,
......@@ -3701,6 +3708,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
37013708 this.check_trait_item(
37023709 item.id,
37033710 *ident,
3711 *ident,
37043712 &item.kind,
37053713 TypeNS,
37063714 item.span,
......@@ -3726,6 +3734,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
37263734 this.check_trait_item(
37273735 item.id,
37283736 delegation.ident,
3737 delegation.ident,
37293738 &item.kind,
37303739 ValueNS,
37313740 item.span,
......@@ -3750,6 +3759,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
37503759 &mut self,
37513760 id: NodeId,
37523761 mut ident: Ident,
3762 mut reported_ident: Ident,
37533763 kind: &AssocItemKind,
37543764 ns: Namespace,
37553765 span: Span,
......@@ -3763,6 +3773,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
37633773 return;
37643774 };
37653775 ident.span.normalize_to_macros_2_0_and_adjust(module.expansion);
3776 reported_ident.span.normalize_to_macros_2_0_and_adjust(module.expansion);
37663777 let key = BindingKey::new(IdentKey::new(ident), ns);
37673778 let mut decl = self.r.resolution(module, key).and_then(|r| r.best_decl());
37683779 debug!(?decl);
......@@ -3798,10 +3809,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
37983809
37993810 let Some(decl) = decl else {
38003811 // We could not find the method: report an error.
3801 let candidate = self.find_similarly_named_assoc_item(ident.name, kind);
3812 let candidate = self.find_similarly_named_assoc_item(reported_ident.name, kind);
38023813 let path = &self.current_trait_ref.as_ref().unwrap().1.path;
38033814 let path_names = path_names_to_string(path);
3804 self.report_error(span, err(ident, path_names, candidate));
3815 self.report_error(span, err(reported_ident, path_names, candidate));
38053816 feed_visibility(self, module.def_id());
38063817 return;
38073818 };
compiler/rustc_target/src/spec/base/wasm.rs+7
......@@ -118,6 +118,13 @@ pub(crate) fn options() -> TargetOptions {
118118 // with unwinding.
119119 llvm_args: cvs!["-wasm-use-legacy-eh=false"],
120120
121 // WASI's `sys::args::init` function ignores its arguments; instead,
122 // `args::args()` makes the WASI API calls itself.
123 //
124 // Other Wasm targets make no use of `std::env` entirely.
125 // Emscripten enables it explicitly.
126 main_needs_argc_argv: false,
127
121128 ..Default::default()
122129 }
123130}
compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs+1
......@@ -28,6 +28,7 @@ pub(crate) fn target() -> Target {
2828 crt_static_respected: true,
2929 crt_static_default: true,
3030 crt_static_allows_dylibs: true,
31 main_needs_argc_argv: true,
3132 panic_strategy: PanicStrategy::Unwind,
3233 no_default_libraries: false,
3334 families: cvs!["unix", "wasm"],
compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs-4
......@@ -41,10 +41,6 @@ pub(crate) fn target() -> Target {
4141 // without a main function.
4242 options.crt_static_allows_dylibs = true;
4343
44 // WASI's `sys::args::init` function ignores its arguments; instead,
45 // `args::args()` makes the WASI API calls itself.
46 options.main_needs_argc_argv = false;
47
4844 // And, WASI mangles the name of "main" to distinguish between different
4945 // signatures.
5046 options.entry_name = "__main_void".into();
compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs-4
......@@ -52,10 +52,6 @@ pub(crate) fn target() -> Target {
5252 // without a main function.
5353 options.crt_static_allows_dylibs = true;
5454
55 // WASI's `sys::args::init` function ignores its arguments; instead,
56 // `args::args()` makes the WASI API calls itself.
57 options.main_needs_argc_argv = false;
58
5955 // And, WASI mangles the name of "main" to distinguish between different
6056 // signatures.
6157 options.entry_name = "__main_void".into();
compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs-4
......@@ -46,10 +46,6 @@ pub(crate) fn target() -> Target {
4646 // without a main function.
4747 options.crt_static_allows_dylibs = true;
4848
49 // WASI's `sys::args::init` function ignores its arguments; instead,
50 // `args::args()` makes the WASI API calls itself.
51 options.main_needs_argc_argv = false;
52
5349 // And, WASI mangles the name of "main" to distinguish between different
5450 // signatures.
5551 options.entry_name = "__main_void".into();
library/alloc/src/str.rs+4-1
......@@ -308,7 +308,10 @@ impl str {
308308 pub fn replace<P: Pattern>(&self, from: P, to: &str) -> String {
309309 // Fast path for replacing a single ASCII character with another.
310310 if let Some(from_byte) = match from.as_utf8_pattern() {
311 Some(Utf8Pattern::StringPattern([from_byte])) => Some(*from_byte),
311 Some(Utf8Pattern::StringPattern(s)) => match s.as_bytes() {
312 [from_byte] => Some(*from_byte),
313 _ => None,
314 },
312315 Some(Utf8Pattern::CharPattern(c)) => c.as_ascii().map(|ascii_char| ascii_char.to_u8()),
313316 _ => None,
314317 } {
library/alloc/src/string.rs+1-1
......@@ -2654,7 +2654,7 @@ impl<'b> Pattern for &'b String {
26542654
26552655 #[inline]
26562656 fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> {
2657 Some(Utf8Pattern::StringPattern(self.as_bytes()))
2657 Some(Utf8Pattern::StringPattern(self.as_str()))
26582658 }
26592659}
26602660
library/core/src/str/pattern.rs+5-3
......@@ -161,7 +161,7 @@ pub trait Pattern: Sized {
161161 }
162162 }
163163
164 /// Returns the pattern as utf-8 bytes if possible.
164 /// Returns the pattern as UTF-8 if possible.
165165 fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> {
166166 None
167167 }
......@@ -172,7 +172,9 @@ pub trait Pattern: Sized {
172172#[derive(Copy, Clone, Eq, PartialEq, Debug)]
173173pub enum Utf8Pattern<'a> {
174174 /// Type returned by String and str types.
175 StringPattern(&'a [u8]),
175 /// This stores `str` rather than bytes so callers cannot describe
176 /// non-UTF-8 string patterns through this API.
177 StringPattern(&'a str),
176178 /// Type returned by char types.
177179 CharPattern(char),
178180}
......@@ -1049,7 +1051,7 @@ impl<'b> Pattern for &'b str {
10491051
10501052 #[inline]
10511053 fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> {
1052 Some(Utf8Pattern::StringPattern(self.as_bytes()))
1054 Some(Utf8Pattern::StringPattern(*self))
10531055 }
10541056}
10551057
library/std/src/env.rs+1-1
......@@ -689,7 +689,7 @@ pub fn home_dir() -> Option<PathBuf> {
689689/// [GetTempPath]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
690690/// [appledoc]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10
691691///
692/// ```no_run
692/// ```
693693/// use std::env;
694694///
695695/// fn main() {
src/librustdoc/html/macro_expansion.rs+15-2
......@@ -1,5 +1,8 @@
1use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt, walk_ty};
2use rustc_ast::{Crate, Expr, Item, Pat, Stmt, Ty};
1use rustc_ast::visit::{
2 AssocCtxt, Visitor, walk_assoc_item, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt,
3 walk_ty,
4};
5use rustc_ast::{AssocItem, Crate, Expr, Item, Pat, Stmt, Ty};
36use rustc_data_structures::fx::FxHashMap;
47use rustc_span::source_map::SourceMap;
58use rustc_span::{BytePos, Span};
......@@ -161,4 +164,14 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> {
161164 walk_ty(self, ty);
162165 }
163166 }
167
168 fn visit_assoc_item(&mut self, item: &'ast AssocItem, ctxt: AssocCtxt) -> Self::Result {
169 if item.span.from_expansion() {
170 self.handle_new_span(item.span, || {
171 rustc_ast_pretty::pprust::assoc_item_to_string(item)
172 });
173 } else {
174 walk_assoc_item(self, item, ctxt);
175 }
176 }
164177}
tests/assembly-llvm/wasm_legacy_eh.rs created+80
......@@ -0,0 +1,80 @@
1//@ only-wasm32
2//@ assembly-output: emit-asm
3//@ compile-flags: -C target-feature=+exception-handling
4//@ compile-flags: -C panic=unwind
5//@ compile-flags: -C llvm-args=-wasm-use-legacy-eh=true
6
7// Verifies that user-supplied `-Cllvm-args` can override an LLVM argument that
8// was set in the target spec. The `wasm32-unknown-unknown` target spec pins
9// `-wasm-use-legacy-eh=false`; this test asserts that passing the opposite
10// value via `-Cllvm-args` switches code generation back to the legacy
11// exception-handling instructions.
12
13#![crate_type = "lib"]
14#![feature(core_intrinsics)]
15
16extern "C-unwind" {
17 fn may_panic();
18}
19
20extern "C" {
21 fn log_number(number: usize);
22}
23
24struct LogOnDrop;
25
26impl Drop for LogOnDrop {
27 fn drop(&mut self) {
28 unsafe {
29 log_number(0);
30 }
31 }
32}
33
34// CHECK-LABEL: test_cleanup:
35#[no_mangle]
36pub fn test_cleanup() {
37 let _log_on_drop = LogOnDrop;
38 unsafe {
39 may_panic();
40 }
41
42 // CHECK-NOT: try_table
43 // CHECK-NOT: catch_all_ref
44 // CHECK-NOT: throw_ref
45 // CHECK-NOT: call
46 // CHECK: try
47 // CHECK: call may_panic
48 // CHECK: catch_all
49 // CHECK: rethrow
50 // CHECK: end_try
51}
52
53// CHECK-LABEL: test_rtry:
54#[no_mangle]
55pub fn test_rtry() {
56 unsafe {
57 core::intrinsics::catch_unwind(
58 |_| {
59 may_panic();
60 },
61 core::ptr::null_mut(),
62 |data, exception| {
63 log_number(data as usize);
64 log_number(exception as usize);
65 },
66 );
67 }
68
69 // CHECK-NOT: try_table
70 // CHECK-NOT: catch_all_ref
71 // CHECK-NOT: throw_ref
72 // CHECK-NOT: call
73 // CHECK: try
74 // CHECK: call may_panic
75 // CHECK: catch
76 // CHECK: call log_number
77 // CHECK: call log_number
78 // CHECK-NOT: rethrow
79 // CHECK: end_try
80}
tests/coverage/macros/context-mismatch-issue-147339.cov-map+6-26
......@@ -1,40 +1,20 @@
1Function name: context_mismatch_issue_147339::a (unused)
2Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
1Function name: context_mismatch_issue_147339::_function (unused)
2Raw bytes (14): 0x[01, 01, 00, 02, 00, 14, 11, 00, 26, 00, 02, 11, 00, 12]
33Number of files: 1
44- file 0 => $DIR/context-mismatch-issue-147339.rs
55Number of expressions: 0
66Number of file 0 mappings: 2
7- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
8- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
9Highest counter ID seen: (none)
10
11Function name: context_mismatch_issue_147339::b (unused)
12Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
13Number of files: 1
14- file 0 => $DIR/context-mismatch-issue-147339.rs
15Number of expressions: 0
16Number of file 0 mappings: 2
17- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
18- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
19Highest counter ID seen: (none)
20
21Function name: context_mismatch_issue_147339::c (unused)
22Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
23Number of files: 1
24- file 0 => $DIR/context-mismatch-issue-147339.rs
25Number of expressions: 0
26Number of file 0 mappings: 2
27- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
28- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
7- Code(Zero) at (prev + 20, 17) to (start + 0, 38)
8- Code(Zero) at (prev + 2, 17) to (start + 0, 18)
299Highest counter ID seen: (none)
3010
3111Function name: context_mismatch_issue_147339::main
32Raw bytes (14): 0x[01, 01, 00, 02, 01, 14, 01, 00, 0a, 01, 00, 0c, 00, 0d]
12Raw bytes (14): 0x[01, 01, 00, 02, 01, 1f, 01, 00, 0a, 01, 00, 0c, 00, 0d]
3313Number of files: 1
3414- file 0 => $DIR/context-mismatch-issue-147339.rs
3515Number of expressions: 0
3616Number of file 0 mappings: 2
37- Code(Counter(0)) at (prev + 20, 1) to (start + 0, 10)
17- Code(Counter(0)) at (prev + 31, 1) to (start + 0, 10)
3818- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13)
3919Highest counter ID seen: c0
4020
tests/coverage/macros/context-mismatch-issue-147339.coverage+19-15
......@@ -6,23 +6,27 @@
66 LL| |//
77 LL| |// Reported in <https://github.com/rust-lang/rust/issues/147339>.
88 LL| |
9 LL| |macro_rules! foo {
10 LL| | ($($m:ident $($f:ident $v:tt)+),*) => {
11 LL| | $($(macro_rules! $f { () => { $v } })+)*
12 LL| 0| $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })*
13 ------------------
14 | Unexecuted instantiation: context_mismatch_issue_147339::a
15 ------------------
16 | Unexecuted instantiation: context_mismatch_issue_147339::b
17 ------------------
18 | Unexecuted instantiation: context_mismatch_issue_147339::c
19 ------------------
20 LL| | }
9 LL| |macro_rules! outer_macro {
10 LL| | (
11 LL| | $v:tt
12 LL| | ) => {
13 LL| | macro_rules! _other_macro_that_mentions_v {
14 LL| | () => {
15 LL| | $v
16 LL| | };
17 LL| | }
18 LL| | macro_rules! inner_macro {
19 LL| | () => {
20 LL| 0| fn _function() -> i32 {
21 LL| | $v
22 LL| 0| }
23 LL| | };
24 LL| | }
25 LL| | };
2126 LL| |}
2227 LL| |
23 LL| |foo!(m a 1 b 2, n c 3);
24 LL| |m!();
25 LL| |n!();
28 LL| |outer_macro!(1);
29 LL| |inner_macro!();
2630 LL| |
2731 LL| 1|fn main() {}
2832
tests/coverage/macros/context-mismatch-issue-147339.rs+19-8
......@@ -6,15 +6,26 @@
66//
77// Reported in <https://github.com/rust-lang/rust/issues/147339>.
88
9macro_rules! foo {
10 ($($m:ident $($f:ident $v:tt)+),*) => {
11 $($(macro_rules! $f { () => { $v } })+)*
12 $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })*
13 }
9macro_rules! outer_macro {
10 (
11 $v:tt
12 ) => {
13 macro_rules! _other_macro_that_mentions_v {
14 () => {
15 $v
16 };
17 }
18 macro_rules! inner_macro {
19 () => {
20 fn _function() -> i32 {
21 $v
22 }
23 };
24 }
25 };
1426}
1527
16foo!(m a 1 b 2, n c 3);
17m!();
18n!();
28outer_macro!(1);
29inner_macro!();
1930
2031fn main() {}
tests/rustdoc-html/macro-expansion/assoc-items-decl-macro.rs created+24
......@@ -0,0 +1,24 @@
1// Ensure assoc items work for decl macros.
2// Regression test for <https://github.com/rust-lang/rust/issues/156075>.
3
4//@ compile-flags: -Zunstable-options --generate-macro-expansion
5
6#![crate_name = "foo"]
7#![feature(decl_macro)]
8
9//@ has 'src/foo/assoc-items-decl-macro.rs.html'
10
11pub macro first() {
12 type P1 = bool;
13 fn u1() {}
14}
15
16trait C1 {
17 type P1;
18 fn u1();
19}
20
21impl C1 for u32 {
22 //@ matches - '//*[@class="expansion"]/*[@class="expanded"]' 'type P1 = bool;\nfn u1\(\) {}'
23 first!();
24}
tests/rustdoc-html/macro-expansion/assoc-items-macro.rs created+25
......@@ -0,0 +1,25 @@
1// Ensure assoc items work for macro rules.
2// Regression test for <https://github.com/rust-lang/rust/issues/156075>.
3
4//@ compile-flags: -Zunstable-options --generate-macro-expansion
5
6#![crate_name = "foo"]
7
8//@ has 'src/foo/assoc-items-macro.rs.html'
9
10macro_rules! first {
11 () => {
12 type P1 = bool;
13 fn u1() {}
14 }
15}
16
17trait C1 {
18 type P1;
19 fn u1();
20}
21
22impl C1 for u32 {
23 //@ matches - '//*[@class="expansion"]/*[@class="expanded"]' 'type P1 = bool;\nfn u1\(\) {}'
24 first!();
25}
tests/rustdoc-ui/not-wf-ambiguous-normalization.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
22 --> $DIR/not-wf-ambiguous-normalization.rs:14:6
33 |
44LL | impl<T> Allocator for DefaultAllocator {
5 | ^ unconstrained type parameter
5 | -^-
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `T`
69
710error: aborting due to 1 previous error
811
tests/rustdoc-ui/synthetic-auto-trait-impls/unconstrained-param-in-impl-ambiguity.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `Q` is not constrained by the impl trait, self
22 --> $DIR/unconstrained-param-in-impl-ambiguity.rs:7:13
33 |
44LL | unsafe impl<Q: Trait> Send for Inner {}
5 | ^ unconstrained type parameter
5 | -^--------
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `Q`
69
710error: aborting due to 1 previous error
811
tests/ui/associated-inherent-types/hr-do-not-blame-outlives-static-ice.stderr+7
......@@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
33 |
44LL | impl<'a> Foo<fn(&())> {
55 | ^^ unconstrained lifetime parameter
6 |
7help: use the lifetime parameter `'a` in the `Foo` type and use it in the type definition
8 |
9LL ~ struct Foo<T, 'a>(T);
10LL |
11LL ~ impl<'a> Foo<fn(&()), 'a> {
12 |
613
714error[E0308]: mismatched types
815 --> $DIR/hr-do-not-blame-outlives-static-ice.rs:13:11
tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `X` is not constrained by the impl trait, self
22 --> $DIR/inherent-assoc-ty-mismatch-issue-153539.rs:9:6
33 |
44LL | impl<X> S<'_> {
5 | ^ unconstrained type parameter
5 | -^-
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `X`
69
710error[E0308]: mismatched types
811 --> $DIR/inherent-assoc-ty-mismatch-issue-153539.rs:17:5
tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr+4-1
......@@ -27,7 +27,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
2727 --> $DIR/next-solver-opaque-inherent-fn-ptr-issue-155204.rs:7:6
2828 |
2929LL | impl<T> Windows<fn(&())> {
30 | ^ unconstrained type parameter
30 | -^-
31 | ||
32 | |unconstrained type parameter
33 | help: remove the unused type parameter `T`
3134
3235error[E0282]: type annotations needed
3336 --> $DIR/next-solver-opaque-inherent-fn-ptr-issue-155204.rs:12:22
tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr+4-1
......@@ -24,7 +24,10 @@ error[E0207]: the const parameter `X` is not constrained by the impl trait, self
2424 --> $DIR/next-solver-opaque-inherent-no-ice.rs:6:6
2525 |
2626LL | impl<const X: y> Foo {
27 | ^^^^^^^^^^ unconstrained const parameter
27 | -^^^^^^^^^^-
28 | ||
29 | |unconstrained const parameter
30 | help: remove the unused type parameter `X`
2831 |
2932 = note: expressions using a const parameter must map each value to a distinct output value
3033 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/associated-types/issue-26262.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: Tr> S<T::Assoc> {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `S` type and use it in the type definition
8 |
9LL ~ struct S<T, T>(T);
10LL |
11LL | trait Tr { type Assoc; fn test(); }
12LL |
13LL ~ impl<T: Tr> S<T::Assoc, T> {
14 |
615
716error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
817 --> $DIR/issue-26262.rs:17:6
tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
33 |
44LL | impl<'a> Fun for Holder {
55 | ^^ unconstrained lifetime parameter
6 |
7help: use the lifetime parameter `'a` in the `Holder` type and use it in the type definition
8 |
9LL ~ struct Holder<'a> {
10LL | x: String,
11LL | }
12LL |
13LL ~ impl<'a> Fun for Holder<'a> {
14 |
615
716error: aborting due to 1 previous error
817
tests/ui/async-await/issues/issue-78654.full.stderr+4-1
......@@ -8,7 +8,10 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self
88 --> $DIR/issue-78654.rs:9:6
99 |
1010LL | impl<const H: feature> Foo {
11 | ^^^^^^^^^^^^^^^^ unconstrained const parameter
11 | -^^^^^^^^^^^^^^^^-
12 | ||
13 | |unconstrained const parameter
14 | help: remove the unused type parameter `H`
1215 |
1316 = note: expressions using a const parameter must map each value to a distinct output value
1417 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/async-await/issues/issue-78654.min.stderr+4-1
......@@ -8,7 +8,10 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self
88 --> $DIR/issue-78654.rs:9:6
99 |
1010LL | impl<const H: feature> Foo {
11 | ^^^^^^^^^^^^^^^^ unconstrained const parameter
11 | -^^^^^^^^^^^^^^^^-
12 | ||
13 | |unconstrained const parameter
14 | help: remove the unused type parameter `H`
1215 |
1316 = note: expressions using a const parameter must map each value to a distinct output value
1417 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.stderr+8-2
......@@ -37,7 +37,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self
3737 --> $DIR/unsized-anon-const-err-2.rs:13:6
3838 |
3939LL | impl<const N: i32> Copy for S<A> {}
40 | ^^^^^^^^^^^^ unconstrained const parameter
40 | -^^^^^^^^^^^^-
41 | ||
42 | |unconstrained const parameter
43 | help: remove the unused type parameter `N`
4144 |
4245 = note: expressions using a const parameter must map each value to a distinct output value
4346 = note: proving the result of expressions other than the parameter are unique is not supported
......@@ -46,7 +49,10 @@ error[E0207]: the const parameter `M` is not constrained by the impl trait, self
4649 --> $DIR/unsized-anon-const-err-2.rs:16:6
4750 |
4851LL | impl<const M: usize> Copy for S<A> {}
49 | ^^^^^^^^^^^^^^ unconstrained const parameter
52 | -^^^^^^^^^^^^^^-
53 | ||
54 | |unconstrained const parameter
55 | help: remove the unused type parameter `M`
5056 |
5157 = note: expressions using a const parameter must map each value to a distinct output value
5258 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr+4-1
......@@ -24,7 +24,10 @@ error[E0207]: the const parameter `NUM` is not constrained by the impl trait, se
2424 --> $DIR/post-analysis-user-facing-param-env.rs:5:10
2525 |
2626LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo
27 | ^^^^^^^^^^^^^^^^ unconstrained const parameter
27 | --^^^^^^^^^^^^^^^^
28 | | |
29 | | unconstrained const parameter
30 | help: remove the unused type parameter `NUM`
2831 |
2932 = note: expressions using a const parameter must map each value to a distinct output value
3033 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr+8
......@@ -71,6 +71,14 @@ LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
7171 |
7272 = note: expressions using a const parameter must map each value to a distinct output value
7373 = note: proving the result of expressions other than the parameter are unique is not supported
74help: use the type parameter `N` in the `ConstChunksExact` type and use it in the type definition
75 |
76LL ~ struct ConstChunksExact<'rem, T: 'a, const N: usize, N> {}
77LL |
78LL |
79LL |
80LL ~ impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}, N> {
81 |
7482
7583error: aborting due to 8 previous errors
7684
tests/ui/const-generics/issues/issue-68366.full.stderr+8-2
......@@ -14,7 +14,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self
1414 --> $DIR/issue-68366.rs:12:7
1515 |
1616LL | impl <const N: usize> Collatz<{Some(N)}> {}
17 | ^^^^^^^^^^^^^^ unconstrained const parameter
17 | -^^^^^^^^^^^^^^-
18 | ||
19 | |unconstrained const parameter
20 | help: remove the unused type parameter `N`
1821 |
1922 = note: expressions using a const parameter must map each value to a distinct output value
2023 = note: proving the result of expressions other than the parameter are unique is not supported
......@@ -23,7 +26,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self
2326 --> $DIR/issue-68366.rs:19:6
2427 |
2528LL | impl<const N: usize> Foo {}
26 | ^^^^^^^^^^^^^^ unconstrained const parameter
29 | -^^^^^^^^^^^^^^-
30 | ||
31 | |unconstrained const parameter
32 | help: remove the unused type parameter `N`
2733 |
2834 = note: expressions using a const parameter must map each value to a distinct output value
2935 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/const-generics/issues/issue-68366.min.stderr+8-2
......@@ -23,7 +23,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self
2323 --> $DIR/issue-68366.rs:12:7
2424 |
2525LL | impl <const N: usize> Collatz<{Some(N)}> {}
26 | ^^^^^^^^^^^^^^ unconstrained const parameter
26 | -^^^^^^^^^^^^^^-
27 | ||
28 | |unconstrained const parameter
29 | help: remove the unused type parameter `N`
2730 |
2831 = note: expressions using a const parameter must map each value to a distinct output value
2932 = note: proving the result of expressions other than the parameter are unique is not supported
......@@ -32,7 +35,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self
3235 --> $DIR/issue-68366.rs:19:6
3336 |
3437LL | impl<const N: usize> Foo {}
35 | ^^^^^^^^^^^^^^ unconstrained const parameter
38 | -^^^^^^^^^^^^^^-
39 | ||
40 | |unconstrained const parameter
41 | help: remove the unused type parameter `N`
3642 |
3743 = note: expressions using a const parameter must map each value to a distinct output value
3844 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr+8
......@@ -53,6 +53,14 @@ LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<
5353 |
5454 = note: expressions using a const parameter must map each value to a distinct output value
5555 = note: proving the result of expressions other than the parameter are unique is not supported
56help: use the type parameter `N` in the `ConstChunksExact` type and use it in the type definition
57 |
58LL ~ struct ConstChunksExact<'a, T: '_, const assert: usize, N> {}
59LL |
60LL |
61LL |
62LL ~ impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}, N> {
63 |
5664
5765error[E0308]: mismatched types
5866 --> $DIR/normalizing_with_unconstrained_impl_params.rs:6:27
tests/ui/delegation/generics/free-to-trait-static-reuse.rs+6
......@@ -1,3 +1,5 @@
1//@ compile-flags: -Z deduplicate-diagnostics=yes
2
13#![feature(fn_delegation)]
24
35trait Bound<T> {}
......@@ -19,12 +21,16 @@ reuse <usize as Trait>::static_method::<'static, Vec<i32>, false> as bar2;
1921
2022reuse Trait::static_method as error { self - 123 }
2123//~^ ERROR: type annotations needed
24//~| ERROR: delegation self type is not specified
2225reuse Trait::<'static, i32, 123>::static_method as error2;
2326//~^ ERROR: type annotations needed
27//~| ERROR: delegation self type is not specified
2428reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3;
2529//~^ ERROR: type annotations needed
30//~| ERROR: delegation self type is not specified
2631reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 }
2732//~^ ERROR: type annotations needed
33//~| ERROR: delegation self type is not specified
2834
2935reuse <String as Trait>::static_method as error5;
3036//~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied
tests/ui/delegation/generics/free-to-trait-static-reuse.stderr+51-19
......@@ -1,21 +1,53 @@
1error: delegation self type is not specified
2 --> $DIR/free-to-trait-static-reuse.rs:22:14
3 |
4LL | reuse Trait::static_method as error { self - 123 }
5 | ^^^^^^^^^^^^^
6 |
7 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
8
9error: delegation self type is not specified
10 --> $DIR/free-to-trait-static-reuse.rs:25:35
11 |
12LL | reuse Trait::<'static, i32, 123>::static_method as error2;
13 | ^^^^^^^^^^^^^
14 |
15 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
16
17error: delegation self type is not specified
18 --> $DIR/free-to-trait-static-reuse.rs:28:35
19 |
20LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3;
21 | ^^^^^^^^^^^^^
22 |
23 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
24
25error: delegation self type is not specified
26 --> $DIR/free-to-trait-static-reuse.rs:31:14
27 |
28LL | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 }
29 | ^^^^^^^^^^^^^
30 |
31 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
32
133error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
2 --> $DIR/free-to-trait-static-reuse.rs:33:49
34 --> $DIR/free-to-trait-static-reuse.rs:39:49
335 |
436LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
537 | ^^^^^^ unsatisfied trait bound
638 |
739help: the trait `Bound<T>` is not implemented for `Struct`
8 --> $DIR/free-to-trait-static-reuse.rs:32:1
40 --> $DIR/free-to-trait-static-reuse.rs:38:1
941 |
1042LL | struct Struct;
1143 | ^^^^^^^^^^^^^
1244help: the trait `Bound<T>` is implemented for `usize`
13 --> $DIR/free-to-trait-static-reuse.rs:13:1
45 --> $DIR/free-to-trait-static-reuse.rs:15:1
1446 |
1547LL | impl<T> Bound<T> for usize {}
1648 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
1749note: required by a bound in `Trait`
18 --> $DIR/free-to-trait-static-reuse.rs:7:11
50 --> $DIR/free-to-trait-static-reuse.rs:9:11
1951 |
2052LL | trait Trait<'a, T, const X: usize>
2153 | ----- required by a bound in this trait
......@@ -24,13 +56,13 @@ LL | Self: Bound<T>,
2456 | ^^^^^^^^ required by this bound in `Trait`
2557
2658error[E0283]: type annotations needed
27 --> $DIR/free-to-trait-static-reuse.rs:20:14
59 --> $DIR/free-to-trait-static-reuse.rs:22:14
2860 |
2961LL | reuse Trait::static_method as error { self - 123 }
3062 | ^^^^^^^^^^^^^ cannot infer type
3163 |
3264note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found
33 --> $DIR/free-to-trait-static-reuse.rs:12:1
65 --> $DIR/free-to-trait-static-reuse.rs:14:1
3466 |
3567LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
3668 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -39,13 +71,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
3971 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4072
4173error[E0283]: type annotations needed
42 --> $DIR/free-to-trait-static-reuse.rs:22:35
74 --> $DIR/free-to-trait-static-reuse.rs:25:35
4375 |
4476LL | reuse Trait::<'static, i32, 123>::static_method as error2;
4577 | ^^^^^^^^^^^^^ cannot infer type
4678 |
4779note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found
48 --> $DIR/free-to-trait-static-reuse.rs:12:1
80 --> $DIR/free-to-trait-static-reuse.rs:14:1
4981 |
5082LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
5183 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -54,13 +86,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
5486 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5587
5688error[E0283]: type annotations needed
57 --> $DIR/free-to-trait-static-reuse.rs:24:35
89 --> $DIR/free-to-trait-static-reuse.rs:28:35
5890 |
5991LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3;
6092 | ^^^^^^^^^^^^^ cannot infer type
6193 |
6294note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found
63 --> $DIR/free-to-trait-static-reuse.rs:12:1
95 --> $DIR/free-to-trait-static-reuse.rs:14:1
6496 |
6597LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
6698 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -69,13 +101,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
69101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70102
71103error[E0283]: type annotations needed
72 --> $DIR/free-to-trait-static-reuse.rs:26:14
104 --> $DIR/free-to-trait-static-reuse.rs:31:14
73105 |
74106LL | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 }
75107 | ^^^^^^^^^^^^^ cannot infer type
76108 |
77109note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found
78 --> $DIR/free-to-trait-static-reuse.rs:12:1
110 --> $DIR/free-to-trait-static-reuse.rs:14:1
79111 |
80112LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
81113 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -84,13 +116,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
84116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85117
86118error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied
87 --> $DIR/free-to-trait-static-reuse.rs:29:8
119 --> $DIR/free-to-trait-static-reuse.rs:35:8
88120 |
89121LL | reuse <String as Trait>::static_method as error5;
90122 | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String`
91123 |
92124help: the following other types implement trait `Trait<'a, T, X>`
93 --> $DIR/free-to-trait-static-reuse.rs:12:1
125 --> $DIR/free-to-trait-static-reuse.rs:14:1
94126 |
95127LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
96128 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize`
......@@ -99,23 +131,23 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
99131 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct`
100132
101133error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
102 --> $DIR/free-to-trait-static-reuse.rs:36:8
134 --> $DIR/free-to-trait-static-reuse.rs:42:8
103135 |
104136LL | reuse <Struct as Trait>::static_method as error6;
105137 | ^^^^^^ unsatisfied trait bound
106138 |
107139help: the trait `Bound<T>` is not implemented for `Struct`
108 --> $DIR/free-to-trait-static-reuse.rs:32:1
140 --> $DIR/free-to-trait-static-reuse.rs:38:1
109141 |
110142LL | struct Struct;
111143 | ^^^^^^^^^^^^^
112144help: the trait `Bound<T>` is implemented for `usize`
113 --> $DIR/free-to-trait-static-reuse.rs:13:1
145 --> $DIR/free-to-trait-static-reuse.rs:15:1
114146 |
115147LL | impl<T> Bound<T> for usize {}
116148 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
117149note: required by a bound in `Trait::static_method`
118 --> $DIR/free-to-trait-static-reuse.rs:7:11
150 --> $DIR/free-to-trait-static-reuse.rs:9:11
119151 |
120152LL | Self: Bound<T>,
121153 | ^^^^^^^^ required by this bound in `Trait::static_method`
......@@ -123,7 +155,7 @@ LL | {
123155LL | fn static_method<'c: 'c, U, const B: bool>(x: usize) {}
124156 | ------------- required by a bound in this associated function
125157
126error: aborting due to 7 previous errors
158error: aborting due to 11 previous errors
127159
128160Some errors have detailed explanations: E0277, E0283.
129161For more information about an error, try `rustc --explain E0277`.
tests/ui/delegation/self-ty-ice-156388.rs created+8
......@@ -0,0 +1,8 @@
1//@ compile-flags: -Z deduplicate-diagnostics=yes
2
3#![feature(fn_delegation)]
4
5reuse Default::default;
6//~^ ERROR: delegation self type is not specified
7
8fn main() {}
tests/ui/delegation/self-ty-ice-156388.stderr created+10
......@@ -0,0 +1,10 @@
1error: delegation self type is not specified
2 --> $DIR/self-ty-ice-156388.rs:5:16
3 |
4LL | reuse Default::default;
5 | ^^^^^^^
6 |
7 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
8
9error: aborting due to 1 previous error
10
tests/ui/delegation/target-expr.rs+3
......@@ -1,3 +1,5 @@
1//@ compile-flags: -Z deduplicate-diagnostics=yes
2
13#![feature(fn_delegation)]
24
35trait Trait {
......@@ -14,6 +16,7 @@ fn foo(x: i32) -> i32 { x }
1416fn bar<T: Default>(_: T) {
1517 reuse Trait::static_method {
1618 //~^ ERROR mismatched types
19 //~| ERROR: delegation self type is not specified
1720 let _ = T::Default();
1821 //~^ ERROR can't use generic parameters from outer item
1922 }
tests/ui/delegation/target-expr.stderr+17-8
......@@ -1,18 +1,18 @@
11error[E0401]: can't use generic parameters from outer item
2 --> $DIR/target-expr.rs:17:17
2 --> $DIR/target-expr.rs:20:17
33 |
44LL | fn bar<T: Default>(_: T) {
55 | - type parameter from outer item
66LL | reuse Trait::static_method {
77 | ------------- generic parameter used in this inner delegated function
8LL |
8...
99LL | let _ = T::Default();
1010 | ^ use of generic parameter from outer item
1111 |
1212 = note: nested items are independent from their parent item for everything except for privacy and name resolution
1313
1414error[E0434]: can't capture dynamic environment in a fn item
15 --> $DIR/target-expr.rs:25:17
15 --> $DIR/target-expr.rs:28:17
1616 |
1717LL | let x = y;
1818 | ^
......@@ -20,7 +20,7 @@ LL | let x = y;
2020 = help: use the `|| { ... }` closure form instead
2121
2222error[E0424]: expected value, found module `self`
23 --> $DIR/target-expr.rs:32:5
23 --> $DIR/target-expr.rs:35:5
2424 |
2525LL | fn main() {
2626 | ---- this function can't have a `self` parameter
......@@ -29,29 +29,38 @@ LL | self.0;
2929 | ^^^^ `self` value is a keyword only available in methods with a `self` parameter
3030
3131error[E0425]: cannot find value `x` in this scope
32 --> $DIR/target-expr.rs:34:13
32 --> $DIR/target-expr.rs:37:13
3333 |
3434LL | let z = x;
3535 | ^
3636 |
3737help: the binding `x` is available in a different scope in the same function
38 --> $DIR/target-expr.rs:25:13
38 --> $DIR/target-expr.rs:28:13
3939 |
4040LL | let x = y;
4141 | ^
4242
43error: delegation self type is not specified
44 --> $DIR/target-expr.rs:17:18
45 |
46LL | reuse Trait::static_method {
47 | ^^^^^^^^^^^^^
48 |
49 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
50
4351error[E0308]: mismatched types
44 --> $DIR/target-expr.rs:15:32
52 --> $DIR/target-expr.rs:17:32
4553 |
4654LL | reuse Trait::static_method {
4755 | ________________________________^
4856LL | |
57LL | |
4958LL | | let _ = T::Default();
5059LL | |
5160LL | | }
5261 | |_____^ expected `i32`, found `()`
5362
54error: aborting due to 5 previous errors
63error: aborting due to 6 previous errors
5564
5665Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434.
5766For more information about an error, try `rustc --explain E0308`.
tests/ui/delegation/unsupported.current.stderr+21-13
......@@ -1,41 +1,49 @@
1error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`
2 --> $DIR/unsupported.rs:29:25
1error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
2 --> $DIR/unsupported.rs:30:25
33 |
44LL | reuse to_reuse::opaque_ret;
55 | ^^^^^^^^^^
66 |
77note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8 --> $DIR/unsupported.rs:29:25
8 --> $DIR/unsupported.rs:30:25
99 |
1010LL | reuse to_reuse::opaque_ret;
1111 | ^^^^^^^^^^
12 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret` is compatible with trait definition
14 --> $DIR/unsupported.rs:29:25
12 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition
14 --> $DIR/unsupported.rs:30:25
1515 |
1616LL | reuse to_reuse::opaque_ret;
1717 | ^^^^^^^^^^
1818 = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
1919
20error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`
21 --> $DIR/unsupported.rs:32:24
20error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
21 --> $DIR/unsupported.rs:33:24
2222 |
2323LL | reuse ToReuse::opaque_ret;
2424 | ^^^^^^^^^^
2525 |
2626note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
27 --> $DIR/unsupported.rs:32:24
27 --> $DIR/unsupported.rs:33:24
2828 |
2929LL | reuse ToReuse::opaque_ret;
3030 | ^^^^^^^^^^
31 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret` is compatible with trait definition
33 --> $DIR/unsupported.rs:32:24
31 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition
33 --> $DIR/unsupported.rs:33:24
3434 |
3535LL | reuse ToReuse::opaque_ret;
3636 | ^^^^^^^^^^
3737 = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
3838
39error: aborting due to 2 previous errors
39error: delegation self type is not specified
40 --> $DIR/unsupported.rs:54:18
41 |
42LL | reuse Trait::foo;
43 | ^^^
44 |
45 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
46
47error: aborting due to 3 previous errors
4048
4149For more information about this error, try `rustc --explain E0391`.
tests/ui/delegation/unsupported.next.stderr+21-13
......@@ -1,41 +1,49 @@
1error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`
2 --> $DIR/unsupported.rs:29:25
1error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
2 --> $DIR/unsupported.rs:30:25
33 |
44LL | reuse to_reuse::opaque_ret;
55 | ^^^^^^^^^^
66 |
77note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8 --> $DIR/unsupported.rs:29:25
8 --> $DIR/unsupported.rs:30:25
99 |
1010LL | reuse to_reuse::opaque_ret;
1111 | ^^^^^^^^^^
12 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret` is compatible with trait definition
14 --> $DIR/unsupported.rs:29:25
12 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition
14 --> $DIR/unsupported.rs:30:25
1515 |
1616LL | reuse to_reuse::opaque_ret;
1717 | ^^^^^^^^^^
1818 = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
1919
20error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`
21 --> $DIR/unsupported.rs:32:24
20error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
21 --> $DIR/unsupported.rs:33:24
2222 |
2323LL | reuse ToReuse::opaque_ret;
2424 | ^^^^^^^^^^
2525 |
2626note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
27 --> $DIR/unsupported.rs:32:24
27 --> $DIR/unsupported.rs:33:24
2828 |
2929LL | reuse ToReuse::opaque_ret;
3030 | ^^^^^^^^^^
31 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret` is compatible with trait definition
33 --> $DIR/unsupported.rs:32:24
31 = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition
33 --> $DIR/unsupported.rs:33:24
3434 |
3535LL | reuse ToReuse::opaque_ret;
3636 | ^^^^^^^^^^
3737 = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
3838
39error: aborting due to 2 previous errors
39error: delegation self type is not specified
40 --> $DIR/unsupported.rs:54:18
41 |
42LL | reuse Trait::foo;
43 | ^^^
44 |
45 = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`
46
47error: aborting due to 3 previous errors
4048
4149For more information about this error, try `rustc --explain E0391`.
tests/ui/delegation/unsupported.rs+2
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Z deduplicate-diagnostics=yes
12//@ revisions: current next
23//@ ignore-compare-mode-next-solver (explicit revisions)
34//@[next] compile-flags: -Znext-solver
......@@ -51,6 +52,7 @@ mod effects {
5152 }
5253
5354 reuse Trait::foo;
55 //~^ ERROR: delegation self type is not specified
5456}
5557
5658fn main() {}
tests/ui/dropck/unconstrained_const_param_on_drop.stderr+4-1
......@@ -22,7 +22,10 @@ error[E0207]: the const parameter `UNUSED` is not constrained by the impl trait,
2222 --> $DIR/unconstrained_const_param_on_drop.rs:3:6
2323 |
2424LL | impl<const UNUSED: usize> Drop for Foo {}
25 | ^^^^^^^^^^^^^^^^^^^ unconstrained const parameter
25 | -^^^^^^^^^^^^^^^^^^^-
26 | ||
27 | |unconstrained const parameter
28 | help: remove the unused type parameter `UNUSED`
2629 |
2730 = note: expressions using a const parameter must map each value to a distinct output value
2831 = note: proving the result of expressions other than the parameter are unique is not supported
tests/ui/eii/dylib_needs_impl.rs created+7
......@@ -0,0 +1,7 @@
1//@ no-prefer-dynamic
2//@ needs-crate-type: dylib
3#![crate_type = "dylib"]
4#![feature(extern_item_impls)]
5
6#[eii(eii1)] //~ ERROR `#[eii1]` required, but not found
7fn decl1(x: u64);
tests/ui/eii/dylib_needs_impl.stderr created+10
......@@ -0,0 +1,10 @@
1error: `#[eii1]` required, but not found
2 --> $DIR/dylib_needs_impl.rs:6:7
3 |
4LL | #[eii(eii1)]
5 | ^^^^ expected because `#[eii1]` was declared here in crate `dylib_needs_impl`
6 |
7 = help: expected at least one implementation in crate `dylib_needs_impl` or any of its dependencies
8
9error: aborting due to 1 previous error
10
tests/ui/error-codes/E0207.stderr+7
......@@ -3,6 +3,13 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: Default> Foo {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Foo` type and use it in the type definition
8 |
9LL ~ struct Foo<T>;
10LL |
11LL ~ impl<T: Default> Foo<T> {
12 |
613
714error: aborting due to 1 previous error
815
tests/ui/feature-gates/feature-gate-pin_ergonomics.rs+8
......@@ -17,6 +17,14 @@ impl Drop for Foo {
1717 //~^ ERROR use of unstable library feature `pin_ergonomics` [E0658]
1818}
1919
20struct Sugar;
21
22impl Drop for Sugar {
23 //~^ ERROR not all trait items implemented, missing: `drop`
24 fn drop(&pin mut self) {} //~ ERROR pinned reference syntax is experimental
25 //~^ ERROR use of unstable library feature `pin_ergonomics` [E0658]
26}
27
2028fn foo(mut x: Pin<&mut Foo>) {
2129 Foo::foo_sugar(x.as_mut());
2230 Foo::foo_sugar_const(x.as_ref());
tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr+58-30
......@@ -29,7 +29,17 @@ LL | fn pin_drop(&pin mut self) {}
2929 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030
3131error[E0658]: pinned reference syntax is experimental
32 --> $DIR/feature-gate-pin_ergonomics.rs:23:14
32 --> $DIR/feature-gate-pin_ergonomics.rs:24:14
33 |
34LL | fn drop(&pin mut self) {}
35 | ^^^
36 |
37 = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information
38 = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable
39 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40
41error[E0658]: pinned reference syntax is experimental
42 --> $DIR/feature-gate-pin_ergonomics.rs:31:14
3343 |
3444LL | let _y: &pin mut Foo = x;
3545 | ^^^
......@@ -39,7 +49,7 @@ LL | let _y: &pin mut Foo = x;
3949 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4050
4151error[E0658]: pinned reference syntax is experimental
42 --> $DIR/feature-gate-pin_ergonomics.rs:27:14
52 --> $DIR/feature-gate-pin_ergonomics.rs:35:14
4353 |
4454LL | let _y: &pin const Foo = x;
4555 | ^^^
......@@ -49,7 +59,7 @@ LL | let _y: &pin const Foo = x;
4959 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
5060
5161error[E0658]: pinned reference syntax is experimental
52 --> $DIR/feature-gate-pin_ergonomics.rs:30:18
62 --> $DIR/feature-gate-pin_ergonomics.rs:38:18
5363 |
5464LL | fn foo_sugar(_: &pin mut Foo) {}
5565 | ^^^
......@@ -59,7 +69,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {}
5969 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
6070
6171error[E0658]: pinned reference syntax is experimental
62 --> $DIR/feature-gate-pin_ergonomics.rs:42:18
72 --> $DIR/feature-gate-pin_ergonomics.rs:50:18
6373 |
6474LL | fn baz_sugar(_: &pin const Foo) {}
6575 | ^^^
......@@ -69,7 +79,7 @@ LL | fn baz_sugar(_: &pin const Foo) {}
6979 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
7080
7181error[E0658]: pinned reference syntax is experimental
72 --> $DIR/feature-gate-pin_ergonomics.rs:45:31
82 --> $DIR/feature-gate-pin_ergonomics.rs:53:31
7383 |
7484LL | let mut x: Pin<&mut _> = &pin mut Foo;
7585 | ^^^
......@@ -79,7 +89,7 @@ LL | let mut x: Pin<&mut _> = &pin mut Foo;
7989 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8090
8191error[E0658]: pinned reference syntax is experimental
82 --> $DIR/feature-gate-pin_ergonomics.rs:50:23
92 --> $DIR/feature-gate-pin_ergonomics.rs:58:23
8393 |
8494LL | let x: Pin<&_> = &pin const Foo;
8595 | ^^^
......@@ -89,7 +99,7 @@ LL | let x: Pin<&_> = &pin const Foo;
8999 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
90100
91101error[E0658]: pinned reference syntax is experimental
92 --> $DIR/feature-gate-pin_ergonomics.rs:57:6
102 --> $DIR/feature-gate-pin_ergonomics.rs:65:6
93103 |
94104LL | &pin mut x: &pin mut i32,
95105 | ^^^
......@@ -99,7 +109,7 @@ LL | &pin mut x: &pin mut i32,
99109 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
100110
101111error[E0658]: pinned reference syntax is experimental
102 --> $DIR/feature-gate-pin_ergonomics.rs:57:18
112 --> $DIR/feature-gate-pin_ergonomics.rs:65:18
103113 |
104114LL | &pin mut x: &pin mut i32,
105115 | ^^^
......@@ -109,7 +119,7 @@ LL | &pin mut x: &pin mut i32,
109119 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
110120
111121error[E0658]: pinned reference syntax is experimental
112 --> $DIR/feature-gate-pin_ergonomics.rs:60:6
122 --> $DIR/feature-gate-pin_ergonomics.rs:68:6
113123 |
114124LL | &pin const y: &'a pin const i32,
115125 | ^^^
......@@ -119,7 +129,7 @@ LL | &pin const y: &'a pin const i32,
119129 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
120130
121131error[E0658]: pinned reference syntax is experimental
122 --> $DIR/feature-gate-pin_ergonomics.rs:60:23
132 --> $DIR/feature-gate-pin_ergonomics.rs:68:23
123133 |
124134LL | &pin const y: &'a pin const i32,
125135 | ^^^
......@@ -129,7 +139,7 @@ LL | &pin const y: &'a pin const i32,
129139 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
130140
131141error[E0658]: pinned reference syntax is experimental
132 --> $DIR/feature-gate-pin_ergonomics.rs:63:9
142 --> $DIR/feature-gate-pin_ergonomics.rs:71:9
133143 |
134144LL | ref pin mut z: i32,
135145 | ^^^
......@@ -139,7 +149,7 @@ LL | ref pin mut z: i32,
139149 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
140150
141151error[E0658]: pinned reference syntax is experimental
142 --> $DIR/feature-gate-pin_ergonomics.rs:64:9
152 --> $DIR/feature-gate-pin_ergonomics.rs:72:9
143153 |
144154LL | ref pin const w: i32,
145155 | ^^^
......@@ -149,7 +159,7 @@ LL | ref pin const w: i32,
149159 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
150160
151161error[E0658]: pinned reference syntax is experimental
152 --> $DIR/feature-gate-pin_ergonomics.rs:76:23
162 --> $DIR/feature-gate-pin_ergonomics.rs:84:23
153163 |
154164LL | fn foo_sugar(&pin mut self) {}
155165 | ^^^
......@@ -159,7 +169,7 @@ LL | fn foo_sugar(&pin mut self) {}
159169 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
160170
161171error[E0658]: pinned reference syntax is experimental
162 --> $DIR/feature-gate-pin_ergonomics.rs:77:29
172 --> $DIR/feature-gate-pin_ergonomics.rs:85:29
163173 |
164174LL | fn foo_sugar_const(&pin const self) {}
165175 | ^^^
......@@ -169,7 +179,7 @@ LL | fn foo_sugar_const(&pin const self) {}
169179 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
170180
171181error[E0658]: pinned reference syntax is experimental
172 --> $DIR/feature-gate-pin_ergonomics.rs:81:22
182 --> $DIR/feature-gate-pin_ergonomics.rs:89:22
173183 |
174184LL | fn pin_drop(&pin mut self) {}
175185 | ^^^
......@@ -179,7 +189,7 @@ LL | fn pin_drop(&pin mut self) {}
179189 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
180190
181191error[E0658]: pinned reference syntax is experimental
182 --> $DIR/feature-gate-pin_ergonomics.rs:87:18
192 --> $DIR/feature-gate-pin_ergonomics.rs:95:18
183193 |
184194LL | let _y: &pin mut Foo = x;
185195 | ^^^
......@@ -189,7 +199,7 @@ LL | let _y: &pin mut Foo = x;
189199 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
190200
191201error[E0658]: pinned reference syntax is experimental
192 --> $DIR/feature-gate-pin_ergonomics.rs:90:22
202 --> $DIR/feature-gate-pin_ergonomics.rs:98:22
193203 |
194204LL | fn foo_sugar(_: &pin mut Foo) {}
195205 | ^^^
......@@ -199,7 +209,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {}
199209 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
200210
201211error[E0658]: pinned reference syntax is experimental
202 --> $DIR/feature-gate-pin_ergonomics.rs:102:22
212 --> $DIR/feature-gate-pin_ergonomics.rs:110:22
203213 |
204214LL | fn baz_sugar(_: &pin const Foo) {}
205215 | ^^^
......@@ -209,7 +219,7 @@ LL | fn baz_sugar(_: &pin const Foo) {}
209219 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
210220
211221error[E0658]: pinned reference syntax is experimental
212 --> $DIR/feature-gate-pin_ergonomics.rs:105:35
222 --> $DIR/feature-gate-pin_ergonomics.rs:113:35
213223 |
214224LL | let mut x: Pin<&mut _> = &pin mut Foo;
215225 | ^^^
......@@ -219,7 +229,7 @@ LL | let mut x: Pin<&mut _> = &pin mut Foo;
219229 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
220230
221231error[E0658]: pinned reference syntax is experimental
222 --> $DIR/feature-gate-pin_ergonomics.rs:110:27
232 --> $DIR/feature-gate-pin_ergonomics.rs:118:27
223233 |
224234LL | let x: Pin<&_> = &pin const Foo;
225235 | ^^^
......@@ -229,7 +239,7 @@ LL | let x: Pin<&_> = &pin const Foo;
229239 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
230240
231241error[E0658]: pinned reference syntax is experimental
232 --> $DIR/feature-gate-pin_ergonomics.rs:117:10
242 --> $DIR/feature-gate-pin_ergonomics.rs:125:10
233243 |
234244LL | &pin mut x: &pin mut i32,
235245 | ^^^
......@@ -239,7 +249,7 @@ LL | &pin mut x: &pin mut i32,
239249 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
240250
241251error[E0658]: pinned reference syntax is experimental
242 --> $DIR/feature-gate-pin_ergonomics.rs:117:22
252 --> $DIR/feature-gate-pin_ergonomics.rs:125:22
243253 |
244254LL | &pin mut x: &pin mut i32,
245255 | ^^^
......@@ -249,7 +259,7 @@ LL | &pin mut x: &pin mut i32,
249259 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
250260
251261error[E0658]: pinned reference syntax is experimental
252 --> $DIR/feature-gate-pin_ergonomics.rs:120:10
262 --> $DIR/feature-gate-pin_ergonomics.rs:128:10
253263 |
254264LL | &pin const y: &'a pin const i32,
255265 | ^^^
......@@ -259,7 +269,7 @@ LL | &pin const y: &'a pin const i32,
259269 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
260270
261271error[E0658]: pinned reference syntax is experimental
262 --> $DIR/feature-gate-pin_ergonomics.rs:120:27
272 --> $DIR/feature-gate-pin_ergonomics.rs:128:27
263273 |
264274LL | &pin const y: &'a pin const i32,
265275 | ^^^
......@@ -269,7 +279,7 @@ LL | &pin const y: &'a pin const i32,
269279 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
270280
271281error[E0658]: pinned reference syntax is experimental
272 --> $DIR/feature-gate-pin_ergonomics.rs:123:13
282 --> $DIR/feature-gate-pin_ergonomics.rs:131:13
273283 |
274284LL | ref pin mut z: i32,
275285 | ^^^
......@@ -279,7 +289,7 @@ LL | ref pin mut z: i32,
279289 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
280290
281291error[E0658]: pinned reference syntax is experimental
282 --> $DIR/feature-gate-pin_ergonomics.rs:124:13
292 --> $DIR/feature-gate-pin_ergonomics.rs:132:13
283293 |
284294LL | ref pin const w: i32,
285295 | ^^^
......@@ -308,6 +318,16 @@ LL | fn pin_drop(&pin mut self) {}
308318 = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable
309319 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
310320
321error[E0658]: use of unstable library feature `pin_ergonomics`
322 --> $DIR/feature-gate-pin_ergonomics.rs:24:5
323 |
324LL | fn drop(&pin mut self) {}
325 | ^^^^^^^^^^^^^^^^^^^^^^
326 |
327 = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information
328 = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable
329 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
330
311331error[E0046]: not all trait items implemented, missing: `drop`
312332 --> $DIR/feature-gate-pin_ergonomics.rs:14:1
313333 |
......@@ -316,8 +336,16 @@ LL | impl Drop for Foo {
316336 |
317337 = help: implement the missing item: `fn drop(&mut self) { todo!() }`
318338
339error[E0046]: not all trait items implemented, missing: `drop`
340 --> $DIR/feature-gate-pin_ergonomics.rs:22:1
341 |
342LL | impl Drop for Sugar {
343 | ^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
344 |
345 = help: implement the missing item: `fn drop(&mut self) { todo!() }`
346
319347error[E0382]: use of moved value: `x`
320 --> $DIR/feature-gate-pin_ergonomics.rs:34:9
348 --> $DIR/feature-gate-pin_ergonomics.rs:42:9
321349 |
322350LL | fn bar(x: Pin<&mut Foo>) {
323351 | - move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait
......@@ -327,7 +355,7 @@ LL | foo(x);
327355 | ^ value used here after move
328356 |
329357note: consider changing this parameter type in function `foo` to borrow instead if owning the value isn't necessary
330 --> $DIR/feature-gate-pin_ergonomics.rs:20:15
358 --> $DIR/feature-gate-pin_ergonomics.rs:28:15
331359 |
332360LL | fn foo(mut x: Pin<&mut Foo>) {
333361 | --- ^^^^^^^^^^^^^ this parameter takes ownership of the value
......@@ -335,7 +363,7 @@ LL | fn foo(mut x: Pin<&mut Foo>) {
335363 | in this function
336364
337365error[E0382]: use of moved value: `x`
338 --> $DIR/feature-gate-pin_ergonomics.rs:39:5
366 --> $DIR/feature-gate-pin_ergonomics.rs:47:5
339367 |
340368LL | fn baz(mut x: Pin<&mut Foo>) {
341369 | ----- move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait
......@@ -354,7 +382,7 @@ help: consider reborrowing the `Pin` instead of moving it
354382LL | x.as_mut().foo();
355383 | +++++++++
356384
357error: aborting due to 34 previous errors
385error: aborting due to 37 previous errors
358386
359387Some errors have detailed explanations: E0046, E0382, E0658.
360388For more information about an error, try `rustc --explain E0046`.
tests/ui/generic-associated-types/bugs/issue-87735.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self
33 |
44LL | impl<'b, T, U> AsRef2 for Foo<T>
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `U` in the `Foo` type and use it in the type definition
8 |
9LL ~ struct Foo<T, U>(T);
10LL | #[derive(Debug)]
11LL | struct FooRef<'a, U>(&'a [U]);
12LL |
13LL ~ impl<'b, T, U> AsRef2 for Foo<T, U>
14 |
615
716error[E0309]: the parameter type `U` may not live long enough
817 --> $DIR/issue-87735.rs:34:3
tests/ui/generic-associated-types/bugs/issue-88526.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `I` is not constrained by the impl trait, self
22 --> $DIR/issue-88526.rs:25:13
33 |
44LL | impl<'q, Q, I, F> A for TestB<Q, F>
5 | ^ unconstrained type parameter
5 | ^--
6 | |
7 | unconstrained type parameter
8 | help: remove the unused type parameter `I`
69
710error[E0309]: the parameter type `F` may not live long enough
811 --> $DIR/issue-88526.rs:16:5
tests/ui/generics/unconstrained-param-default-available.rs created+18
......@@ -0,0 +1,18 @@
1//! Test that making use of parameter is suggested when a parameter with default type is available
2
3struct S<U = i32> {
4 _u: U,
5}
6impl<V> MyTrait for S {}
7//~^ ERROR the type parameter `V` is not constrained by the impl trait, self type, or predicates
8
9struct S2<T, U = i32> {
10 _t: T,
11 _u: U,
12}
13impl<T, V> MyTrait for S2<T> {}
14//~^ ERROR the type parameter `V` is not constrained by the impl trait, self type, or predicates
15
16trait MyTrait {}
17
18fn main() {}
tests/ui/generics/unconstrained-param-default-available.stderr created+35
......@@ -0,0 +1,35 @@
1error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates
2 --> $DIR/unconstrained-param-default-available.rs:6:6
3 |
4LL | impl<V> MyTrait for S {}
5 | ^ unconstrained type parameter
6 |
7help: either remove the unused type parameter `V`
8 |
9LL - impl<V> MyTrait for S {}
10LL + impl MyTrait for S {}
11 |
12help: or use it
13 |
14LL | impl<V> MyTrait for S<V> {}
15 | +++
16
17error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates
18 --> $DIR/unconstrained-param-default-available.rs:13:9
19 |
20LL | impl<T, V> MyTrait for S2<T> {}
21 | ^ unconstrained type parameter
22 |
23help: either remove the unused type parameter `V`
24 |
25LL - impl<T, V> MyTrait for S2<T> {}
26LL + impl<T> MyTrait for S2<T> {}
27 |
28help: or use it
29 |
30LL | impl<T, V> MyTrait for S2<T, V> {}
31 | +++
32
33error: aborting due to 2 previous errors
34
35For more information about this error, try `rustc --explain E0207`.
tests/ui/generics/unconstrained-type-params-inherent-impl.stderr+8-2
......@@ -2,13 +2,19 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
22 --> $DIR/unconstrained-type-params-inherent-impl.rs:11:6
33 |
44LL | impl<T> MyType {
5 | ^ unconstrained type parameter
5 | -^-
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `T`
69
710error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
811 --> $DIR/unconstrained-type-params-inherent-impl.rs:20:9
912 |
1013LL | impl<T, U> MyType1<T> {
11 | ^ unconstrained type parameter
14 | --^
15 | | |
16 | | unconstrained type parameter
17 | help: remove the unused type parameter `U`
1218
1319error: aborting due to 2 previous errors
1420
tests/ui/generics/unconstrained-used-param.rs created+23
......@@ -0,0 +1,23 @@
1//! Test that making use of parameter is suggested when the parameter is used in the impl
2//! but not in the trait or self type
3
4struct S;
5impl<T> S {
6//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
7 fn foo(&self, x: T) {
8 // use T here
9 }
10}
11
12
13struct S2<F> {
14 _f: F,
15}
16impl<F, T> S2<F> {
17//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
18 fn foo(&self, x: T) {
19 // use T here
20 }
21}
22
23fn main() {}
tests/ui/generics/unconstrained-used-param.stderr created+29
......@@ -0,0 +1,29 @@
1error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2 --> $DIR/unconstrained-used-param.rs:5:6
3 |
4LL | impl<T> S {
5 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `S` type and use it in the type definition
8 |
9LL ~ struct S<T>;
10LL ~ impl<T> S<T> {
11 |
12
13error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
14 --> $DIR/unconstrained-used-param.rs:16:9
15 |
16LL | impl<F, T> S2<F> {
17 | ^ unconstrained type parameter
18 |
19help: use the type parameter `T` in the `S2` type and use it in the type definition
20 |
21LL ~ struct S2<F, T> {
22LL | _f: F,
23LL | }
24LL ~ impl<F, T> S2<F, T> {
25 |
26
27error: aborting due to 2 previous errors
28
29For more information about this error, try `rustc --explain E0207`.
tests/ui/issues/issue-16562.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
22 --> $DIR/issue-16562.rs:10:6
33 |
44LL | impl<T, M: MatrixShape> Collection for Col<M, usize> {
5 | ^ unconstrained type parameter
5 | ^--
6 | |
7 | unconstrained type parameter
8 | help: remove the unused type parameter `T`
69
710error: aborting due to 1 previous error
811
tests/ui/issues/issue-22886.stderr+7
......@@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
33 |
44LL | impl<'a> Iterator for Newtype {
55 | ^^ unconstrained lifetime parameter
6 |
7help: use the lifetime parameter `'a` in the `Newtype` type and use it in the type definition
8 |
9LL ~ struct Newtype<'a>(Option<Box<usize>>);
10LL |
11LL ~ impl<'a> Iterator for Newtype<'a> {
12 |
613
714error: aborting due to 1 previous error
815
tests/ui/issues/issue-35139.stderr+7
......@@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
33 |
44LL | impl<'a> MethodType for MTFn {
55 | ^^ unconstrained lifetime parameter
6 |
7help: use the lifetime parameter `'a` in the `MTFn` type and use it in the type definition
8 |
9LL ~ pub struct MTFn<'a>;
10LL |
11LL ~ impl<'a> MethodType for MTFn<'a> {
12 |
613
714error: aborting due to 1 previous error
815
tests/ui/pin-ergonomics/pinned-drop-check.rs+83-5
......@@ -25,11 +25,11 @@ mod pin_drop_only {
2525 struct Bar;
2626
2727 impl Drop for Foo {
28 fn pin_drop(&pin mut self) {} // ok, only `pin_drop` is implemented
28 fn pin_drop(&pin mut self) {} // ok, non-`#[pin_v2]` can also implement `pin_drop`
2929 }
3030
3131 impl Drop for Bar {
32 fn pin_drop(&pin mut self) {} // ok, non-`#[pin_v2]` can also implement `pin_drop`
32 fn pin_drop(&pin mut self) {} // ok, `#[pin_v2]` implements `pin_drop`
3333 }
3434}
3535
......@@ -60,16 +60,67 @@ mod neither {
6060 impl Drop for Bar {} //~ ERROR not all trait items implemented, missing one of: `drop`, `pin_drop` [E0046]
6161}
6262
63mod drop_wrong_type {
63mod drop_sugar {
6464 struct Foo;
6565 #[pin_v2]
6666 struct Bar;
6767
6868 impl Drop for Foo {
69 fn drop(&pin mut self) {} //~ ERROR method `drop` has an incompatible type for trait [E0053]
69 fn drop(&pin mut self) {} // ok, sugar for `pin_drop`
7070 }
71
7172 impl Drop for Bar {
72 fn drop(&pin mut self) {}
73 fn drop(&pin mut self) {} // ok, sugar for `pin_drop`
74 }
75}
76
77mod drop_pin_const_wrong_type {
78 struct Foo;
79 #[pin_v2]
80 struct Bar;
81
82 impl Drop for Foo {
83 fn drop(&pin const self) {} //~ ERROR method `drop` has an incompatible type for trait [E0053]
84 }
85
86 impl Drop for Bar {
87 fn drop(&pin const self) {}
88 //~^ ERROR method `drop` has an incompatible type for trait [E0053]
89 //~| ERROR `Bar` must implement `pin_drop`
90 }
91}
92
93mod drop_with_lifetime_wrong_type {
94 struct Foo;
95 #[pin_v2]
96 struct Bar;
97
98 impl Drop for Foo {
99 fn drop<'a>(&'a pin mut self) {}
100 //~^ ERROR method `drop` has an incompatible type for trait [E0053]
101 }
102
103 impl Drop for Bar {
104 fn drop<'a>(&'a pin mut self) {}
105 //~^ ERROR method `drop` has an incompatible type for trait [E0053]
106 //~| ERROR `Bar` must implement `pin_drop`
107 }
108}
109
110mod drop_explicit_pin_wrong_type {
111 use std::pin::Pin;
112
113 struct Foo;
114 #[pin_v2]
115 struct Bar;
116
117 impl Drop for Foo {
118 fn drop(self: Pin<&mut Self>) {}
119 //~^ ERROR method `drop` has an incompatible type for trait [E0053]
120 }
121
122 impl Drop for Bar {
123 fn drop(self: Pin<&mut Self>) {}
73124 //~^ ERROR method `drop` has an incompatible type for trait [E0053]
74125 //~| ERROR `Bar` must implement `pin_drop`
75126 }
......@@ -124,4 +175,31 @@ mod explicit_call_drop {
124175 }
125176}
126177
178mod explicit_call_drop_sugar {
179 struct Foo;
180
181 impl Drop for Foo {
182 fn drop(&pin mut self) {
183 Drop::drop(todo!()); //~ ERROR explicit use of destructor method [E0040]
184 Drop::pin_drop(todo!()); //~ ERROR explicit use of destructor method [E0040]
185 }
186 }
187}
188
189mod sugar_and_pin_drop {
190 struct Foo;
191 #[pin_v2]
192 struct Bar;
193
194 impl Drop for Foo {
195 fn drop(&pin mut self) {}
196 fn pin_drop(&pin mut self) {} //~ ERROR duplicate definitions with name `pin_drop`
197 }
198
199 impl Drop for Bar {
200 fn drop(&pin mut self) {}
201 fn pin_drop(&pin mut self) {} //~ ERROR duplicate definitions with name `pin_drop`
202 }
203}
204
127205fn main() {}
tests/ui/pin-ergonomics/pinned-drop-check.stderr+165-28
......@@ -1,3 +1,27 @@
1error[E0201]: duplicate definitions with name `pin_drop`:
2 --> $DIR/pinned-drop-check.rs:196:9
3 |
4LL | fn drop(&pin mut self) {}
5 | ------------------------- previous definition here
6LL | fn pin_drop(&pin mut self) {}
7 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition
8 |
9 --> $SRC_DIR/core/src/ops/drop.rs:LL:COL
10 |
11 = note: item in trait
12
13error[E0201]: duplicate definitions with name `pin_drop`:
14 --> $DIR/pinned-drop-check.rs:201:9
15 |
16LL | fn drop(&pin mut self) {}
17 | ------------------------- previous definition here
18LL | fn pin_drop(&pin mut self) {}
19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition
20 |
21 --> $SRC_DIR/core/src/ops/drop.rs:LL:COL
22 |
23 = note: item in trait
24
125error: `Bar` must implement `pin_drop`
226 --> $DIR/pinned-drop-check.rs:18:9
327 |
......@@ -55,56 +79,157 @@ LL | impl Drop for Bar {}
5579 | ^^^^^^^^^^^^^^^^^ missing one of `drop`, `pin_drop` in implementation
5680
5781error: `Bar` must implement `pin_drop`
58 --> $DIR/pinned-drop-check.rs:72:9
82 --> $DIR/pinned-drop-check.rs:87:9
5983 |
60LL | fn drop(&pin mut self) {}
61 | ^^^^^^^^^^^^^^^^^^^^^^
84LL | fn drop(&pin const self) {}
85 | ^^^^^^^^^^^^^^^^^^^^^^^^
6286 |
6387 = help: structurally pinned types must keep `Pin`'s safety contract
6488note: `Bar` is marked `#[pin_v2]` here
65 --> $DIR/pinned-drop-check.rs:65:5
89 --> $DIR/pinned-drop-check.rs:79:5
6690 |
6791LL | #[pin_v2]
6892 | ^^^^^^^^^
6993help: implement `pin_drop` instead
7094 |
71LL | fn pin_drop(&pin mut self) {}
72 | ++++
95LL - fn drop(&pin const self) {}
96LL + fn pin_drop(&pin mut self) {}
97 |
7398help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning
7499 |
75100LL - #[pin_v2]
76101 |
77102
78103error[E0053]: method `drop` has an incompatible type for trait
79 --> $DIR/pinned-drop-check.rs:69:17
104 --> $DIR/pinned-drop-check.rs:83:17
80105 |
81LL | fn drop(&pin mut self) {}
82 | ^^^^^^^^^^^^^ expected `&mut drop_wrong_type::Foo`, found `Pin<&mut drop_wrong_type::Foo>`
106LL | fn drop(&pin const self) {}
107 | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Foo`, found `Pin<&drop_pin_const_wrong_type::Foo>`
83108 |
84 = note: expected signature `fn(&mut drop_wrong_type::Foo)`
85 found signature `fn(Pin<&mut drop_wrong_type::Foo>)`
109 = note: expected signature `fn(&mut drop_pin_const_wrong_type::Foo)`
110 found signature `fn(Pin<&drop_pin_const_wrong_type::Foo>)`
86111help: change the self-receiver type to match the trait
87112 |
88LL - fn drop(&pin mut self) {}
113LL - fn drop(&pin const self) {}
89114LL + fn drop(&mut self) {}
90115 |
91116
92117error[E0053]: method `drop` has an incompatible type for trait
93 --> $DIR/pinned-drop-check.rs:72:17
118 --> $DIR/pinned-drop-check.rs:87:17
94119 |
95LL | fn drop(&pin mut self) {}
96 | ^^^^^^^^^^^^^ expected `&mut drop_wrong_type::Bar`, found `Pin<&mut drop_wrong_type::Bar>`
120LL | fn drop(&pin const self) {}
121 | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Bar`, found `Pin<&drop_pin_const_wrong_type::Bar>`
122 |
123 = note: expected signature `fn(&mut drop_pin_const_wrong_type::Bar)`
124 found signature `fn(Pin<&drop_pin_const_wrong_type::Bar>)`
125help: change the self-receiver type to match the trait
126 |
127LL - fn drop(&pin const self) {}
128LL + fn drop(&mut self) {}
129 |
130
131error: `Bar` must implement `pin_drop`
132 --> $DIR/pinned-drop-check.rs:104:9
133 |
134LL | fn drop<'a>(&'a pin mut self) {}
135 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136 |
137 = help: structurally pinned types must keep `Pin`'s safety contract
138note: `Bar` is marked `#[pin_v2]` here
139 --> $DIR/pinned-drop-check.rs:95:5
140 |
141LL | #[pin_v2]
142 | ^^^^^^^^^
143help: implement `pin_drop` instead
144 |
145LL - fn drop<'a>(&'a pin mut self) {}
146LL + fn pin_drop(&pin mut self) {}
147 |
148help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning
149 |
150LL - #[pin_v2]
151 |
152
153error[E0053]: method `drop` has an incompatible type for trait
154 --> $DIR/pinned-drop-check.rs:99:21
155 |
156LL | fn drop<'a>(&'a pin mut self) {}
157 | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Foo`, found `Pin<&mut Foo>`
158 |
159 = note: expected signature `fn(&mut drop_with_lifetime_wrong_type::Foo)`
160 found signature `fn(Pin<&mut drop_with_lifetime_wrong_type::Foo>)`
161help: change the self-receiver type to match the trait
162 |
163LL - fn drop<'a>(&'a pin mut self) {}
164LL + fn drop<'a>(&mut self) {}
97165 |
98 = note: expected signature `fn(&mut drop_wrong_type::Bar)`
99 found signature `fn(Pin<&mut drop_wrong_type::Bar>)`
166
167error[E0053]: method `drop` has an incompatible type for trait
168 --> $DIR/pinned-drop-check.rs:104:21
169 |
170LL | fn drop<'a>(&'a pin mut self) {}
171 | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Bar`, found `Pin<&mut Bar>`
172 |
173 = note: expected signature `fn(&mut drop_with_lifetime_wrong_type::Bar)`
174 found signature `fn(Pin<&mut drop_with_lifetime_wrong_type::Bar>)`
175help: change the self-receiver type to match the trait
176 |
177LL - fn drop<'a>(&'a pin mut self) {}
178LL + fn drop<'a>(&mut self) {}
179 |
180
181error: `Bar` must implement `pin_drop`
182 --> $DIR/pinned-drop-check.rs:123:9
183 |
184LL | fn drop(self: Pin<&mut Self>) {}
185 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
186 |
187 = help: structurally pinned types must keep `Pin`'s safety contract
188note: `Bar` is marked `#[pin_v2]` here
189 --> $DIR/pinned-drop-check.rs:114:5
190 |
191LL | #[pin_v2]
192 | ^^^^^^^^^
193help: implement `pin_drop` instead
194 |
195LL - fn drop(self: Pin<&mut Self>) {}
196LL + fn pin_drop(&pin mut self) {}
197 |
198help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning
199 |
200LL - #[pin_v2]
201 |
202
203error[E0053]: method `drop` has an incompatible type for trait
204 --> $DIR/pinned-drop-check.rs:118:23
205 |
206LL | fn drop(self: Pin<&mut Self>) {}
207 | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Foo`, found `Pin<&mut Foo>`
208 |
209 = note: expected signature `fn(&mut drop_explicit_pin_wrong_type::Foo)`
210 found signature `fn(Pin<&mut drop_explicit_pin_wrong_type::Foo>)`
100211help: change the self-receiver type to match the trait
101212 |
102LL - fn drop(&pin mut self) {}
213LL - fn drop(self: Pin<&mut Self>) {}
214LL + fn drop(&mut self) {}
215 |
216
217error[E0053]: method `drop` has an incompatible type for trait
218 --> $DIR/pinned-drop-check.rs:123:23
219 |
220LL | fn drop(self: Pin<&mut Self>) {}
221 | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Bar`, found `Pin<&mut Bar>`
222 |
223 = note: expected signature `fn(&mut drop_explicit_pin_wrong_type::Bar)`
224 found signature `fn(Pin<&mut drop_explicit_pin_wrong_type::Bar>)`
225help: change the self-receiver type to match the trait
226 |
227LL - fn drop(self: Pin<&mut Self>) {}
103228LL + fn drop(&mut self) {}
104229 |
105230
106231error[E0053]: method `pin_drop` has an incompatible type for trait
107 --> $DIR/pinned-drop-check.rs:84:21
232 --> $DIR/pinned-drop-check.rs:135:21
108233 |
109234LL | fn pin_drop(&mut self) {}
110235 | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Foo>`, found `&mut pin_drop_wrong_type::Foo`
......@@ -118,7 +243,7 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Foo>) {}
118243 |
119244
120245error[E0053]: method `pin_drop` has an incompatible type for trait
121 --> $DIR/pinned-drop-check.rs:88:21
246 --> $DIR/pinned-drop-check.rs:139:21
122247 |
123248LL | fn pin_drop(&mut self) {}
124249 | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Bar>`, found `&mut pin_drop_wrong_type::Bar`
......@@ -132,14 +257,14 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Bar>) {}
132257 |
133258
134259error: `Bar` must implement `pin_drop`
135 --> $DIR/pinned-drop-check.rs:103:9
260 --> $DIR/pinned-drop-check.rs:154:9
136261 |
137262LL | fn drop(&mut self) {
138263 | ^^^^^^^^^^^^^^^^^^
139264 |
140265 = help: structurally pinned types must keep `Pin`'s safety contract
141266note: `Bar` is marked `#[pin_v2]` here
142 --> $DIR/pinned-drop-check.rs:94:5
267 --> $DIR/pinned-drop-check.rs:145:5
143268 |
144269LL | #[pin_v2]
145270 | ^^^^^^^^^
......@@ -154,30 +279,42 @@ LL - #[pin_v2]
154279 |
155280
156281error[E0040]: explicit use of destructor method
157 --> $DIR/pinned-drop-check.rs:99:13
282 --> $DIR/pinned-drop-check.rs:150:13
158283 |
159284LL | Drop::pin_drop(todo!());
160285 | ^^^^^^^^^^^^^^ explicit destructor calls not allowed
161286
162287error[E0040]: explicit use of destructor method
163 --> $DIR/pinned-drop-check.rs:105:13
288 --> $DIR/pinned-drop-check.rs:156:13
164289 |
165290LL | Drop::pin_drop(todo!());
166291 | ^^^^^^^^^^^^^^ explicit destructor calls not allowed
167292
168293error[E0040]: explicit use of destructor method
169 --> $DIR/pinned-drop-check.rs:117:13
294 --> $DIR/pinned-drop-check.rs:168:13
295 |
296LL | Drop::drop(todo!());
297 | ^^^^^^^^^^ explicit destructor calls not allowed
298
299error[E0040]: explicit use of destructor method
300 --> $DIR/pinned-drop-check.rs:173:13
170301 |
171302LL | Drop::drop(todo!());
172303 | ^^^^^^^^^^ explicit destructor calls not allowed
173304
174305error[E0040]: explicit use of destructor method
175 --> $DIR/pinned-drop-check.rs:122:13
306 --> $DIR/pinned-drop-check.rs:183:13
176307 |
177308LL | Drop::drop(todo!());
178309 | ^^^^^^^^^^ explicit destructor calls not allowed
179310
180error: aborting due to 15 previous errors
311error[E0040]: explicit use of destructor method
312 --> $DIR/pinned-drop-check.rs:184:13
313 |
314LL | Drop::pin_drop(todo!());
315 | ^^^^^^^^^^^^^^ explicit destructor calls not allowed
316
317error: aborting due to 25 previous errors
181318
182Some errors have detailed explanations: E0040, E0046, E0053.
319Some errors have detailed explanations: E0040, E0046, E0053, E0201.
183320For more information about an error, try `rustc --explain E0040`.
tests/ui/pin-ergonomics/pinned-drop-sugar-no-core.rs created+78
......@@ -0,0 +1,78 @@
1//@ check-pass
2
3#![no_std]
4#![no_core]
5#![no_main]
6#![feature(no_core, pin_ergonomics, lang_items)]
7#![allow(incomplete_features)]
8
9#[lang = "pointee_sized"]
10trait PointeeSized {}
11
12#[lang = "meta_sized"]
13trait MetaSized: PointeeSized {}
14
15#[lang = "sized"]
16trait Sized: MetaSized {}
17
18#[lang = "copy"]
19trait Copy {}
20
21#[lang = "legacy_receiver"]
22trait LegacyReceiver: PointeeSized {}
23
24#[lang = "deref"]
25trait Deref: PointeeSized {
26 #[lang = "deref_target"]
27 type Target: PointeeSized;
28
29 fn deref(&self) -> &Self::Target;
30}
31
32#[lang = "deref_mut"]
33trait DerefMut: Deref + PointeeSized {
34 fn deref_mut(&mut self) -> &mut Self::Target;
35}
36
37#[lang = "pin"]
38struct Pin<T> {
39 pointer: T,
40}
41
42impl<T: PointeeSized> LegacyReceiver for &T {}
43impl<T: PointeeSized> LegacyReceiver for &mut T {}
44impl<Ptr: LegacyReceiver> LegacyReceiver for Pin<Ptr> {}
45
46impl<Ptr: Deref> Deref for Pin<Ptr> {
47 type Target = Ptr::Target;
48
49 fn deref(&self) -> &Self::Target {
50 &*self.pointer
51 }
52}
53
54impl<Ptr: DerefMut> DerefMut for Pin<Ptr> {
55 fn deref_mut(&mut self) -> &mut Self::Target {
56 &mut *self.pointer
57 }
58}
59
60impl<T: PointeeSized> Deref for &mut T {
61 type Target = T;
62
63 fn deref(&self) -> &Self::Target {
64 self
65 }
66}
67
68struct LocalDrop;
69
70impl Drop for LocalDrop {
71 fn drop(&pin mut self) {}
72}
73
74#[lang = "drop"]
75trait Drop {
76 fn drop(&mut self) {}
77 fn pin_drop(self: Pin<&mut Self>) {}
78}
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs created+62
......@@ -0,0 +1,62 @@
1//@ edition:2024
2
3#![feature(pin_ergonomics)]
4#![allow(incomplete_features)]
5
6use std::pin::Pin;
7
8struct S;
9
10trait NeedsPinDrop {
11 fn pin_drop(self: Pin<&mut Self>);
12}
13
14impl NeedsPinDrop for S {
15 //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046]
16 fn drop(&pin mut self) {}
17 //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait
18}
19
20trait HasDrop {
21 fn drop(self: Pin<&mut Self>);
22}
23
24impl HasDrop for S {
25 //~^ ERROR not all trait items implemented, missing: `drop` [E0046]
26 fn drop(&pin mut self) {}
27 //~^ ERROR method `drop` is not a member of trait `HasDrop` [E0407]
28}
29
30trait HasPinnedDropReceiver {
31 fn drop(self: &pin mut Self);
32}
33
34impl HasPinnedDropReceiver for S {
35 //~^ ERROR not all trait items implemented, missing: `drop` [E0046]
36 fn drop(&pin mut self) {}
37 //~^ ERROR method `drop` is not a member of trait `HasPinnedDropReceiver` [E0407]
38}
39
40struct Inherent;
41
42impl Inherent {
43 fn drop(&pin mut self) {}
44}
45
46mod local_drop_trait {
47 use std::pin::Pin;
48
49 struct S;
50
51 trait Drop {
52 fn pin_drop(self: Pin<&mut Self>);
53 }
54
55 impl Drop for S {
56 //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046]
57 fn drop(&pin mut self) {}
58 //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait
59 }
60}
61
62fn main() {}
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr created+70
......@@ -0,0 +1,70 @@
1error[E0407]: method `drop` is not a member of trait `HasDrop`
2 --> $DIR/pinned-drop-sugar-not-other-traits.rs:26:5
3 |
4LL | fn drop(&pin mut self) {}
5 | ^^^----^^^^^^^^^^^^^^^^^^
6 | | |
7 | | help: there is an associated function with a similar name: `drop`
8 | not a member of trait `HasDrop`
9
10error[E0407]: method `drop` is not a member of trait `HasPinnedDropReceiver`
11 --> $DIR/pinned-drop-sugar-not-other-traits.rs:36:5
12 |
13LL | fn drop(&pin mut self) {}
14 | ^^^----^^^^^^^^^^^^^^^^^^
15 | | |
16 | | help: there is an associated function with a similar name: `drop`
17 | not a member of trait `HasPinnedDropReceiver`
18
19error: method `drop` with `&pin mut self` is only supported for the `Drop` trait
20 --> $DIR/pinned-drop-sugar-not-other-traits.rs:16:5
21 |
22LL | fn drop(&pin mut self) {}
23 | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation
24
25error: method `drop` with `&pin mut self` is only supported for the `Drop` trait
26 --> $DIR/pinned-drop-sugar-not-other-traits.rs:57:9
27 |
28LL | fn drop(&pin mut self) {}
29 | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation
30
31error[E0046]: not all trait items implemented, missing: `pin_drop`
32 --> $DIR/pinned-drop-sugar-not-other-traits.rs:14:1
33 |
34LL | fn pin_drop(self: Pin<&mut Self>);
35 | ---------------------------------- `pin_drop` from trait
36...
37LL | impl NeedsPinDrop for S {
38 | ^^^^^^^^^^^^^^^^^^^^^^^ missing `pin_drop` in implementation
39
40error[E0046]: not all trait items implemented, missing: `drop`
41 --> $DIR/pinned-drop-sugar-not-other-traits.rs:24:1
42 |
43LL | fn drop(self: Pin<&mut Self>);
44 | ------------------------------ `drop` from trait
45...
46LL | impl HasDrop for S {
47 | ^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
48
49error[E0046]: not all trait items implemented, missing: `drop`
50 --> $DIR/pinned-drop-sugar-not-other-traits.rs:34:1
51 |
52LL | fn drop(self: &pin mut Self);
53 | ----------------------------- `drop` from trait
54...
55LL | impl HasPinnedDropReceiver for S {
56 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
57
58error[E0046]: not all trait items implemented, missing: `pin_drop`
59 --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:5
60 |
61LL | fn pin_drop(self: Pin<&mut Self>);
62 | ---------------------------------- `pin_drop` from trait
63...
64LL | impl Drop for S {
65 | ^^^^^^^^^^^^^^^ missing `pin_drop` in implementation
66
67error: aborting due to 8 previous errors
68
69Some errors have detailed explanations: E0046, E0407.
70For more information about an error, try `rustc --explain E0046`.
tests/ui/pin-ergonomics/pinned-drop-sugar.rs created+31
......@@ -0,0 +1,31 @@
1//@ check-pass
2//@ edition:2024
3
4#![feature(pin_ergonomics)]
5#![allow(incomplete_features)]
6
7struct Unpinned;
8
9#[pin_v2]
10struct Pinned;
11
12struct Qualified;
13struct CoreQualified;
14
15impl Drop for Unpinned {
16 fn drop(&pin mut self) {}
17}
18
19impl Drop for Pinned {
20 fn drop(&pin mut self) {}
21}
22
23impl std::ops::Drop for Qualified {
24 fn drop(&pin mut self) {}
25}
26
27impl core::ops::Drop for CoreQualified {
28 fn drop(&pin mut self) {}
29}
30
31fn main() {}
tests/ui/suggestions/auxiliary/generics_other_crate.rs created+4
......@@ -0,0 +1,4 @@
1//! This file is used to test suggestions for generics in other crates.
2
3pub struct External;
4pub struct ExternalGeneric<T>(T);
tests/ui/suggestions/unconstrained-params.rs created+54
......@@ -0,0 +1,54 @@
1//@ aux-build:generics_other_crate.rs
2
3extern crate generics_other_crate;
4use generics_other_crate::External;
5
6struct Local;
7struct Defaulted<T = u32>(T);
8
9// Case 1: Unused parameter -> suggests removing T
10impl<T> Local {}
11//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
12//~| HELP: remove the unused type parameter `T`
13
14// Case 2: T used in body but not in self type
15// -> suggests adding T to self type and struct definition
16impl<T> Local {
17 //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
18 //~| HELP: use the type parameter `T` in the `Local` type and use it in the type definition
19 fn check() {
20 let _: T;
21 }
22}
23
24
25// Case 3: Struct has a generic parameter with a default
26// -> suggests adding T to the self type
27impl<T> Defaulted {}
28//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
29//~| HELP: either remove the unused type parameter `T`
30//~| HELP: or use it
31
32// Case 4: Generated from a macro
33macro_rules! make_impl {
34 ($t:ident) => {
35 impl<$t> Local {}
36 //~^ HELP: remove the unused type parameter `U`
37 }
38}
39make_impl!(U);
40//~^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates
41
42// Case 5: Type defined in another crate
43impl<T> External {
44 //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
45 //~| ERROR: cannot define inherent `impl` for a type outside of the crate where the type is defined [E0116]
46 //~| HELP: use the type parameter `T` in the `External` type and use it in the type definition
47 //~| HELP: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it
48 fn check() {
49 let _: T;
50 }
51}
52
53
54fn main() {}
tests/ui/suggestions/unconstrained-params.stderr created+68
......@@ -0,0 +1,68 @@
1error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2 --> $DIR/unconstrained-params.rs:10:6
3 |
4LL | impl<T> Local {}
5 | -^-
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `T`
9
10error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
11 --> $DIR/unconstrained-params.rs:16:6
12 |
13LL | impl<T> Local {
14 | ^ unconstrained type parameter
15 |
16help: use the type parameter `T` in the `Local` type and use it in the type definition
17 |
18LL ~ struct Local<T>;
19LL | struct Defaulted<T = u32>(T);
20...
21LL | // -> suggests adding T to self type and struct definition
22LL ~ impl<T> Local<T> {
23 |
24
25error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
26 --> $DIR/unconstrained-params.rs:27:6
27 |
28LL | impl<T> Defaulted {}
29 | ^ unconstrained type parameter
30 |
31help: either remove the unused type parameter `T`
32 |
33LL - impl<T> Defaulted {}
34LL + impl Defaulted {}
35 |
36help: or use it
37 |
38LL | impl<T> Defaulted<T> {}
39 | +++
40
41error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
42 --> $DIR/unconstrained-params.rs:39:12
43 |
44LL | impl<$t> Local {}
45 | ---- help: remove the unused type parameter `U`
46...
47LL | make_impl!(U);
48 | ^ unconstrained type parameter
49
50error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
51 --> $DIR/unconstrained-params.rs:43:6
52 |
53LL | impl<T> External {
54 | ^ unconstrained type parameter
55
56error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
57 --> $DIR/unconstrained-params.rs:43:1
58 |
59LL | impl<T> External {
60 | ^^^^^^^^^^^^^^^^ impl for type defined outside of crate
61 |
62 = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it
63 = note: for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>
64
65error: aborting due to 6 previous errors
66
67Some errors have detailed explanations: E0116, E0207.
68For more information about an error, try `rustc --explain E0116`.
tests/ui/traits/associated_type_bound/generic-const-args-default.rs+1-1
......@@ -3,7 +3,7 @@
33
44#![feature(min_generic_const_args)]
55
6trait Bar<const N: bool = false> {}
6trait Bar<const N: usize = const { 1 + 1 }> {}
77
88trait Foo {
99 type AssocB: Bar;
tests/ui/traits/error-reporting/leaking-vars-in-cause-code-2.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self
22 --> $DIR/leaking-vars-in-cause-code-2.rs:19:9
33 |
44LL | impl<T, U> Trait<()> for B<T>
5 | ^ unconstrained type parameter
5 | --^
6 | | |
7 | | unconstrained type parameter
8 | help: remove the unused type parameter `U`
69
710error[E0277]: the trait bound `(): IncompleteGuidance` is not satisfied
811 --> $DIR/leaking-vars-in-cause-code-2.rs:29:19
tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: ?Sized> Every for Thing {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Thing` type and use it in the type definition
8 |
9LL ~ struct Thing<T>;
10LL |
11...
12LL | }
13LL ~ impl<T: ?Sized> Every for Thing<T> {
14 |
615
716error[E0277]: the size for values of type `T` cannot be known at compilation time
817 --> $DIR/unconstrained-projection-normalization-2.rs:16:18
tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: ?Sized> Every for Thing {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Thing` type and use it in the type definition
8 |
9LL ~ struct Thing<T>;
10LL |
11...
12LL | }
13LL ~ impl<T: ?Sized> Every for Thing<T> {
14 |
615
716error[E0277]: the size for values of type `T` cannot be known at compilation time
817 --> $DIR/unconstrained-projection-normalization-2.rs:16:18
tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: ?Sized> Every for Thing {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Thing` type and use it in the type definition
8 |
9LL ~ struct Thing<T>;
10LL |
11...
12LL | }
13LL ~ impl<T: ?Sized> Every for Thing<T> {
14 |
615
716error[E0277]: the size for values of type `T` cannot be known at compilation time
817 --> $DIR/unconstrained-projection-normalization.rs:15:18
tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: ?Sized> Every for Thing {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Thing` type and use it in the type definition
8 |
9LL ~ struct Thing<T>;
10LL |
11...
12LL | }
13LL ~ impl<T: ?Sized> Every for Thing<T> {
14 |
615
716error[E0277]: the size for values of type `T` cannot be known at compilation time
817 --> $DIR/unconstrained-projection-normalization.rs:15:18
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr+9
......@@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
33 |
44LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
55 | ^ unconstrained type parameter
6 |
7help: use the type parameter `T` in the `Scope` type and use it in the type definition
8 |
9LL ~ struct Scope<T, T>(Phantom2<DummyT<T>>);
10LL |
11...
12LL |
13LL ~ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U, T> {
14 |
615
716error: item does not constrain `DummyT::{opaque#0}`
817 --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:30:8
tests/ui/type-alias-impl-trait/issue-74244.stderr+4-1
......@@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
22 --> $DIR/issue-74244.rs:9:6
33 |
44LL | impl<T> Allocator for DefaultAllocator {
5 | ^ unconstrained type parameter
5 | -^-
6 | ||
7 | |unconstrained type parameter
8 | help: remove the unused type parameter `T`
69
710error: aborting due to 1 previous error
811