authorbors <bors@rust-lang.org> 2025-06-24 10:22:30 UTC
committerbors <bors@rust-lang.org> 2025-06-24 10:22:30 UTC
log36b21637e93b038453924d3c66821089e71d8baa
treee5abef64f88d9244a0394e45b105762d68ed275f
parente4b9d0141fdd210fcceebd2b67f7be113401c461
parent7b864ac1905f0b118d2e4ca1beeede86ac91e5a1

Auto merge of #142956 - GuillaumeGomez:rollup-867246h, r=GuillaumeGomez

Rollup of 9 pull requests Successful merges: - rust-lang/rust#140005 (Set MSG_NOSIGNAL for UnixStream) - rust-lang/rust#140622 (compiletest: Improve diagnostics for line annotation mismatches) - rust-lang/rust#142354 (Fixes firefox copy paste issue) - rust-lang/rust#142695 (Port `#[rustc_skip_during_method_dispatch]` to the new attribute system) - rust-lang/rust#142779 (Add note about `str::split` handling of no matches.) - rust-lang/rust#142894 (phantom_variance_markers: fix identifier usage in macro) - rust-lang/rust#142928 (Fix hang in --print=file-names in bootstrap) - rust-lang/rust#142932 (rustdoc-json: Keep empty generic args if parenthesized) - rust-lang/rust#142933 (Simplify root goal API of solver a bit) r? `@ghost` `@rustbot` modify labels: rollup

56 files changed, 681 insertions(+), 236 deletions(-)

