Auto merge of #87347 - GuillaumeGomez:rollup-ke92xxc, r=GuillaumeGomez

Rollup of 9 pull requests

Successful merges:

 - #87187 (Fix NixOS detection)
 - #87206 (avoid temporary vectors/reuse iterators)
 - #87230 (Fix docblock <table> overflow)
 - #87273 (Recognize bounds on impls as const bounds)
 - #87279 (Add comments explaining the unix command-line argument support.)
 - #87301 (Fix typo in compile.rs)
 - #87311 (Get back the more precise suggestion spans of old regionck)
 - #87321 (Add long explanation for E0722)
 - #87342 (Add long explanation for E0757)

Failed merges:

 - #87270 (Don't display <table> in item summary)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-07-21 13:54:22 +00:00
commit 05f2326c05
28 changed files with 184 additions and 61 deletions

View File

@ -72,13 +72,9 @@ impl Path {
) -> ast::Path { ) -> ast::Path {
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect(); let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
let lt = mk_lifetimes(cx, span, &self.lifetime); let lt = mk_lifetimes(cx, span, &self.lifetime);
let tys: Vec<P<ast::Ty>> = let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));
self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect(); let params =
let params = lt lt.into_iter().map(GenericArg::Lifetime).chain(tys.map(GenericArg::Type)).collect();
.into_iter()
.map(GenericArg::Lifetime)
.chain(tys.into_iter().map(GenericArg::Type))
.collect();
match self.kind { match self.kind {
PathKind::Global => cx.path_all(span, true, idents, params), PathKind::Global => cx.path_all(span, true, idents, params),

View File

@ -418,6 +418,7 @@ E0716: include_str!("./error_codes/E0716.md"),
E0718: include_str!("./error_codes/E0718.md"), E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"), E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"), E0720: include_str!("./error_codes/E0720.md"),
E0722: include_str!("./error_codes/E0722.md"),
E0724: include_str!("./error_codes/E0724.md"), E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"), E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"), E0727: include_str!("./error_codes/E0727.md"),
@ -449,6 +450,7 @@ E0753: include_str!("./error_codes/E0753.md"),
E0754: include_str!("./error_codes/E0754.md"), E0754: include_str!("./error_codes/E0754.md"),
E0755: include_str!("./error_codes/E0755.md"), E0755: include_str!("./error_codes/E0755.md"),
E0756: include_str!("./error_codes/E0756.md"), E0756: include_str!("./error_codes/E0756.md"),
E0757: include_str!("./error_codes/E0757.md"),
E0758: include_str!("./error_codes/E0758.md"), E0758: include_str!("./error_codes/E0758.md"),
E0759: include_str!("./error_codes/E0759.md"), E0759: include_str!("./error_codes/E0759.md"),
E0760: include_str!("./error_codes/E0760.md"), E0760: include_str!("./error_codes/E0760.md"),
@ -634,10 +636,8 @@ E0783: include_str!("./error_codes/E0783.md"),
E0711, // a feature has been declared with conflicting stability attributes E0711, // a feature has been declared with conflicting stability attributes
E0717, // rustc_promotable without stability attribute E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword // E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
// E0723, unstable feature in `const` context // E0723, unstable feature in `const` context
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`. // E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]`
E0772, // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`. E0772, // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`.
} }

View File

@ -0,0 +1,31 @@
The `optimize` attribute was malformed.
Erroneous code example:
```compile_fail,E0722
#![feature(optimize_attribute)]
#[optimize(something)] // error: invalid argument
pub fn something() {}
```
The `#[optimize]` attribute should be used as follows:
- `#[optimize(size)]` -- instructs the optimization pipeline to generate code
that's smaller rather than faster
- `#[optimize(speed)]` -- instructs the optimization pipeline to generate code
that's faster rather than smaller
For example:
```
#![feature(optimize_attribute)]
#[optimize(size)]
pub fn something() {}
```
See [RFC 2412] for more details.
[RFC 2412]: https://rust-lang.github.io/rfcs/2412-optimize-attr.html

View File

