diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index e86e807279d6f..a3f5c18f2e75c 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -16,7 +16,7 @@ use rustc_hir::def::Res; use rustc_hir::definitions::DefPathData; use rustc_session::errors::report_lit_error; use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned}; -use rustc_span::symbol::{kw, sym, Ident}; +use rustc_span::symbol::{sym, Ident}; use rustc_span::DUMMY_SP; use thin_vec::thin_vec; @@ -596,38 +596,14 @@ impl<'hir> LoweringContext<'_, 'hir> { ) -> hir::ExprKind<'hir> { let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span))); - // Resume argument type, which should be `&mut Context<'_>`. - // NOTE: Using the `'static` lifetime here is technically cheating. - // The `Future::poll` argument really is `&'a mut Context<'b>`, but we cannot - // express the fact that we are not storing it across yield-points yet, - // and we would thus run into lifetime errors. - // See . - // Our lowering makes sure we are not mis-using the `_task_context` input type - // in the sense that we are indeed not using it across yield points. We - // get a fresh `&mut Context` for each resume / call of `Future::poll`. - // This "cheating" was previously done with a `ResumeTy` that contained a raw - // pointer, and a `get_context` accessor that pulled the `Context` lifetimes - // out of thin air. - let context_lifetime_ident = Ident::with_dummy_span(kw::StaticLifetime); - let context_lifetime = self.arena.alloc(hir::Lifetime { - hir_id: self.next_id(), - ident: context_lifetime_ident, - res: hir::LifetimeName::Static, - }); - let context_path = - hir::QPath::LangItem(hir::LangItem::Context, self.lower_span(span), None); - let context_ty = hir::MutTy { - ty: self.arena.alloc(hir::Ty { - hir_id: self.next_id(), - kind: hir::TyKind::Path(context_path), - span: self.lower_span(span), - }), - mutbl: hir::Mutability::Mut, - }; + // Resume argument type: `ResumeTy` + let unstable_span = + self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone()); + let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span, None); let input_ty = hir::Ty { hir_id: self.next_id(), - kind: hir::TyKind::Rptr(context_lifetime, context_ty), - span: self.lower_span(span), + kind: hir::TyKind::Path(resume_ty), + span: unstable_span, }; // The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`. @@ -686,9 +662,12 @@ impl<'hir> LoweringContext<'_, 'hir> { .map_or(false, |attrs| attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))); let hir_id = self.lower_node_id(closure_node_id); - let unstable_span = - self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone()); if track_caller { + let unstable_span = self.mark_span_with_reason( + DesugaringKind::Async, + span, + self.allow_gen_future.clone(), + ); self.lower_attrs( hir_id, &[Attribute { @@ -731,7 +710,7 @@ impl<'hir> LoweringContext<'_, 'hir> { /// mut __awaitee => loop { /// match unsafe { ::std::future::Future::poll( /// <::std::pin::Pin>::new_unchecked(&mut __awaitee), - /// task_context, + /// ::std::future::get_context(task_context), /// ) } { /// ::std::task::Poll::Ready(result) => break result, /// ::std::task::Poll::Pending => {} @@ -772,7 +751,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // unsafe { // ::std::future::Future::poll( // ::std::pin::Pin::new_unchecked(&mut __awaitee), - // task_context, + // ::std::future::get_context(task_context), // ) // } let poll_expr = { @@ -790,10 +769,16 @@ impl<'hir> LoweringContext<'_, 'hir> { arena_vec![self; ref_mut_awaitee], Some(expr_hir_id), ); + let get_context = self.expr_call_lang_item_fn_mut( + gen_future_span, + hir::LangItem::GetContext, + arena_vec![self; task_context], + Some(expr_hir_id), + ); let call = self.expr_call_lang_item_fn( span, hir::LangItem::FuturePoll, - arena_vec![self; new_unchecked, task_context], + arena_vec![self; new_unchecked, get_context], Some(expr_hir_id), ); self.arena.alloc(self.expr_unsafe(call)) diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 67c512e98d68d..883a4bbe8e823 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -239,8 +239,10 @@ E0452: include_str!("./error_codes/E0452.md"), E0453: include_str!("./error_codes/E0453.md"), E0454: include_str!("./error_codes/E0454.md"), E0455: include_str!("./error_codes/E0455.md"), +E0457: include_str!("./error_codes/E0457.md"), E0458: include_str!("./error_codes/E0458.md"), E0459: include_str!("./error_codes/E0459.md"), +E0460: include_str!("./error_codes/E0460.md"), E0463: include_str!("./error_codes/E0463.md"), E0464: include_str!("./error_codes/E0464.md"), E0466: include_str!("./error_codes/E0466.md"), @@ -592,8 +594,6 @@ E0791: include_str!("./error_codes/E0791.md"), // E0421, // merged into 531 // E0427, // merged into 530 // E0456, // plugin `..` is not available for triple `..` - E0457, // plugin `..` only found in rlib format, but must be available... - E0460, // found possibly newer version of crate `..` E0461, // couldn't find crate `..` with expected target triple .. E0462, // found staticlib `..` instead of rlib or dylib E0465, // multiple .. candidates for `..` found diff --git a/compiler/rustc_error_codes/src/error_codes/E0457.md b/compiler/rustc_error_codes/src/error_codes/E0457.md new file mode 100644 index 0000000000000..53d384d36c426 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0457.md @@ -0,0 +1,36 @@ +Plugin `..` only found in rlib format, but must be available in dylib format. + +Erroronous code example: + +`rlib-plugin.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_type = "rlib"] +#![feature(rustc_private)] + +extern crate rustc_middle; +extern crate rustc_driver; + +use rustc_driver::plugin::Registry; + +#[no_mangle] +fn __rustc_plugin_registrar(_: &mut Registry) {} +``` + +`main.rs` +```ignore (needs-linkage-with-other-tests) +#![feature(plugin)] +#![plugin(rlib_plugin)] // error: plugin `rlib_plugin` only found in rlib + // format, but must be available in dylib + +fn main() {} +``` + +The compiler exposes a plugin interface to allow altering the compile process +(adding lints, etc). Plugins must be defined in their own crates (similar to +[proc-macro](../reference/procedural-macros.html) isolation) and then compiled +and linked to another crate. Plugin crates *must* be compiled to the +dynamically-linked dylib format, and not the statically-linked rlib format. +Learn more about different output types in +[this section](../reference/linkage.html) of the Rust reference. + +This error is easily fixed by recompiling the plugin crate in the dylib format. diff --git a/compiler/rustc_error_codes/src/error_codes/E0460.md b/compiler/rustc_error_codes/src/error_codes/E0460.md new file mode 100644 index 0000000000000..001678a9bce06 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0460.md @@ -0,0 +1,71 @@ +Found possibly newer version of crate `..` which `..` depends on. + +Consider these erroneous files: + +`a1.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "a"] + +pub fn foo() {} +``` + +`a2.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "a"] + +pub fn foo() { + println!("foo()"); +} +``` + +`b.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "b"] + +extern crate a; // linked with `a1.rs` + +pub fn foo() { + a::foo::(); +} +``` + +`main.rs` +```ignore (needs-linkage-with-other-tests) +extern crate a; // linked with `a2.rs` +extern crate b; // error: found possibly newer version of crate `a` which `b` + // depends on + +fn main() {} +``` + +The dependency graph of this program can be represented as follows: +```text + crate `main` + | + +-------------+ + | | + | v +depends: | crate `b` + `a` v1 | | + | | depends: + | | `a` v2 + v | + crate `a` <------+ +``` + +Crate `main` depends on crate `a` (version 1) and crate `b` which in turn +depends on crate `a` (version 2); this discrepancy in versions cannot be +reconciled. This difference in versions typically occurs when one crate is +compiled and linked, then updated and linked to another crate. The crate +"version" is a SVH (Strict Version Hash) of the crate in an +implementation-specific way. Note that this error can *only* occur when +directly compiling and linking with `rustc`; [Cargo] automatically resolves +dependencies, without using the compiler's own dependency management that +causes this issue. + +This error can be fixed by: + * Using [Cargo], the Rust package manager, automatically fixing this issue. + * Recompiling crate `a` so that both crate `b` and `main` have a uniform + version to depend on. + +[Cargo]: ../cargo/index.html diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index b51257df713ea..038509031b180 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -286,9 +286,10 @@ language_item_table! { // FIXME(swatinem): the following lang items are used for async lowering and // should become obsolete eventually. + ResumeTy, sym::ResumeTy, resume_ty, Target::Struct, GenericRequirement::None; IdentityFuture, sym::identity_future, identity_future_fn, Target::Fn, GenericRequirement::None; + GetContext, sym::get_context, get_context_fn, Target::Fn, GenericRequirement::None; - Context, sym::Context, context, Target::Struct, GenericRequirement::None; FuturePoll, sym::poll, future_poll_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; FromFrom, sym::from, from_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ace095736c92f..9de6d9dc483c5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -164,7 +164,6 @@ symbols! { Capture, Center, Clone, - Context, Continue, Copy, Count, @@ -264,6 +263,7 @@ symbols! { Relaxed, Release, Result, + ResumeTy, Return, Right, Rust, @@ -753,6 +753,7 @@ symbols! { generic_associated_types_extended, generic_const_exprs, generic_param_attrs, + get_context, global_allocator, global_asm, globs, diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs index 2a8e12fd4cf60..f2b961d62e00c 100644 --- a/library/core/src/future/mod.rs +++ b/library/core/src/future/mod.rs @@ -44,7 +44,7 @@ pub use poll_fn::{poll_fn, PollFn}; /// non-Send/Sync as well, and we don't want that. /// /// It also simplifies the HIR lowering of `.await`. -// FIXME(swatinem): This type can be removed when bumping the bootstrap compiler +#[cfg_attr(not(bootstrap), lang = "ResumeTy")] #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] #[derive(Debug, Copy, Clone)] @@ -61,7 +61,6 @@ unsafe impl Sync for ResumeTy {} /// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give /// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`). // This is `const` to avoid extra errors after we recover from `const async fn` -// FIXME(swatinem): This fn can be removed when bumping the bootstrap compiler #[cfg_attr(bootstrap, lang = "from_generator")] #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] @@ -103,8 +102,7 @@ where GenFuture(gen) } -// FIXME(swatinem): This fn can be removed when bumping the bootstrap compiler -#[cfg_attr(bootstrap, lang = "get_context")] +#[lang = "get_context"] #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] #[must_use] @@ -115,10 +113,6 @@ pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { unsafe { &mut *cx.0.as_ptr().cast() } } -// FIXME(swatinem): This fn is currently needed to work around shortcomings -// in type and lifetime inference. -// See the comment at the bottom of `LoweringContext::make_async_expr` and -// . #[cfg_attr(not(bootstrap), lang = "identity_future")] #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 4524fa4c48d2b..3f8acc8505ff1 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -485,6 +485,16 @@ impl> Pin