compiler/rustc_attr_data_structures/src/attributes.rs+3
......@@ -259,6 +259,9 @@ pub enum AttributeKind {
259259 /// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
260260 Repr(ThinVec<(ReprAttr, Span)>),
261261
262 /// Represents `#[rustc_skip_during_method_dispatch]`.
263 SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },
264
262265 /// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
263266 Stability {
264267 stability: Stability,
compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs+7-7
......@@ -50,8 +50,8 @@ impl<S: Stage> SingleAttributeParser<S> for ColdParser {
5050 const TEMPLATE: AttributeTemplate = template!(Word);
5151
5252 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
53 if !args.no_args() {
54 cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
53 if let Err(span) = args.no_args() {
54 cx.expected_no_args(span);
5555 return None;
5656 }
5757
......@@ -67,8 +67,8 @@ pub(crate) struct NakedParser {
6767impl<S: Stage> AttributeParser<S> for NakedParser {
6868 const ATTRIBUTES: AcceptMapping<Self, S> =
6969 &[(&[sym::naked], template!(Word), |this, cx, args| {
70 if !args.no_args() {
71 cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
70 if let Err(span) = args.no_args() {
71 cx.expected_no_args(span);
7272 return;
7373 }
7474
......@@ -175,10 +175,10 @@ impl<S: Stage> SingleAttributeParser<S> for NoMangleParser {
175175 const TEMPLATE: AttributeTemplate = template!(Word);
176176
177177 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
178 if !args.no_args() {
179 cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
178 if let Err(span) = args.no_args() {
179 cx.expected_no_args(span);
180180 return None;
181 };
181 }
182182
183183 Some(AttributeKind::NoMangle(cx.attr_span))
184184 }
compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs+8-4
......@@ -14,8 +14,10 @@ impl<S: Stage> SingleAttributeParser<S> for AsPtrParser {
1414 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1515 const TEMPLATE: AttributeTemplate = template!(Word);
1616
17 fn convert(cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> {
18 // FIXME: check that there's no args (this is currently checked elsewhere)
17 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
18 if let Err(span) = args.no_args() {
19 cx.expected_no_args(span);
20 }
1921 Some(AttributeKind::AsPtr(cx.attr_span))
2022 }
2123}
......@@ -27,8 +29,10 @@ impl<S: Stage> SingleAttributeParser<S> for PubTransparentParser {
2729 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
2830 const TEMPLATE: AttributeTemplate = template!(Word);
2931
30 fn convert(cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> {
31 // FIXME: check that there's no args (this is currently checked elsewhere)
32 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
33 if let Err(span) = args.no_args() {
34 cx.expected_no_args(span);
35 }
3236 Some(AttributeKind::PubTransparent(cx.attr_span))
3337 }
3438}
compiler/rustc_attr_parsing/src/attributes/mod.rs+1
......@@ -36,6 +36,7 @@ pub(crate) mod must_use;
3636pub(crate) mod repr;
3737pub(crate) mod semantics;
3838pub(crate) mod stability;
39pub(crate) mod traits;
3940pub(crate) mod transparency;
4041pub(crate) mod util;
4142
compiler/rustc_attr_parsing/src/attributes/semantics.rs+4-1
......@@ -13,7 +13,10 @@ impl<S: Stage> SingleAttributeParser<S> for MayDangleParser {
1313 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
1414 const TEMPLATE: AttributeTemplate = template!(Word);
1515
16 fn convert(cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> {
16 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
17 if let Err(span) = args.no_args() {
18 cx.expected_no_args(span);
19 }
1720 Some(AttributeKind::MayDangle(cx.attr_span))
1821 }
1922}
compiler/rustc_attr_parsing/src/attributes/stability.rs+6-3
......@@ -139,7 +139,10 @@ impl<S: Stage> SingleAttributeParser<S> for ConstStabilityIndirectParser {
139139 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
140140 const TEMPLATE: AttributeTemplate = template!(Word);
141141
142 fn convert(_cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> {
142 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
143 if let Err(span) = args.no_args() {
144 cx.expected_no_args(span);
145 }
143146 Some(AttributeKind::ConstStabilityIndirect)
144147 }
145148}
......@@ -361,8 +364,8 @@ pub(crate) fn parse_unstability<S: Stage>(
361364 };
362365 }
363366 Some(sym::soft) => {
364 if !param.args().no_args() {
365 cx.emit_err(session_diagnostics::SoftNoArgs { span: param.span() });
367 if let Err(span) = args.no_args() {
368 cx.emit_err(session_diagnostics::SoftNoArgs { span });
366369 }
367370 is_soft = true;
368371 }
compiler/rustc_attr_parsing/src/attributes/traits.rs created+54
......@@ -0,0 +1,54 @@
1use core::mem;
2
3use rustc_attr_data_structures::AttributeKind;
4use rustc_feature::{AttributeTemplate, template};
5use rustc_span::{Symbol, sym};
6
7use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
8use crate::context::{AcceptContext, Stage};
9use crate::parser::ArgParser;
10
11pub(crate) struct SkipDuringMethodDispatchParser;
12
13impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
14 const PATH: &[Symbol] = &[sym::rustc_skip_during_method_dispatch];
15 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
16 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
17
18 const TEMPLATE: AttributeTemplate = template!(List: "array, boxed_slice");
19
20 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
21 let mut array = false;
22 let mut boxed_slice = false;
23 let Some(args) = args.list() else {
24 cx.expected_list(cx.attr_span);
25 return None;
26 };
27 if args.is_empty() {
28 cx.expected_at_least_one_argument(args.span);
29 return None;
30 }
31 for arg in args.mixed() {
32 let Some(arg) = arg.meta_item() else {
33 cx.unexpected_literal(arg.span());
34 continue;
35 };
36 if let Err(span) = arg.args().no_args() {
37 cx.expected_no_args(span);
38 }
39 let path = arg.path();
40 let (key, skip): (Symbol, &mut bool) = match path.word_sym() {
41 Some(key @ sym::array) => (key, &mut array),
42 Some(key @ sym::boxed_slice) => (key, &mut boxed_slice),
43 _ => {
44 cx.expected_specific_argument(path.span(), vec!["array", "boxed_slice"]);
45 continue;
46 }
47 };
48 if mem::replace(skip, true) {
49 cx.duplicate_key(arg.span(), key);
50 }
51 }
52 Some(AttributeKind::SkipDuringMethodDispatch { array, boxed_slice, span: cx.attr_span })
53 }
54}
compiler/rustc_attr_parsing/src/context.rs+12
......@@ -26,6 +26,7 @@ use crate::attributes::semantics::MayDangleParser;
2626use crate::attributes::stability::{
2727 BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
2828};
29use crate::attributes::traits::SkipDuringMethodDispatchParser;
2930use crate::attributes::transparency::TransparencyParser;
3031use crate::attributes::{AttributeParser as _, Combine, Single};
3132use crate::parser::{ArgParser, MetaItemParser, PathParser};
......@@ -119,6 +120,7 @@ attribute_parsers!(
119120 Single<OptimizeParser>,
120121 Single<PubTransparentParser>,
121122 Single<RustcForceInlineParser>,
123 Single<SkipDuringMethodDispatchParser>,
122124 Single<TransparencyParser>,
123125 // tidy-alphabetical-end
124126 ];
......@@ -325,6 +327,16 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
325327 })
326328 }
327329
330 pub(crate) fn expected_at_least_one_argument(&self, span: Span) -> ErrorGuaranteed {
331 self.emit_err(AttributeParseError {
332 span,
333 attr_span: self.attr_span,
334 template: self.template.clone(),
335 attribute: self.attr_path.clone(),
336 reason: AttributeParseErrorReason::ExpectedAtLeastOneArgument,
337 })
338 }
339
328340 pub(crate) fn expected_specific_argument(
329341 &self,
330342 span: Span,
compiler/rustc_attr_parsing/src/parser.rs+9-3
......@@ -169,9 +169,15 @@ impl<'a> ArgParser<'a> {
169169 }
170170 }
171171
172 /// Asserts that there are no arguments
173 pub fn no_args(&self) -> bool {
174 matches!(self, Self::NoArgs)
172 /// Assert that there were no args.
173 /// If there were, get a span to the arguments
174 /// (to pass to [`AcceptContext::expected_no_args`](crate::context::AcceptContext::expected_no_args)).
175 pub fn no_args(&self) -> Result<(), Span> {
176 match self {
177 Self::NoArgs => Ok(()),
178 Self::List(args) => Err(args.span),
179 Self::NameValue(args) => Err(args.eq_span.to(args.value_span)),
180 }
175181 }
176182}
177183
compiler/rustc_attr_parsing/src/session_diagnostics.rs+4
......@@ -496,6 +496,7 @@ pub(crate) struct NakedFunctionIncompatibleAttribute {
496496pub(crate) enum AttributeParseErrorReason {
497497 ExpectedNoArgs,
498498 ExpectedStringLiteral { byte_string: Option<Span> },
499 ExpectedAtLeastOneArgument,
499500 ExpectedSingleArgument,
500501 ExpectedList,
501502 UnexpectedLiteral,
......@@ -539,6 +540,9 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
539540 diag.span_label(self.span, "expected a single argument here");
540541 diag.code(E0805);
541542 }
543 AttributeParseErrorReason::ExpectedAtLeastOneArgument => {
544 diag.span_label(self.span, "expected at least 1 argument here");
545 }
542546 AttributeParseErrorReason::ExpectedList => {
543547 diag.span_label(self.span, "expected this to be a list");
544548 }
compiler/rustc_feature/src/builtin_attrs.rs+1-1
......@@ -1083,7 +1083,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
10831083 "the `#[rustc_main]` attribute is used internally to specify test entry point function",
10841084 ),
10851085 rustc_attr!(
1086 rustc_skip_during_method_dispatch, Normal, template!(List: "array, boxed_slice"), WarnFollowing,
1086 rustc_skip_during_method_dispatch, Normal, template!(List: "array, boxed_slice"), ErrorFollowing,
10871087 EncodeCrossCrate::No,
10881088 "the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \
10891089 from method dispatch when the receiver is of the following type, for compatibility in \
compiler/rustc_hir_analysis/src/collect.rs+6-16
......@@ -21,6 +21,7 @@ use std::ops::Bound;
2121
2222use rustc_abi::ExternAbi;
2323use rustc_ast::Recovered;
24use rustc_attr_data_structures::{AttributeKind, find_attr};
2425use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2526use rustc_data_structures::unord::UnordMap;
2627use rustc_errors::{
......@@ -1151,22 +1152,11 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
11511152 let rustc_coinductive = tcx.has_attr(def_id, sym::rustc_coinductive);
11521153 let is_fundamental = tcx.has_attr(def_id, sym::fundamental);
11531154
1154 // FIXME: We could probably do way better attribute validation here.
1155 let mut skip_array_during_method_dispatch = false;
1156 let mut skip_boxed_slice_during_method_dispatch = false;
1157 for attr in tcx.get_attrs(def_id, sym::rustc_skip_during_method_dispatch) {
1158 if let Some(lst) = attr.meta_item_list() {
1159 for item in lst {
1160 if let Some(ident) = item.ident() {
1161 match ident.as_str() {
1162 "array" => skip_array_during_method_dispatch = true,
1163 "boxed_slice" => skip_boxed_slice_during_method_dispatch = true,
1164 _ => (),
1165 }
1166 }
1167 }
1168 }
1169 }
1155 let [skip_array_during_method_dispatch, skip_boxed_slice_during_method_dispatch] = find_attr!(
1156 tcx.get_all_attrs(def_id),
1157 AttributeKind::SkipDuringMethodDispatch { array, boxed_slice, span:_ } => [*array, *boxed_slice]
1158 )
1159 .unwrap_or([false; 2]);
11701160
11711161 let specialization_kind = if tcx.has_attr(def_id, sym::rustc_unsafe_specialization_marker) {
11721162 ty::trait_def::TraitSpecializationKind::Marker
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs+22-25
......@@ -147,13 +147,9 @@ pub trait SolverDelegateEvalExt: SolverDelegate {
147147 fn evaluate_root_goal(
148148 &self,
149149 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
150 generate_proof_tree: GenerateProofTree,
151150 span: <Self::Interner as Interner>::Span,
152151 stalled_on: Option<GoalStalledOn<Self::Interner>>,
153 ) -> (
154 Result<GoalEvaluation<Self::Interner>, NoSolution>,
155 Option<inspect::GoalEvaluation<Self::Interner>>,
156 );
152 ) -> Result<GoalEvaluation<Self::Interner>, NoSolution>;
157153
158154 /// Check whether evaluating `goal` with a depth of `root_depth` may
159155 /// succeed. This only returns `false` if the goal is guaranteed to
......@@ -170,17 +166,16 @@ pub trait SolverDelegateEvalExt: SolverDelegate {
170166
171167 // FIXME: This is only exposed because we need to use it in `analyse.rs`
172168 // which is not yet uplifted. Once that's done, we should remove this.
173 fn evaluate_root_goal_raw(
169 fn evaluate_root_goal_for_proof_tree(
174170 &self,
175171 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
176 generate_proof_tree: GenerateProofTree,
177 stalled_on: Option<GoalStalledOn<Self::Interner>>,
172 span: <Self::Interner as Interner>::Span,
178173 ) -> (
179174 Result<
180175 (NestedNormalizationGoals<Self::Interner>, GoalEvaluation<Self::Interner>),
181176 NoSolution,
182177 >,
183 Option<inspect::GoalEvaluation<Self::Interner>>,
178 inspect::GoalEvaluation<Self::Interner>,
184179 );
185180}
186181
......@@ -193,13 +188,17 @@ where
193188 fn evaluate_root_goal(
194189 &self,
195190 goal: Goal<I, I::Predicate>,
196 generate_proof_tree: GenerateProofTree,
197191 span: I::Span,
198192 stalled_on: Option<GoalStalledOn<I>>,
199 ) -> (Result<GoalEvaluation<I>, NoSolution>, Option<inspect::GoalEvaluation<I>>) {
200 EvalCtxt::enter_root(self, self.cx().recursion_limit(), generate_proof_tree, span, |ecx| {
201 ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on)
202 })
193 ) -> Result<GoalEvaluation<I>, NoSolution> {
194 EvalCtxt::enter_root(
195 self,
196 self.cx().recursion_limit(),
197 GenerateProofTree::No,
198 span,
199 |ecx| ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on),
200 )
201 .0
203202 }
204203
205204 fn root_goal_may_hold_with_depth(
......@@ -217,24 +216,22 @@ where
217216 }
218217
219218 #[instrument(level = "debug", skip(self))]
220 fn evaluate_root_goal_raw(
219 fn evaluate_root_goal_for_proof_tree(
221220 &self,
222221 goal: Goal<I, I::Predicate>,
223 generate_proof_tree: GenerateProofTree,
224 stalled_on: Option<GoalStalledOn<I>>,
222 span: I::Span,
225223 ) -> (
226224 Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolution>,
227 Option<inspect::GoalEvaluation<I>>,
225 inspect::GoalEvaluation<I>,
228226 ) {
229 EvalCtxt::enter_root(
227 let (result, proof_tree) = EvalCtxt::enter_root(
230228 self,
231229 self.cx().recursion_limit(),
232 generate_proof_tree,
233 I::Span::dummy(),
234 |ecx| {
235 ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on)
236 },
237 )
230 GenerateProofTree::Yes,
231 span,
232 |ecx| ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal, None),
233 );
234 (result, proof_tree.unwrap())
238235 }
239236}
240237
compiler/rustc_parse/src/validate_attr.rs+7
......@@ -286,13 +286,20 @@ fn emit_malformed_attribute(
286286 if matches!(
287287 name,
288288 sym::inline
289 | sym::may_dangle
290 | sym::rustc_as_ptr
291 | sym::rustc_pub_transparent
292 | sym::rustc_const_stable_indirect
289293 | sym::rustc_force_inline
290294 | sym::rustc_confusables
295 | sym::rustc_skip_during_method_dispatch
291296 | sym::repr
292297 | sym::align
293298 | sym::deprecated
294299 | sym::optimize
295300 | sym::cold
301 | sym::naked
302 | sym::no_mangle
296303 | sym::must_use
297304 ) {
298305 return;
compiler/rustc_passes/src/check_attr.rs+9-6
......@@ -118,6 +118,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
118118 for attr in attrs {
119119 let mut style = None;
120120 match attr {
121 Attribute::Parsed(AttributeKind::SkipDuringMethodDispatch {
122 span: attr_span,
123 ..
124 }) => {
125 self.check_must_be_applied_to_trait(*attr_span, span, target);
126 }
121127 Attribute::Parsed(AttributeKind::Confusables { first_span, .. }) => {
122128 self.check_confusables(*first_span, target);
123129 }
......@@ -250,7 +256,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
250256 | [sym::rustc_must_implement_one_of, ..]
251257 | [sym::rustc_deny_explicit_impl, ..]
252258 | [sym::rustc_do_not_implement_via_object, ..]
253 | [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target),
259 | [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr.span(), span, target),
254260 [sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
255261 [sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
256262 [sym::rustc_pass_by_value, ..] => self.check_pass_by_value(attr, span, target),
......@@ -1805,14 +1811,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
18051811 }
18061812
18071813 /// Checks if the attribute is applied to a trait.
1808 fn check_must_be_applied_to_trait(&self, attr: &Attribute, span: Span, target: Target) {
1814 fn check_must_be_applied_to_trait(&self, attr_span: Span, defn_span: Span, target: Target) {
18091815 match target {
18101816 Target::Trait => {}
18111817 _ => {
1812 self.dcx().emit_err(errors::AttrShouldBeAppliedToTrait {
1813 attr_span: attr.span(),
1814 defn_span: span,
1815 });
1818 self.dcx().emit_err(errors::AttrShouldBeAppliedToTrait { attr_span, defn_span });
18161819 }
18171820 }
18181821 }
compiler/rustc_span/src/symbol.rs+1
......@@ -577,6 +577,7 @@ symbols! {
577577 box_new,
578578 box_patterns,
579579 box_syntax,
580 boxed_slice,
580581 bpf_target_feature,
581582 braced_empty_structs,
582583 branch,
compiler/rustc_trait_selection/src/solve/fulfill.rs+7-17
......@@ -14,7 +14,7 @@ use rustc_middle::ty::{
1414};
1515use rustc_next_trait_solver::delegate::SolverDelegate as _;
1616use rustc_next_trait_solver::solve::{
17 GenerateProofTree, GoalEvaluation, GoalStalledOn, HasChanged, SolverDelegateEvalExt as _,
17 GoalEvaluation, GoalStalledOn, HasChanged, SolverDelegateEvalExt as _,
1818};
1919use rustc_span::Span;
2020use thin_vec::ThinVec;
......@@ -106,14 +106,11 @@ impl<'tcx> ObligationStorage<'tcx> {
106106 self.overflowed.extend(
107107 ExtractIf::new(&mut self.pending, |(o, stalled_on)| {
108108 let goal = o.as_goal();
109 let result = <&SolverDelegate<'tcx>>::from(infcx)
110 .evaluate_root_goal(
111 goal,
112 GenerateProofTree::No,
113 o.cause.span,
114 stalled_on.take(),
115 )
116 .0;
109 let result = <&SolverDelegate<'tcx>>::from(infcx).evaluate_root_goal(
110 goal,
111 o.cause.span,
112 stalled_on.take(),
113 );
117114 matches!(result, Ok(GoalEvaluation { has_changed: HasChanged::Yes, .. }))
118115 })
119116 .map(|(o, _)| o),
......@@ -207,14 +204,7 @@ where
207204 continue;
208205 }
209206
210 let result = delegate
211 .evaluate_root_goal(
212 goal,
213 GenerateProofTree::No,
214 obligation.cause.span,
215 stalled_on,
216 )
217 .0;
207 let result = delegate.evaluate_root_goal(goal, obligation.cause.span, stalled_on);
218208 self.inspect_evaluated_obligation(infcx, &obligation, &result);
219209 let GoalEvaluation { certainty, has_changed, stalled_on } = match result {
220210 Ok(result) => result,
compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs+6-12
......@@ -11,9 +11,7 @@ use rustc_middle::traits::query::NoSolution;
1111use rustc_middle::ty::error::{ExpectedFound, TypeError};
1212use rustc_middle::ty::{self, Ty, TyCtxt};
1313use rustc_middle::{bug, span_bug};
14use rustc_next_trait_solver::solve::{
15 GenerateProofTree, GoalEvaluation, SolverDelegateEvalExt as _,
16};
14use rustc_next_trait_solver::solve::{GoalEvaluation, SolverDelegateEvalExt as _};
1715use tracing::{instrument, trace};
1816
1917use crate::solve::delegate::SolverDelegate;
......@@ -90,15 +88,11 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>(
9088 root_obligation: PredicateObligation<'tcx>,
9189) -> FulfillmentError<'tcx> {
9290 let (code, refine_obligation) = infcx.probe(|_| {
93 match <&SolverDelegate<'tcx>>::from(infcx)
94 .evaluate_root_goal(
95 root_obligation.as_goal(),
96 GenerateProofTree::No,
97 root_obligation.cause.span,
98 None,
99 )
100 .0
101 {
91 match <&SolverDelegate<'tcx>>::from(infcx).evaluate_root_goal(
92 root_obligation.as_goal(),
93 root_obligation.cause.span,
94 None,
95 ) {
10296 Ok(GoalEvaluation { certainty: Certainty::Maybe(MaybeCause::Ambiguity), .. }) => {
10397 (FulfillmentErrorCode::Ambiguity { overflow: None }, true)
10498 }
compiler/rustc_trait_selection/src/solve/inspect/analyse.rs+6-14
......@@ -20,7 +20,7 @@ use rustc_middle::ty::{TyCtxt, VisitorResult, try_visit};
2020use rustc_middle::{bug, ty};
2121use rustc_next_trait_solver::resolve::eager_resolve_vars;
2222use rustc_next_trait_solver::solve::inspect::{self, instantiate_canonical_state};
23use rustc_next_trait_solver::solve::{GenerateProofTree, MaybeCause, SolverDelegateEvalExt as _};
23use rustc_next_trait_solver::solve::{MaybeCause, SolverDelegateEvalExt as _};
2424use rustc_span::Span;
2525use tracing::instrument;
2626
......@@ -248,9 +248,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
248248 // considering the constrained RHS, and pass the resulting certainty to
249249 // `InspectGoal::new` so that the goal has the right result (and maintains
250250 // the impression that we don't do this normalizes-to infer hack at all).
251 let (nested, proof_tree) =
252 infcx.evaluate_root_goal_raw(goal, GenerateProofTree::Yes, None);
253 let proof_tree = proof_tree.unwrap();
251 let (nested, proof_tree) = infcx.evaluate_root_goal_for_proof_tree(goal, span);
254252 let nested_goals_result = nested.and_then(|(nested, _)| {
255253 normalizes_to_term_hack.constrain_and(
256254 infcx,
......@@ -284,9 +282,8 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
284282 // into another candidate who ends up with different inference
285283 // constraints, we get an ICE if we already applied the constraints
286284 // from the chosen candidate.
287 let proof_tree = infcx
288 .probe(|_| infcx.evaluate_root_goal(goal, GenerateProofTree::Yes, span, None).1)
289 .unwrap();
285 let proof_tree =
286 infcx.probe(|_| infcx.evaluate_root_goal_for_proof_tree(goal, span).1);
290287 InspectGoal::new(infcx, self.goal.depth + 1, proof_tree, None, source)
291288 }
292289 }
......@@ -488,13 +485,8 @@ impl<'tcx> InferCtxt<'tcx> {
488485 depth: usize,
489486 visitor: &mut V,
490487 ) -> V::Result {
491 let (_, proof_tree) = <&SolverDelegate<'tcx>>::from(self).evaluate_root_goal(
492 goal,
493 GenerateProofTree::Yes,
494 visitor.span(),
495 None,
496 );
497 let proof_tree = proof_tree.unwrap();
488 let (_, proof_tree) = <&SolverDelegate<'tcx>>::from(self)
489 .evaluate_root_goal_for_proof_tree(goal, visitor.span());
498490 visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Misc))
499491 }
500492}
library/core/src/marker/variance.rs+1-1
......@@ -18,7 +18,7 @@ macro_rules! phantom_type {
1818 pub struct $name:ident <$t:ident> ($($inner:tt)*);
1919 )*) => {$(
2020 $(#[$attr])*
21 pub struct $name<$t>($($inner)*) where T: ?Sized;
21 pub struct $name<$t>($($inner)*) where $t: ?Sized;
2222
2323 impl<T> $name<T>
2424 where T: ?Sized
library/core/src/str/mod.rs+6
......@@ -1495,6 +1495,9 @@ impl str {
14951495 /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
14961496 /// function or closure that determines if a character matches.
14971497 ///
1498 /// If there are no matches the full string slice is returned as the only
1499 /// item in the iterator.
1500 ///
14981501 /// [`char`]: prim@char
14991502 /// [pattern]: self::pattern
15001503 ///
......@@ -1526,6 +1529,9 @@ impl str {
15261529 /// let v: Vec<&str> = "lion::tiger::leopard".split("::").collect();
15271530 /// assert_eq!(v, ["lion", "tiger", "leopard"]);
15281531 ///
1532 /// let v: Vec<&str> = "AABBCC".split("DD").collect();
1533 /// assert_eq!(v, ["AABBCC"]);
1534 ///
15291535 /// let v: Vec<&str> = "abc1def2ghi".split(char::is_numeric).collect();
15301536 /// assert_eq!(v, ["abc", "def", "ghi"]);
15311537 ///
library/std/src/net/tcp.rs+6
......@@ -53,6 +53,12 @@ use crate::time::Duration;
5353/// Ok(())
5454/// } // the stream is closed here
5555/// ```
56///
57/// # Platform-specific Behavior
58///
59/// On Unix, writes to the underlying socket in `SOCK_STREAM` mode are made with
60/// `MSG_NOSIGNAL` flag. This suppresses the emission of the `SIGPIPE` signal when writing
61/// to disconnected socket. In some cases, getting a `SIGPIPE` would trigger process termination.
5662#[stable(feature = "rust1", since = "1.0.0")]
5763pub struct TcpStream(net_imp::TcpStream);
5864
library/std/src/os/unix/net/stream.rs+22-1
......@@ -1,3 +1,18 @@
1cfg_if::cfg_if! {
2 if #[cfg(any(
3 target_os = "linux", target_os = "android",
4 target_os = "hurd",
5 target_os = "dragonfly", target_os = "freebsd",
6 target_os = "openbsd", target_os = "netbsd",
7 target_os = "solaris", target_os = "illumos",
8 target_os = "haiku", target_os = "nto",
9 target_os = "cygwin"))] {
10 use libc::MSG_NOSIGNAL;
11 } else {
12 const MSG_NOSIGNAL: core::ffi::c_int = 0x0;
13 }
14}
15
116use super::{SocketAddr, sockaddr_un};
217#[cfg(any(doc, target_os = "android", target_os = "linux"))]
318use super::{SocketAncillary, recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to};
......@@ -41,6 +56,12 @@ use crate::time::Duration;
4156/// Ok(())
4257/// }
4358/// ```
59///
60/// # `SIGPIPE`
61///
62/// Writes to the underlying socket in `SOCK_STREAM` mode are made with `MSG_NOSIGNAL` flag.
63/// This suppresses the emission of the `SIGPIPE` signal when writing to disconnected socket.
64/// In some cases getting a `SIGPIPE` would trigger process termination.
4465#[stable(feature = "unix_socket", since = "1.10.0")]
4566pub struct UnixStream(pub(super) Socket);
4667
......@@ -633,7 +654,7 @@ impl io::Write for UnixStream {
633654#[stable(feature = "unix_socket", since = "1.10.0")]
634655impl<'a> io::Write for &'a UnixStream {
635656 fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
636 self.0.write(buf)
657 self.0.send_with_flags(buf, MSG_NOSIGNAL)
637658 }
638659
639660 fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
library/std/src/sys/net/connection/socket/unix.rs+8
......@@ -281,6 +281,14 @@ impl Socket {
281281 self.0.duplicate().map(Socket)
282282 }
283283
284 pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> io::Result<usize> {
285 let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
286 let ret = cvt(unsafe {
287 libc::send(self.as_raw_fd(), buf.as_ptr() as *const c_void, len, flags)
288 })?;
289 Ok(ret as usize)
290 }
291
284292 fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: c_int) -> io::Result<()> {
285293 let ret = cvt(unsafe {
286294 libc::recv(
src/bootstrap/src/core/builder/cargo.rs+1
......@@ -683,6 +683,7 @@ impl Builder<'_> {
683683 .arg("--print=file-names")
684684 .arg("--crate-type=proc-macro")
685685 .arg("-")
686 .stdin(std::process::Stdio::null())
686687 .run_capture(self)
687688 .stderr();
688689
src/bootstrap/src/utils/exec.rs+5
......@@ -119,6 +119,11 @@ impl<'a> BootstrapCommand {
119119 self
120120 }
121121
122 pub fn stdin(&mut self, stdin: std::process::Stdio) -> &mut Self {
123 self.command.stdin(stdin);
124 self
125 }
126
122127 #[must_use]
123128 pub fn delay_failure(self) -> Self {
124129 Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
src/librustdoc/html/static/js/main.js+29-1
......@@ -1,6 +1,6 @@
11// Local js definitions:
22/* global addClass, getSettingValue, hasClass, updateLocalStorage */
3/* global onEachLazy, removeClass, getVar */
3/* global onEachLazy, removeClass, getVar, nonnull */
44
55"use strict";
66
......@@ -2138,3 +2138,31 @@ function preLoadCss(cssUrl) {
21382138 elem.addEventListener("click", showHideCodeExampleButtons);
21392139 });
21402140}());
2141
2142// This section is a bugfix for firefox: when copying text with `user-select: none`, it adds
2143// extra backline characters.
2144//
2145// Rustdoc issue: Workaround for https://github.com/rust-lang/rust/issues/141464
2146// Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1273836
2147(function() {
2148 document.body.addEventListener("copy", event => {
2149 let target = nonnull(event.target);
2150 let isInsideCode = false;
2151 while (target && target !== document.body) {
2152 // @ts-expect-error
2153 if (target.tagName === "CODE") {
2154 isInsideCode = true;
2155 break;
2156 }
2157 // @ts-expect-error
2158 target = target.parentElement;
2159 }
2160 if (!isInsideCode) {
2161 return;
2162 }
2163 const selection = document.getSelection();
2164 // @ts-expect-error
2165 nonnull(event.clipboardData).setData("text/plain", selection.toString());
2166 event.preventDefault();
2167 });
2168}());
src/librustdoc/json/conversions.rs+16-13
......@@ -194,22 +194,25 @@ impl FromClean<attrs::Deprecation> for Deprecation {
194194}
195195
196196impl FromClean<clean::GenericArgs> for Option<Box<GenericArgs>> {
197 fn from_clean(args: &clean::GenericArgs, renderer: &JsonRenderer<'_>) -> Self {
197 fn from_clean(generic_args: &clean::GenericArgs, renderer: &JsonRenderer<'_>) -> Self {
198198 use clean::GenericArgs::*;
199 if args.is_empty() {
200 return None;
201 }
202 Some(Box::new(match args {
203 AngleBracketed { args, constraints } => GenericArgs::AngleBracketed {
204 args: args.into_json(renderer),
205 constraints: constraints.into_json(renderer),
206 },
207 Parenthesized { inputs, output } => GenericArgs::Parenthesized {
199 match generic_args {
200 AngleBracketed { args, constraints } => {
201 if generic_args.is_empty() {
202 None
203 } else {
204 Some(Box::new(GenericArgs::AngleBracketed {
205 args: args.into_json(renderer),
206 constraints: constraints.into_json(renderer),
207 }))
208 }
209 }
210 Parenthesized { inputs, output } => Some(Box::new(GenericArgs::Parenthesized {
208211 inputs: inputs.into_json(renderer),
209212 output: output.into_json(renderer),
210 },
211 ReturnTypeNotation => GenericArgs::ReturnTypeNotation,
212 }))
213 })),
214 ReturnTypeNotation => Some(Box::new(GenericArgs::ReturnTypeNotation)),
215 }
213216 }
214217}
215218
src/tools/compiletest/src/errors.rs+23-23
......@@ -16,6 +16,8 @@ pub enum ErrorKind {
1616 Suggestion,
1717 Warning,
1818 Raw,
19 /// Used for better recovery and diagnostics in compiletest.
20 Unknown,
1921}
2022
2123impl ErrorKind {
......@@ -31,21 +33,25 @@ impl ErrorKind {
3133
3234 /// Either the canonical uppercase string, or some additional versions for compatibility.
3335 /// FIXME: consider keeping only the canonical versions here.
34 pub fn from_user_str(s: &str) -> ErrorKind {
35 match s {
36 fn from_user_str(s: &str) -> Option<ErrorKind> {
37 Some(match s {
3638 "HELP" | "help" => ErrorKind::Help,
3739 "ERROR" | "error" => ErrorKind::Error,
38 // `MONO_ITEM` makes annotations in `codegen-units` tests syntactically correct,
39 // but those tests never use the error kind later on.
40 "NOTE" | "note" | "MONO_ITEM" => ErrorKind::Note,
40 "NOTE" | "note" => ErrorKind::Note,
4141 "SUGGESTION" => ErrorKind::Suggestion,
4242 "WARN" | "WARNING" | "warn" | "warning" => ErrorKind::Warning,
4343 "RAW" => ErrorKind::Raw,
44 _ => panic!(
44 _ => return None,
45 })
46 }
47
48 pub fn expect_from_user_str(s: &str) -> ErrorKind {
49 ErrorKind::from_user_str(s).unwrap_or_else(|| {
50 panic!(
4551 "unexpected diagnostic kind `{s}`, expected \
46 `ERROR`, `WARN`, `NOTE`, `HELP` or `SUGGESTION`"
47 ),
48 }
52 `ERROR`, `WARN`, `NOTE`, `HELP`, `SUGGESTION` or `RAW`"
53 )
54 })
4955 }
5056}
5157
......@@ -58,6 +64,7 @@ impl fmt::Display for ErrorKind {
5864 ErrorKind::Suggestion => write!(f, "SUGGESTION"),
5965 ErrorKind::Warning => write!(f, "WARN"),
6066 ErrorKind::Raw => write!(f, "RAW"),
67 ErrorKind::Unknown => write!(f, "UNKNOWN"),
6168 }
6269 }
6370}
......@@ -65,6 +72,7 @@ impl fmt::Display for ErrorKind {
6572#[derive(Debug)]
6673pub struct Error {
6774 pub line_num: Option<usize>,
75 pub column_num: Option<usize>,
6876 /// What kind of message we expect (e.g., warning, error, suggestion).
6977 pub kind: ErrorKind,
7078 pub msg: String,
......@@ -74,17 +82,6 @@ pub struct Error {
7482 pub require_annotation: bool,
7583}
7684
77impl Error {
78 pub fn render_for_expected(&self) -> String {
79 use colored::Colorize;
80 format!("{: <10}line {: >3}: {}", self.kind, self.line_num_str(), self.msg.cyan())
81 }
82
83 pub fn line_num_str(&self) -> String {
84 self.line_num.map_or("?".to_string(), |line_num| line_num.to_string())
85 }
86}
87
8885/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
8986/// The former is a "follow" that inherits its target from the preceding line;
9087/// the latter is an "adjusts" that goes that many lines up.
......@@ -168,8 +165,10 @@ fn parse_expected(
168165 let rest = line[tag.end()..].trim_start();
169166 let (kind_str, _) =
170167 rest.split_once(|c: char| c != '_' && !c.is_ascii_alphabetic()).unwrap_or((rest, ""));
171 let kind = ErrorKind::from_user_str(kind_str);
172 let untrimmed_msg = &rest[kind_str.len()..];
168 let (kind, untrimmed_msg) = match ErrorKind::from_user_str(kind_str) {
169 Some(kind) => (kind, &rest[kind_str.len()..]),
170 None => (ErrorKind::Unknown, rest),
171 };
173172 let msg = untrimmed_msg.strip_prefix(':').unwrap_or(untrimmed_msg).trim().to_owned();
174173
175174 let line_num_adjust = &captures["adjust"];
......@@ -182,6 +181,7 @@ fn parse_expected(
182181 } else {
183182 (false, Some(line_num - line_num_adjust.len()))
184183 };
184 let column_num = Some(tag.start() + 1);
185185
186186 debug!(
187187 "line={:?} tag={:?} follow_prev={:?} kind={:?} msg={:?}",
......@@ -191,7 +191,7 @@ fn parse_expected(
191191 kind,
192192 msg
193193 );
194 Some((follow_prev, Error { line_num, kind, msg, require_annotation: true }))
194 Some((follow_prev, Error { line_num, column_num, kind, msg, require_annotation: true }))
195195}
196196
197197#[cfg(test)]
src/tools/compiletest/src/header.rs+1-1
......@@ -593,7 +593,7 @@ impl TestProps {
593593 config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS)
594594 {
595595 self.dont_require_annotations
596 .insert(ErrorKind::from_user_str(err_kind.trim()));
596 .insert(ErrorKind::expect_from_user_str(err_kind.trim()));
597597 }
598598 },
599599 );
src/tools/compiletest/src/json.rs+15-25
......@@ -36,9 +36,7 @@ struct UnusedExternNotification {
3636struct DiagnosticSpan {
3737 file_name: String,
3838 line_start: usize,
39 line_end: usize,
4039 column_start: usize,
41 column_end: usize,
4240 is_primary: bool,
4341 label: Option<String>,
4442 suggested_replacement: Option<String>,
......@@ -148,6 +146,7 @@ pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
148146 Ok(diagnostic) => push_actual_errors(&mut errors, &diagnostic, &[], file_name),
149147 Err(_) => errors.push(Error {
150148 line_num: None,
149 column_num: None,
151150 kind: ErrorKind::Raw,
152151 msg: line.to_string(),
153152 require_annotation: false,
......@@ -193,25 +192,9 @@ fn push_actual_errors(
193192 // also ensure that `//~ ERROR E123` *always* works. The
194193 // assumption is that these multi-line error messages are on their
195194 // way out anyhow.
196 let with_code = |span: Option<&DiagnosticSpan>, text: &str| {
197 // FIXME(#33000) -- it'd be better to use a dedicated
198 // UI harness than to include the line/col number like
199 // this, but some current tests rely on it.
200 //
201 // Note: Do NOT include the filename. These can easily
202 // cause false matches where the expected message
203 // appears in the filename, and hence the message
204 // changes but the test still passes.
205 let span_str = match span {
206 Some(DiagnosticSpan { line_start, column_start, line_end, column_end, .. }) => {
207 format!("{line_start}:{column_start}: {line_end}:{column_end}")
208 }
209 None => format!("?:?: ?:?"),
210 };
211 match &diagnostic.code {
212 Some(code) => format!("{span_str}: {text} [{}]", code.code),
213 None => format!("{span_str}: {text}"),
214 }
195 let with_code = |text| match &diagnostic.code {
196 Some(code) => format!("{text} [{}]", code.code),
197 None => format!("{text}"),
215198 };
216199
217200 // Convert multi-line messages into multiple errors.
......@@ -225,8 +208,9 @@ fn push_actual_errors(
225208 || Regex::new(r"aborting due to \d+ previous errors?|\d+ warnings? emitted").unwrap();
226209 errors.push(Error {
227210 line_num: None,
211 column_num: None,
228212 kind,
229 msg: with_code(None, first_line),
213 msg: with_code(first_line),
230214 require_annotation: diagnostic.level != "failure-note"
231215 && !RE.get_or_init(re_init).is_match(first_line),
232216 });
......@@ -234,8 +218,9 @@ fn push_actual_errors(
234218 for span in primary_spans {
235219 errors.push(Error {
236220 line_num: Some(span.line_start),
221 column_num: Some(span.column_start),
237222 kind,
238 msg: with_code(Some(span), first_line),
223 msg: with_code(first_line),
239224 require_annotation: true,
240225 });
241226 }
......@@ -244,16 +229,18 @@ fn push_actual_errors(
244229 if primary_spans.is_empty() {
245230 errors.push(Error {
246231 line_num: None,
232 column_num: None,
247233 kind,
248 msg: with_code(None, next_line),
234 msg: with_code(next_line),
249235 require_annotation: false,
250236 });
251237 } else {
252238 for span in primary_spans {
253239 errors.push(Error {
254240 line_num: Some(span.line_start),
241 column_num: Some(span.column_start),
255242 kind,
256 msg: with_code(Some(span), next_line),
243 msg: with_code(next_line),
257244 require_annotation: false,
258245 });
259246 }
......@@ -266,6 +253,7 @@ fn push_actual_errors(
266253 for (index, line) in suggested_replacement.lines().enumerate() {
267254 errors.push(Error {
268255 line_num: Some(span.line_start + index),
256 column_num: Some(span.column_start),
269257 kind: ErrorKind::Suggestion,
270258 msg: line.to_string(),
271259 // Empty suggestions (suggestions to remove something) are common
......@@ -288,6 +276,7 @@ fn push_actual_errors(
288276 if let Some(label) = &span.label {
289277 errors.push(Error {
290278 line_num: Some(span.line_start),
279 column_num: Some(span.column_start),
291280 kind: ErrorKind::Note,
292281 msg: label.clone(),
293282 // Empty labels (only underlining spans) are common and do not need annotations.
......@@ -310,6 +299,7 @@ fn push_backtrace(
310299 if Path::new(&expansion.span.file_name) == Path::new(&file_name) {
311300 errors.push(Error {
312301 line_num: Some(expansion.span.line_start),
302 column_num: Some(expansion.span.column_start),
313303 kind: ErrorKind::Note,
314304 msg: format!("in this expansion of {}", expansion.macro_decl_name),
315305 require_annotation: true,
src/tools/compiletest/src/runtest.rs+120-27
......@@ -11,7 +11,7 @@ use std::{env, iter, str};
1111
1212use build_helper::fs::remove_and_create_dir_all;
1313use camino::{Utf8Path, Utf8PathBuf};
14use colored::Colorize;
14use colored::{Color, Colorize};
1515use regex::{Captures, Regex};
1616use tracing::*;
1717
......@@ -677,9 +677,6 @@ impl<'test> TestCx<'test> {
677677 return;
678678 }
679679
680 // On Windows, translate all '\' path separators to '/'
681 let file_name = self.testpaths.file.to_string().replace(r"\", "/");
682
683680 // On Windows, keep all '\' path separators to match the paths reported in the JSON output
684681 // from the compiler
685682 let diagnostic_file_name = if self.props.remap_src_base {
......@@ -704,6 +701,7 @@ impl<'test> TestCx<'test> {
704701 .map(|e| Error { msg: self.normalize_output(&e.msg, &[]), ..e });
705702
706703 let mut unexpected = Vec::new();
704 let mut unimportant = Vec::new();
707705 let mut found = vec![false; expected_errors.len()];
708706 for actual_error in actual_errors {
709707 for pattern in &self.props.error_patterns {
......@@ -738,14 +736,9 @@ impl<'test> TestCx<'test> {
738736 && expected_kinds.contains(&actual_error.kind)
739737 && !self.props.dont_require_annotations.contains(&actual_error.kind)
740738 {
741 self.error(&format!(
742 "{}:{}: unexpected {}: '{}'",
743 file_name,
744 actual_error.line_num_str(),
745 actual_error.kind,
746 actual_error.msg
747 ));
748739 unexpected.push(actual_error);
740 } else {
741 unimportant.push(actual_error);
749742 }
750743 }
751744 }
......@@ -755,39 +748,140 @@ impl<'test> TestCx<'test> {
755748 // anything not yet found is a problem
756749 for (index, expected_error) in expected_errors.iter().enumerate() {
757750 if !found[index] {
758 self.error(&format!(
759 "{}:{}: expected {} not found: {}",
760 file_name,
761 expected_error.line_num_str(),
762 expected_error.kind,
763 expected_error.msg
764 ));
765751 not_found.push(expected_error);
766752 }
767753 }
768754
769755 if !unexpected.is_empty() || !not_found.is_empty() {
770756 self.error(&format!(
771 "{} unexpected errors found, {} expected errors not found",
757 "{} unexpected diagnostics reported, {} expected diagnostics not reported",
772758 unexpected.len(),
773759 not_found.len()
774760 ));
775 println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
761
762 // Emit locations in a format that is short (relative paths) but "clickable" in editors.
763 // Also normalize path separators to `/`.
764 let file_name = self
765 .testpaths
766 .file
767 .strip_prefix(self.config.src_root.as_str())
768 .unwrap_or(&self.testpaths.file)
769 .to_string()
770 .replace(r"\", "/");
771 let line_str = |e: &Error| {
772 let line_num = e.line_num.map_or("?".to_string(), |line_num| line_num.to_string());
773 // `file:?:NUM` may be confusing to editors and unclickable.
774 let opt_col_num = match e.column_num {
775 Some(col_num) if line_num != "?" => format!(":{col_num}"),
776 _ => "".to_string(),
777 };
778 format!("{file_name}:{line_num}{opt_col_num}")
779 };
780 let print_error = |e| println!("{}: {}: {}", line_str(e), e.kind, e.msg.cyan());
781 let push_suggestion =
782 |suggestions: &mut Vec<_>, e: &Error, kind, line, msg, color, rank| {
783 let mut ret = String::new();
784 if kind {
785 ret += &format!("{} {}", "with kind".color(color), e.kind);
786 }
787 if line {
788 if !ret.is_empty() {
789 ret.push(' ');
790 }
791 ret += &format!("{} {}", "on line".color(color), line_str(e));
792 }
793 if msg {
794 if !ret.is_empty() {
795 ret.push(' ');
796 }
797 ret += &format!("{} {}", "with message".color(color), e.msg.cyan());
798 }
799 suggestions.push((ret, rank));
800 };
801 let show_suggestions = |mut suggestions: Vec<_>, prefix: &str, color| {
802 // Only show suggestions with the highest rank.
803 suggestions.sort_by_key(|(_, rank)| *rank);
804 if let Some(&(_, top_rank)) = suggestions.first() {
805 for (suggestion, rank) in suggestions {
806 if rank == top_rank {
807 println!(" {} {suggestion}", prefix.color(color));
808 }
809 }
810 }
811 };
812
813 // Fuzzy matching quality:
814 // - message and line / message and kind - great, suggested
815 // - only message - good, suggested
816 // - known line and kind - ok, suggested
817 // - only known line - meh, but suggested
818 // - others are not worth suggesting
776819 if !unexpected.is_empty() {
777 println!("{}", "--- unexpected errors (from JSON output) ---".green());
820 let header = "--- reported in JSON output but not expected in test file ---";
821 println!("{}", header.green());
778822 for error in &unexpected {
779 println!("{}", error.render_for_expected());
823 print_error(error);
824 let mut suggestions = Vec::new();
825 for candidate in &not_found {
826 let mut push_red_suggestion = |line, msg, rank| {
827 push_suggestion(
828 &mut suggestions,
829 candidate,
830 candidate.kind != error.kind,
831 line,
832 msg,
833 Color::Red,
834 rank,
835 )
836 };
837 if error.msg.contains(&candidate.msg) {
838 push_red_suggestion(candidate.line_num != error.line_num, false, 0);
839 } else if candidate.line_num.is_some()
840 && candidate.line_num == error.line_num
841 {
842 push_red_suggestion(false, true, 1);
843 }
844 }
845
846 show_suggestions(suggestions, "expected", Color::Red);
780847 }
781848 println!("{}", "---".green());
782849 }
783850 if !not_found.is_empty() {
784 println!("{}", "--- not found errors (from test file) ---".red());
851 let header = "--- expected in test file but not reported in JSON output ---";
852 println!("{}", header.red());
785853 for error in &not_found {
786 println!("{}", error.render_for_expected());
854 print_error(error);
855 let mut suggestions = Vec::new();
856 for candidate in unexpected.iter().chain(&unimportant) {
857 let mut push_green_suggestion = |line, msg, rank| {
858 push_suggestion(
859 &mut suggestions,
860 candidate,
861 candidate.kind != error.kind,
862 line,
863 msg,
864 Color::Green,
865 rank,
866 )
867 };
868 if candidate.msg.contains(&error.msg) {
869 push_green_suggestion(candidate.line_num != error.line_num, false, 0);
870 } else if candidate.line_num.is_some()
871 && candidate.line_num == error.line_num
872 {
873 push_green_suggestion(false, true, 1);
874 }
875 }
876
877 show_suggestions(suggestions, "reported", Color::Green);
787878 }
788 println!("{}", "---\n".red());
879 println!("{}", "---".red());
789880 }
790 panic!("errors differ from expected");
881 panic!(
882 "errors differ from expected\nstatus: {}\ncommand: {}\n",
883 proc_res.status, proc_res.cmdline
884 );
791885 }
792886 }
793887
......@@ -2073,7 +2167,6 @@ impl<'test> TestCx<'test> {
20732167 println!("{}", String::from_utf8_lossy(&output.stdout));
20742168 eprintln!("{}", String::from_utf8_lossy(&output.stderr));
20752169 } else {
2076 use colored::Colorize;
20772170 eprintln!("warning: no pager configured, falling back to unified diff");
20782171 eprintln!(
20792172 "help: try configuring a git pager (e.g. `delta`) with `git config --global core.pager delta`"
tests/incremental/issue-61323.rs+1-1
......@@ -1,7 +1,7 @@
11//@ revisions: rpass cfail
22
33enum A {
4 //[cfail]~^ ERROR 3:1: 3:7: recursive types `A` and `C` have infinite size [E0072]
4 //[cfail]~^ ERROR recursive types `A` and `C` have infinite size [E0072]
55 B(C),
66}
77
tests/rustdoc-json/generic-args.rs+3
......@@ -17,4 +17,7 @@ pub fn my_fn1(_: <MyStruct as MyTrait>::MyType) {}
1717//@ is "$.index[?(@.name=='my_fn2')].inner.function.sig.inputs[0][1].dyn_trait.traits[0].trait.args.angle_bracketed.constraints[0].args" null
1818pub fn my_fn2(_: IntoIterator<Item = MyStruct, IntoIter = impl Clone>) {}
1919
20//@ is "$.index[?(@.name=='my_fn3')].inner.function.sig.inputs[0][1].impl_trait[0].trait_bound.trait.args.parenthesized.inputs" []
21pub fn my_fn3(f: impl FnMut()) {}
22
2023fn main() {}
tests/ui/argument-suggestions/issue-100478.rs+2-2
......@@ -32,8 +32,8 @@ fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
3232
3333fn main() {
3434 three_diff(T2::new(0)); //~ ERROR function takes
35 four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308]
36 four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308]
35 four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR arguments to this function are incorrect [E0308]
36 four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR arguments to this function are incorrect [E0308]
3737
3838 let p1 = T1::new(0);
3939 let p2 = Arc::new(T2::new(0));
tests/ui/async-await/incorrect-move-async-order-issue-79694.fixed+1-1
......@@ -4,5 +4,5 @@
44// Regression test for issue 79694
55
66fn main() {
7 let _ = async move { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect
7 let _ = async move { }; //~ ERROR the order of `move` and `async` is incorrect
88}
tests/ui/async-await/incorrect-move-async-order-issue-79694.rs+1-1
......@@ -4,5 +4,5 @@
44// Regression test for issue 79694
55
66fn main() {
7 let _ = move async { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect
7 let _ = move async { }; //~ ERROR the order of `move` and `async` is incorrect
88}
tests/ui/attributes/rustc_skip_during_method_dispatch.rs created+38
......@@ -0,0 +1,38 @@
1#![feature(rustc_attrs)]
2
3#[rustc_skip_during_method_dispatch]
4//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input [E0539]
5trait NotAList {}
6
7#[rustc_skip_during_method_dispatch = "array"]
8//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input [E0539]
9trait AlsoNotAList {}
10
11#[rustc_skip_during_method_dispatch()]
12//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input
13trait Argless {}
14
15#[rustc_skip_during_method_dispatch(array, boxed_slice, array)]
16//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input
17trait Duplicate {}
18
19#[rustc_skip_during_method_dispatch(slice)]
20//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input
21trait Unexpected {}
22
23#[rustc_skip_during_method_dispatch(array = true)]
24//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input
25trait KeyValue {}
26
27#[rustc_skip_during_method_dispatch("array")]
28//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input
29trait String {}
30
31#[rustc_skip_during_method_dispatch(array, boxed_slice)]
32trait OK {}
33
34#[rustc_skip_during_method_dispatch(array)]
35//~^ ERROR: attribute should be applied to a trait
36impl OK for () {}
37
38fn main() {}
tests/ui/attributes/rustc_skip_during_method_dispatch.stderr created+76
......@@ -0,0 +1,76 @@
1error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input
2 --> $DIR/rustc_skip_during_method_dispatch.rs:3:1
3 |
4LL | #[rustc_skip_during_method_dispatch]
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | |
7 | expected this to be a list
8 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
9
10error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input
11 --> $DIR/rustc_skip_during_method_dispatch.rs:7:1
12 |
13LL | #[rustc_skip_during_method_dispatch = "array"]
14 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 | |
16 | expected this to be a list
17 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
18
19error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input
20 --> $DIR/rustc_skip_during_method_dispatch.rs:11:1
21 |
22LL | #[rustc_skip_during_method_dispatch()]
23 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^
24 | | |
25 | | expected at least 1 argument here
26 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
27
28error[E0538]: malformed `rustc_skip_during_method_dispatch` attribute input
29 --> $DIR/rustc_skip_during_method_dispatch.rs:15:1
30 |
31LL | #[rustc_skip_during_method_dispatch(array, boxed_slice, array)]
32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^
33 | | |
34 | | found `array` used as a key more than once
35 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
36
37error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input
38 --> $DIR/rustc_skip_during_method_dispatch.rs:19:1
39 |
40LL | #[rustc_skip_during_method_dispatch(slice)]
41 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^
42 | | |
43 | | valid arguments are `array` or `boxed_slice`
44 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
45
46error[E0565]: malformed `rustc_skip_during_method_dispatch` attribute input
47 --> $DIR/rustc_skip_during_method_dispatch.rs:23:1
48 |
49LL | #[rustc_skip_during_method_dispatch(array = true)]
50 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^
51 | | |
52 | | didn't expect any arguments here
53 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
54
55error[E0565]: malformed `rustc_skip_during_method_dispatch` attribute input
56 --> $DIR/rustc_skip_during_method_dispatch.rs:27:1
57 |
58LL | #[rustc_skip_during_method_dispatch("array")]
59 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^
60 | | |
61 | | didn't expect a literal here
62 | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
63
64error: attribute should be applied to a trait
65 --> $DIR/rustc_skip_during_method_dispatch.rs:34:1
66 |
67LL | #[rustc_skip_during_method_dispatch(array)]
68 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69LL |
70LL | impl OK for () {}
71 | ----------------- not a trait
72
73error: aborting due to 8 previous errors
74
75Some errors have detailed explanations: E0538, E0539, E0565.
76For more information about an error, try `rustc --explain E0538`.
tests/ui/compiletest-self-test/line-annotation-mismatches.rs created+42
......@@ -0,0 +1,42 @@
1//@ should-fail
2
3// The warning is reported with unknown line
4//@ compile-flags: -D raw_pointer_derive
5//~? WARN kind and unknown line match the reported warning, but we do not suggest it
6
7// The error is expected but not reported at all.
8//~ ERROR this error does not exist
9
10// The error is reported but not expected at all.
11// "`main` function not found in crate" (the main function is intentionally not added)
12
13// An "unimportant" diagnostic is expected on a wrong line.
14//~ ERROR aborting due to
15
16// An "unimportant" diagnostic is expected with a wrong kind.
17//~? ERROR For more information about an error
18
19fn wrong_line_or_kind() {
20 // A diagnostic expected on a wrong line.
21 unresolved1;
22 //~ ERROR cannot find value `unresolved1` in this scope
23
24 // A diagnostic expected with a wrong kind.
25 unresolved2; //~ WARN cannot find value `unresolved2` in this scope
26
27 // A diagnostic expected with a missing kind (treated as a wrong kind).
28 unresolved3; //~ cannot find value `unresolved3` in this scope
29
30 // A diagnostic expected with a wrong line and kind.
31 unresolved4;
32 //~ WARN cannot find value `unresolved4` in this scope
33}
34
35fn wrong_message() {
36 // A diagnostic expected with a wrong message, but the line is known and right.
37 unresolvedA; //~ ERROR stub message 1
38
39 // A diagnostic expected with a wrong message, but the line is known and right,
40 // even if the kind doesn't match.
41 unresolvedB; //~ WARN stub message 2
42}
tests/ui/compiletest-self-test/line-annotation-mismatches.stderr created+61
......@@ -0,0 +1,61 @@
1warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
2 |
3 = note: requested on the command line with `-D raw_pointer_derive`
4 = note: `#[warn(renamed_and_removed_lints)]` on by default
5
6error[E0425]: cannot find value `unresolved1` in this scope
7 --> $DIR/line-annotation-mismatches.rs:21:5
8 |
9LL | unresolved1;
10 | ^^^^^^^^^^^ not found in this scope
11
12error[E0425]: cannot find value `unresolved2` in this scope
13 --> $DIR/line-annotation-mismatches.rs:25:5
14 |
15LL | unresolved2;
16 | ^^^^^^^^^^^ not found in this scope
17
18error[E0425]: cannot find value `unresolved3` in this scope
19 --> $DIR/line-annotation-mismatches.rs:28:5
20 |
21LL | unresolved3;
22 | ^^^^^^^^^^^ not found in this scope
23
24error[E0425]: cannot find value `unresolved4` in this scope
25 --> $DIR/line-annotation-mismatches.rs:31:5
26 |
27LL | unresolved4;
28 | ^^^^^^^^^^^ not found in this scope
29
30error[E0425]: cannot find value `unresolvedA` in this scope
31 --> $DIR/line-annotation-mismatches.rs:37:5
32 |
33LL | unresolvedA;
34 | ^^^^^^^^^^^ not found in this scope
35
36error[E0425]: cannot find value `unresolvedB` in this scope
37 --> $DIR/line-annotation-mismatches.rs:41:5
38 |
39LL | unresolvedB;
40 | ^^^^^^^^^^^ not found in this scope
41
42warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
43 |
44 = note: requested on the command line with `-D raw_pointer_derive`
45 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
46
47error[E0601]: `main` function not found in crate `line_annotation_mismatches`
48 --> $DIR/line-annotation-mismatches.rs:42:2
49 |
50LL | }
51 | ^ consider adding a `main` function to `$DIR/line-annotation-mismatches.rs`
52
53warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
54 |
55 = note: requested on the command line with `-D raw_pointer_derive`
56 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
57
58error: aborting due to 7 previous errors; 3 warnings emitted
59
60Some errors have detailed explanations: E0425, E0601.
61For more information about an error, try `rustc --explain E0425`.
tests/ui/feature-gates/feature-gate-cfi_encoding.rs+1-1
......@@ -1,4 +1,4 @@
11#![crate_type = "lib"]
22
3#[cfi_encoding = "3Bar"] //~ERROR 3:1: 3:25: the `#[cfi_encoding]` attribute is an experimental feature [E0658]
3#[cfi_encoding = "3Bar"] //~ ERROR the `#[cfi_encoding]` attribute is an experimental feature [E0658]
44pub struct Foo(i32);
tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs+1-1
......@@ -1,4 +1,4 @@
11fn main() {
22 let _ : &(dyn Send,) = &((),);
3 //~^ ERROR 2:28: 2:34: mismatched types [E0308]
3 //~^ ERROR mismatched types [E0308]
44}
tests/ui/impl-header-lifetime-elision/assoc-type.rs+1-1
......@@ -9,7 +9,7 @@ trait MyTrait {
99
1010impl MyTrait for &i32 {
1111 type Output = &i32;
12 //~^ ERROR 11:19: 11:20: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
12 //~^ ERROR in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
1313}
1414
1515impl MyTrait for &u32 {
tests/ui/imports/issue-28134.rs+1-1
......@@ -2,4 +2,4 @@
22
33#![allow(soft_unstable)]
44#![test]
5//~^ ERROR 4:1: 4:9: `test` attribute cannot be used at crate level
5//~^ ERROR `test` attribute cannot be used at crate level
tests/ui/inference/hint-closure-signature-119266.rs+1-1
......@@ -3,7 +3,7 @@ fn main() {
33 //~^ NOTE: the found closure
44
55 let x: fn(i32) = x;
6 //~^ ERROR: 5:22: 5:23: mismatched types [E0308]
6 //~^ ERROR: mismatched types [E0308]
77 //~| NOTE: incorrect number of function parameters
88 //~| NOTE: expected due to this
99 //~| NOTE: expected fn pointer `fn(i32)`
tests/ui/integral-indexing.rs+8-8
......@@ -3,14 +3,14 @@ pub fn main() {
33 let s: String = "abcdef".to_string();
44 v[3_usize];
55 v[3];
6 v[3u8]; //~ERROR : the type `[isize]` cannot be indexed by `u8`
7 v[3i8]; //~ERROR : the type `[isize]` cannot be indexed by `i8`
8 v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32`
9 v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32`
6 v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8`
7 v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8`
8 v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32`
9 v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32`
1010 s.as_bytes()[3_usize];
1111 s.as_bytes()[3];
12 s.as_bytes()[3u8]; //~ERROR : the type `[u8]` cannot be indexed by `u8`
13 s.as_bytes()[3i8]; //~ERROR : the type `[u8]` cannot be indexed by `i8`
14 s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32`
15 s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32`
12 s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8`
13 s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8`
14 s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32`
15 s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32`
1616}
tests/ui/issues/issue-92741.rs+3-3
......@@ -1,17 +1,17 @@
11//@ run-rustfix
22fn main() {}
33fn _foo() -> bool {
4 & //~ ERROR 4:5: 6:36: mismatched types [E0308]
4 & //~ ERROR mismatched types [E0308]
55 mut
66 if true { true } else { false }
77}
88
99fn _bar() -> bool {
10 & //~ ERROR 10:5: 11:40: mismatched types [E0308]
10 & //~ ERROR mismatched types [E0308]
1111 mut if true { true } else { false }
1212}
1313
1414fn _baz() -> bool {
15 & mut //~ ERROR 15:5: 16:36: mismatched types [E0308]
15 & mut //~ ERROR mismatched types [E0308]
1616 if true { true } else { false }
1717}
tests/ui/lifetimes/no_lending_iterators.rs+3-3
......@@ -2,7 +2,7 @@ struct Data(String);
22
33impl Iterator for Data {
44 type Item = &str;
5 //~^ ERROR 4:17: 4:18: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
5 //~^ ERROR associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
66
77 fn next(&mut self) -> Option<Self::Item> {
88 Some(&self.0)
......@@ -16,7 +16,7 @@ trait Bar {
1616
1717impl Bar for usize {
1818 type Item = &usize;
19 //~^ ERROR 18:17: 18:18: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
19 //~^ ERROR in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
2020
2121 fn poke(&mut self, item: Self::Item) {
2222 self += *item;
......@@ -25,7 +25,7 @@ impl Bar for usize {
2525
2626impl Bar for isize {
2727 type Item<'a> = &'a isize;
28 //~^ ERROR 27:14: 27:18: lifetime parameters or bounds on associated type `Item` do not match the trait declaration [E0195]
28 //~^ ERROR lifetime parameters or bounds on associated type `Item` do not match the trait declaration [E0195]
2929
3030 fn poke(&mut self, item: Self::Item) {
3131 self += *item;
tests/ui/mismatched_types/transforming-option-ref-issue-127545.rs+4-4
......@@ -2,17 +2,17 @@
22#![crate_type = "lib"]
33
44pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> {
5 arg //~ ERROR 5:5: 5:8: mismatched types [E0308]
5 arg //~ ERROR mismatched types [E0308]
66}
77
88pub fn bar(arg: Option<&Vec<i32>>) -> &[i32] {
9 arg.unwrap_or(&[]) //~ ERROR 9:19: 9:22: mismatched types [E0308]
9 arg.unwrap_or(&[]) //~ ERROR mismatched types [E0308]
1010}
1111
1212pub fn barzz<'a>(arg: Option<&'a Vec<i32>>, v: &'a [i32]) -> &'a [i32] {
13 arg.unwrap_or(v) //~ ERROR 13:19: 13:20: mismatched types [E0308]
13 arg.unwrap_or(v) //~ ERROR mismatched types [E0308]
1414}
1515
1616pub fn convert_result(arg: Result<&Vec<i32>, ()>) -> &[i32] {
17 arg.unwrap_or(&[]) //~ ERROR 17:19: 17:22: mismatched types [E0308]
17 arg.unwrap_or(&[]) //~ ERROR mismatched types [E0308]
1818}
tests/ui/sanitizer/cfi/invalid-attr-encoding.rs+1-1
......@@ -7,5 +7,5 @@
77#![no_core]
88#![no_main]
99
10#[cfi_encoding] //~ERROR 10:1: 10:16: malformed `cfi_encoding` attribute input
10#[cfi_encoding] //~ ERROR malformed `cfi_encoding` attribute input
1111pub struct Type1(i32);
tests/ui/suggestions/issue-105645.rs+1-1
......@@ -2,7 +2,7 @@ fn main() {
22 let mut buf = [0u8; 50];
33 let mut bref = buf.as_slice();
44 foo(&mut bref);
5 //~^ ERROR 4:9: 4:18: the trait bound `&[u8]: std::io::Write` is not satisfied [E0277]
5 //~^ ERROR the trait bound `&[u8]: std::io::Write` is not satisfied [E0277]
66}
77
88fn foo(_: &mut impl std::io::Write) {}
tests/ui/suggestions/suggest-full-enum-variant-for-local-module.rs+1-1
......@@ -6,5 +6,5 @@ mod option {
66}
77
88fn main() {
9 let _: option::O<()> = (); //~ ERROR 9:28: 9:30: mismatched types [E0308]
9 let _: option::O<()> = (); //~ ERROR mismatched types [E0308]
1010}
tests/ui/type/option-ref-advice.rs+2-2
......@@ -3,9 +3,9 @@
33fn takes_option(_arg: Option<&String>) {}
44
55fn main() {
6 takes_option(&None); //~ ERROR 6:18: 6:23: mismatched types [E0308]
6 takes_option(&None); //~ ERROR mismatched types [E0308]
77
88 let x = String::from("x");
99 let res = Some(x);
10 takes_option(&res); //~ ERROR 10:18: 10:22: mismatched types [E0308]
10 takes_option(&res); //~ ERROR mismatched types [E0308]
1111}
tests/ui/typeck/issue-100246.rs+1-1
......@@ -25,6 +25,6 @@ fn downcast<'a, W: ?Sized>() -> std::io::Result<&'a W> {
2525struct Other;
2626
2727fn main() -> std::io::Result<()> {
28 let other: Other = downcast()?;//~ERROR 28:24: 28:35: `?` operator has incompatible types
28 let other: Other = downcast()?; //~ ERROR `?` operator has incompatible types
2929 Ok(())
3030}
tests/ui/typeck/issue-89275.rs+1-1
......@@ -25,5 +25,5 @@ fn downcast<'a, W: ?Sized>() -> &'a W {
2525struct Other;
2626
2727fn main() {
28 let other: &mut Other = downcast();//~ERROR 28:29: 28:39: mismatched types [E0308]
28 let other: &mut Other = downcast();//~ ERROR mismatched types [E0308]
2929}