@ -0,0 +1,33 @@
A function was given both the `ffi_const` and `ffi_pure` attributes.
Erroneous code example:
```compile_fail,E0757
#![feature(ffi_const, ffi_pure)]
extern "C" {
#[ffi_const]
#[ffi_pure] // error: `#[ffi_const]` function cannot be `#[ffi_pure]`
pub fn square(num: i32) -> i32;
}
```
As `ffi_const` provides stronger guarantees than `ffi_pure`, remove the
`ffi_pure` attribute:
```
#![feature(ffi_const)]
extern "C" {
#[ffi_const]
pub fn square(num: i32) -> i32;
}
```
You can get more information about `const` and `pure` in the [GCC documentation
on Common Function Attributes]. The unstable Rust Book has more information
about [`ffi_const`] and [`ffi_pure`].
[GCC documentation on Common Function Attributes]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
[`ffi_const`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-const.html
[`ffi_pure`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-pure.html

View File

@ -3060,6 +3060,27 @@ impl<'hir> Node<'hir> {
Node::Crate(_) | Node::Visibility(_) => None, Node::Crate(_) | Node::Visibility(_) => None,
} }
} }
/// Returns `Constness::Const` when this node is a const fn/impl.
pub fn constness(&self) -> Constness {
match self {
Node::Item(Item {
kind: ItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
..
})
| Node::TraitItem(TraitItem {
kind: TraitItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
..
})
| Node::ImplItem(ImplItem {
kind: ImplItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
..
})
| Node::Item(Item { kind: ItemKind::Impl(Impl { constness, .. }), .. }) => *constness,
_ => Constness::NotConst,
}
}
} }
// Some nodes are used a lot. Make sure they don't unintentionally get bigger. // Some nodes are used a lot. Make sure they don't unintentionally get bigger.

View File

@ -2130,7 +2130,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let new_lt = generics let new_lt = generics
.as_ref() .as_ref()
.and_then(|(parent_g, g)| { .and_then(|(parent_g, g)| {
let possible: Vec<_> = (b'a'..=b'z').map(|c| format!("'{}", c as char)).collect(); let mut possible = (b'a'..=b'z').map(|c| format!("'{}", c as char));
let mut lts_names = g let mut lts_names = g
.params .params
.iter() .iter()
@ -2146,7 +2146,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
); );
} }
let lts = lts_names.iter().map(|s| -> &str { &*s }).collect::<Vec<_>>(); let lts = lts_names.iter().map(|s| -> &str { &*s }).collect::<Vec<_>>();
possible.into_iter().find(|candidate| !lts.contains(&candidate.as_str())) possible.find(|candidate| !lts.contains(&candidate.as_str()))
}) })
.unwrap_or("'lt".to_string()); .unwrap_or("'lt".to_string());
let add_lt_sugg = generics let add_lt_sugg = generics

View File

@ -9,7 +9,7 @@ use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, RegionVid, Ty}; use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{kw, sym};
use rustc_span::Span; use rustc_span::{BytePos, Span};
use crate::util::borrowck_errors; use crate::util::borrowck_errors;
@ -641,12 +641,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} else { } else {
"'_".to_string() "'_".to_string()
}; };
let suggestion = if snippet.ends_with(';') { let span = if snippet.ends_with(';') {
// `type X = impl Trait;` // `type X = impl Trait;`
format!("{} + {};", &snippet[..snippet.len() - 1], suggestable_fr_name) span.with_hi(span.hi() - BytePos(1))
} else { } else {
format!("{} + {}", snippet, suggestable_fr_name) span
}; };
let suggestion = format!(" + {}", suggestable_fr_name);
let span = span.shrink_to_hi();
diag.span_suggestion( diag.span_suggestion(
span, span,
&format!( &format!(

View File

@ -897,16 +897,19 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
permitted = true; permitted = true;
} }
} }
let mut const_impls = true; if !permitted {
tcx.for_each_relevant_impl(trait_id, substs.type_at(0), |imp| { // if trait's impls are all const, permit the call.
if const_impls { let mut const_impls = true;
if let hir::Constness::NotConst = tcx.impl_constness(imp) { tcx.for_each_relevant_impl(trait_id, substs.type_at(0), |imp| {
const_impls = false; if const_impls {
if let hir::Constness::NotConst = tcx.impl_constness(imp) {
const_impls = false;
}
} }
});
if const_impls {
permitted = true;
} }
});
if const_impls {
permitted = true;
} }
} }

View File

@ -15,7 +15,6 @@ use rustc_hir::def_id::DefId;
use rustc_infer::infer; use rustc_infer::infer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; use rustc_infer::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::hir::map::blocks::FnLikeNode;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Const, Ty, TyCtxt}; use rustc_middle::ty::{self, Const, Ty, TyCtxt};
@ -175,13 +174,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
} }
fn default_constness_for_trait_bounds(&self) -> hir::Constness { fn default_constness_for_trait_bounds(&self) -> hir::Constness {
// FIXME: refactor this into a method self.tcx.hir().get(self.body_id).constness()
let node = self.tcx.hir().get(self.body_id);
if let Some(fn_like) = FnLikeNode::from_node(node) {
fn_like.constness()
} else {
hir::Constness::NotConst
}
} }
fn get_type_parameter_bounds( fn get_type_parameter_bounds(

View File

@ -35,7 +35,6 @@ use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::weak_lang_items; use rustc_hir::weak_lang_items;
use rustc_hir::{GenericParamKind, HirId, Node}; use rustc_hir::{GenericParamKind, HirId, Node};
use rustc_middle::hir::map::blocks::FnLikeNode;
use rustc_middle::hir::map::Map; use rustc_middle::hir::map::Map;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::mono::Linkage; use rustc_middle::mir::mono::Linkage;
@ -358,11 +357,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
} }
fn default_constness_for_trait_bounds(&self) -> hir::Constness { fn default_constness_for_trait_bounds(&self) -> hir::Constness {
if let Some(fn_like) = FnLikeNode::from_node(self.node()) { self.node().constness()
fn_like.constness()
} else {
hir::Constness::NotConst
}
} }
fn get_type_parameter_bounds( fn get_type_parameter_bounds(

View File

@ -77,10 +77,18 @@ mod imp {
use crate::ptr; use crate::ptr;
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering}; use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};
// The system-provided argc and argv, which we store in static memory
// here so that we can defer the work of parsing them until its actually
// needed.
//
// Note that we never mutate argv/argc, the argv array, or the argv
// strings, which allows the code in this file to be very simple.
static ARGC: AtomicIsize = AtomicIsize::new(0); static ARGC: AtomicIsize = AtomicIsize::new(0);
static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut()); static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut());
unsafe fn really_init(argc: isize, argv: *const *const u8) { unsafe fn really_init(argc: isize, argv: *const *const u8) {
// These don't need to be ordered with each other or other stores,
// because they only hold the unmodified system-provide argv/argc.
ARGC.store(argc, Ordering::Relaxed); ARGC.store(argc, Ordering::Relaxed);
ARGV.store(argv as *mut _, Ordering::Relaxed); ARGV.store(argv as *mut _, Ordering::Relaxed);
} }
@ -122,8 +130,14 @@ mod imp {
fn clone() -> Vec<OsString> { fn clone() -> Vec<OsString> {
unsafe { unsafe {
// Load ARGC and ARGV without a lock. If the store to either ARGV or // Load ARGC and ARGV, which hold the unmodified system-provided
// ARGC isn't visible yet, we'll return an empty argument list. // argc/argv, so we can read the pointed-to memory without atomics
// or synchronization.
//
// If either ARGC or ARGV is still zero or null, then either there
// really are no arguments, or someone is asking for `args()`
// before initialization has completed, and we return an empty
// list.
let argv = ARGV.load(Ordering::Relaxed); let argv = ARGV.load(Ordering::Relaxed);
let argc = if argv.is_null() { 0 } else { ARGC.load(Ordering::Relaxed) }; let argc = if argv.is_null() { 0 } else { ARGC.load(Ordering::Relaxed) };
(0..argc) (0..argc)

View File

@ -580,7 +580,13 @@ class RustBuild(object):
if ostype != "Linux": if ostype != "Linux":
return return
if not os.path.exists("/etc/NIXOS"): # Use `/etc/os-release` instead of `/etc/NIXOS`.
# The latter one does not exist on NixOS when using tmpfs as root.
try:
with open("/etc/os-release", "r") as f:
if not any(line.strip() == "ID=nixos" for line in f):
return
except FileNotFoundError:
return return
if os.path.exists("/lib"): if os.path.exists("/lib"):
return return

View File

@ -2,7 +2,7 @@
//! library. //! library.
//! //!
//! This module contains some of the real meat in the rustbuild build system //! This module contains some of the real meat in the rustbuild build system
//! which is where Cargo is used to compiler the standard library, libtest, and //! which is where Cargo is used to compile the standard library, libtest, and
//! compiler. This module is also responsible for assembling the sysroot as it //! compiler. This module is also responsible for assembling the sysroot as it
//! goes along from the output of the previous stage. //! goes along from the output of the previous stage.

View File

@ -560,7 +560,8 @@ nav.sub {
.docblock table { .docblock table {
margin: .5em 0; margin: .5em 0;
width: calc(100% - 2px); width: calc(100% - 2px);
border: 1px dashed; overflow-x: auto;
display: block;
} }
.docblock table td { .docblock table td {

View File

@ -140,7 +140,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #5c6773; border-bottom-color: #5c6773;
} }
.docblock table, .docblock table td, .docblock table th { .docblock table td, .docblock table th {
border-color: #5c6773; border-color: #5c6773;
} }

View File

@ -97,7 +97,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #DDD; border-bottom-color: #DDD;
} }
.docblock table, .docblock table td, .docblock table th { .docblock table td, .docblock table th {
border-color: #ddd; border-color: #ddd;
} }

View File

@ -97,7 +97,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #ddd; border-bottom-color: #ddd;
} }
.docblock table, .docblock table td, .docblock table th { .docblock table td, .docblock table th {
border-color: #ddd; border-color: #ddd;
} }

View File

@ -0,0 +1,9 @@
// This test ensures that the type declaration content overflow is handled inside the <pre> directly.
goto: file://|DOC_PATH|/lib2/long_table/struct.Foo.html
// We set a fixed size so there is no chance of "random" resize.
size: (1100, 800)
// Logically, the ".docblock" and the "<p>" should have the same scroll width.
compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["scrollWidth"])
assert-property: (".top-doc .docblock", {"scrollWidth": "816"})
// However, since there is overflow in the <table>, its scroll width is bigger.
assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})

View File

@ -57,3 +57,12 @@ pub mod long_trait {
pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem: DerefMut<Target = u32> pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem: DerefMut<Target = u32>
+ From<u128> + Send + Sync + AsRef<str> + 'static {} + From<u128> + Send + Sync + AsRef<str> + 'static {}
} }
pub mod long_table {
/// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two |
/// | ----------- | ----------- | ----------- | ----------- |
/// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two |
///
/// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq
pub struct Foo;
}

View File

@ -1,7 +0,0 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

View File

@ -51,4 +51,5 @@ LL | #[optimize(banana)]
error: aborting due to 6 previous errors error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0658`. Some errors have detailed explanations: E0658, E0722.
For more information about an error, try `rustc --explain E0658`.

