diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index f6679ae9bb352..d58d05095cdcb 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -58,16 +58,29 @@ macro_rules! into_diagnostic_arg_using_display { } } +macro_rules! into_diagnostic_arg_for_number { + ($( $ty:ty ),+ $(,)?) => { + $( + impl IntoDiagnosticArg for $ty { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + // HACK: `FluentNumber` the underline backing struct represent + // numbers using a f64 which can't represent all the i128 numbers + // So in order to be able to use fluent selectors and still + // have all the numbers representable we only convert numbers + // below a certain threshold. + if let Ok(n) = TryInto::::try_into(self) && n >= -100 && n <= 100 { + DiagnosticArgValue::Number(n) + } else { + self.to_string().into_diagnostic_arg() + } + } + } + )+ + } +} + into_diagnostic_arg_using_display!( ast::ParamKindOrd, - i8, - u8, - i16, - u16, - u32, - i64, - i128, - u128, std::io::Error, Box, std::num::NonZeroU32, @@ -82,17 +95,7 @@ into_diagnostic_arg_using_display!( ExitStatus, ); -impl IntoDiagnosticArg for i32 { - fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { - DiagnosticArgValue::Number(self.into()) - } -} - -impl IntoDiagnosticArg for u64 { - fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { - DiagnosticArgValue::Number(self.into()) - } -} +into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize); impl IntoDiagnosticArg for bool { fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { @@ -154,12 +157,6 @@ impl IntoDiagnosticArg for PathBuf { } } -impl IntoDiagnosticArg for usize { - fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { - DiagnosticArgValue::Number(self as i128) - } -} - impl IntoDiagnosticArg for PanicStrategy { fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string())) diff --git a/compiler/rustc_hir_analysis/src/astconv/lint.rs b/compiler/rustc_hir_analysis/src/astconv/lint.rs index 33e782abc68ed..553c8a698619c 100644 --- a/compiler/rustc_hir_analysis/src/astconv/lint.rs +++ b/compiler/rustc_hir_analysis/src/astconv/lint.rs @@ -132,7 +132,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ], Applicability::MachineApplicable, ); - } else if diag.is_error() && is_downgradable { + } else if is_downgradable { // We'll emit the object safety error already, with a structured suggestion. diag.downgrade_to_delayed_bug(); } @@ -158,7 +158,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } if !is_object_safe { diag.note(format!("`{trait_name}` it is not object safe, so it can't be `dyn`")); - if diag.is_error() && is_downgradable { + if is_downgradable { // We'll emit the object safety error already, with a structured suggestion. diag.downgrade_to_delayed_bug(); } @@ -241,13 +241,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } else { let msg = "trait objects without an explicit `dyn` are deprecated"; tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| { - if self_ty.span.can_be_used_for_suggestions() - && !self.maybe_lint_impl_trait(self_ty, lint) - { + if self_ty.span.can_be_used_for_suggestions() { lint.multipart_suggestion_verbose( "use `dyn`", sugg, - Applicability::MachineApplicable, + Applicability::MaybeIncorrect, ); } self.maybe_lint_blanket_trait_impl(self_ty, lint); diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 0b8a25eedafad..47f6e3f934eca 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1601,23 +1601,33 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.ty_to_value_string(rcvr_ty.peel_refs()) }; if let SelfSource::MethodCall(_) = source { - let first_arg = if let Some(CandidateSource::Impl(impl_did)) = static_candidates.get(0) - && let Some(assoc) = self.associated_value(*impl_did, item_name) - && assoc.kind == ty::AssocKind::Fn - { + let first_arg = static_candidates.get(0).and_then(|candidate_source| { + let (assoc_did, self_ty) = match candidate_source { + CandidateSource::Impl(impl_did) => { + (*impl_did, self.tcx.type_of(*impl_did).instantiate_identity()) + } + CandidateSource::Trait(trait_did) => (*trait_did, rcvr_ty), + }; + + let assoc = self.associated_value(assoc_did, item_name)?; + if assoc.kind != ty::AssocKind::Fn { + return None; + } + + // for CandidateSource::Impl, `Self` will be instantiated to a concrete type + // but for CandidateSource::Trait, `Self` is still `Self` let sig = self.tcx.fn_sig(assoc.def_id).instantiate_identity(); sig.inputs().skip_binder().get(0).and_then(|first| { - let impl_ty = self.tcx.type_of(*impl_did).instantiate_identity(); // if the type of first arg is the same as the current impl type, we should take the first arg into assoc function - if first.peel_refs() == impl_ty { + let first_ty = first.peel_refs(); + if first_ty == self_ty || first_ty == self.tcx.types.self_param { Some(first.ref_mutability().map_or("", |mutbl| mutbl.ref_prefix_str())) } else { None } }) - } else { - None - }; + }); + let mut applicability = Applicability::MachineApplicable; let args = if let SelfSource::MethodCall(receiver) = source && let Some(args) = args diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index 5d6a7f75df843..b9914f6cb7a00 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -221,9 +221,6 @@ pub struct ScopeTree { /// variable is declared. var_map: FxIndexMap, - /// Maps from a `NodeId` to the associated destruction scope (if any). - destruction_scopes: FxIndexMap, - /// Identifies expressions which, if captured into a temporary, ought to /// have a temporary whose lifetime extends to the end of the enclosing *block*, /// and not the enclosing *statement*. Expressions that are not present in this @@ -336,11 +333,6 @@ impl ScopeTree { let prev = self.parent_map.insert(child, p); assert!(prev.is_none()); } - - // Record the destruction scopes for later so we can query them. - if let ScopeData::Destruction = child.data { - self.destruction_scopes.insert(child.item_local_id(), child); - } } pub fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: Scope) { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index dd9157564db37..7a24b819b5f56 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -791,13 +791,28 @@ impl<'a> Parser<'a> { && let [segment] = &attr_kind.item.path.segments[..] && segment.ident.name == sym::cfg && let Some(args_span) = attr_kind.item.args.span() - && let Ok(next_attr) = snapshot.parse_attribute(InnerAttrPolicy::Forbidden(None)) + && let next_attr = match snapshot.parse_attribute(InnerAttrPolicy::Forbidden(None)) + { + Ok(next_attr) => next_attr, + Err(inner_err) => { + err.cancel(); + inner_err.cancel(); + return; + } + } && let ast::AttrKind::Normal(next_attr_kind) = next_attr.kind && let Some(next_attr_args_span) = next_attr_kind.item.args.span() && let [next_segment] = &next_attr_kind.item.path.segments[..] && segment.ident.name == sym::cfg - && let Ok(next_expr) = snapshot.parse_expr() { + let next_expr = match snapshot.parse_expr() { + Ok(next_expr) => next_expr, + Err(inner_err) => { + err.cancel(); + inner_err.cancel(); + return; + } + }; // We have for sure // #[cfg(..)] // expr diff --git a/library/core/src/iter/adapters/intersperse.rs b/library/core/src/iter/adapters/intersperse.rs index d8bbd424cf258..c97a59b614f9d 100644 --- a/library/core/src/iter/adapters/intersperse.rs +++ b/library/core/src/iter/adapters/intersperse.rs @@ -1,4 +1,5 @@ -use super::Peekable; +use crate::fmt; +use crate::iter::{Fuse, FusedIterator}; /// An iterator adapter that places a separator between all elements. /// @@ -10,9 +11,18 @@ pub struct Intersperse where I::Item: Clone, { + started: bool, separator: I::Item, - iter: Peekable, - needs_sep: bool, + next_item: Option, + iter: Fuse, +} + +#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] +impl FusedIterator for Intersperse +where + I: FusedIterator, + I::Item: Clone, +{ } impl Intersperse @@ -20,7 +30,7 @@ where I::Item: Clone, { pub(in crate::iter) fn new(iter: I, separator: I::Item) -> Self { - Self { iter: iter.peekable(), separator, needs_sep: false } + Self { started: false, separator, next_item: None, iter: iter.fuse() } } } @@ -33,27 +43,43 @@ where type Item = I::Item; #[inline] - fn next(&mut self) -> Option { - if self.needs_sep && self.iter.peek().is_some() { - self.needs_sep = false; - Some(self.separator.clone()) + fn next(&mut self) -> Option { + if self.started { + if let Some(v) = self.next_item.take() { + Some(v) + } else { + let next_item = self.iter.next(); + if next_item.is_some() { + self.next_item = next_item; + Some(self.separator.clone()) + } else { + None + } + } } else { - self.needs_sep = true; + self.started = true; self.iter.next() } } + fn size_hint(&self) -> (usize, Option) { + intersperse_size_hint(&self.iter, self.started, self.next_item.is_some()) + } + fn fold(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B, { let separator = self.separator; - intersperse_fold(self.iter, init, f, move || separator.clone(), self.needs_sep) - } - - fn size_hint(&self) -> (usize, Option) { - intersperse_size_hint(&self.iter, self.needs_sep) + intersperse_fold( + self.iter, + init, + f, + move || separator.clone(), + self.started, + self.next_item, + ) } } @@ -66,39 +92,50 @@ pub struct IntersperseWith where I: Iterator, { + started: bool, separator: G, - iter: Peekable, - needs_sep: bool, + next_item: Option, + iter: Fuse, +} + +#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] +impl FusedIterator for IntersperseWith +where + I: FusedIterator, + G: FnMut() -> I::Item, +{ } #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] -impl crate::fmt::Debug for IntersperseWith +impl fmt::Debug for IntersperseWith where - I: Iterator + crate::fmt::Debug, - I::Item: crate::fmt::Debug, - G: crate::fmt::Debug, + I: Iterator + fmt::Debug, + I::Item: fmt::Debug, + G: fmt::Debug, { - fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("IntersperseWith") + .field("started", &self.started) .field("separator", &self.separator) .field("iter", &self.iter) - .field("needs_sep", &self.needs_sep) + .field("next_item", &self.next_item) .finish() } } #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] -impl crate::clone::Clone for IntersperseWith +impl Clone for IntersperseWith where - I: Iterator + crate::clone::Clone, - I::Item: crate::clone::Clone, + I: Iterator + Clone, + I::Item: Clone, G: Clone, { fn clone(&self) -> Self { - IntersperseWith { + Self { + started: self.started, separator: self.separator.clone(), iter: self.iter.clone(), - needs_sep: self.needs_sep.clone(), + next_item: self.next_item.clone(), } } } @@ -109,7 +146,7 @@ where G: FnMut() -> I::Item, { pub(in crate::iter) fn new(iter: I, separator: G) -> Self { - Self { iter: iter.peekable(), separator, needs_sep: false } + Self { started: false, separator, next_item: None, iter: iter.fuse() } } } @@ -122,38 +159,52 @@ where type Item = I::Item; #[inline] - fn next(&mut self) -> Option { - if self.needs_sep && self.iter.peek().is_some() { - self.needs_sep = false; - Some((self.separator)()) + fn next(&mut self) -> Option { + if self.started { + if let Some(v) = self.next_item.take() { + Some(v) + } else { + let next_item = self.iter.next(); + if next_item.is_some() { + self.next_item = next_item; + Some((self.separator)()) + } else { + None + } + } } else { - self.needs_sep = true; + self.started = true; self.iter.next() } } + fn size_hint(&self) -> (usize, Option) { + intersperse_size_hint(&self.iter, self.started, self.next_item.is_some()) + } + fn fold(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B, { - intersperse_fold(self.iter, init, f, self.separator, self.needs_sep) - } - - fn size_hint(&self) -> (usize, Option) { - intersperse_size_hint(&self.iter, self.needs_sep) + intersperse_fold(self.iter, init, f, self.separator, self.started, self.next_item) } } -fn intersperse_size_hint(iter: &I, needs_sep: bool) -> (usize, Option) +fn intersperse_size_hint(iter: &I, started: bool, next_is_some: bool) -> (usize, Option) where I: Iterator, { let (lo, hi) = iter.size_hint(); - let next_is_elem = !needs_sep; ( - lo.saturating_sub(next_is_elem as usize).saturating_add(lo), - hi.and_then(|hi| hi.saturating_sub(next_is_elem as usize).checked_add(hi)), + lo.saturating_sub(!started as usize) + .saturating_add(next_is_some as usize) + .saturating_add(lo), + hi.and_then(|hi| { + hi.saturating_sub(!started as usize) + .saturating_add(next_is_some as usize) + .checked_add(hi) + }), ) } @@ -162,7 +213,8 @@ fn intersperse_fold( init: B, mut f: F, mut separator: G, - needs_sep: bool, + started: bool, + mut next_item: Option, ) -> B where I: Iterator, @@ -171,12 +223,9 @@ where { let mut accum = init; - if !needs_sep { - if let Some(x) = iter.next() { - accum = f(accum, x); - } else { - return accum; - } + let first = if started { next_item.take() } else { iter.next() }; + if let Some(x) = first { + accum = f(accum, x); } iter.fold(accum, |mut accum, x| { diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index 408002d18cadb..959c3289affbf 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -1893,7 +1893,6 @@ impl Ipv6Addr { /// # Examples /// /// ``` - /// #![feature(ip)] /// use std::net::Ipv6Addr; /// /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false); diff --git a/tests/codegen/pow_of_two.rs b/tests/codegen/pow_of_two.rs index a8c0550e33263..372360dfd12c7 100644 --- a/tests/codegen/pow_of_two.rs +++ b/tests/codegen/pow_of_two.rs @@ -4,7 +4,7 @@ #[no_mangle] pub fn a(exp: u32) -> u64 { // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64 - // CHECK: %{{[^ ]+}} = zext i32 %exp to i64 + // CHECK: %{{[^ ]+}} = zext{{( nneg)?}} i32 %exp to i64 // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}} // CHECK: ret i64 %{{[^ ]+}} 2u64.pow(exp) @@ -14,7 +14,7 @@ pub fn a(exp: u32) -> u64 { #[no_mangle] pub fn b(exp: u32) -> i64 { // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64 - // CHECK: %{{[^ ]+}} = zext i32 %exp to i64 + // CHECK: %{{[^ ]+}} = zext{{( nneg)?}} i32 %exp to i64 // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}} // CHECK: ret i64 %{{[^ ]+}} 2i64.pow(exp) diff --git a/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr b/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr new file mode 100644 index 0000000000000..7aec3a73fe964 --- /dev/null +++ b/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Copy` cannot be made into an object + --> $DIR/avoid-ice-on-warning-2.rs:4:13 + | +LL | fn id(f: Copy) -> usize { + | ^^^^ `Copy` cannot be made into an object + | + = note: the trait cannot be made into an object because it requires `Self: Sized` + = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/object-safety/avoid-ice-on-warning-2.stderr b/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr similarity index 60% rename from tests/ui/object-safety/avoid-ice-on-warning-2.stderr rename to tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr index 2755eee6f3529..41c09b7df6289 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-2.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr @@ -1,43 +1,33 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-2.rs:1:13 + --> $DIR/avoid-ice-on-warning-2.rs:4:13 | LL | fn id(f: Copy) -> usize { | ^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `Copy` it is not object safe, so it can't be `dyn` = note: `#[warn(bare_trait_objects)]` on by default -help: use a new generic type parameter, constrained by `Copy` +help: use `dyn` | -LL | fn id(f: T) -> usize { - | +++++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference - | -LL | fn id(f: impl Copy) -> usize { - | ++++ +LL | fn id(f: dyn Copy) -> usize { + | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-2.rs:1:13 + --> $DIR/avoid-ice-on-warning-2.rs:4:13 | LL | fn id(f: Copy) -> usize { | ^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `Copy` it is not object safe, so it can't be `dyn` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use a new generic type parameter, constrained by `Copy` - | -LL | fn id(f: T) -> usize { - | +++++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference +help: use `dyn` | -LL | fn id(f: impl Copy) -> usize { - | ++++ +LL | fn id(f: dyn Copy) -> usize { + | +++ error[E0038]: the trait `Copy` cannot be made into an object - --> $DIR/avoid-ice-on-warning-2.rs:1:13 + --> $DIR/avoid-ice-on-warning-2.rs:4:13 | LL | fn id(f: Copy) -> usize { | ^^^^ `Copy` cannot be made into an object diff --git a/tests/ui/object-safety/avoid-ice-on-warning-2.rs b/tests/ui/object-safety/avoid-ice-on-warning-2.rs index cd34362d3dd52..9a6a4378fa383 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-2.rs +++ b/tests/ui/object-safety/avoid-ice-on-warning-2.rs @@ -1,9 +1,12 @@ +// revisions: old new +//[old] edition:2015 +//[new] edition:2021 fn id(f: Copy) -> usize { -//~^ WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! -//~| ERROR the trait `Copy` cannot be made into an object +//~^ ERROR the trait `Copy` cannot be made into an object +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! f() } fn main() {} diff --git a/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr b/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr new file mode 100644 index 0000000000000..fd92d43ef9a24 --- /dev/null +++ b/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr @@ -0,0 +1,47 @@ +error[E0038]: the trait `A` cannot be made into an object + --> $DIR/avoid-ice-on-warning-3.rs:4:19 + | +LL | trait B { fn f(a: A) -> A; } + | ^ `A` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/avoid-ice-on-warning-3.rs:12:14 + | +LL | trait A { fn g(b: B) -> B; } + | - ^ ...because associated function `g` has no `self` parameter + | | + | this trait cannot be made into an object... +help: consider turning `g` into a method by giving it a `&self` argument + | +LL | trait A { fn g(&self, b: B) -> B; } + | ++++++ +help: alternatively, consider constraining `g` so it does not apply to trait objects + | +LL | trait A { fn g(b: B) -> B where Self: Sized; } + | +++++++++++++++++ + +error[E0038]: the trait `B` cannot be made into an object + --> $DIR/avoid-ice-on-warning-3.rs:12:19 + | +LL | trait A { fn g(b: B) -> B; } + | ^ `B` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/avoid-ice-on-warning-3.rs:4:14 + | +LL | trait B { fn f(a: A) -> A; } + | - ^ ...because associated function `f` has no `self` parameter + | | + | this trait cannot be made into an object... +help: consider turning `f` into a method by giving it a `&self` argument + | +LL | trait B { fn f(&self, a: A) -> A; } + | ++++++ +help: alternatively, consider constraining `f` so it does not apply to trait objects + | +LL | trait B { fn f(a: A) -> A where Self: Sized; } + | +++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/object-safety/avoid-ice-on-warning-3.stderr b/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr similarity index 63% rename from tests/ui/object-safety/avoid-ice-on-warning-3.stderr rename to tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr index 0fc67770b96dd..a36e2519c804d 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-3.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr @@ -1,93 +1,78 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:9:19 + --> $DIR/avoid-ice-on-warning-3.rs:4:19 | -LL | trait A { fn g(b: B) -> B; } +LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `B` it is not object safe, so it can't be `dyn` = note: `#[warn(bare_trait_objects)]` on by default -help: use a new generic type parameter, constrained by `B` - | -LL | trait A { fn g(b: T) -> B; } - | ++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference +help: use `dyn` | -LL | trait A { fn g(b: impl B) -> B; } - | ++++ +LL | trait B { fn f(a: dyn A) -> A; } + | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:9:25 + --> $DIR/avoid-ice-on-warning-3.rs:4:25 | -LL | trait A { fn g(b: B) -> B; } +LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: `B` is not object safe, use `impl B` to return an opaque type, as long as you return a single underlying type +help: use `dyn` | -LL | trait A { fn g(b: B) -> impl B; } - | ++++ +LL | trait B { fn f(a: A) -> dyn A; } + | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:1:19 + --> $DIR/avoid-ice-on-warning-3.rs:12:19 | -LL | trait B { fn f(a: A) -> A; } +LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `A` it is not object safe, so it can't be `dyn` -help: use a new generic type parameter, constrained by `A` - | -LL | trait B { fn f(a: T) -> A; } - | ++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference +help: use `dyn` | -LL | trait B { fn f(a: impl A) -> A; } - | ++++ +LL | trait A { fn g(b: dyn B) -> B; } + | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:1:25 + --> $DIR/avoid-ice-on-warning-3.rs:12:25 | -LL | trait B { fn f(a: A) -> A; } +LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: `A` is not object safe, use `impl A` to return an opaque type, as long as you return a single underlying type +help: use `dyn` | -LL | trait B { fn f(a: A) -> impl A; } - | ++++ +LL | trait A { fn g(b: B) -> dyn B; } + | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:1:19 + --> $DIR/avoid-ice-on-warning-3.rs:4:19 | LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `A` it is not object safe, so it can't be `dyn` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use a new generic type parameter, constrained by `A` - | -LL | trait B { fn f(a: T) -> A; } - | ++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference +help: use `dyn` | -LL | trait B { fn f(a: impl A) -> A; } - | ++++ +LL | trait B { fn f(a: dyn A) -> A; } + | +++ error[E0038]: the trait `A` cannot be made into an object - --> $DIR/avoid-ice-on-warning-3.rs:1:19 + --> $DIR/avoid-ice-on-warning-3.rs:4:19 | LL | trait B { fn f(a: A) -> A; } | ^ `A` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/avoid-ice-on-warning-3.rs:9:14 + --> $DIR/avoid-ice-on-warning-3.rs:12:14 | LL | trait A { fn g(b: B) -> B; } | - ^ ...because associated function `g` has no `self` parameter @@ -103,32 +88,27 @@ LL | trait A { fn g(b: B) -> B where Self: Sized; } | +++++++++++++++++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning-3.rs:9:19 + --> $DIR/avoid-ice-on-warning-3.rs:12:19 | LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see - = note: `B` it is not object safe, so it can't be `dyn` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use a new generic type parameter, constrained by `B` - | -LL | trait A { fn g(b: T) -> B; } - | ++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference +help: use `dyn` | -LL | trait A { fn g(b: impl B) -> B; } - | ++++ +LL | trait A { fn g(b: dyn B) -> B; } + | +++ error[E0038]: the trait `B` cannot be made into an object - --> $DIR/avoid-ice-on-warning-3.rs:9:19 + --> $DIR/avoid-ice-on-warning-3.rs:12:19 | LL | trait A { fn g(b: B) -> B; } | ^ `B` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/avoid-ice-on-warning-3.rs:1:14 + --> $DIR/avoid-ice-on-warning-3.rs:4:14 | LL | trait B { fn f(a: A) -> A; } | - ^ ...because associated function `f` has no `self` parameter diff --git a/tests/ui/object-safety/avoid-ice-on-warning-3.rs b/tests/ui/object-safety/avoid-ice-on-warning-3.rs index caaf4d0fd99aa..40563e233dec6 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-3.rs +++ b/tests/ui/object-safety/avoid-ice-on-warning-3.rs @@ -1,17 +1,20 @@ +// revisions: old new +//[old] edition:2015 +//[new] edition:2021 trait B { fn f(a: A) -> A; } -//~^ WARN trait objects without an explicit `dyn` are deprecated -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN this is accepted in the current edition -//~| WARN this is accepted in the current edition -//~| ERROR the trait `A` cannot be made into an object +//~^ ERROR the trait `A` cannot be made into an object +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN this is accepted in the current edition +//[old]~| WARN this is accepted in the current edition +//[old]~| WARN this is accepted in the current edition trait A { fn g(b: B) -> B; } -//~^ WARN trait objects without an explicit `dyn` are deprecated -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN this is accepted in the current edition -//~| WARN this is accepted in the current edition -//~| ERROR the trait `B` cannot be made into an object +//~^ ERROR the trait `B` cannot be made into an object +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN this is accepted in the current edition +//[old]~| WARN this is accepted in the current edition +//[old]~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/object-safety/avoid-ice-on-warning.new.stderr b/tests/ui/object-safety/avoid-ice-on-warning.new.stderr new file mode 100644 index 0000000000000..517f910080de7 --- /dev/null +++ b/tests/ui/object-safety/avoid-ice-on-warning.new.stderr @@ -0,0 +1,15 @@ +error: return types are denoted using `->` + --> $DIR/avoid-ice-on-warning.rs:4:23 + | +LL | fn call_this(f: F) : Fn(&str) + call_that {} + | ^ help: use `->` instead + +error[E0405]: cannot find trait `call_that` in this scope + --> $DIR/avoid-ice-on-warning.rs:4:36 + | +LL | fn call_this(f: F) : Fn(&str) + call_that {} + | ^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0405`. diff --git a/tests/ui/object-safety/avoid-ice-on-warning.stderr b/tests/ui/object-safety/avoid-ice-on-warning.old.stderr similarity index 71% rename from tests/ui/object-safety/avoid-ice-on-warning.stderr rename to tests/ui/object-safety/avoid-ice-on-warning.old.stderr index 1046f177e8296..7c7af9682800f 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning.old.stderr @@ -1,17 +1,17 @@ error: return types are denoted using `->` - --> $DIR/avoid-ice-on-warning.rs:1:23 + --> $DIR/avoid-ice-on-warning.rs:4:23 | LL | fn call_this(f: F) : Fn(&str) + call_that {} | ^ help: use `->` instead error[E0405]: cannot find trait `call_that` in this scope - --> $DIR/avoid-ice-on-warning.rs:1:36 + --> $DIR/avoid-ice-on-warning.rs:4:36 | LL | fn call_this(f: F) : Fn(&str) + call_that {} | ^^^^^^^^^ not found in this scope warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/avoid-ice-on-warning.rs:1:25 + --> $DIR/avoid-ice-on-warning.rs:4:25 | LL | fn call_this(f: F) : Fn(&str) + call_that {} | ^^^^^^^^^^^^^^^^^^^^ @@ -19,10 +19,10 @@ LL | fn call_this(f: F) : Fn(&str) + call_that {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: `Fn(&str) + call_that` is not object safe, use `impl Fn(&str) + call_that` to return an opaque type, as long as you return a single underlying type +help: use `dyn` | -LL | fn call_this(f: F) : impl Fn(&str) + call_that {} - | ++++ +LL | fn call_this(f: F) : dyn Fn(&str) + call_that {} + | +++ error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/object-safety/avoid-ice-on-warning.rs b/tests/ui/object-safety/avoid-ice-on-warning.rs index d2a1eeb5286b0..5192da94216e1 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning.rs +++ b/tests/ui/object-safety/avoid-ice-on-warning.rs @@ -1,6 +1,9 @@ +// revisions: old new +//[old] edition:2015 +//[new] edition:2021 fn call_this(f: F) : Fn(&str) + call_that {} //~^ ERROR return types are denoted using `->` //~| ERROR cannot find trait `call_that` in this scope -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! +//[old]~| WARN trait objects without an explicit `dyn` are deprecated +//[old]~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! fn main() {} diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.fixed b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.fixed deleted file mode 100644 index e95b982966d0b..0000000000000 --- a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.fixed +++ /dev/null @@ -1,9 +0,0 @@ -// run-rustfix -#![deny(bare_trait_objects)] -fn ord_prefer_dot(s: String) -> impl Ord { - //~^ ERROR the trait `Ord` cannot be made into an object - (s.starts_with("."), s) -} -fn main() { - let _ = ord_prefer_dot(String::new()); -} diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.fixed b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.fixed new file mode 100644 index 0000000000000..301c36c619139 --- /dev/null +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.fixed @@ -0,0 +1,16 @@ +// revisions: old new +//[old] edition:2015 +//[new] edition:2021 +//[new] run-rustfix +// FIXME: the test suite tries to create a crate called `bare_trait_dont_suggest_dyn.new` +#![crate_name="bare_trait_dont_suggest_dyn"] +#![deny(bare_trait_objects)] +fn ord_prefer_dot(s: String) -> impl Ord { + //~^ ERROR the trait `Ord` cannot be made into an object + //[old]~| ERROR trait objects without an explicit `dyn` are deprecated + //[old]~| WARNING this is accepted in the current edition (Rust 2015) + (s.starts_with("."), s) +} +fn main() { + let _ = ord_prefer_dot(String::new()); +} diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.stderr b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr similarity index 95% rename from tests/ui/object-safety/bare-trait-dont-suggest-dyn.stderr rename to tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr index 2c499d240ab0b..52db31d620c3d 100644 --- a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.stderr +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Ord` cannot be made into an object - --> $DIR/bare-trait-dont-suggest-dyn.rs:3:33 + --> $DIR/bare-trait-dont-suggest-dyn.rs:8:33 | LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ `Ord` cannot be made into an object diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr new file mode 100644 index 0000000000000..274d5a639a43b --- /dev/null +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr @@ -0,0 +1,39 @@ +error: trait objects without an explicit `dyn` are deprecated + --> $DIR/bare-trait-dont-suggest-dyn.rs:8:33 + | +LL | fn ord_prefer_dot(s: String) -> Ord { + | ^^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +note: the lint level is defined here + --> $DIR/bare-trait-dont-suggest-dyn.rs:7:9 + | +LL | #![deny(bare_trait_objects)] + | ^^^^^^^^^^^^^^^^^^ +help: use `dyn` + | +LL | fn ord_prefer_dot(s: String) -> dyn Ord { + | +++ + +error[E0038]: the trait `Ord` cannot be made into an object + --> $DIR/bare-trait-dont-suggest-dyn.rs:8:33 + | +LL | fn ord_prefer_dot(s: String) -> Ord { + | ^^^ `Ord` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: the trait cannot be made into an object because it uses `Self` as a type parameter + ::: $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: the trait cannot be made into an object because it uses `Self` as a type parameter +help: consider using an opaque type instead + | +LL | fn ord_prefer_dot(s: String) -> impl Ord { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.rs b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.rs index fdf7e0a77aa34..64586b77b8c2b 100644 --- a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.rs +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.rs @@ -1,7 +1,14 @@ -// run-rustfix +// revisions: old new +//[old] edition:2015 +//[new] edition:2021 +//[new] run-rustfix +// FIXME: the test suite tries to create a crate called `bare_trait_dont_suggest_dyn.new` +#![crate_name="bare_trait_dont_suggest_dyn"] #![deny(bare_trait_objects)] fn ord_prefer_dot(s: String) -> Ord { //~^ ERROR the trait `Ord` cannot be made into an object + //[old]~| ERROR trait objects without an explicit `dyn` are deprecated + //[old]~| WARNING this is accepted in the current edition (Rust 2015) (s.starts_with("."), s) } fn main() { diff --git a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.rs b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.rs new file mode 100644 index 0000000000000..a7412f51782fb --- /dev/null +++ b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.rs @@ -0,0 +1,9 @@ +// Issue #118164: recovery path leaving unemitted error behind +fn bar() -> String { + #[cfg(feature = )] + [1, 2, 3].iter().map().collect::() //~ ERROR expected `;`, found `#` + #[attr] //~ ERROR expected statement after outer attribute +} +fn main() { + let _ = bar(); +} diff --git a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.stderr b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.stderr new file mode 100644 index 0000000000000..dd0081cc2dff9 --- /dev/null +++ b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body.stderr @@ -0,0 +1,27 @@ +error: expected `;`, found `#` + --> $DIR/properly-recover-from-trailing-outer-attribute-in-body.rs:4:47 + | +LL | #[cfg(feature = )] + | ------------------ only `;` terminated statements or tail expressions are allowed after this attribute +LL | [1, 2, 3].iter().map().collect::() + | ^ expected `;` here +LL | #[attr] + | - unexpected token + | +help: add `;` here + | +LL | [1, 2, 3].iter().map().collect::(); + | + +help: alternatively, consider surrounding the expression with a block + | +LL | { [1, 2, 3].iter().map().collect::() } + | + + + +error: expected statement after outer attribute + --> $DIR/properly-recover-from-trailing-outer-attribute-in-body.rs:5:5 + | +LL | #[attr] + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.fixed b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.fixed new file mode 100644 index 0000000000000..86ac07a93a367 --- /dev/null +++ b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.fixed @@ -0,0 +1,29 @@ +// run-rustfix + +struct A { + +} + +trait M { + fn foo(_a: Self); + fn bar(_a: Self); + fn baz(_a: i32); +} + +impl M for A { + fn foo(_a: Self) {} + fn bar(_a: A) {} + fn baz(_a: i32) {} +} + +fn main() { + let _a = A {}; + A::foo(_a); + //~^ ERROR no method named `foo` found + A::baz(0); + //~^ ERROR no method named `baz` found + + let _b = A {}; + A::bar(_b); + //~^ ERROR no method named `bar` found +} diff --git a/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.rs b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.rs new file mode 100644 index 0000000000000..9a57ffb77405a --- /dev/null +++ b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.rs @@ -0,0 +1,29 @@ +// run-rustfix + +struct A { + +} + +trait M { + fn foo(_a: Self); + fn bar(_a: Self); + fn baz(_a: i32); +} + +impl M for A { + fn foo(_a: Self) {} + fn bar(_a: A) {} + fn baz(_a: i32) {} +} + +fn main() { + let _a = A {}; + _a.foo(); + //~^ ERROR no method named `foo` found + _a.baz(0); + //~^ ERROR no method named `baz` found + + let _b = A {}; + _b.bar(); + //~^ ERROR no method named `bar` found +} diff --git a/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.stderr b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.stderr new file mode 100644 index 0000000000000..0df2b08d3be82 --- /dev/null +++ b/tests/ui/suggestions/suggest-assoc-fn-call-for-impl-trait.stderr @@ -0,0 +1,60 @@ +error[E0599]: no method named `foo` found for struct `A` in the current scope + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:21:8 + | +LL | struct A { + | -------- method `foo` not found for this struct +... +LL | _a.foo(); + | ---^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `A::foo(_a)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in the trait `M` + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:8:5 + | +LL | fn foo(_a: Self); + | ^^^^^^^^^^^^^^^^^ + +error[E0599]: no method named `baz` found for struct `A` in the current scope + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:23:8 + | +LL | struct A { + | -------- method `baz` not found for this struct +... +LL | _a.baz(0); + | ---^^^--- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `A::baz(0)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in the trait `M` + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:10:5 + | +LL | fn baz(_a: i32); + | ^^^^^^^^^^^^^^^^ + +error[E0599]: no method named `bar` found for struct `A` in the current scope + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:27:8 + | +LL | struct A { + | -------- method `bar` not found for this struct +... +LL | _b.bar(); + | ---^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `A::bar(_b)` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in the trait `M` + --> $DIR/suggest-assoc-fn-call-for-impl-trait.rs:9:5 + | +LL | fn bar(_a: Self); + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/traits/bound/not-on-bare-trait.stderr b/tests/ui/traits/bound/not-on-bare-trait.stderr index 8d0e40be788c1..6d56851bf3495 100644 --- a/tests/ui/traits/bound/not-on-bare-trait.stderr +++ b/tests/ui/traits/bound/not-on-bare-trait.stderr @@ -7,18 +7,10 @@ LL | fn foo(_x: Foo + Send) { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: use a new generic type parameter, constrained by `Foo + Send` +help: use `dyn` | -LL | fn foo(_x: T) { - | +++++++++++++++ ~ -help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference - | -LL | fn foo(_x: impl Foo + Send) { - | ++++ -help: alternatively, use a trait object to accept any type that implements `Foo + Send`, accessing its methods at runtime using dynamic dispatch - | -LL | fn foo(_x: &(dyn Foo + Send)) { - | +++++ + +LL | fn foo(_x: dyn Foo + Send) { + | +++ error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time --> $DIR/not-on-bare-trait.rs:7:8 diff --git a/triagebot.toml b/triagebot.toml index 07af53106f10f..c46f9c9003079 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -663,7 +663,6 @@ libs = [ "@joshtriplett", "@Mark-Simulacrum", "@m-ou-se", - "@thomcc", ] bootstrap = [ "@Mark-Simulacrum", @@ -803,7 +802,7 @@ project-stable-mir = [ "/library/panic_unwind" = ["libs"] "/library/proc_macro" = ["@petrochenkov"] "/library/std" = ["libs"] -"/library/std/src/sys/pal/windows" = ["@ChrisDenton", "@thomcc"] +"/library/std/src/sys/pal/windows" = ["@ChrisDenton"] "/library/stdarch" = ["libs"] "/library/test" = ["libs"] "/src/bootstrap" = ["bootstrap"]