{ /// /// Unlike `Pin::new_unchecked`, this method is safe because the pointer /// `P` dereferences to an [`Unpin`] type, which cancels the pinning guarantees. + /// + /// # Examples + /// + /// ``` + /// use std::pin::Pin; + /// + /// let mut val: u8 = 5; + /// // We can pin the value, since it doesn't care about being moved + /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val); + /// ``` #[inline(always)] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] #[stable(feature = "pin", since = "1.33.0")] @@ -496,8 +506,20 @@ impl> Pin

{ /// Unwraps this `Pin

` returning the underlying pointer. /// - /// This requires that the data inside this `Pin` is [`Unpin`] so that we + /// This requires that the data inside this `Pin` implements [`Unpin`] so that we /// can ignore the pinning invariants when unwrapping it. + /// + /// # Examples + /// + /// ``` + /// use std::pin::Pin; + /// + /// let mut val: u8 = 5; + /// let pinned: Pin<&mut u8> = Pin::new(&mut val); + /// // Unwrap the pin to get a reference to the value + /// let r = Pin::into_inner(pinned); + /// assert_eq!(*r, 5); + /// ``` #[inline(always)] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] #[stable(feature = "pin_into_inner", since = "1.39.0")] @@ -707,6 +729,18 @@ impl Pin

{ /// /// This overwrites pinned data, but that is okay: its destructor gets /// run before being overwritten, so no pinning guarantee is violated. + /// + /// # Example + /// + /// ``` + /// use std::pin::Pin; + /// + /// let mut val: u8 = 5; + /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val); + /// println!("{}", pinned); // 5 + /// pinned.as_mut().set(10); + /// println!("{}", pinned); // 10 + /// ``` #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn set(&mut self, value: P::Target) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 9ab9b0ba1c797..0cff972df3a5a 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -174,7 +174,6 @@ impl RawWakerVTable { /// Currently, `Context` only serves to provide access to a [`&Waker`](Waker) /// which can be used to wake the current task. #[stable(feature = "futures_api", since = "1.36.0")] -#[cfg_attr(not(bootstrap), lang = "Context")] pub struct Context<'a> { waker: &'a Waker, // Ensure we future-proof against variance changes by forcing diff --git a/library/std/src/path.rs b/library/std/src/path.rs index a835b855dddf4..73b5056e93267 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2039,12 +2039,12 @@ impl Path { /// #![feature(path_as_mut_os_str)] /// use std::path::{Path, PathBuf}; /// - /// let mut path = PathBuf::from("/Foo.TXT").into_boxed_path(); + /// let mut path = PathBuf::from("Foo.TXT"); /// - /// assert_ne!(&*path, Path::new("/foo.txt")); + /// assert_ne!(path, Path::new("foo.txt")); /// /// path.as_mut_os_str().make_ascii_lowercase(); - /// assert_eq!(&*path, Path::new("/foo.txt")); + /// assert_eq!(path, Path::new("foo.txt")); /// ``` #[unstable(feature = "path_as_mut_os_str", issue = "105021")] #[must_use] diff --git a/src/doc/nomicon b/src/doc/nomicon index ae406aa5287a9..dd37e21ccee43 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit ae406aa5287a9e025abb72343aaceec98458c117 +Subproject commit dd37e21ccee43918ed18a71581bb2af537ffe4fc diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index a9869b4a3c4ca..995df09b65c58 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit a9869b4a3c4cac3bc6099b41f088679e268400b8 +Subproject commit 995df09b65c582eb6290ab7ea5d9485983eb4c37 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index e269950a57fa6..8b42eb5f57d3d 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit e269950a57fa6fcda356426545fb5aa3691a7ced +Subproject commit 8b42eb5f57d3d8ed2257a22d0e850d9db52afed3 diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 022ed606cc3b8..efb19467c8709 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -322,10 +322,6 @@ main { margin-right: auto; } -.source .width-limiter { - max-width: unset; -} - details:not(.rustdoc-toggle) summary { margin-bottom: .6em; } diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index aa3bf827db4bf..bcaff957af2f6 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -99,7 +99,7 @@

{#- -#} {{- sidebar|safe -}} {#- -#}
{#- -#} -
{#- -#} + {%- if page.css_class != "source" -%}
{%- endif -%} {#- -#}
{{- content|safe -}}
{#- -#} -
{#- -#} + {%- if page.css_class != "source" -%}
{%- endif -%}
{#- -#} {{- layout.external_html.after_content|safe -}}
(_: T) -> ! { LL | | panic!() LL | | } | |_^ - = note: required because it captures the following types: `&mut Context<'_>`, `Option`, `impl Future`, `()` + = note: required because it captures the following types: `ResumeTy`, `Option`, `impl Future`, `()` note: required because it's used within this `async fn` body --> $DIR/async-await-let-else.rs:21:32 | diff --git a/src/test/ui/async-await/issue-68112.drop_tracking.stderr b/src/test/ui/async-await/issue-68112.drop_tracking.stderr index 1c90bedae790c..f2802698fd5b6 100644 --- a/src/test/ui/async-await/issue-68112.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-68112.drop_tracking.stderr @@ -57,7 +57,7 @@ note: required because it appears within the type `impl Future impl Future>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `&mut Context<'_>`, `impl Future>>`, `()`, `Ready` + = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `Ready` note: required because it's used within this `async` block --> $DIR/issue-68112.rs:60:20 | diff --git a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr index e09ae7fedd805..38eb85b302fd5 100644 --- a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr +++ b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr @@ -57,7 +57,7 @@ note: required because it appears within the type `impl Future impl Future>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `&mut Context<'_>`, `impl Future>>`, `()`, `i32`, `Ready` + = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `i32`, `Ready` note: required because it's used within this `async` block --> $DIR/issue-68112.rs:60:20 | diff --git a/src/test/ui/async-await/issue-69446-fnmut-capture.stderr b/src/test/ui/async-await/issue-69446-fnmut-capture.stderr index e6ad2f0d444bb..3d2b0402bc52c 100644 --- a/src/test/ui/async-await/issue-69446-fnmut-capture.stderr +++ b/src/test/ui/async-await/issue-69446-fnmut-capture.stderr @@ -14,9 +14,6 @@ LL | | }); | = note: `FnMut` closures only have access to their captured variables while they are executing... = note: ...therefore, they cannot allow references to captured variables to escape - = note: requirement occurs because of a mutable reference to `Context<'_>` - = note: mutable references are invariant over their type parameter - = help: see for more information about variance error: aborting due to previous error diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index a8fd97cde8f7a..721234aa4a782 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -18,7 +18,7 @@ LL | async fn baz(_c: impl FnMut() -> T) where T: Future { | ___________________________________________________________________^ LL | | } | |_^ - = note: required because it captures the following types: `&mut Context<'_>`, `impl Future`, `()` + = note: required because it captures the following types: `ResumeTy`, `impl Future`, `()` note: required because it's used within this `async` block --> $DIR/issue-70935-complex-spans.rs:16:5 | diff --git a/src/test/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr b/src/test/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr index 25876d5084015..17b4ef7bdc671 100644 --- a/src/test/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr +++ b/src/test/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr @@ -11,7 +11,7 @@ LL | async fn foo() { | = help: within `impl Future`, the trait `Send` is not implemented for `NotSend` = note: required because it appears within the type `(NotSend,)` - = note: required because it captures the following types: `&mut Context<'_>`, `(NotSend,)`, `()`, `impl Future` + = note: required because it captures the following types: `ResumeTy`, `(NotSend,)`, `()`, `impl Future` note: required because it's used within this `async fn` body --> $DIR/partial-drop-partial-reinit.rs:31:16 | diff --git a/src/test/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr b/src/test/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr index dba2a620779f0..34d8a159f1064 100644 --- a/src/test/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr +++ b/src/test/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr @@ -11,7 +11,7 @@ LL | async fn foo() { | = help: within `impl Future`, the trait `Send` is not implemented for `NotSend` = note: required because it appears within the type `(NotSend,)` - = note: required because it captures the following types: `&mut Context<'_>`, `(NotSend,)`, `impl Future`, `()` + = note: required because it captures the following types: `ResumeTy`, `(NotSend,)`, `impl Future`, `()` note: required because it's used within this `async fn` body --> $DIR/partial-drop-partial-reinit.rs:31:16 | diff --git a/src/test/ui/regions/closure-in-projection-issue-97405.rs b/src/test/ui/regions/closure-in-projection-issue-97405.rs index 88b1c1396516d..e567d5c2723f2 100644 --- a/src/test/ui/regions/closure-in-projection-issue-97405.rs +++ b/src/test/ui/regions/closure-in-projection-issue-97405.rs @@ -22,11 +22,11 @@ fn good_generic_fn() { // This should fail because `T` ends up in the upvars of the closure. fn bad_generic_fn(t: T) { assert_static(opaque(async move { t; }).next()); - //~^ ERROR the parameter type `T` may not live long enough + //~^ ERROR the associated type `::Item` may not live long enough assert_static(opaque(move || { t; }).next()); //~^ ERROR the associated type `::Item` may not live long enough assert_static(opaque(opaque(async move { t; }).next()).next()); - //~^ ERROR the parameter type `T` may not live long enough + //~^ ERROR the associated type `::Item` may not live long enough } fn main() {} diff --git a/src/test/ui/regions/closure-in-projection-issue-97405.stderr b/src/test/ui/regions/closure-in-projection-issue-97405.stderr index 907964aaf379e..c08f1059ebf58 100644 --- a/src/test/ui/regions/closure-in-projection-issue-97405.stderr +++ b/src/test/ui/regions/closure-in-projection-issue-97405.stderr @@ -1,13 +1,11 @@ -error[E0310]: the parameter type `T` may not live long enough +error[E0310]: the associated type `::Item` may not live long enough --> $DIR/closure-in-projection-issue-97405.rs:24:5 | LL | assert_static(opaque(async move { t; }).next()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | fn bad_generic_fn(t: T) { - | +++++++++ + = help: consider adding an explicit lifetime bound `::Item: 'static`... + = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0310]: the associated type `::Item` may not live long enough --> $DIR/closure-in-projection-issue-97405.rs:26:5 @@ -18,16 +16,14 @@ LL | assert_static(opaque(move || { t; }).next()); = help: consider adding an explicit lifetime bound `::Item: 'static`... = note: ...so that the type `::Item` will meet its required lifetime bounds -error[E0310]: the parameter type `T` may not live long enough +error[E0310]: the associated type `::Item` may not live long enough --> $DIR/closure-in-projection-issue-97405.rs:28:5 | LL | assert_static(opaque(opaque(async move { t; }).next()).next()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | fn bad_generic_fn(t: T) { - | +++++++++ + = help: consider adding an explicit lifetime bound `::Item: 'static`... + = note: ...so that the type `::Item` will meet its required lifetime bounds error: aborting due to 3 previous errors diff --git a/src/test/ui/svh/changing-crates.stderr b/src/test/ui/svh/changing-crates.stderr index 7244919e86d5d..caefdfc96f038 100644 --- a/src/test/ui/svh/changing-crates.stderr +++ b/src/test/ui/svh/changing-crates.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-lit.stderr b/src/test/ui/svh/svh-change-lit.stderr index 1e97e9d0557d0..5e890c6aa5795 100644 --- a/src/test/ui/svh/svh-change-lit.stderr +++ b/src/test/ui/svh/svh-change-lit.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-significant-cfg.stderr b/src/test/ui/svh/svh-change-significant-cfg.stderr index f04046f4c87bf..dcc250d5216b0 100644 --- a/src/test/ui/svh/svh-change-significant-cfg.stderr +++ b/src/test/ui/svh/svh-change-significant-cfg.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-trait-bound.stderr b/src/test/ui/svh/svh-change-trait-bound.stderr index a778c61806a50..2035993d218ec 100644 --- a/src/test/ui/svh/svh-change-trait-bound.stderr +++ b/src/test/ui/svh/svh-change-trait-bound.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-arg.stderr b/src/test/ui/svh/svh-change-type-arg.stderr index f09babf93fd35..eef85aa954611 100644 --- a/src/test/ui/svh/svh-change-type-arg.stderr +++ b/src/test/ui/svh/svh-change-type-arg.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-ret.stderr b/src/test/ui/svh/svh-change-type-ret.stderr index 0998cd4b5496e..247f74e50df60 100644 --- a/src/test/ui/svh/svh-change-type-ret.stderr +++ b/src/test/ui/svh/svh-change-type-ret.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-static.stderr b/src/test/ui/svh/svh-change-type-static.stderr index 9c48cbd30a508..78b54f227f0f0 100644 --- a/src/test/ui/svh/svh-change-type-static.stderr +++ b/src/test/ui/svh/svh-change-type-static.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-use-trait.stderr b/src/test/ui/svh/svh-use-trait.stderr index 5780cfef357d6..d8a81864dcaa8 100644 --- a/src/test/ui/svh/svh-use-trait.stderr +++ b/src/test/ui/svh/svh-use-trait.stderr @@ -11,3 +11,4 @@ LL | extern crate utb; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/type-alias-impl-trait/auxiliary/coherence_cross_crate_trait_decl.rs b/src/test/ui/type-alias-impl-trait/auxiliary/coherence_cross_crate_trait_decl.rs new file mode 100644 index 0000000000000..712ed55438e68 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/auxiliary/coherence_cross_crate_trait_decl.rs @@ -0,0 +1,9 @@ +pub trait SomeTrait {} + +impl SomeTrait for () {} + +// Adding this `impl` would cause errors in this crate's dependent, +// so it would be a breaking change. We explicitly don't add this impl, +// as the dependent crate already assumes this impl exists and thus already +// does not compile. +//impl SomeTrait for i32 {} diff --git a/src/test/ui/type-alias-impl-trait/coherence_cross_crate.rs b/src/test/ui/type-alias-impl-trait/coherence_cross_crate.rs new file mode 100644 index 0000000000000..a63e0a1ee6f70 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/coherence_cross_crate.rs @@ -0,0 +1,24 @@ +// aux-build: coherence_cross_crate_trait_decl.rs +// This test ensures that adding an `impl SomeTrait for i32` within +// `coherence_cross_crate_trait_decl` is not a breaking change, by +// making sure that even without such an impl this test fails to compile. + +#![feature(type_alias_impl_trait)] + +extern crate coherence_cross_crate_trait_decl; + +use coherence_cross_crate_trait_decl::SomeTrait; + +trait OtherTrait {} + +type Alias = impl SomeTrait; + +fn constrain() -> Alias { + () +} + +impl OtherTrait for Alias {} +impl OtherTrait for i32 {} +//~^ ERROR: conflicting implementations of trait `OtherTrait` for type `Alias` + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/coherence_cross_crate.stderr b/src/test/ui/type-alias-impl-trait/coherence_cross_crate.stderr new file mode 100644 index 0000000000000..63a3ce29cc77b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/coherence_cross_crate.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `OtherTrait` for type `Alias` + --> $DIR/coherence_cross_crate.rs:21:1 + | +LL | impl OtherTrait for Alias {} + | ------------------------- first implementation here +LL | impl OtherTrait for i32 {} + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias` + | + = note: upstream crates may add a new impl of trait `coherence_cross_crate_trait_decl::SomeTrait` for type `i32` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`.