View File

@ -6,3 +6,4 @@ LL | #[ffi_pure]
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0757`.

View File

@ -9,7 +9,7 @@ LL | fn elided(x: &i32) -> impl Copy { x }
help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
| |
LL | fn elided(x: &i32) -> impl Copy + '_ { x } LL | fn elided(x: &i32) -> impl Copy + '_ { x }
| ^^^^^^^^^^^^^^ | ^^^^
error: lifetime may not live long enough error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:5:32 --> $DIR/must_outlive_least_region_or_bound.rs:5:32
@ -23,7 +23,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound
| |
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
| ^^^^^^^^^^^^^^ | ^^^^
error: lifetime may not live long enough error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:7:46 --> $DIR/must_outlive_least_region_or_bound.rs:7:46

View File

@ -9,7 +9,7 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
| |
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^
error: lifetime may not live long enough error: lifetime may not live long enough
--> $DIR/static-return-lifetime-infered.rs:9:37 --> $DIR/static-return-lifetime-infered.rs:9:37
@ -23,7 +23,7 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound
| |
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -0,0 +1,15 @@
// check-pass
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
trait MyPartialEq {
fn eq(&self, other: &Self) -> bool;
}
impl<T: PartialEq> const MyPartialEq for T {
fn eq(&self, other: &Self) -> bool {
PartialEq::eq(self, other)
}
}
fn main() {}

View File

@ -9,7 +9,7 @@ LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
| |
LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self } LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self }
| ^^^^^^^^^^^^^^^ | ^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -9,7 +9,7 @@ LL | fn f(self: Pin<&Self>) -> impl Clone { self }
help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
| |
LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self } LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self }
| ^^^^^^^^^^^^^^^ | ^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -9,7 +9,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
| |
LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^
error: lifetime may not live long enough error: lifetime may not live long enough
--> $DIR/trait-object-nested-in-impl-trait.rs:39:9 --> $DIR/trait-object-nested-in-impl-trait.rs:39:9
@ -47,7 +47,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound
| |
LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^
error: aborting due to 4 previous errors error: aborting due to 4 previous errors