diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 570ec45557dea..097bd07c74ce8 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -437,13 +437,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ) .emit(); } - } else { - if attr.has_name(sym::deprecated) { - self.sess - .struct_span_err(attr.span, "`#[deprecated]` cannot be used in staged API") - .span_label(attr.span, "use `#[rustc_deprecated]` instead") - .emit(); - } } } diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 061fee7f569af..613320087d2dd 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -664,6 +664,7 @@ where { let mut depr: Option<(Deprecation, Span)> = None; let diagnostic = &sess.parse_sess.span_diagnostic; + let is_rustc = sess.features_untracked().staged_api; 'outer: for attr in attrs_iter { if !(attr.has_name(sym::deprecated) || attr.has_name(sym::rustc_deprecated)) { @@ -728,17 +729,31 @@ where continue 'outer; } } - sym::note if attr.has_name(sym::deprecated) => { + sym::note => { if !get(mi, &mut note) { continue 'outer; } } + // FIXME(jhpratt) remove this after a bootstrap occurs. Emitting an + // error specific to the renaming would be a good idea as well. sym::reason if attr.has_name(sym::rustc_deprecated) => { if !get(mi, &mut note) { continue 'outer; } } - sym::suggestion if attr.has_name(sym::rustc_deprecated) => { + sym::suggestion => { + if !sess.features_untracked().deprecated_suggestion { + let mut diag = sess.struct_span_err( + mi.span, + "suggestions on deprecated items are unstable", + ); + if sess.is_nightly_build() { + diag.help("add `#![feature(deprecated_suggestion)]` to the crate root"); + } + // FIXME(jhpratt) change this to an actual tracking issue + diag.note("see #XXX for more details").emit(); + } + if !get(mi, &mut suggestion) { continue 'outer; } @@ -752,7 +767,7 @@ where if attr.has_name(sym::deprecated) { &["since", "note"] } else { - &["since", "reason", "suggestion"] + &["since", "note", "suggestion"] }, ), ); @@ -775,24 +790,22 @@ where } } - if suggestion.is_some() && attr.has_name(sym::deprecated) { - unreachable!("only allowed on rustc_deprecated") - } - - if attr.has_name(sym::rustc_deprecated) { + if is_rustc { if since.is_none() { handle_errors(&sess.parse_sess, attr.span, AttrError::MissingSince); continue; } if note.is_none() { - struct_span_err!(diagnostic, attr.span, E0543, "missing 'reason'").emit(); + struct_span_err!(diagnostic, attr.span, E0543, "missing 'note'").emit(); continue; } } - let is_since_rustc_version = attr.has_name(sym::rustc_deprecated); - depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span)); + depr = Some(( + Deprecation { since, note, suggestion, is_since_rustc_version: is_rustc }, + attr.span, + )); } depr diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 52c44231d8f0e..831d408195e2f 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1657,6 +1657,31 @@ impl EmitterWriter { let line_start = sm.lookup_char_pos(parts[0].span.lo()).line; draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1); let mut lines = complete.lines(); + if lines.clone().next().is_none() { + // Account for a suggestion to completely remove a line(s) with whitespace (#94192). + let line_end = sm.lookup_char_pos(parts[0].span.hi()).line; + for line in line_start..=line_end { + buffer.puts( + row_num - 1 + line - line_start, + 0, + &self.maybe_anonymized(line), + Style::LineNumber, + ); + buffer.puts( + row_num - 1 + line - line_start, + max_line_num_len + 1, + "- ", + Style::Removal, + ); + buffer.puts( + row_num - 1 + line - line_start, + max_line_num_len + 3, + &normalize_whitespace(&*file_lines.file.get_line(line - 1).unwrap()), + Style::Removal, + ); + } + row_num += line_end - line_start; + } for (line_pos, (line, highlight_parts)) in lines.by_ref().zip(highlights).take(MAX_SUGGESTION_HIGHLIGHT_LINES).enumerate() { diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index a69d28b184aed..1899e837eeabe 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -362,6 +362,8 @@ declare_features! ( (active, default_alloc_error_handler, "1.48.0", Some(66741), None), /// Allows default type parameters to influence type inference. (active, default_type_parameter_fallback, "1.3.0", Some(27336), None), + /// Allows having using `suggestion` in the `#[deprecated]` attribute. + (active, deprecated_suggestion, "1.61.0", Some(94785), None), /// Allows `#[derive(Default)]` and `#[default]` on enums. (active, derive_default_enum, "1.56.0", Some(86985), None), /// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index bb51f880099a6..9c7b8f8032496 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -461,7 +461,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // DuplicatesOk since it has its own validation ungated!( rustc_deprecated, Normal, - template!(List: r#"since = "version", reason = "...""#), DuplicatesOk // See E0550 + template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550 ), // DuplicatesOk since it has its own validation ungated!( diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 8b0e7794f92ac..da54ad06e048b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1886,6 +1886,15 @@ impl<'tcx> Ty<'tcx> { } } + #[inline] + pub fn is_array_slice(self) -> bool { + match self.kind() { + Slice(_) => true, + RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_)), + _ => false, + } + } + #[inline] pub fn is_array(self) -> bool { matches!(self.kind(), Array(..)) diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 37a9f0ecd8c18..f36a1f61aaccb 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -202,7 +202,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { self.tcx.sess, *span, E0549, - "rustc_deprecated attribute must be paired with \ + "deprecated attribute must be paired with \ either stable or unstable attribute" ) .emit(); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3884578f5d46c..6b5dcacd12bd3 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -562,6 +562,7 @@ symbols! { delay_span_bug_from_inside_query, deny, deprecated, + deprecated_suggestion, deref, deref_method, deref_mut, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 6dfbdace8e2a0..59c88b6603c22 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -11,7 +11,7 @@ use std::iter; use super::InferCtxtPrivExt; -crate trait InferCtxtExt<'tcx> { +pub trait InferCtxtExt<'tcx> { /*private*/ fn impl_similar_to( &self, @@ -204,6 +204,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { flags.push((sym::_Self, Some("{integral}".to_owned()))); } + if self_ty.is_array_slice() { + flags.push((sym::_Self, Some("&[]".to_owned()))); + } + if let ty::Array(aty, len) = self_ty.kind() { flags.push((sym::_Self, Some("[]".to_owned()))); flags.push((sym::_Self, Some(format!("[{}]", aty)))); diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index 3d0f76f7a93eb..d3e9820834ab9 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -165,6 +165,12 @@ pub enum CastError { NonScalar, UnknownExprPtrKind, UnknownCastPtrKind, + /// Cast of int to (possibly) fat raw pointer. + /// + /// Argument is the specific name of the metadata in plain words, such as "a vtable" + /// or "a length". If this argument is None, then the metadata is unknown, for example, + /// when we're typechecking a type parameter with a ?Sized bound. + IntToFatCast(Option<&'static str>), } impl From for CastError { @@ -522,6 +528,35 @@ impl<'a, 'tcx> CastCheck<'tcx> { .diagnostic() .emit(); } + CastError::IntToFatCast(known_metadata) => { + let mut err = struct_span_err!( + fcx.tcx.sess, + self.cast_span, + E0606, + "cannot cast `{}` to a pointer that {} wide", + fcx.ty_to_string(self.expr_ty), + if known_metadata.is_some() { "is" } else { "may be" } + ); + + err.span_label( + self.cast_span, + format!( + "creating a `{}` requires both an address and {}", + self.cast_ty, + known_metadata.unwrap_or("type-specific metadata"), + ), + ); + + if fcx.tcx.sess.is_nightly_build() { + err.span_label( + self.expr.span, + "consider casting this expression to `*const ()`, \ + then using `core::ptr::from_raw_parts`", + ); + } + + err.emit(); + } CastError::UnknownCastPtrKind | CastError::UnknownExprPtrKind => { let unknown_cast_to = match e { CastError::UnknownCastPtrKind => true, @@ -900,7 +935,13 @@ impl<'a, 'tcx> CastCheck<'tcx> { match fcx.pointer_kind(m_cast.ty, self.span)? { None => Err(CastError::UnknownCastPtrKind), Some(PointerKind::Thin) => Ok(CastKind::AddrPtrCast), - _ => Err(CastError::IllegalCast), + Some(PointerKind::Vtable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))), + Some(PointerKind::Length) => Err(CastError::IntToFatCast(Some("a length"))), + Some( + PointerKind::OfProjection(_) + | PointerKind::OfOpaque(_, _) + | PointerKind::OfParam(_), + ) => Err(CastError::IntToFatCast(None)), } } diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 0ae2dfa180b9e..504e1ce8c9f51 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -19,9 +19,10 @@ use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rustc_span::lev_distance; use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{source_map, FileName, MultiSpan, Span}; -use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; +use rustc_trait_selection::traits::error_reporting::on_unimplemented::InferCtxtExt as _; +use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::{ - FulfillmentError, Obligation, ObligationCause, ObligationCauseCode, + FulfillmentError, Obligation, ObligationCause, ObligationCauseCode, OnUnimplementedNote, }; use std::cmp::Ordering; @@ -483,150 +484,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - let mut label_span_not_found = || { - if unsatisfied_predicates.is_empty() { - err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); - let is_string_or_ref_str = match actual.kind() { - ty::Ref(_, ty, _) => { - ty.is_str() - || matches!( - ty.kind(), - ty::Adt(adt, _) if self.tcx.is_diagnostic_item(sym::String, adt.did) - ) - } - ty::Adt(adt, _) => self.tcx.is_diagnostic_item(sym::String, adt.did), - _ => false, - }; - if is_string_or_ref_str && item_name.name == sym::iter { - err.span_suggestion_verbose( - item_name.span, - "because of the in-memory representation of `&str`, to obtain \ - an `Iterator` over each of its codepoint use method `chars`", - String::from("chars"), - Applicability::MachineApplicable, - ); - } - if let ty::Adt(adt, _) = rcvr_ty.kind() { - let mut inherent_impls_candidate = self - .tcx - .inherent_impls(adt.did) - .iter() - .copied() - .filter(|def_id| { - if let Some(assoc) = self.associated_value(*def_id, item_name) { - // Check for both mode is the same so we avoid suggesting - // incorrect associated item. - match (mode, assoc.fn_has_self_parameter, source) { - (Mode::MethodCall, true, SelfSource::MethodCall(_)) => { - // We check that the suggest type is actually - // different from the received one - // So we avoid suggestion method with Box - // for instance - self.tcx.at(span).type_of(*def_id) != actual - && self.tcx.at(span).type_of(*def_id) != rcvr_ty - } - (Mode::Path, false, _) => true, - _ => false, - } - } else { - false - } - }) - .collect::>(); - if !inherent_impls_candidate.is_empty() { - inherent_impls_candidate.sort(); - inherent_impls_candidate.dedup(); - - // number of type to shows at most. - let limit = if inherent_impls_candidate.len() == 5 { 5 } else { 4 }; - let type_candidates = inherent_impls_candidate - .iter() - .take(limit) - .map(|impl_item| { - format!("- `{}`", self.tcx.at(span).type_of(*impl_item)) - }) - .collect::>() - .join("\n"); - let additional_types = if inherent_impls_candidate.len() > limit { - format!( - "\nand {} more types", - inherent_impls_candidate.len() - limit - ) - } else { - "".to_string() - }; - err.note(&format!( - "the {item_kind} was found for\n{}{}", - type_candidates, additional_types - )); - } - } - } else { - err.span_label(span, format!("{item_kind} cannot be called on `{ty_str}` due to unsatisfied trait bounds")); - } - }; - - // If the method name is the name of a field with a function or closure type, - // give a helping note that it has to be called as `(x.f)(...)`. - if let SelfSource::MethodCall(expr) = source { - let field_receiver = - self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() { - ty::Adt(def, substs) if !def.is_enum() => { - let variant = &def.non_enum_variant(); - self.tcx.find_field_index(item_name, variant).map(|index| { - let field = &variant.fields[index]; - let field_ty = field.ty(tcx, substs); - (field, field_ty) - }) - } - _ => None, - }); - - if let Some((field, field_ty)) = field_receiver { - let scope = self.tcx.parent_module(self.body_id).to_def_id(); - let is_accessible = field.vis.is_accessible_from(scope, self.tcx); - - if is_accessible { - if self.is_fn_ty(field_ty, span) { - let expr_span = expr.span.to(item_name.span); - err.multipart_suggestion( - &format!( - "to call the function stored in `{}`, \ - surround the field access with parentheses", - item_name, - ), - vec![ - (expr_span.shrink_to_lo(), '('.to_string()), - (expr_span.shrink_to_hi(), ')'.to_string()), - ], - Applicability::MachineApplicable, - ); - } else { - let call_expr = self - .tcx - .hir() - .expect_expr(self.tcx.hir().get_parent_node(expr.hir_id)); - - if let Some(span) = call_expr.span.trim_start(item_name.span) { - err.span_suggestion( - span, - "remove the arguments", - String::new(), - Applicability::MaybeIncorrect, - ); - } - } - } - - let field_kind = if is_accessible { "field" } else { "private field" }; - err.span_label(item_name.span, format!("{}, not a method", field_kind)); - } else if lev_candidate.is_none() && static_sources.is_empty() { - label_span_not_found(); - } - } else { - label_span_not_found(); - } - if self.is_fn_ty(rcvr_ty, span) { fn report_function(err: &mut Diagnostic, name: T) { err.note( @@ -645,12 +502,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + let mut custom_span_label = false; + if !static_sources.is_empty() { err.note( "found the following associated functions; to be used as methods, \ functions must have a `self` parameter", ); err.span_label(span, "this is an associated function, not a method"); + custom_span_label = true; } if static_sources.len() == 1 { let ty_str = if let Some(CandidateSource::ImplSource(impl_did)) = @@ -686,6 +546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { report_candidates(span, &mut err, static_sources, sugg_span); } + let mut bound_spans = vec![]; let mut restrict_type_params = false; let mut unsatisfied_bounds = false; if item_name.name == sym::count && self.is_slice_ty(actual, span) { @@ -709,7 +570,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.sess.source_map().guess_head_span(self.tcx.def_span(def_id)) }; let mut type_params = FxHashMap::default(); - let mut bound_spans = vec![]; + + // Pick out the list of unimplemented traits on the receiver. + // This is used for custom error messages with the `#[rustc_on_unimplemented]` attribute. + let mut unimplemented_traits = FxHashMap::default(); + for (predicate, _parent_pred, cause) in &unsatisfied_predicates { + if let (ty::PredicateKind::Trait(p), Some(cause)) = + (predicate.kind().skip_binder(), cause.as_ref()) + { + if p.trait_ref.self_ty() != rcvr_ty { + // This is necessary, not just to keep the errors clean, but also + // because our derived obligations can wind up with a trait ref that + // requires a different param_env to be correctly compared. + continue; + } + unimplemented_traits.entry(p.trait_ref.def_id).or_insert(( + predicate.kind().rebind(p.trait_ref), + Obligation { + cause: cause.clone(), + param_env: self.param_env, + predicate: predicate.clone(), + recursion_depth: 0, + }, + )); + } + } let mut collect_type_param_suggestions = |self_ty: Ty<'tcx>, parent_pred: ty::Predicate<'tcx>, obligation: &str| { @@ -945,11 +830,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { bound_list.sort_by(|(_, a), (_, b)| a.cmp(b)); // Sort alphabetically. bound_list.dedup_by(|(_, a), (_, b)| a == b); // #35677 bound_list.sort_by_key(|(pos, _)| *pos); // Keep the original predicate order. - bound_spans.sort(); - bound_spans.dedup(); - for (span, msg) in bound_spans.into_iter() { - err.span_label(span, &msg); - } + if !bound_list.is_empty() || !skip_list.is_empty() { let bound_list = bound_list .into_iter() @@ -957,9 +838,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .collect::>() .join("\n"); let actual_prefix = actual.prefix_string(self.tcx); - err.set_primary_message(&format!( + info!("unimplemented_traits.len() == {}", unimplemented_traits.len()); + let (primary_message, label) = if unimplemented_traits.len() == 1 { + unimplemented_traits + .into_iter() + .next() + .map(|(_, (trait_ref, obligation))| { + if trait_ref.self_ty().references_error() + || actual.references_error() + { + // Avoid crashing. + return (None, None); + } + let OnUnimplementedNote { message, label, .. } = + self.infcx.on_unimplemented_note(trait_ref, &obligation); + (message, label) + }) + .unwrap_or((None, None)) + } else { + (None, None) + }; + let primary_message = primary_message.unwrap_or_else(|| format!( "the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, but its trait bounds were not satisfied" )); + err.set_primary_message(&primary_message); + if let Some(label) = label { + custom_span_label = true; + err.span_label(span, label); + } if !bound_list.is_empty() { err.note(&format!( "the following trait bounds were not satisfied:\n{bound_list}" @@ -971,6 +877,156 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + let mut label_span_not_found = || { + if unsatisfied_predicates.is_empty() { + err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); + let is_string_or_ref_str = match actual.kind() { + ty::Ref(_, ty, _) => { + ty.is_str() + || matches!( + ty.kind(), + ty::Adt(adt, _) if self.tcx.is_diagnostic_item(sym::String, adt.did) + ) + } + ty::Adt(adt, _) => self.tcx.is_diagnostic_item(sym::String, adt.did), + _ => false, + }; + if is_string_or_ref_str && item_name.name == sym::iter { + err.span_suggestion_verbose( + item_name.span, + "because of the in-memory representation of `&str`, to obtain \ + an `Iterator` over each of its codepoint use method `chars`", + String::from("chars"), + Applicability::MachineApplicable, + ); + } + if let ty::Adt(adt, _) = rcvr_ty.kind() { + let mut inherent_impls_candidate = self + .tcx + .inherent_impls(adt.did) + .iter() + .copied() + .filter(|def_id| { + if let Some(assoc) = self.associated_value(*def_id, item_name) { + // Check for both mode is the same so we avoid suggesting + // incorrect associated item. + match (mode, assoc.fn_has_self_parameter, source) { + (Mode::MethodCall, true, SelfSource::MethodCall(_)) => { + // We check that the suggest type is actually + // different from the received one + // So we avoid suggestion method with Box + // for instance + self.tcx.at(span).type_of(*def_id) != actual + && self.tcx.at(span).type_of(*def_id) != rcvr_ty + } + (Mode::Path, false, _) => true, + _ => false, + } + } else { + false + } + }) + .collect::>(); + if !inherent_impls_candidate.is_empty() { + inherent_impls_candidate.sort(); + inherent_impls_candidate.dedup(); + + // number of type to shows at most. + let limit = if inherent_impls_candidate.len() == 5 { 5 } else { 4 }; + let type_candidates = inherent_impls_candidate + .iter() + .take(limit) + .map(|impl_item| { + format!("- `{}`", self.tcx.at(span).type_of(*impl_item)) + }) + .collect::>() + .join("\n"); + let additional_types = if inherent_impls_candidate.len() > limit { + format!( + "\nand {} more types", + inherent_impls_candidate.len() - limit + ) + } else { + "".to_string() + }; + err.note(&format!( + "the {item_kind} was found for\n{}{}", + type_candidates, additional_types + )); + } + } + } else { + err.span_label(span, format!("{item_kind} cannot be called on `{ty_str}` due to unsatisfied trait bounds")); + } + }; + + // If the method name is the name of a field with a function or closure type, + // give a helping note that it has to be called as `(x.f)(...)`. + if let SelfSource::MethodCall(expr) = source { + let field_receiver = + self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() { + ty::Adt(def, substs) if !def.is_enum() => { + let variant = &def.non_enum_variant(); + self.tcx.find_field_index(item_name, variant).map(|index| { + let field = &variant.fields[index]; + let field_ty = field.ty(tcx, substs); + (field, field_ty) + }) + } + _ => None, + }); + + if let Some((field, field_ty)) = field_receiver { + let scope = self.tcx.parent_module(self.body_id).to_def_id(); + let is_accessible = field.vis.is_accessible_from(scope, self.tcx); + + if is_accessible { + if self.is_fn_ty(field_ty, span) { + let expr_span = expr.span.to(item_name.span); + err.multipart_suggestion( + &format!( + "to call the function stored in `{}`, \ + surround the field access with parentheses", + item_name, + ), + vec![ + (expr_span.shrink_to_lo(), '('.to_string()), + (expr_span.shrink_to_hi(), ')'.to_string()), + ], + Applicability::MachineApplicable, + ); + } else { + let call_expr = self + .tcx + .hir() + .expect_expr(self.tcx.hir().get_parent_node(expr.hir_id)); + + if let Some(span) = call_expr.span.trim_start(item_name.span) { + err.span_suggestion( + span, + "remove the arguments", + String::new(), + Applicability::MaybeIncorrect, + ); + } + } + } + + let field_kind = if is_accessible { "field" } else { "private field" }; + err.span_label(item_name.span, format!("{}, not a method", field_kind)); + } else if lev_candidate.is_none() && !custom_span_label { + label_span_not_found(); + } + } else if !custom_span_label { + label_span_not_found(); + } + + bound_spans.sort(); + bound_spans.dedup(); + for (span, msg) in bound_spans.into_iter() { + err.span_label(span, &msg); + } + if actual.is_numeric() && actual.is_fresh() || restrict_type_params { } else { self.suggest_traits_to_import( diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index ee79021ed536e..20dfbc6347c4f 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -276,9 +276,10 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] { } #[stable(feature = "index_trait_on_arrays", since = "1.50.0")] -impl Index for [T; N] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const Index for [T; N] where - [T]: Index, + [T]: ~const Index, { type Output = <[T] as Index>::Output; @@ -289,9 +290,10 @@ where } #[stable(feature = "index_trait_on_arrays", since = "1.50.0")] -impl IndexMut for [T; N] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const IndexMut for [T; N] where - [T]: IndexMut, + [T]: ~const IndexMut, { #[inline] fn index_mut(&mut self, index: I) -> &mut Self::Output { diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index b38df1c2d0228..c35d0784dd5a4 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -34,6 +34,11 @@ fn _assert_is_object_safe(_: &dyn Iterator) {} note = "`..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant \ to have a bounded `RangeInclusive`: `0..=end`" ), + on( + _Self = "[]", + label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`" + ), + on(_Self = "&[]", label = "`{Self}` is not an iterator; try calling `.iter()`"), on( _Self = "&str", label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ddd8ae0c02ca5..97add8f2c6a74 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -149,6 +149,8 @@ #![feature(variant_count)] #![feature(const_array_from_ref)] #![feature(const_slice_from_ref)] +#![feature(const_slice_index)] +#![feature(const_is_char_boundary)] // // Language features: #![feature(abi_unadjusted)] @@ -167,6 +169,7 @@ #![feature(const_refs_to_cell)] #![feature(decl_macro)] #![feature(derive_default_enum)] +#![cfg_attr(not(bootstrap), feature(deprecated_suggestion))] #![feature(doc_cfg)] #![feature(doc_notable_trait)] #![feature(rustdoc_internals)] diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 72105888f9447..07fd317e07486 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -809,7 +809,7 @@ impl u8 { ascii::escape_default(self) } - pub(crate) fn is_utf8_char_boundary(self) -> bool { + pub(crate) const fn is_utf8_char_boundary(self) -> bool { // This is bit magic equivalent to: b < 128 || b >= 192 (self as i8) >= -0x40 } diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index 1136722067874..5029e0560b892 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -446,7 +446,7 @@ impl RangeInclusive { /// Converts to an exclusive `Range` for `SliceIndex` implementations. /// The caller is responsible for dealing with `end == usize::MAX`. #[inline] - pub(crate) fn into_slice_range(self) -> Range { + pub(crate) const fn into_slice_range(self) -> Range { // If we're not exhausted, we want to simply slice `start..end + 1`. // If we are exhausted, then slicing with `end + 1..end + 1` gives us an // empty range that is still subject to bounds-checks for that endpoint. diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 485a5965f4cf7..ee544b4842e86 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1032,10 +1032,11 @@ impl *const [T] { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked(self, index: I) -> *const I::Output + pub const unsafe fn get_unchecked(self, index: I) -> *const I::Output where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. unsafe { index.get_unchecked(self) } diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 1412e836ebfc2..3374b48c88c6b 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1302,10 +1302,11 @@ impl *mut [T] { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline(always)] - pub unsafe fn get_unchecked_mut(self, index: I) -> *mut I::Output + pub const unsafe fn get_unchecked_mut(self, index: I) -> *mut I::Output where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. unsafe { index.get_unchecked_mut(self) } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 77b93e0c24cc9..c744ad5dd2deb 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -630,10 +630,11 @@ impl NonNull<[T]> { /// } /// ``` #[unstable(feature = "slice_ptr_get", issue = "74265")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut(self, index: I) -> NonNull + pub const unsafe fn get_unchecked_mut(self, index: I) -> NonNull where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { // SAFETY: the caller ensures that `self` is dereferenceable and `index` in-bounds. // As a consequence, the resulting pointer cannot be null. diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 0298bba8d329e..7e6fbbe353889 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -1,12 +1,14 @@ //! Indexing implementations for `[T]`. +use crate::intrinsics::const_eval_select; use crate::ops; use crate::ptr; #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index for [T] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const ops::Index for [T] where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { type Output = I::Output; @@ -17,9 +19,10 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl ops::IndexMut for [T] +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const ops::IndexMut for [T] where - I: SliceIndex<[T]>, + I: ~const SliceIndex<[T]>, { #[inline] fn index_mut(&mut self, index: I) -> &mut I::Output { @@ -31,31 +34,72 @@ where #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_start_index_len_fail(index: usize, len: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_start_index_len_fail(index: usize, len: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { + const_eval_select( + (index, len), + slice_start_index_len_fail_ct, + slice_start_index_len_fail_rt, + ) + } +} + +// FIXME const-hack +fn slice_start_index_len_fail_rt(index: usize, len: usize) -> ! { panic!("range start index {} out of range for slice of length {}", index, len); } +const fn slice_start_index_len_fail_ct(_: usize, _: usize) -> ! { + panic!("slice start index is out of range for slice"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_end_index_len_fail(index: usize, len: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_end_index_len_fail(index: usize, len: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { + const_eval_select((index, len), slice_end_index_len_fail_ct, slice_end_index_len_fail_rt) + } +} + +// FIXME const-hack +fn slice_end_index_len_fail_rt(index: usize, len: usize) -> ! { panic!("range end index {} out of range for slice of length {}", index, len); } +const fn slice_end_index_len_fail_ct(_: usize, _: usize) -> ! { + panic!("slice end index is out of range for slice"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_index_order_fail(index: usize, end: usize) -> ! { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +const fn slice_index_order_fail(index: usize, end: usize) -> ! { + // SAFETY: we are just panicking here + unsafe { const_eval_select((index, end), slice_index_order_fail_ct, slice_index_order_fail_rt) } +} + +// FIXME const-hack +fn slice_index_order_fail_rt(index: usize, end: usize) -> ! { panic!("slice index starts at {} but ends at {}", index, end); } +const fn slice_index_order_fail_ct(_: usize, _: usize) -> ! { + panic!("slice index start is larger than end"); +} + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_start_index_overflow_fail() -> ! { +const fn slice_start_index_overflow_fail() -> ! { panic!("attempted to index slice from after maximum usize"); } @@ -63,7 +107,7 @@ fn slice_start_index_overflow_fail() -> ! { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] -fn slice_end_index_overflow_fail() -> ! { +const fn slice_end_index_overflow_fail() -> ! { panic!("attempted to index slice up to maximum usize"); } @@ -153,7 +197,8 @@ pub unsafe trait SliceIndex: private_slice_index::Sealed { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl SliceIndex<[T]> for usize { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for usize { type Output = T; #[inline] @@ -197,7 +242,8 @@ unsafe impl SliceIndex<[T]> for usize { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl SliceIndex<[T]> for ops::Range { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::Range { type Output = [T]; #[inline] @@ -261,7 +307,8 @@ unsafe impl SliceIndex<[T]> for ops::Range { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl SliceIndex<[T]> for ops::RangeTo { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::RangeTo { type Output = [T]; #[inline] @@ -298,7 +345,8 @@ unsafe impl SliceIndex<[T]> for ops::RangeTo { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl SliceIndex<[T]> for ops::RangeFrom { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::RangeFrom { type Output = [T]; #[inline] @@ -343,7 +391,8 @@ unsafe impl SliceIndex<[T]> for ops::RangeFrom { } #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] -unsafe impl SliceIndex<[T]> for ops::RangeFull { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::RangeFull { type Output = [T]; #[inline] @@ -378,7 +427,8 @@ unsafe impl SliceIndex<[T]> for ops::RangeFull { } #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex<[T]> for ops::RangeInclusive { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::RangeInclusive { type Output = [T]; #[inline] @@ -421,7 +471,8 @@ unsafe impl SliceIndex<[T]> for ops::RangeInclusive { } #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex<[T]> for ops::RangeToInclusive { type Output = [T]; #[inline] diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 9467c7f54bac7..7311fe40e04d6 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -324,10 +324,11 @@ impl [T] { /// assert_eq!(None, v.get(0..4)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get(&self, index: I) -> Option<&I::Output> + pub const fn get(&self, index: I) -> Option<&I::Output> where - I: SliceIndex, + I: ~const SliceIndex, { index.get(self) } @@ -348,10 +349,11 @@ impl [T] { /// assert_eq!(x, &[0, 42, 2]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get_mut(&mut self, index: I) -> Option<&mut I::Output> + pub const fn get_mut(&mut self, index: I) -> Option<&mut I::Output> where - I: SliceIndex, + I: ~const SliceIndex, { index.get_mut(self) } @@ -379,10 +381,11 @@ impl [T] { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked(&self, index: I) -> &I::Output + pub const unsafe fn get_unchecked(&self, index: I) -> &I::Output where - I: SliceIndex, + I: ~const SliceIndex, { // SAFETY: the caller must uphold most of the safety requirements for `get_unchecked`; // the slice is dereferenceable because `self` is a safe reference. @@ -415,10 +418,11 @@ impl [T] { /// assert_eq!(x, &[1, 13, 4]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut(&mut self, index: I) -> &mut I::Output + pub const unsafe fn get_unchecked_mut(&mut self, index: I) -> &mut I::Output where - I: SliceIndex, + I: ~const SliceIndex, { // SAFETY: the caller must uphold the safety requirements for `get_unchecked_mut`; // the slice is dereferenceable because `self` is a safe reference. diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 09709dc3cf6df..f66bab999a98a 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -79,7 +79,23 @@ use iter::{MatchesInternal, SplitNInternal}; #[inline(never)] #[cold] #[track_caller] -fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { +#[rustc_allow_const_fn_unstable(const_eval_select)] +const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { + // SAFETY: panics for both branches + unsafe { + crate::intrinsics::const_eval_select( + (s, begin, end), + slice_error_fail_ct, + slice_error_fail_rt, + ) + } +} + +const fn slice_error_fail_ct(_: &str, _: usize, _: usize) -> ! { + panic!("failed to slice string"); +} + +fn slice_error_fail_rt(s: &str, begin: usize, end: usize) -> ! { const MAX_DISPLAY_LENGTH: usize = 256; let trunc_len = s.floor_char_boundary(MAX_DISPLAY_LENGTH); let s_trunc = &s[..trunc_len]; @@ -189,8 +205,9 @@ impl str { /// ``` #[must_use] #[stable(feature = "is_char_boundary", since = "1.9.0")] + #[rustc_const_unstable(feature = "const_is_char_boundary", issue = "none")] #[inline] - pub fn is_char_boundary(&self, index: usize) -> bool { + pub const fn is_char_boundary(&self, index: usize) -> bool { // 0 is always ok. // Test for 0 explicitly so that it can optimize out the check // easily and skip reading string data for that case. @@ -418,8 +435,9 @@ impl str { /// assert!(v.get(..42).is_none()); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get>(&self, i: I) -> Option<&I::Output> { + pub const fn get>(&self, i: I) -> Option<&I::Output> { i.get(self) } @@ -450,8 +468,9 @@ impl str { /// assert_eq!("HEllo", v); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub fn get_mut>(&mut self, i: I) -> Option<&mut I::Output> { + pub const fn get_mut>(&mut self, i: I) -> Option<&mut I::Output> { i.get_mut(self) } @@ -482,8 +501,9 @@ impl str { /// } /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked>(&self, i: I) -> &I::Output { + pub const unsafe fn get_unchecked>(&self, i: I) -> &I::Output { // SAFETY: the caller must uphold the safety contract for `get_unchecked`; // the slice is dereferenceable because `self` is a safe reference. // The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is. @@ -517,8 +537,12 @@ impl str { /// } /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[inline] - pub unsafe fn get_unchecked_mut>(&mut self, i: I) -> &mut I::Output { + pub const unsafe fn get_unchecked_mut>( + &mut self, + i: I, + ) -> &mut I::Output { // SAFETY: the caller must uphold the safety contract for `get_unchecked_mut`; // the slice is dereferenceable because `self` is a safe reference. // The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is. diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index 952676247489f..8b6b4fa02f833 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -53,9 +53,10 @@ impl PartialOrd for str { } #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index for str +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const ops::Index for str where - I: SliceIndex, + I: ~const SliceIndex, { type Output = I::Output; @@ -66,9 +67,10 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl ops::IndexMut for str +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +impl const ops::IndexMut for str where - I: SliceIndex, + I: ~const SliceIndex, { #[inline] fn index_mut(&mut self, index: I) -> &mut I::Output { @@ -79,7 +81,7 @@ where #[inline(never)] #[cold] #[track_caller] -fn str_index_overflow_fail() -> ! { +const fn str_index_overflow_fail() -> ! { panic!("attempted to index str up to maximum usize"); } @@ -96,7 +98,8 @@ fn str_index_overflow_fail() -> ! { /// /// Equivalent to `&self[0 .. len]` or `&mut self[0 .. len]`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex for ops::RangeFull { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::RangeFull { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -160,7 +163,8 @@ unsafe impl SliceIndex for ops::RangeFull { /// // &s[3 .. 100]; /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex for ops::Range { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::Range { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -247,7 +251,8 @@ unsafe impl SliceIndex for ops::Range { /// Panics if `end` does not point to the starting byte offset of a /// character (as defined by `is_char_boundary`), or if `end > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex for ops::RangeTo { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::RangeTo { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -317,7 +322,8 @@ unsafe impl SliceIndex for ops::RangeTo { /// Panics if `begin` does not point to the starting byte offset of /// a character (as defined by `is_char_boundary`), or if `begin > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] -unsafe impl SliceIndex for ops::RangeFrom { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::RangeFrom { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -393,7 +399,8 @@ unsafe impl SliceIndex for ops::RangeFrom { /// to the ending byte offset of a character (`end + 1` is either a starting /// byte offset or equal to `len`), if `begin > end`, or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex for ops::RangeInclusive { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::RangeInclusive { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { @@ -444,7 +451,8 @@ unsafe impl SliceIndex for ops::RangeInclusive { /// (`end + 1` is either a starting byte offset as defined by /// `is_char_boundary`, or equal to `len`), or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] -unsafe impl SliceIndex for ops::RangeToInclusive { +#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] +unsafe impl const SliceIndex for ops::RangeToInclusive { type Output = str; #[inline] fn get(self, slice: &str) -> Option<&Self::Output> { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c35389d44f9fc..ebc0c5180d77b 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -263,6 +263,7 @@ #![feature(doc_cfg)] #![feature(doc_cfg_hide)] #![feature(rustdoc_internals)] +#![cfg_attr(not(bootstrap), feature(deprecated_suggestion))] #![feature(doc_masked)] #![feature(doc_notable_trait)] #![feature(dropck_eyepatch)] diff --git a/src/test/ui/cast/fat-ptr-cast.rs b/src/test/ui/cast/fat-ptr-cast.rs index a0fad583a1645..b5276dc619bfb 100644 --- a/src/test/ui/cast/fat-ptr-cast.rs +++ b/src/test/ui/cast/fat-ptr-cast.rs @@ -19,6 +19,15 @@ fn main() { q as *const [i32]; //~ ERROR cannot cast // #21397 - let t: *mut (dyn Trait + 'static) = 0 as *mut _; //~ ERROR casting - let mut fail: *const str = 0 as *const str; //~ ERROR casting + let t: *mut (dyn Trait + 'static) = 0 as *mut _; + //~^ ERROR cannot cast `usize` to a pointer that is wide + let mut fail: *const str = 0 as *const str; + //~^ ERROR cannot cast `usize` to a pointer that is wide + let mut fail2: *const str = 0isize as *const str; + //~^ ERROR cannot cast `isize` to a pointer that is wide +} + +fn foo() { + let s = 0 as *const T; + //~^ ERROR cannot cast `usize` to a pointer that may be wide } diff --git a/src/test/ui/cast/fat-ptr-cast.stderr b/src/test/ui/cast/fat-ptr-cast.stderr index 0b0c288fe3b61..18e7b68ff3c22 100644 --- a/src/test/ui/cast/fat-ptr-cast.stderr +++ b/src/test/ui/cast/fat-ptr-cast.stderr @@ -50,19 +50,39 @@ error[E0607]: cannot cast thin pointer `*const i32` to fat pointer `*const [i32] LL | q as *const [i32]; | ^^^^^^^^^^^^^^^^^ -error[E0606]: casting `usize` as `*mut (dyn Trait + 'static)` is invalid - --> $DIR/fat-ptr-cast.rs:22:41 +error[E0606]: cannot cast `usize` to a pointer that is wide + --> $DIR/fat-ptr-cast.rs:22:46 | LL | let t: *mut (dyn Trait + 'static) = 0 as *mut _; - | ^^^^^^^^^^^ + | - ^^^^^^ creating a `*mut (dyn Trait + 'static)` requires both an address and a vtable + | | + | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` -error[E0606]: casting `usize` as `*const str` is invalid - --> $DIR/fat-ptr-cast.rs:23:32 +error[E0606]: cannot cast `usize` to a pointer that is wide + --> $DIR/fat-ptr-cast.rs:24:37 | LL | let mut fail: *const str = 0 as *const str; - | ^^^^^^^^^^^^^^^ + | - ^^^^^^^^^^ creating a `*const str` requires both an address and a length + | | + | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` -error: aborting due to 9 previous errors +error[E0606]: cannot cast `isize` to a pointer that is wide + --> $DIR/fat-ptr-cast.rs:26:43 + | +LL | let mut fail2: *const str = 0isize as *const str; + | ------ ^^^^^^^^^^ creating a `*const str` requires both an address and a length + | | + | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` + +error[E0606]: cannot cast `usize` to a pointer that may be wide + --> $DIR/fat-ptr-cast.rs:31:18 + | +LL | let s = 0 as *const T; + | - ^^^^^^^^ creating a `*const T` requires both an address and type-specific metadata + | | + | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` + +error: aborting due to 11 previous errors Some errors have detailed explanations: E0605, E0606, E0607. For more information about an error, try `rustc --explain E0605`. diff --git a/src/test/ui/deprecation/deprecation-in-staged-api.rs b/src/test/ui/deprecation/deprecation-in-staged-api.rs deleted file mode 100644 index 910bfd1b5e48a..0000000000000 --- a/src/test/ui/deprecation/deprecation-in-staged-api.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(staged_api)] -#![stable(feature = "stable_test_feature", since = "1.0.0")] -#[deprecated] //~ ERROR `#[deprecated]` cannot be used in staged API -fn main() {} diff --git a/src/test/ui/deprecation/deprecation-in-staged-api.stderr b/src/test/ui/deprecation/deprecation-in-staged-api.stderr deleted file mode 100644 index 5c14f5ed356f3..0000000000000 --- a/src/test/ui/deprecation/deprecation-in-staged-api.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `#[deprecated]` cannot be used in staged API - --> $DIR/deprecation-in-staged-api.rs:3:1 - | -LL | #[deprecated] - | ^^^^^^^^^^^^^ use `#[rustc_deprecated]` instead - -error: aborting due to previous error - diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs new file mode 100644 index 0000000000000..a2d0023e3f479 --- /dev/null +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs @@ -0,0 +1,6 @@ +// compile-flags: --crate-type=lib + +#![no_implicit_prelude] + +#[deprecated(suggestion = "foo")] //~ ERROR suggestions on deprecated items are unstable +struct Foo {} diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr new file mode 100644 index 0000000000000..3b995fed75c8c --- /dev/null +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr @@ -0,0 +1,11 @@ +error: suggestions on deprecated items are unstable + --> $DIR/feature-gate-deprecated_suggestion.rs:5:14 + | +LL | #[deprecated(suggestion = "foo")] + | ^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(deprecated_suggestion)]` to the crate root + = note: see #XXX for more details + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/rustc_deprecation-in-future.rs b/src/test/ui/deprecation/staged-deprecation-in-future.rs similarity index 80% rename from src/test/ui/deprecation/rustc_deprecation-in-future.rs rename to src/test/ui/deprecation/staged-deprecation-in-future.rs index 3715f8eb2252d..87b15ec303c33 100644 --- a/src/test/ui/deprecation/rustc_deprecation-in-future.rs +++ b/src/test/ui/deprecation/staged-deprecation-in-future.rs @@ -4,11 +4,11 @@ #![stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] -#[rustc_deprecated(since = "99.99.99", reason = "effectively never")] +#[deprecated(since = "99.99.99", note = "effectively never")] #[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] pub struct S1; -#[rustc_deprecated(since = "TBD", reason = "literally never")] +#[deprecated(since = "TBD", note = "literally never")] #[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] pub struct S2; diff --git a/src/test/ui/deprecation/rustc_deprecation-in-future.stderr b/src/test/ui/deprecation/staged-deprecation-in-future.stderr similarity index 75% rename from src/test/ui/deprecation/rustc_deprecation-in-future.stderr rename to src/test/ui/deprecation/staged-deprecation-in-future.stderr index 1c3339a8a9dc0..13d98044a88d8 100644 --- a/src/test/ui/deprecation/rustc_deprecation-in-future.stderr +++ b/src/test/ui/deprecation/staged-deprecation-in-future.stderr @@ -1,17 +1,17 @@ error: use of unit struct `S1` that will be deprecated in future version 99.99.99: effectively never - --> $DIR/rustc_deprecation-in-future.rs:16:13 + --> $DIR/staged-deprecation-in-future.rs:16:13 | LL | let _ = S1; | ^^ | note: the lint level is defined here - --> $DIR/rustc_deprecation-in-future.rs:1:9 + --> $DIR/staged-deprecation-in-future.rs:1:9 | LL | #![deny(deprecated_in_future)] | ^^^^^^^^^^^^^^^^^^^^ error: use of unit struct `S2` that will be deprecated in a future Rust version: literally never - --> $DIR/rustc_deprecation-in-future.rs:17:13 + --> $DIR/staged-deprecation-in-future.rs:17:13 | LL | let _ = S2; | ^^ diff --git a/src/test/ui/deprecation/suggestion.fixed b/src/test/ui/deprecation/suggestion.fixed index 7d662227881ac..d9fa2b56eeef7 100644 --- a/src/test/ui/deprecation/suggestion.fixed +++ b/src/test/ui/deprecation/suggestion.fixed @@ -1,6 +1,7 @@ // run-rustfix #![feature(staged_api)] +#![feature(deprecated_suggestion)] #![stable(since = "1.0.0", feature = "test")] @@ -10,9 +11,9 @@ struct Foo; impl Foo { - #[rustc_deprecated( + #[deprecated( since = "1.0.0", - reason = "replaced by `replacement`", + note = "replaced by `replacement`", suggestion = "replacement", )] #[stable(since = "1.0.0", feature = "test")] @@ -22,9 +23,9 @@ impl Foo { } mod bar { - #[rustc_deprecated( + #[deprecated( since = "1.0.0", - reason = "replaced by `replacement`", + note = "replaced by `replacement`", suggestion = "replacement", )] #[stable(since = "1.0.0", feature = "test")] diff --git a/src/test/ui/deprecation/suggestion.rs b/src/test/ui/deprecation/suggestion.rs index b34dc0eb83a20..9dc2eaf255507 100644 --- a/src/test/ui/deprecation/suggestion.rs +++ b/src/test/ui/deprecation/suggestion.rs @@ -1,6 +1,7 @@ // run-rustfix #![feature(staged_api)] +#![feature(deprecated_suggestion)] #![stable(since = "1.0.0", feature = "test")] @@ -10,9 +11,9 @@ struct Foo; impl Foo { - #[rustc_deprecated( + #[deprecated( since = "1.0.0", - reason = "replaced by `replacement`", + note = "replaced by `replacement`", suggestion = "replacement", )] #[stable(since = "1.0.0", feature = "test")] @@ -22,9 +23,9 @@ impl Foo { } mod bar { - #[rustc_deprecated( + #[deprecated( since = "1.0.0", - reason = "replaced by `replacement`", + note = "replaced by `replacement`", suggestion = "replacement", )] #[stable(since = "1.0.0", feature = "test")] diff --git a/src/test/ui/deprecation/suggestion.stderr b/src/test/ui/deprecation/suggestion.stderr index 7d78b2222444f..8d1e108345f30 100644 --- a/src/test/ui/deprecation/suggestion.stderr +++ b/src/test/ui/deprecation/suggestion.stderr @@ -1,17 +1,17 @@ error: use of deprecated function `bar::deprecated`: replaced by `replacement` - --> $DIR/suggestion.rs:41:10 + --> $DIR/suggestion.rs:42:10 | LL | bar::deprecated(); | ^^^^^^^^^^ help: replace the use of the deprecated function: `replacement` | note: the lint level is defined here - --> $DIR/suggestion.rs:7:9 + --> $DIR/suggestion.rs:8:9 | LL | #![deny(deprecated)] | ^^^^^^^^^^ error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement` - --> $DIR/suggestion.rs:39:9 + --> $DIR/suggestion.rs:40:9 | LL | foo.deprecated(); | ^^^^^^^^^^ help: replace the use of the deprecated associated function: `replacement` diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs deleted file mode 100644 index 3acfbd0ca23ae..0000000000000 --- a/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Testing gating of `#[rustc_deprecated]` in "weird" places. -// -// This file sits on its own because these signal errors, making -// this test incompatible with the "warnings only" nature of -// issue-43106-gating-of-builtin-attrs.rs - -#![rustc_deprecated()] -//~^ ERROR stability attributes may not be used outside of the standard library -//~| ERROR missing 'since' [E0542] - -#[rustc_deprecated()] -//~^ ERROR stability attributes may not be used outside of the standard library -//~| ERROR missing 'since' [E0542] -mod rustc_deprecated { - mod inner { - #![rustc_deprecated()] - //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR missing 'since' [E0542] - } - - #[rustc_deprecated()] - //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR missing 'since' [E0542] - fn f() {} - - #[rustc_deprecated()] - //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR missing 'since' [E0542] - //~| ERROR missing 'since' [E0542] - struct S; - - #[rustc_deprecated()] - //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR missing 'since' [E0542] - type T = S; - - #[rustc_deprecated()] - //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR missing 'since' [E0542] - impl S {} -} - -fn main() {} diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr deleted file mode 100644 index 4ec78f318c233..0000000000000 --- a/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr +++ /dev/null @@ -1,94 +0,0 @@ -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:9 - | -LL | #![rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:21:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:26:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:32:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:37:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:11:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1 - | -LL | #![rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1 - | -LL | #![rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:11:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:9 - | -LL | #![rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:21:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:26:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:26:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:32:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:37:5 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 15 previous errors - -Some errors have detailed explanations: E0542, E0734. -For more information about an error, try `rustc --explain E0542`. diff --git a/src/test/ui/issues/issue-17337.rs b/src/test/ui/issues/issue-17337.rs index 3fd81401e00fd..193f89f837897 100644 --- a/src/test/ui/issues/issue-17337.rs +++ b/src/test/ui/issues/issue-17337.rs @@ -7,7 +7,7 @@ struct Foo; impl Foo { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn foo(self) {} } diff --git a/src/test/ui/issues/issue-21596.stderr b/src/test/ui/issues/issue-21596.stderr index b0524f056ef7f..a336d1b0ed55d 100644 --- a/src/test/ui/issues/issue-21596.stderr +++ b/src/test/ui/issues/issue-21596.stderr @@ -1,8 +1,8 @@ -error[E0599]: the method `to_string` exists for raw pointer `*const u8`, but its trait bounds were not satisfied +error[E0599]: `*const u8` doesn't implement `std::fmt::Display` --> $DIR/issue-21596.rs:4:22 | LL | println!("{}", z.to_string()); - | ^^^^^^^^^ method cannot be called on `*const u8` due to unsatisfied trait bounds + | ^^^^^^^^^ `*const u8` cannot be formatted with the default formatter | = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior diff --git a/src/test/ui/lint/auxiliary/inherited_stability.rs b/src/test/ui/lint/auxiliary/inherited_stability.rs index 1e7eb26fde272..62100e5cc9496 100644 --- a/src/test/ui/lint/auxiliary/inherited_stability.rs +++ b/src/test/ui/lint/auxiliary/inherited_stability.rs @@ -20,7 +20,7 @@ pub mod stable_mod { #[unstable(feature = "unstable_test_feature", issue = "none")] pub mod unstable_mod { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} pub fn unstable() {} diff --git a/src/test/ui/lint/auxiliary/lint_output_format.rs b/src/test/ui/lint/auxiliary/lint_output_format.rs index 58cae180196d3..4e3547250e4c4 100644 --- a/src/test/ui/lint/auxiliary/lint_output_format.rs +++ b/src/test/ui/lint/auxiliary/lint_output_format.rs @@ -4,7 +4,7 @@ #![unstable(feature = "unstable_test_feature", issue = "none")] #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn foo() -> usize { 20 } diff --git a/src/test/ui/lint/auxiliary/lint_stability.rs b/src/test/ui/lint/auxiliary/lint_stability.rs index de4058887cffd..99c29dcdda677 100644 --- a/src/test/ui/lint/auxiliary/lint_stability.rs +++ b/src/test/ui/lint/auxiliary/lint_stability.rs @@ -5,21 +5,21 @@ #![stable(feature = "lint_stability", since = "1.0.0")] #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_text() {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "99.99.99", reason = "text")] +#[deprecated(since = "99.99.99", note = "text")] pub fn deprecated_future() {} #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_unstable() {} #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_unstable_text() {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -37,17 +37,17 @@ pub struct MethodTester; impl MethodTester { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated(&self) {} #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_unstable(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_unstable_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -64,17 +64,17 @@ impl MethodTester { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub trait Trait { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated(&self) {} #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_unstable(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_unstable_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -93,7 +93,7 @@ pub trait TraitWithAssociatedTypes { #[unstable(feature = "unstable_test_feature", issue = "none")] type TypeUnstable = u8; #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] type TypeDeprecated = u8; } @@ -104,18 +104,18 @@ impl Trait for MethodTester {} pub trait UnstableTrait { fn dummy(&self) { } } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub trait DeprecatedTrait { #[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { } } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize } #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize } @@ -133,10 +133,10 @@ pub enum UnstableEnum {} pub enum StableEnum {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableUnitStruct; @@ -146,10 +146,10 @@ pub struct StableUnitStruct; #[stable(feature = "stable_test_feature", since = "1.0.0")] pub enum Enum { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedUnstableVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] UnstableVariant, @@ -159,10 +159,10 @@ pub enum Enum { } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); diff --git a/src/test/ui/lint/auxiliary/lint_stability_fields.rs b/src/test/ui/lint/auxiliary/lint_stability_fields.rs index 3cbb48c4a6be0..e72a501e11b40 100644 --- a/src/test/ui/lint/auxiliary/lint_stability_fields.rs +++ b/src/test/ui/lint/auxiliary/lint_stability_fields.rs @@ -6,7 +6,7 @@ pub struct Stable { pub inherit: u8, #[unstable(feature = "unstable_test_feature", issue = "none")] pub override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] pub override2: u8, #[stable(feature = "rust2", since = "2.0.0")] @@ -17,7 +17,7 @@ pub struct Stable { pub struct Stable2(#[stable(feature = "rust2", since = "2.0.0")] pub u8, #[unstable(feature = "unstable_test_feature", issue = "none")] pub u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8, + #[deprecated(since = "1.0.0", note = "text")] pub u8, pub u8); #[stable(feature = "rust1", since = "1.0.0")] @@ -28,7 +28,7 @@ pub enum Stable3 { Override1, #[unstable(feature = "unstable_test_feature", issue = "none")] Override2, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] Override3, } @@ -38,7 +38,7 @@ pub struct Unstable { pub inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] pub override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] pub override2: u8, } @@ -47,10 +47,10 @@ pub struct Unstable { pub struct Unstable2(pub u8, #[stable(feature = "rust1", since = "1.0.0")] pub u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8); + #[deprecated(since = "1.0.0", note = "text")] pub u8); #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct Deprecated { pub inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] @@ -60,7 +60,7 @@ pub struct Deprecated { } #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct Deprecated2(pub u8, #[stable(feature = "rust1", since = "1.0.0")] pub u8, #[unstable(feature = "unstable_test_feature", issue = "none")] pub u8); diff --git a/src/test/ui/lint/lint-stability-2.rs b/src/test/ui/lint/lint-stability-2.rs index 2a4f95f555fd9..94a8d08c8fe9c 100644 --- a/src/test/ui/lint/lint-stability-2.rs +++ b/src/test/ui/lint/lint-stability-2.rs @@ -169,10 +169,10 @@ mod cross_crate { mod this_crate { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_text() {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -190,10 +190,10 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -209,10 +209,10 @@ mod this_crate { pub trait Trait { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -229,7 +229,7 @@ mod this_crate { impl Trait for MethodTester {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize } @@ -243,7 +243,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableUnitStruct; @@ -252,7 +252,7 @@ mod this_crate { pub enum Enum { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] UnstableVariant, @@ -262,7 +262,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedTupleStruct(isize); #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableTupleStruct(isize); @@ -382,7 +382,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_fn_body() { fn fn_in_body() {} fn_in_body(); @@ -390,7 +390,7 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_method_body(&self) { fn fn_in_body() {} fn_in_body(); @@ -398,7 +398,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub trait DeprecatedTrait { fn dummy(&self) { } } diff --git a/src/test/ui/lint/lint-stability-deprecated.rs b/src/test/ui/lint/lint-stability-deprecated.rs index 2f600971da113..bdc66e83083f6 100644 --- a/src/test/ui/lint/lint-stability-deprecated.rs +++ b/src/test/ui/lint/lint-stability-deprecated.rs @@ -219,10 +219,10 @@ mod inheritance { mod this_crate { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_text() {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -240,10 +240,10 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -259,10 +259,10 @@ mod this_crate { pub trait Trait { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -279,7 +279,7 @@ mod this_crate { impl Trait for MethodTester {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize } @@ -293,7 +293,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableUnitStruct; @@ -302,7 +302,7 @@ mod this_crate { pub enum Enum { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] UnstableVariant, @@ -312,7 +312,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedTupleStruct(isize); #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableTupleStruct(isize); @@ -433,7 +433,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_fn_body() { fn fn_in_body() {} fn_in_body(); //~ WARN use of deprecated function `this_crate::test_fn_body::fn_in_body`: text @@ -441,7 +441,7 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_method_body(&self) { fn fn_in_body() {} fn_in_body(); //~ WARN use of deprecated function `this_crate::MethodTester::test_method_body::fn_in_body`: text @@ -449,7 +449,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub trait DeprecatedTrait { fn dummy(&self) { } } diff --git a/src/test/ui/lint/lint-stability-fields-deprecated.rs b/src/test/ui/lint/lint-stability-fields-deprecated.rs index a44eb1ce10a22..a5511966d7e79 100644 --- a/src/test/ui/lint/lint-stability-fields-deprecated.rs +++ b/src/test/ui/lint/lint-stability-fields-deprecated.rs @@ -160,7 +160,7 @@ mod this_crate { inherit: u8, #[unstable(feature = "unstable_test_feature", issue = "none")] override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] override2: u8, } @@ -169,14 +169,14 @@ mod this_crate { struct Stable2(u8, #[stable(feature = "rust1", since = "1.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + #[deprecated(since = "1.0.0", note = "text")] u8); #[unstable(feature = "unstable_test_feature", issue = "none")] struct Unstable { inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] override2: u8, } @@ -185,10 +185,10 @@ mod this_crate { struct Unstable2(u8, #[stable(feature = "rust1", since = "1.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + #[deprecated(since = "1.0.0", note = "text")] u8); #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] struct Deprecated { inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] @@ -198,7 +198,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] struct Deprecated2(u8, #[stable(feature = "rust1", since = "1.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] u8); diff --git a/src/test/ui/lint/lint-stability-fields.rs b/src/test/ui/lint/lint-stability-fields.rs index 4083648984867..51990b6eef161 100644 --- a/src/test/ui/lint/lint-stability-fields.rs +++ b/src/test/ui/lint/lint-stability-fields.rs @@ -135,7 +135,7 @@ mod this_crate { inherit: u8, #[unstable(feature = "unstable_test_feature", issue = "none")] override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] override2: u8, #[stable(feature = "rust2", since = "2.0.0")] @@ -146,14 +146,14 @@ mod this_crate { struct Stable2(u8, #[stable(feature = "rust2", since = "2.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + #[deprecated(since = "1.0.0", note = "text")] u8); #[unstable(feature = "unstable_test_feature", issue = "none")] struct Unstable { inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "unstable_test_feature", issue = "none")] override2: u8, } @@ -162,10 +162,10 @@ mod this_crate { struct Unstable2(u8, #[stable(feature = "rust1", since = "1.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + #[deprecated(since = "1.0.0", note = "text")] u8); #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] struct Deprecated { inherit: u8, #[stable(feature = "rust1", since = "1.0.0")] @@ -175,7 +175,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] struct Deprecated2(u8, #[stable(feature = "rust1", since = "1.0.0")] u8, #[unstable(feature = "unstable_test_feature", issue = "none")] u8); diff --git a/src/test/ui/lint/lint-stability.rs b/src/test/ui/lint/lint-stability.rs index e5620a9f8e710..464b32c5f43ed 100644 --- a/src/test/ui/lint/lint-stability.rs +++ b/src/test/ui/lint/lint-stability.rs @@ -204,14 +204,14 @@ mod inheritance { mod this_crate { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_text() {} #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_deprecated(since = "99.99.99", reason = "text")] + #[deprecated(since = "99.99.99", note = "text")] pub fn deprecated_future() {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -229,10 +229,10 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -248,10 +248,10 @@ mod this_crate { pub trait Trait { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -268,7 +268,7 @@ mod this_crate { impl Trait for MethodTester {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize } @@ -282,7 +282,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableUnitStruct; @@ -291,7 +291,7 @@ mod this_crate { pub enum Enum { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] UnstableVariant, @@ -301,7 +301,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedTupleStruct(isize); #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableTupleStruct(isize); @@ -423,7 +423,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_fn_body() { fn fn_in_body() {} fn_in_body(); @@ -431,7 +431,7 @@ mod this_crate { impl MethodTester { #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn test_method_body(&self) { fn fn_in_body() {} fn_in_body(); @@ -439,7 +439,7 @@ mod this_crate { } #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub trait DeprecatedTrait { fn dummy(&self) { } } diff --git a/src/test/ui/macros/auxiliary/unstable-macros.rs b/src/test/ui/macros/auxiliary/unstable-macros.rs index 123e244a53eb4..3aadd4b0ca641 100644 --- a/src/test/ui/macros/auxiliary/unstable-macros.rs +++ b/src/test/ui/macros/auxiliary/unstable-macros.rs @@ -7,7 +7,7 @@ macro_rules! unstable_macro{ () => () } #[stable(feature = "deprecated_macros", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "deprecation reason")] +#[deprecated(since = "1.0.0", note = "deprecation note")] #[macro_export] macro_rules! deprecated_macro{ () => () } diff --git a/src/test/ui/macros/macro-stability.rs b/src/test/ui/macros/macro-stability.rs index 019f6a874cab3..ed7618a672be8 100644 --- a/src/test/ui/macros/macro-stability.rs +++ b/src/test/ui/macros/macro-stability.rs @@ -14,7 +14,7 @@ macro_rules! local_unstable { () => () } macro local_unstable_modern() {} #[stable(feature = "deprecated_macros", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "local deprecation reason")] +#[deprecated(since = "1.0.0", note = "local deprecation note")] #[macro_export] macro_rules! local_deprecated{ () => () } @@ -25,7 +25,7 @@ fn main() { // unstable_macro_modern!(); // ERROR use of unstable library feature 'unstable_macros' deprecated_macro!(); - //~^ WARN use of deprecated macro `deprecated_macro`: deprecation reason + //~^ WARN use of deprecated macro `deprecated_macro`: deprecation note local_deprecated!(); - //~^ WARN use of deprecated macro `local_deprecated`: local deprecation reason + //~^ WARN use of deprecated macro `local_deprecated`: local deprecation note } diff --git a/src/test/ui/macros/macro-stability.stderr b/src/test/ui/macros/macro-stability.stderr index 75da9f47a3573..2cfdb52b174a9 100644 --- a/src/test/ui/macros/macro-stability.stderr +++ b/src/test/ui/macros/macro-stability.stderr @@ -22,7 +22,7 @@ LL | unstable_macro!(); | = help: add `#![feature(unstable_macros)]` to the crate attributes to enable -warning: use of deprecated macro `deprecated_macro`: deprecation reason +warning: use of deprecated macro `deprecated_macro`: deprecation note --> $DIR/macro-stability.rs:27:5 | LL | deprecated_macro!(); @@ -30,7 +30,7 @@ LL | deprecated_macro!(); | = note: `#[warn(deprecated)]` on by default -warning: use of deprecated macro `local_deprecated`: local deprecation reason +warning: use of deprecated macro `local_deprecated`: local deprecation note --> $DIR/macro-stability.rs:29:5 | LL | local_deprecated!(); diff --git a/src/test/ui/methods/issues/issue-94581.rs b/src/test/ui/methods/issues/issue-94581.rs new file mode 100644 index 0000000000000..df393e91db084 --- /dev/null +++ b/src/test/ui/methods/issues/issue-94581.rs @@ -0,0 +1,7 @@ +fn get_slice() -> &'static [i32] { + &[1, 2, 3, 4] +} + +fn main() { + let sqsum = get_slice().map(|i| i * i).sum(); //~ ERROR [E0599] +} diff --git a/src/test/ui/methods/issues/issue-94581.stderr b/src/test/ui/methods/issues/issue-94581.stderr new file mode 100644 index 0000000000000..d6be29cf582c3 --- /dev/null +++ b/src/test/ui/methods/issues/issue-94581.stderr @@ -0,0 +1,15 @@ +error[E0599]: `&'static [i32]` is not an iterator + --> $DIR/issue-94581.rs:6:29 + | +LL | let sqsum = get_slice().map(|i| i * i).sum(); + | ^^^ `&'static [i32]` is not an iterator; try calling `.iter()` + | + = note: the following trait bounds were not satisfied: + `&'static [i32]: Iterator` + which is required by `&mut &'static [i32]: Iterator` + `[i32]: Iterator` + which is required by `&mut [i32]: Iterator` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/methods/method-call-err-msg.rs b/src/test/ui/methods/method-call-err-msg.rs index 86d00ca376026..d53ef445afc1b 100644 --- a/src/test/ui/methods/method-call-err-msg.rs +++ b/src/test/ui/methods/method-call-err-msg.rs @@ -16,7 +16,7 @@ fn main() { let y = Foo; y.zero() - .take() //~ ERROR the method + .take() //~ ERROR not an iterator .one(0); y.three::(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied } diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index c1183e053eb43..c410e076dde26 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -40,7 +40,7 @@ note: associated function defined here LL | fn two(self, _: isize, _: isize) -> Foo { self } | ^^^ ---- -------- -------- -error[E0599]: the method `take` exists for struct `Foo`, but its trait bounds were not satisfied +error[E0599]: `Foo` is not an iterator --> $DIR/method-call-err-msg.rs:19:7 | LL | pub struct Foo; @@ -50,7 +50,7 @@ LL | pub struct Foo; | doesn't satisfy `Foo: Iterator` ... LL | .take() - | ^^^^ method cannot be called on `Foo` due to unsatisfied trait bounds + | ^^^^ `Foo` is not an iterator | = note: the following trait bounds were not satisfied: `Foo: Iterator` diff --git a/src/test/ui/mismatched_types/cast-rfc0401.rs b/src/test/ui/mismatched_types/cast-rfc0401.rs index b8d12fb9809ce..57222f45947b4 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.rs +++ b/src/test/ui/mismatched_types/cast-rfc0401.rs @@ -48,7 +48,7 @@ fn main() let _ = E::A as *const u8; //~ ERROR is invalid let _ = 'a' as *const u8; //~ ERROR is invalid - let _ = 42usize as *const [u8]; //~ ERROR is invalid + let _ = 42usize as *const [u8]; //~ ERROR cannot cast `usize` to a pointer that is wide let _ = v as *const [u8]; //~ ERROR cannot cast let _ = fat_v as *const dyn Foo; //~ ERROR the size for values of type let _ = foo as *const str; //~ ERROR is invalid diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 6dbf24baf2315..5f11e4ded8004 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -148,11 +148,13 @@ error[E0606]: casting `char` as `*const u8` is invalid LL | let _ = 'a' as *const u8; | ^^^^^^^^^^^^^^^^ -error[E0606]: casting `usize` as `*const [u8]` is invalid - --> $DIR/cast-rfc0401.rs:51:13 +error[E0606]: cannot cast `usize` to a pointer that is wide + --> $DIR/cast-rfc0401.rs:51:24 | LL | let _ = 42usize as *const [u8]; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ------- ^^^^^^^^^^^ creating a `*const [u8]` requires both an address and a length + | | + | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]` --> $DIR/cast-rfc0401.rs:52:13 diff --git a/src/test/ui/mismatched_types/issue-36053-2.rs b/src/test/ui/mismatched_types/issue-36053-2.rs index 17d2292baaf68..0252ba2eb0460 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.rs +++ b/src/test/ui/mismatched_types/issue-36053-2.rs @@ -5,6 +5,6 @@ use std::iter::once; fn main() { once::<&str>("str").fuse().filter(|a: &str| true).count(); - //~^ ERROR the method + //~^ ERROR not an iterator //~| ERROR type mismatch in closure arguments } diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index a8bcdf5efe91e..b1010171eb235 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -12,11 +12,11 @@ note: required by a bound in `filter` LL | P: FnMut(&Self::Item) -> bool, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `filter` -error[E0599]: the method `count` exists for struct `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>`, but its trait bounds were not satisfied +error[E0599]: `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` is not an iterator --> $DIR/issue-36053-2.rs:7:55 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); - | -------------- ^^^^^ method cannot be called on `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` due to unsatisfied trait bounds + | -------------- ^^^^^ `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` is not an iterator | | | doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool` | doesn't satisfy `_: FnMut<(&&str,)>` diff --git a/src/test/ui/stability-attribute/auxiliary/lint-stability.rs b/src/test/ui/stability-attribute/auxiliary/lint-stability.rs index de4058887cffd..99c29dcdda677 100644 --- a/src/test/ui/stability-attribute/auxiliary/lint-stability.rs +++ b/src/test/ui/stability-attribute/auxiliary/lint-stability.rs @@ -5,21 +5,21 @@ #![stable(feature = "lint_stability", since = "1.0.0")] #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated() {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_text() {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "99.99.99", reason = "text")] +#[deprecated(since = "99.99.99", note = "text")] pub fn deprecated_future() {} #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_unstable() {} #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub fn deprecated_unstable_text() {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -37,17 +37,17 @@ pub struct MethodTester; impl MethodTester { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated(&self) {} #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_unstable(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] pub fn method_deprecated_unstable_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -64,17 +64,17 @@ impl MethodTester { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub trait Trait { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated(&self) {} #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_unstable(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] fn trait_deprecated_unstable_text(&self) {} #[unstable(feature = "unstable_test_feature", issue = "none")] @@ -93,7 +93,7 @@ pub trait TraitWithAssociatedTypes { #[unstable(feature = "unstable_test_feature", issue = "none")] type TypeUnstable = u8; #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] type TypeDeprecated = u8; } @@ -104,18 +104,18 @@ impl Trait for MethodTester {} pub trait UnstableTrait { fn dummy(&self) { } } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub trait DeprecatedTrait { #[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { } } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize } #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableStruct { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize } @@ -133,10 +133,10 @@ pub enum UnstableEnum {} pub enum StableEnum {} #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableUnitStruct; #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableUnitStruct; @@ -146,10 +146,10 @@ pub struct StableUnitStruct; #[stable(feature = "stable_test_feature", since = "1.0.0")] pub enum Enum { #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[deprecated(since = "1.0.0", note = "text")] DeprecatedUnstableVariant, #[unstable(feature = "unstable_test_feature", issue = "none")] UnstableVariant, @@ -159,10 +159,10 @@ pub enum Enum { } #[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); #[unstable(feature = "unstable_test_feature", issue = "none")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] +#[deprecated(since = "1.0.0", note = "text")] pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); #[unstable(feature = "unstable_test_feature", issue = "none")] pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); diff --git a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs index 231ab966558f9..1d6a6bd4e13fc 100644 --- a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs +++ b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs @@ -40,14 +40,14 @@ pub struct Struct3 { #[stable(feature = "stable_test_feature", since = "1.0.0")] pub field: A, } -#[rustc_deprecated(since = "1.1.0", reason = "test")] +#[deprecated(since = "1.1.0", note = "test")] #[stable(feature = "stable_test_feature", since = "1.0.0")] pub struct Struct5<#[unstable(feature = "unstable_default", issue = "none")] A = usize> { #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -99,7 +99,7 @@ pub enum Enum3 { #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -108,7 +108,7 @@ pub enum Enum4 { None, } -#[rustc_deprecated(since = "1.1.0", reason = "test")] +#[deprecated(since = "1.1.0", note = "test")] #[stable(feature = "stable_test_feature", since = "1.0.0")] pub enum Enum5<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -152,11 +152,11 @@ pub type Alias2 = Option; pub type Alias3 = Result; -#[rustc_deprecated(since = "1.1.0", reason = "test")] +#[deprecated(since = "1.1.0", note = "test")] #[stable(feature = "stable_test_feature", since = "1.0.0")] pub type Alias4 = Option; -#[rustc_deprecated(since = "1.1.0", reason = "test")] +#[deprecated(since = "1.1.0", note = "test")] #[stable(feature = "stable_test_feature", since = "1.0.0")] pub type Alias5<#[unstable(feature = "unstable_default", issue = "none")] T = usize> = Option; diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs index 1627d1d3f9f19..f61acc8aac5db 100644 --- a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs +++ b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs @@ -2,6 +2,4 @@ #[unstable()] //~ ERROR: stability attributes may not be used #[stable()] //~ ERROR: stability attributes may not be used -#[rustc_deprecated()] //~ ERROR: stability attributes may not be used -//~^ ERROR missing 'since' fn main() {} diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr index a2b2d3cbe5951..45d965ea0a069 100644 --- a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr @@ -10,19 +10,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra LL | #[stable()] | ^^^^^^^^^^^ -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0542, E0734. -For more information about an error, try `rustc --explain E0542`. +For more information about this error, try `rustc --explain E0734`. diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged.rs b/src/test/ui/stability-attribute/stability-attribute-non-staged.rs index dfbd9ea5ebf2e..4015f2f971e69 100644 --- a/src/test/ui/stability-attribute/stability-attribute-non-staged.rs +++ b/src/test/ui/stability-attribute/stability-attribute-non-staged.rs @@ -1,5 +1,3 @@ #[unstable()] //~ ERROR: stability attributes may not be used #[stable()] //~ ERROR: stability attributes may not be used -#[rustc_deprecated()] //~ ERROR: stability attributes may not be used -//~^ ERROR missing 'since' fn main() {} diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr b/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr index 9af8d1df4ea04..391f3c2744d3c 100644 --- a/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr @@ -10,19 +10,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra LL | #[stable()] | ^^^^^^^^^^^ -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/stability-attribute-non-staged.rs:3:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0542]: missing 'since' - --> $DIR/stability-attribute-non-staged.rs:3:1 - | -LL | #[rustc_deprecated()] - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0542, E0734. -For more information about an error, try `rustc --explain E0542`. +For more information about this error, try `rustc --explain E0734`. diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity-4.rs b/src/test/ui/stability-attribute/stability-attribute-sanity-4.rs index b85f9342045a0..64f996352196a 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity-4.rs +++ b/src/test/ui/stability-attribute/stability-attribute-sanity-4.rs @@ -18,13 +18,11 @@ mod bogus_attribute_types_2 { fn f4() { } #[stable(feature = "a", since = "b")] - #[rustc_deprecated] //~ ERROR malformed `rustc_deprecated` attribute - //~^ ERROR missing 'since' + #[deprecated] //~ ERROR missing 'since' fn f5() { } #[stable(feature = "a", since = "b")] - #[rustc_deprecated = "a"] //~ ERROR malformed `rustc_deprecated` attribute - //~^ ERROR missing 'since' + #[deprecated = "a"] //~ ERROR missing 'since' fn f6() { } } diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity-4.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity-4.stderr index 651f293ff519e..a76f5be1e3d7c 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity-4.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity-4.stderr @@ -22,30 +22,18 @@ error: malformed `stable` attribute input LL | #[stable = "a"] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[stable(feature = "name", since = "version")]` -error: malformed `rustc_deprecated` attribute input - --> $DIR/stability-attribute-sanity-4.rs:21:5 - | -LL | #[rustc_deprecated] - | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_deprecated(since = "version", reason = "...")]` - -error: malformed `rustc_deprecated` attribute input - --> $DIR/stability-attribute-sanity-4.rs:26:5 - | -LL | #[rustc_deprecated = "a"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_deprecated(since = "version", reason = "...")]` - error[E0542]: missing 'since' --> $DIR/stability-attribute-sanity-4.rs:21:5 | -LL | #[rustc_deprecated] - | ^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated] + | ^^^^^^^^^^^^^ error[E0542]: missing 'since' - --> $DIR/stability-attribute-sanity-4.rs:26:5 + --> $DIR/stability-attribute-sanity-4.rs:25:5 | -LL | #[rustc_deprecated = "a"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated = "a"] + | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0542`. diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.rs b/src/test/ui/stability-attribute/stability-attribute-sanity.rs index fe8079dbc3701..f37a8f328a75a 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.rs +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.rs @@ -37,11 +37,11 @@ mod missing_version { fn f1() { } #[stable(feature = "a", since = "b")] - #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542] + #[deprecated(note = "a")] //~ ERROR missing 'since' [E0542] fn f2() { } #[stable(feature = "a", since = "b")] - #[rustc_deprecated(since = "a")] //~ ERROR missing 'reason' [E0543] + #[deprecated(since = "a")] //~ ERROR missing 'note' [E0543] fn f3() { } } @@ -58,19 +58,19 @@ fn multiple2() { } fn multiple3() { } #[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found -#[rustc_deprecated(since = "b", reason = "text")] -#[rustc_deprecated(since = "b", reason = "text")] //~ ERROR multiple deprecated attributes +#[deprecated(since = "b", note = "text")] +#[deprecated(since = "b", note = "text")] //~ ERROR multiple deprecated attributes #[rustc_const_unstable(feature = "c", issue = "none")] #[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels pub const fn multiple4() { } #[stable(feature = "a", since = "1.0.0")] //~ ERROR invalid deprecation version found //~^ ERROR feature `a` is declared stable since 1.0.0 -#[rustc_deprecated(since = "invalid", reason = "text")] +#[deprecated(since = "invalid", note = "text")] fn invalid_deprecation_version() {} -#[rustc_deprecated(since = "a", reason = "text")] +#[deprecated(since = "a", note = "text")] fn deprecated_without_unstable_or_stable() { } -//~^^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute +//~^^ ERROR deprecated attribute must be paired with either stable or unstable attribute fn main() { } diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index b4e8fc7881549..9e2d9f2708489 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -55,14 +55,14 @@ LL | #[stable(feature = "a")] error[E0542]: missing 'since' --> $DIR/stability-attribute-sanity.rs:40:5 | -LL | #[rustc_deprecated(reason = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(note = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0543]: missing 'reason' +error[E0543]: missing 'note' --> $DIR/stability-attribute-sanity.rs:44:5 | -LL | #[rustc_deprecated(since = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:49:1 @@ -85,10 +85,10 @@ LL | #[stable(feature = "a", since = "b")] error[E0550]: multiple deprecated attributes --> $DIR/stability-attribute-sanity.rs:62:1 | -LL | #[rustc_deprecated(since = "b", reason = "text")] - | ------------------------------------------------- first deprecation attribute -LL | #[rustc_deprecated(since = "b", reason = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute +LL | #[deprecated(since = "b", note = "text")] + | ----------------------------------------- first deprecation attribute +LL | #[deprecated(since = "b", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:64:1 @@ -114,11 +114,11 @@ LL | #[stable(feature = "a", since = "1.0.0")] LL | fn invalid_deprecation_version() {} | ----------------------------------- the stability attribute annotates this item -error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute +error[E0549]: deprecated attribute must be paired with either stable or unstable attribute --> $DIR/stability-attribute-sanity.rs:72:1 | -LL | #[rustc_deprecated(since = "a", reason = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "a", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0711]: feature `a` is declared stable since 1.0.0, but was previously declared stable since b --> $DIR/stability-attribute-sanity.rs:67:1 diff --git a/src/test/ui/str/str-idx.stderr b/src/test/ui/str/str-idx.stderr index 9c3c3646139dc..9ab409bbdcdf8 100644 --- a/src/test/ui/str/str-idx.stderr +++ b/src/test/ui/str/str-idx.stderr @@ -23,8 +23,8 @@ LL | let _ = s.get(4); note: required by a bound in `core::str::::get` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | -LL | pub fn get>(&self, i: I) -> Option<&I::Output> { - | ^^^^^^^^^^^^^^^ required by this bound in `core::str::::get` +LL | pub const fn get>(&self, i: I) -> Option<&I::Output> { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::::get` error[E0277]: the type `str` cannot be indexed by `{integer}` --> $DIR/str-idx.rs:5:29 @@ -40,8 +40,8 @@ LL | let _ = s.get_unchecked(4); note: required by a bound in `core::str::::get_unchecked` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | -LL | pub unsafe fn get_unchecked>(&self, i: I) -> &I::Output { - | ^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_unchecked` +LL | pub const unsafe fn get_unchecked>(&self, i: I) -> &I::Output { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_unchecked` error[E0277]: the type `str` cannot be indexed by `char` --> $DIR/str-idx.rs:6:17 diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index 2559ee9eb49b2..5956e363b0c09 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -47,8 +47,8 @@ LL | s.get_mut(1); note: required by a bound in `core::str::::get_mut` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | -LL | pub fn get_mut>(&mut self, i: I) -> Option<&mut I::Output> { - | ^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_mut` +LL | pub const fn get_mut>(&mut self, i: I) -> Option<&mut I::Output> { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_mut` error[E0277]: the type `str` cannot be indexed by `{integer}` --> $DIR/str-mut-idx.rs:11:25 @@ -64,8 +64,8 @@ LL | s.get_unchecked_mut(1); note: required by a bound in `core::str::::get_unchecked_mut` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | -LL | pub unsafe fn get_unchecked_mut>(&mut self, i: I) -> &mut I::Output { - | ^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_unchecked_mut` +LL | pub const unsafe fn get_unchecked_mut>( + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::str::::get_unchecked_mut` error[E0277]: the type `str` cannot be indexed by `char` --> $DIR/str-mut-idx.rs:13:5 diff --git a/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.rs b/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.rs new file mode 100644 index 0000000000000..56aed77c10e68 --- /dev/null +++ b/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.rs @@ -0,0 +1,30 @@ +struct Wrapper(T); + +fn foo(foo: Wrapper) +//~^ ERROR the size for values of type `T` cannot be known at compilation time +where + T + : + ? + Sized +{ + // +} + +fn bar(foo: Wrapper) +//~^ ERROR the size for values of type `T` cannot be known at compilation time +where T: ?Sized +{ + // +} + +fn qux(foo: Wrapper) +//~^ ERROR the size for values of type `T` cannot be known at compilation time +where + T: ?Sized +{ + // +} + + +fn main() {} diff --git a/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr b/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr new file mode 100644 index 0000000000000..3df17056ef42c --- /dev/null +++ b/src/test/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr @@ -0,0 +1,83 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:3:16 + | +LL | fn foo(foo: Wrapper) + | - ^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +note: required by a bound in `Wrapper` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ required by this bound in `Wrapper` +help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ - ...if indirection were used here: `Box` + | | + | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - where +LL - T +LL - : +LL - ? +LL - Sized + | + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:14:16 + | +LL | fn bar(foo: Wrapper) + | - ^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +note: required by a bound in `Wrapper` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ required by this bound in `Wrapper` +help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ - ...if indirection were used here: `Box` + | | + | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - where T: ?Sized + | + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:21:16 + | +LL | fn qux(foo: Wrapper) + | - ^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +note: required by a bound in `Wrapper` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ required by this bound in `Wrapper` +help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box` + --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 + | +LL | struct Wrapper(T); + | ^ - ...if indirection were used here: `Box` + | | + | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - where +LL - T: ?Sized + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`.