diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 7865c523f758c..6e5ba556ef079 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -252,20 +252,6 @@ impl<'a> AstValidator<'a> { } } - fn visit_struct_field_def(&mut self, field: &'a FieldDef) { - if let Some(ident) = field.ident { - if ident.name == kw::Underscore { - self.visit_vis(&field.vis); - self.visit_ident(ident); - self.visit_ty_common(&field.ty); - self.walk_ty(&field.ty); - walk_list!(self, visit_attribute, &field.attrs); - return; - } - } - self.visit_field_def(field); - } - fn err_handler(&self) -> &rustc_errors::Handler { &self.session.diagnostic() } @@ -1006,8 +992,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_lifetime(self, lifetime); } - fn visit_field_def(&mut self, s: &'a FieldDef) { - visit::walk_field_def(self, s) + fn visit_field_def(&mut self, field: &'a FieldDef) { + visit::walk_field_def(self, field) } fn visit_item(&mut self, item: &'a Item) { @@ -1195,42 +1181,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> { self.check_mod_file_item_asciionly(item.ident); } } - ItemKind::Struct(ref vdata, ref generics) => match vdata { - // Duplicating the `Visitor` logic allows catching all cases - // of `Anonymous(Struct, Union)` outside of a field struct or union. - // - // Inside `visit_ty` the validator catches every `Anonymous(Struct, Union)` it - // encounters, and only on `ItemKind::Struct` and `ItemKind::Union` - // it uses `visit_ty_common`, which doesn't contain that specific check. - VariantData::Struct(ref fields, ..) => { - self.visit_vis(&item.vis); - self.visit_ident(item.ident); - self.visit_generics(generics); - self.with_banned_assoc_ty_bound(|this| { - walk_list!(this, visit_struct_field_def, fields); - }); - walk_list!(self, visit_attribute, &item.attrs); - return; - } - _ => {} - }, - ItemKind::Union(ref vdata, ref generics) => { + ItemKind::Union(ref vdata, ..) => { if vdata.fields().is_empty() { self.err_handler().span_err(item.span, "unions cannot have zero fields"); } - match vdata { - VariantData::Struct(ref fields, ..) => { - self.visit_vis(&item.vis); - self.visit_ident(item.ident); - self.visit_generics(generics); - self.with_banned_assoc_ty_bound(|this| { - walk_list!(this, visit_struct_field_def, fields); - }); - walk_list!(self, visit_attribute, &item.attrs); - return; - } - _ => {} - } } ItemKind::Const(def, .., None) => { self.check_defaultness(item.span, def); diff --git a/compiler/rustc_data_structures/src/sso/set.rs b/compiler/rustc_data_structures/src/sso/set.rs index 4fda3adb7b878..406f0270dcc1b 100644 --- a/compiler/rustc_data_structures/src/sso/set.rs +++ b/compiler/rustc_data_structures/src/sso/set.rs @@ -27,7 +27,7 @@ pub struct SsoHashSet { map: SsoHashMap, } -/// Adapter function used ot return +/// Adapter function used to return /// result if SsoHashMap functions into /// result SsoHashSet should return. #[inline(always)] diff --git a/compiler/rustc_hir_analysis/src/check/dropck.rs b/compiler/rustc_hir_analysis/src/check/dropck.rs index e5b212eb757b6..3d55ffc595f53 100644 --- a/compiler/rustc_hir_analysis/src/check/dropck.rs +++ b/compiler/rustc_hir_analysis/src/check/dropck.rs @@ -184,13 +184,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( let p = p.kind(); match (predicate.skip_binder(), p.skip_binder()) { (ty::PredicateKind::Trait(a), ty::PredicateKind::Trait(b)) => { - // Since struct predicates cannot have ~const, project the impl predicate - // onto one that ignores the constness. This is equivalent to saying that - // we match a `Trait` bound on the struct with a `Trait` or `~const Trait` - // in the impl. - let non_const_a = - ty::TraitPredicate { constness: ty::BoundConstness::NotConst, ..a }; - relator.relate(predicate.rebind(non_const_a), p.rebind(b)).is_ok() + relator.relate(predicate.rebind(a), p.rebind(b)).is_ok() } (ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => { relator.relate(predicate.rebind(a), p.rebind(b)).is_ok() diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index d6cc31331a3bc..61ee467f59577 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1427,6 +1427,7 @@ declare_lint! { "trait-object types were treated as different depending on marker-trait order", @future_incompatible = FutureIncompatibleInfo { reference: "issue #56484 ", + reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, }; } diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs index 8f67161420dad..a7e86141a04ee 100644 --- a/compiler/rustc_middle/src/mir/interpret/queries.rs +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs @@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> { match ty::Instance::resolve_opt_const_arg( self, param_env, - // FIXME: maybe have a seperate version for resolving mir::UnevaluatedConst? + // FIXME: maybe have a separate version for resolving mir::UnevaluatedConst? ct.def, ct.substs, ) { Ok(Some(instance)) => { diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 693c172893154..c8276854016f0 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -264,7 +264,7 @@ fn project_and_unify_type<'cx, 'tcx>( }; debug!(?normalized, ?obligations, "project_and_unify_type result"); let actual = obligation.predicate.term; - // For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs + // For an example where this is necessary see src/test/ui/impl-trait/nested-return-type2.rs // This allows users to omit re-mentioning all bounds on an associated type and just use an // `impl Trait` for the assoc type to add more bounds. let InferOk { value: actual, obligations: new } = diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index b5b2eb0ece0ee..6a71f08330ca9 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1999,9 +1999,7 @@ impl Vec { unsafe { // set self.vec length's to start, to be safe in case Drain is leaked self.set_len(start); - // Use the borrow in the IterMut to indicate borrowing behavior of the - // whole Drain iterator (like &mut T). - let range_slice = slice::from_raw_parts_mut(self.as_mut_ptr().add(start), end - start); + let range_slice = slice::from_raw_parts(self.as_ptr().add(start), end - start); Drain { tail_start: end, tail_len: len - end, diff --git a/library/test/src/term.rs b/library/test/src/term.rs index b256ab7b8f828..a14b0d4f5a962 100644 --- a/library/test/src/term.rs +++ b/library/test/src/term.rs @@ -39,7 +39,7 @@ pub(crate) fn stdout() -> Option> { pub(crate) fn stdout() -> Option> { TerminfoTerminal::new(io::stdout()) .map(|t| Box::new(t) as Box) - .or_else(|| WinConsole::new(io::stdout()).ok().map(|t| Box::new(t) as Box)) + .or_else(|| Some(Box::new(WinConsole::new(io::stdout())) as Box)) } /// Terminal color definitions diff --git a/library/test/src/term/win.rs b/library/test/src/term/win.rs index 4bdbd6ee75f52..55020141a827d 100644 --- a/library/test/src/term/win.rs +++ b/library/test/src/term/win.rs @@ -113,8 +113,7 @@ impl WinConsole { } } - /// Returns `None` whenever the terminal cannot be created for some reason. - pub(crate) fn new(out: T) -> io::Result> { + pub(crate) fn new(out: T) -> WinConsole { use std::mem::MaybeUninit; let fg; @@ -132,13 +131,13 @@ impl WinConsole { bg = color::BLACK; } } - Ok(WinConsole { + WinConsole { buf: out, def_foreground: fg, def_background: bg, foreground: fg, background: bg, - }) + } } } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index afe1ca5d7e520..9785e1f54c1a4 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -634,7 +634,6 @@ pre.example-line-numbers { .out-of-band { flex-grow: 0; font-size: 1.125rem; - font-weight: normal; } .docblock code, .docblock-short code, @@ -1536,6 +1535,7 @@ details.dir-entry a { https://developer.mozilla.org/en-US/docs/Web/CSS/contain */ details.rustdoc-toggle { contain: layout; + position: relative; } /* The hideme class is used on summary tags that contain a span with @@ -1629,10 +1629,6 @@ details.rustdoc-toggle[open] > summary.hideme { position: absolute; } -details.rustdoc-toggle { - position: relative; -} - details.rustdoc-toggle[open] > summary.hideme > span { display: none; } @@ -1983,8 +1979,8 @@ in storage.js } } -.method-toggle summary, -.implementors-toggle summary, +.method-toggle > summary, +.implementors-toggle > summary, .impl, #implementors-list > .docblock, .impl-items > section, @@ -1993,10 +1989,7 @@ in storage.js margin-bottom: 0.75em; } -.method-toggle[open]:not(:last-child) { - margin-bottom: 2em; -} - +.method-toggle[open]:not(:last-child), .implementors-toggle[open]:not(:last-child) { margin-bottom: 2em; } diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml index f3cbe5767ae91..9ae571efbb587 100644 --- a/src/test/rustdoc-gui/docblock-details.goml +++ b/src/test/rustdoc-gui/docblock-details.goml @@ -21,3 +21,14 @@ assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) // So `33 + 15 + 5` == `53` assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) + +// We now check the `` on a method. +assert-css: ( + ".method-toggle .docblock summary h4", + {"border-bottom-width": "0px"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"}) +assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `30 + 15 + 5` == `50` +assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"}) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 77617e10beb70..fdf97e492aa2b 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -317,6 +317,18 @@ pub mod details { ///
I'm the content of the details!
/// pub struct Details; + + impl Details { + /// We check the appearance of the `
`/`` in here. + /// + /// ## Hello + /// + ///
+ ///

I'm a summary

+ ///
I'm the content of the details!
+ ///
+ pub fn method() {} + } } pub mod doc_block_table { diff --git a/src/test/ui/closures/issue-97607.rs b/src/test/ui/closures/issue-97607.rs new file mode 100644 index 0000000000000..74c910ad0bba6 --- /dev/null +++ b/src/test/ui/closures/issue-97607.rs @@ -0,0 +1,12 @@ +// check-pass +#[allow(unused)] + +fn test(f: F) -> Box U + 'static> +where + F: 'static + Fn(T) -> U, + for<'a> U: 'a, // < This is the problematic line, see #97607 +{ + Box::new(move |t| f(t)) +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr deleted file mode 100644 index 3f72734efa1dc..0000000000000 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0271]: type mismatch resolving ` as Stream>::Item == Repr` - --> $DIR/issue-89008.rs:38:43 - | -LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving ` as Stream>::Item == Repr` - | | - | this type parameter - | -note: expected this to be `()` - --> $DIR/issue-89008.rs:17:17 - | -LL | type Item = (); - | ^^ - = note: expected unit type `()` - found type parameter `Repr` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/generic-associated-types/bugs/issue-91762.rs b/src/test/ui/generic-associated-types/bugs/issue-91762.rs index 796935cc06f5b..dec668bec10ed 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-91762.rs +++ b/src/test/ui/generic-associated-types/bugs/issue-91762.rs @@ -1,7 +1,7 @@ // check-fail // known-bug -// We almost certaintly want this to pass, but +// We almost certainly want this to pass, but // it's particularly difficult currently, because we need a way of specifying // that `::With = Self` without using that when we have // a `U`. See `https://github.com/rust-lang/rust/pull/92728` for a (hacky) diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.rs b/src/test/ui/generic-associated-types/issue-89008.rs similarity index 55% rename from src/test/ui/generic-associated-types/bugs/issue-89008.rs rename to src/test/ui/generic-associated-types/issue-89008.rs index 012aa8df2fc3f..669dbafb5d5de 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.rs +++ b/src/test/ui/generic-associated-types/issue-89008.rs @@ -1,42 +1,36 @@ -// check-fail +// check-pass // edition:2021 -// known-bug: #88908 - -// This should pass, but seems to run into a TAIT bug. #![feature(type_alias_impl_trait)] use std::future::Future; +use std::marker::PhantomData; trait Stream { type Item; } -struct Empty(T); -impl Stream for Empty { - type Item = (); +struct Empty { + _phantom: PhantomData, } -fn empty() -> Empty { - todo!() + +impl Stream for Empty { + type Item = T; } trait X { type LineStream<'a, Repr>: Stream where Self: 'a; - - type LineStreamFut<'a,Repr>: Future> where Self: 'a; - - fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>; + type LineStreamFut<'a, Repr>: Future> where Self: 'a; + fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr>; } struct Y; impl X for Y { type LineStream<'a, Repr> = impl Stream; - - type LineStreamFut<'a, Repr> = impl Future> ; - + type LineStreamFut<'a, Repr> = impl Future>; fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { - async {empty()} + async { Empty { _phantom: PhantomData } } } } diff --git a/src/test/ui/let-else/let-else-non-diverging.rs b/src/test/ui/let-else/let-else-non-diverging.rs index 58d2c09776f98..a5442dd82f028 100644 --- a/src/test/ui/let-else/let-else-non-diverging.rs +++ b/src/test/ui/let-else/let-else-non-diverging.rs @@ -11,7 +11,7 @@ fn main() { // Ensure that uninhabited types do not "diverge". // This might be relaxed in the future, but when it is, - // it should be an explicitly wanted descision. + // it should be an explicitly wanted decision. let Some(x) = Some(1) else { foo::() }; //~ ERROR does not diverge } diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr index 3f366bedbf376..2cc4d382d9df9 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr @@ -37,3 +37,45 @@ LL | impl Foo for dyn Send + Sync + Send {} error: aborting due to 3 previous errors +Future incompatibility report: Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:5:1 + | +LL | impl Foo for dyn Send {} + | --------------------- first implementation here +LL | +LL | impl Foo for dyn Send + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 + = note: `#[deny(order_dependent_trait_objects)]` on by default + +Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:11:1 + | +LL | impl Foo for dyn Send + Sync {} + | ---------------------------- first implementation here +LL | +LL | impl Foo for dyn Sync + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 + = note: `#[deny(order_dependent_trait_objects)]` on by default + +Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:15:1 + | +LL | impl Foo for dyn Sync + Send {} + | ---------------------------- first implementation here +... +LL | impl Foo for dyn Send + Sync + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 + = note: `#[deny(order_dependent_trait_objects)]` on by default + diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index ddf0e2d91c097..796c0d388eaf0 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -45,34 +45,55 @@ note: required by a bound in `check` LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `ConstDropImplWithBounds: ~const Destruct` is not satisfied +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | | + | required by a bound introduced by this call + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 + | +LL | struct ConstDropImplWithBounds(PhantomData); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:5 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` --> $DIR/const-drop-fail.rs:48:5 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call -... LL | ConstDropImplWithBounds::(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `ConstDropImplWithBounds` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 | -note: required for `ConstDropImplWithBounds` to implement `~const Destruct` - --> $DIR/const-drop-fail.rs:29:25 +LL | struct ConstDropImplWithBounds(PhantomData); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail.rs:55:9 | -LL | impl const Drop for ConstDropImplWithBounds { - | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: 1 redundant requirement hidden - = note: required for `ConstDropImplWithBounds` to implement `~const Destruct` -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 +LL | impl const Drop for ConstDropImplWithNonConstBounds { + | ^^^^^^^^ | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail.rs:53:1 | -LL | &ConstDropImplWithBounds::(PhantomData), - | + -LL | &mut ConstDropImplWithBounds::(PhantomData), - | ++++ +LL | struct ConstDropImplWithNonConstBounds(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs index 565e2c77ac5ca..d36c7f81ced8c 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -24,7 +24,7 @@ trait A { fn a() { } } impl A for NonTrivialDrop {} -struct ConstDropImplWithBounds(PhantomData); +struct ConstDropImplWithBounds(PhantomData); impl const Drop for ConstDropImplWithBounds { fn drop(&mut self) { @@ -47,6 +47,16 @@ check_all! { //~^ ERROR can't drop ConstDropImplWithBounds::(PhantomData), //~^ ERROR the trait bound + //~| ERROR the trait bound +} + +struct ConstDropImplWithNonConstBounds(PhantomData); + +impl const Drop for ConstDropImplWithNonConstBounds { +//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + fn drop(&mut self) { + T::a(); + } } fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index ddf0e2d91c097..796c0d388eaf0 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -45,34 +45,55 @@ note: required by a bound in `check` LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `ConstDropImplWithBounds: ~const Destruct` is not satisfied +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | | + | required by a bound introduced by this call + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 + | +LL | struct ConstDropImplWithBounds(PhantomData); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:5 + | +LL | ConstDropImplWithBounds::(PhantomData), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` --> $DIR/const-drop-fail.rs:48:5 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call -... LL | ConstDropImplWithBounds::(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `ConstDropImplWithBounds` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 | -note: required for `ConstDropImplWithBounds` to implement `~const Destruct` - --> $DIR/const-drop-fail.rs:29:25 +LL | struct ConstDropImplWithBounds(PhantomData); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail.rs:55:9 | -LL | impl const Drop for ConstDropImplWithBounds { - | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: 1 redundant requirement hidden - = note: required for `ConstDropImplWithBounds` to implement `~const Destruct` -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 +LL | impl const Drop for ConstDropImplWithNonConstBounds { + | ^^^^^^^^ | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail.rs:53:1 | -LL | &ConstDropImplWithBounds::(PhantomData), - | + -LL | &mut ConstDropImplWithBounds::(PhantomData), - | ++++ +LL | struct ConstDropImplWithNonConstBounds(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs index 8b4c406581565..b0fc3adf984a4 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs @@ -60,7 +60,7 @@ mod t { fn foo() {} } - pub struct ConstDropWithBound(pub core::marker::PhantomData); + pub struct ConstDropWithBound(pub core::marker::PhantomData); impl const Drop for ConstDropWithBound { fn drop(&mut self) { diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs new file mode 100644 index 0000000000000..285cef571f332 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs @@ -0,0 +1,17 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn foo(&self) {} +} + +struct Bar(T); + +impl Bar { + const fn foo(&self) { + self.0.foo() + } +} + +fn main() {} diff --git a/src/test/ui/traits/issue-33140-hack-boundaries.stderr b/src/test/ui/traits/issue-33140-hack-boundaries.stderr index 62cfca545b261..58286648d4feb 100644 --- a/src/test/ui/traits/issue-33140-hack-boundaries.stderr +++ b/src/test/ui/traits/issue-33140-hack-boundaries.stderr @@ -66,3 +66,20 @@ error: aborting due to 8 previous errors Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. +Future incompatibility report: Future breakage diagnostic: +warning: conflicting implementations of trait `Trait0` for type `(dyn std::marker::Send + 'static)`: (E0119) + --> $DIR/issue-33140-hack-boundaries.rs:10:1 + | +LL | impl Trait0 for dyn Send {} + | ------------------------ first implementation here +LL | impl Trait0 for dyn Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 +note: the lint level is defined here + --> $DIR/issue-33140-hack-boundaries.rs:2:10 + | +LL | #![allow(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr index 4ab777bd4dfae..0af4df2aecb28 100644 --- a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr +++ b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr @@ -40,3 +40,56 @@ LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } warning: 3 warnings emitted +Future incompatibility report: Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:86:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:89:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ------------------------------------------------------------- first implementation here +... +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:93:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ------------------------------------------------------ first implementation here +... +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.rs b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs similarity index 100% rename from src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.rs rename to src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.stderr b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr similarity index 88% rename from src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.stderr rename to src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr index e9670ad7def4d..9564813512c4a 100644 --- a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.stderr +++ b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/multiple-occurence-ambiguousity.rs:21:26 + --> $DIR/multiple-occurrence-ambiguousity.rs:21:26 | LL | let t: &dyn Bar<_> = s; | ----------- ^ expected trait `Bar`, found trait `Foo`