Auto merge of #82577 - Dylan-DPC:rollup-c3si8ju, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #81794 (update tracking issue for `relaxed_struct_unsize`)
 - #82057 (Replace const_cstr with cstr crate)
 - #82370 (Improve anonymous lifetime note to indicate the target span)
 - #82394 (⬆️ rust-analyzer)
 - #82396 (Add Future trait for doc_spotlight feature doc)
 - #82404 (Test hexagon-enum only when llvm target is present)
 - #82419 (expand: Preserve order of inert attributes during expansion)
 - #82420 (Enable API documentation for `std::os::wasi`.)
 - #82421 (Add a `size()` function to WASI's `MetadataExt`.)
 - #82442 (Skip emitting closure diagnostic when closure_kind_origins has no entry)
 - #82473 (Use libc::accept4 on Android instead of raw syscall.)
 - #82482 (Use small hash set in `mir_inliner_callees`)
 - #82490 (Update cargo)
 - #82494 (Substitute erased lifetimes on bad placeholder type)

Failed merges:

 - #82448 (Combine HasAttrs and HasTokens into AstLike)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-02-27 02:18:11 +00:00
commit 9fa580b117
61 changed files with 568 additions and 374 deletions

View File

@ -904,6 +904,16 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "cstr"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "ctor"
version = "0.1.15"
@ -3698,6 +3708,7 @@ name = "rustc_codegen_llvm"
version = "0.0.0"
dependencies = [
"bitflags",
"cstr",
"libc",
"measureme",
"rustc-demangle",

View File

@ -10,6 +10,7 @@ doctest = false
[dependencies]
bitflags = "1.0"
cstr = "0.2"
libc = "0.2"
measureme = "9.0.0"
snap = "1"

View File

@ -554,7 +554,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
llvm::AddCallSiteAttrString(
callsite,
llvm::AttributePlace::Function,
rustc_data_structures::const_cstr!("cmse_nonsecure_call"),
cstr::cstr!("cmse_nonsecure_call"),
);
}
}

View File

@ -2,8 +2,8 @@
use std::ffi::CString;
use cstr::cstr;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
@ -75,8 +75,8 @@ pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value)
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("frame-pointer"),
const_cstr!("all"),
cstr!("frame-pointer"),
cstr!("all"),
);
}
}
@ -95,7 +95,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("instrument-function-entry-inlined"),
cstr!("instrument-function-entry-inlined"),
&mcount_name,
);
}
@ -129,16 +129,16 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
StackProbeType::None => None,
// Request LLVM to generate the probes inline. If the given LLVM version does not support
// this, no probe is generated at all (even if the attribute is specified).
StackProbeType::Inline => Some(const_cstr!("inline-asm")),
StackProbeType::Inline => Some(cstr!("inline-asm")),
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
StackProbeType::Call => Some(const_cstr!("__rust_probestack")),
StackProbeType::Call => Some(cstr!("__rust_probestack")),
// Pick from the two above based on the LLVM version.
StackProbeType::InlineOrCall { min_llvm_version_for_inline } => {
if llvm_util::get_version() < min_llvm_version_for_inline {
Some(const_cstr!("__rust_probestack"))
Some(cstr!("__rust_probestack"))
} else {
Some(const_cstr!("inline-asm"))
Some(cstr!("inline-asm"))
}
}
};
@ -146,7 +146,7 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("probe-stack"),
cstr!("probe-stack"),
attr_value,
);
}
@ -169,7 +169,7 @@ pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("target-cpu"),
cstr!("target-cpu"),
target_cpu.as_c_str(),
);
}
@ -180,7 +180,7 @@ pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("tune-cpu"),
cstr!("tune-cpu"),
tune_cpu.as_c_str(),
);
}
@ -289,7 +289,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
Attribute::NoAlias.apply_llfn(llvm::AttributePlace::ReturnValue, llfn);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
llvm::AddFunctionAttrString(llfn, Function, const_cstr!("cmse_nonsecure_entry"));
llvm::AddFunctionAttrString(llfn, Function, cstr!("cmse_nonsecure_entry"));
}
sanitize(cx, codegen_fn_attrs.no_sanitize, llfn);
@ -319,7 +319,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("target-features"),
cstr!("target-features"),
&val,
);
}
@ -332,7 +332,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("wasm-import-module"),
cstr!("wasm-import-module"),
&module,
);
@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("wasm-import-name"),
cstr!("wasm-import-name"),
&name,
);
}

View File

@ -5,13 +5,13 @@ use crate::llvm::{AtomicOrdering, AtomicRmwBinOp, SynchronizationScope};
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use cstr::cstr;
use libc::{c_char, c_uint};
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, TypeKind};
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::MemFlags;
use rustc_data_structures::const_cstr;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::layout::TyAndLayout;
@ -979,7 +979,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
let name = const_cstr!("cleanuppad");
let name = cstr!("cleanuppad");
let ret = unsafe {
llvm::LLVMRustBuildCleanupPad(
self.llbuilder,
@ -1003,7 +1003,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
let name = const_cstr!("catchpad");
let name = cstr!("catchpad");
let ret = unsafe {
llvm::LLVMRustBuildCatchPad(
self.llbuilder,
@ -1022,7 +1022,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
unwind: Option<&'ll BasicBlock>,
num_handlers: usize,
) -> &'ll Value {
let name = const_cstr!("catchswitch");
let name = cstr!("catchswitch");
let ret = unsafe {
llvm::LLVMRustBuildCatchSwitch(
self.llbuilder,

View File

@ -5,9 +5,9 @@ use crate::llvm::{self, True};
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use cstr::cstr;
use libc::c_uint;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_hir::def_id::DefId;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
@ -419,9 +419,9 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
.all(|&byte| byte == 0);
let sect_name = if all_bytes_are_zero {
const_cstr!("__DATA,__thread_bss")
cstr!("__DATA,__thread_bss")
} else {
const_cstr!("__DATA,__thread_data")
cstr!("__DATA,__thread_data")
};
llvm::LLVMSetSection(g, sect_name.as_ptr());
}

View File

@ -7,10 +7,10 @@ use crate::llvm_util;
use crate::type_::Type;
use crate::value::Value;
use cstr::cstr;
use rustc_codegen_ssa::base::wants_msvc_seh;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::base_n;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_middle::bug;
@ -414,8 +414,8 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
fn create_used_variable(&self) {
let name = const_cstr!("llvm.used");
let section = const_cstr!("llvm.metadata");
let name = cstr!("llvm.used");
let section = cstr!("llvm.metadata");
let array =
self.const_array(&self.type_ptr_to(self.type_i8()), &*self.used_statics.borrow());

View File

@ -18,8 +18,8 @@ use crate::llvm::debuginfo::{
};
use crate::value::Value;
use cstr::cstr;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@ -1075,7 +1075,7 @@ pub fn compile_unit_metadata(
gcov_cu_info.len() as c_uint,
);
let llvm_gcov_ident = const_cstr!("llvm.gcov");
let llvm_gcov_ident = cstr!("llvm.gcov");
llvm::LLVMAddNamedMetadataOperand(
debug_context.llmod,
llvm_gcov_ident.as_ptr(),
@ -1093,7 +1093,7 @@ pub fn compile_unit_metadata(
);
llvm::LLVMAddNamedMetadataOperand(
debug_context.llmod,
const_cstr!("llvm.ident").as_ptr(),
cstr!("llvm.ident").as_ptr(),
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
);
}

View File

@ -1,30 +0,0 @@
/// This macro creates a zero-overhead &CStr by adding a NUL terminator to
/// the string literal passed into it at compile-time. Use it like:
///
/// ```
/// let some_const_cstr = const_cstr!("abc");
/// ```
///
/// The above is roughly equivalent to:
///
/// ```
/// let some_const_cstr = CStr::from_bytes_with_nul(b"abc\0").unwrap()
/// ```
///
/// Note that macro only checks the string literal for internal NULs if
/// debug-assertions are enabled in order to avoid runtime overhead in release
/// builds.
#[macro_export]
macro_rules! const_cstr {
($s:expr) => {{
use std::ffi::CStr;
let str_plus_nul = concat!($s, "\0");
if cfg!(debug_assertions) {
CStr::from_bytes_with_nul(str_plus_nul.as_bytes()).unwrap()
} else {
unsafe { CStr::from_bytes_with_nul_unchecked(str_plus_nul.as_bytes()) }
}
}};
}

View File

@ -69,7 +69,6 @@ pub mod base_n;
pub mod binary_search_util;
pub mod box_region;
pub mod captures;
pub mod const_cstr;
pub mod flock;
pub mod functor;
pub mod fx;

View File

@ -301,6 +301,8 @@ pub enum InvocationKind {
},
Attr {
attr: ast::Attribute,
// Re-insertion position for inert attributes.
pos: usize,
item: Annotatable,
// Required for resolving derive helper attributes.
derives: Vec<Path>,
@ -690,7 +692,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
_ => unreachable!(),
},
InvocationKind::Attr { attr, mut item, derives } => match ext {
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
SyntaxExtensionKind::Attr(expander) => {
self.gate_proc_macro_input(&item);
self.gate_proc_macro_attr_item(span, &item);
@ -721,7 +723,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
ExpandResult::Retry(item) => {
// Reassemble the original invocation for retrying.
return ExpandResult::Retry(Invocation {
kind: InvocationKind::Attr { attr, item, derives },
kind: InvocationKind::Attr { attr, pos, item, derives },
..invoc
});
}
@ -739,7 +741,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
if *mark_used {
self.cx.sess.mark_attr_used(&attr);
}
item.visit_attrs(|attrs| attrs.push(attr));
item.visit_attrs(|attrs| attrs.insert(pos, attr));
fragment_kind.expect_from_annotatables(iter::once(item))
}
_ => unreachable!(),
@ -1000,17 +1002,20 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
fn collect_attr(
&mut self,
(attr, derives): (ast::Attribute, Vec<Path>),
(attr, pos, derives): (ast::Attribute, usize, Vec<Path>),
item: Annotatable,
kind: AstFragmentKind,
) -> AstFragment {
self.collect(kind, InvocationKind::Attr { attr, item, derives })
self.collect(kind, InvocationKind::Attr { attr, pos, item, derives })
}
/// If `item` is an attribute invocation, remove the attribute and return it together with
/// derives following it. We have to collect the derives in order to resolve legacy derive
/// helpers (helpers written before derives that introduce them).
fn take_first_attr(&mut self, item: &mut impl HasAttrs) -> Option<(ast::Attribute, Vec<Path>)> {
/// its position and derives following it. We have to collect the derives in order to resolve
/// legacy derive helpers (helpers written before derives that introduce them).
fn take_first_attr(
&mut self,
item: &mut impl HasAttrs,
) -> Option<(ast::Attribute, usize, Vec<Path>)> {
let mut attr = None;
item.visit_attrs(|attrs| {
@ -1033,7 +1038,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
})
.collect();
(attr, following_derives)
(attr, attr_pos, following_derives)
})
});

View File

@ -633,7 +633,7 @@ declare_features! (
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
/// Lessens the requirements for structs to implement `Unsize`.
(active, relaxed_struct_unsize, "1.51.0", Some(1), None),
(active, relaxed_struct_unsize, "1.51.0", Some(81793), None),
/// Allows macro attributes to observe output of `#[derive]`.
(active, macro_attributes_in_derive_output, "1.51.0", Some(81119), None),

View File

@ -50,6 +50,7 @@ use super::region_constraints::GenericKind;
use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs};
use crate::infer;
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
use crate::traits::error_reporting::report_object_safety_error;
use crate::traits::{
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
@ -179,7 +180,14 @@ fn msg_span_from_early_bound_and_free_regions(
}
ty::ReFree(ref fr) => match fr.bound_region {
ty::BrAnon(idx) => {
(format!("the anonymous lifetime #{} defined on", idx + 1), tcx.hir().span(node))
if let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region) {
("the anonymous lifetime defined on".to_string(), ty.span)
} else {
(
format!("the anonymous lifetime #{} defined on", idx + 1),
tcx.hir().span(node),
)
}
}
_ => (
format!("the lifetime `{}` as defined on", region),

View File

@ -1,6 +1,7 @@
//! Error Reporting for Anonymous Region Lifetime Errors
//! where both the regions are anonymous.
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError;
@ -66,9 +67,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let scope_def_id_sub = anon_reg_sub.def_id;
let bregion_sub = anon_reg_sub.boundregion;
let ty_sup = self.find_anon_type(sup, &bregion_sup)?;
let ty_sup = find_anon_type(self.tcx(), sup, &bregion_sup)?;
let ty_sub = self.find_anon_type(sub, &bregion_sub)?;
let ty_sub = find_anon_type(self.tcx(), sub, &bregion_sub)?;
debug!(
"try_report_anon_anon_conflict: found_param1={:?} sup={:?} br1={:?}",

View File

@ -1,4 +1,3 @@
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_hir as hir;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::Node;
@ -6,69 +5,66 @@ use rustc_middle::hir::map::Map;
use rustc_middle::middle::resolve_lifetime as rl;
use rustc_middle::ty::{self, Region, TyCtxt};
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// This function calls the `visit_ty` method for the parameters
/// corresponding to the anonymous regions. The `nested_visitor.found_type`
/// contains the anonymous type.
///
/// # Arguments
/// region - the anonymous region corresponding to the anon_anon conflict
/// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
///
/// # Example
/// ```
/// fn foo(x: &mut Vec<&u8>, y: &u8)
/// { x.push(y); }
/// ```
/// The function returns the nested type corresponding to the anonymous region
/// for e.g., `&u8` and Vec<`&u8`.
pub(super) fn find_anon_type(
&self,
region: Region<'tcx>,
br: &ty::BoundRegionKind,
) -> Option<(&hir::Ty<'tcx>, &hir::FnDecl<'tcx>)> {
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
let fndecl = match self.tcx().hir().get(hir_id) {
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
| Node::TraitItem(&hir::TraitItem {
kind: hir::TraitItemKind::Fn(ref m, ..),
..
})
| Node::ImplItem(&hir::ImplItem {
kind: hir::ImplItemKind::Fn(ref m, ..), ..
}) => &m.decl,
_ => return None,
};
fndecl
.inputs
.iter()
.find_map(|arg| self.find_component_for_bound_region(arg, br))
.map(|ty| (ty, &**fndecl))
} else {
None
}
}
// This method creates a FindNestedTypeVisitor which returns the type corresponding
// to the anonymous region.
fn find_component_for_bound_region(
&self,
arg: &'tcx hir::Ty<'tcx>,
br: &ty::BoundRegionKind,
) -> Option<&'tcx hir::Ty<'tcx>> {
let mut nested_visitor = FindNestedTypeVisitor {
tcx: self.tcx(),
bound_region: *br,
found_type: None,
current_index: ty::INNERMOST,
/// This function calls the `visit_ty` method for the parameters
/// corresponding to the anonymous regions. The `nested_visitor.found_type`
/// contains the anonymous type.
///
/// # Arguments
/// region - the anonymous region corresponding to the anon_anon conflict
/// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
///
/// # Example
/// ```
/// fn foo(x: &mut Vec<&u8>, y: &u8)
/// { x.push(y); }
/// ```
/// The function returns the nested type corresponding to the anonymous region
/// for e.g., `&u8` and Vec<`&u8`.
pub(crate) fn find_anon_type(
tcx: TyCtxt<'tcx>,
region: Region<'tcx>,
br: &ty::BoundRegionKind,
) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnDecl<'tcx>)> {
if let Some(anon_reg) = tcx.is_suitable_region(region) {
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
let fndecl = match tcx.hir().get(hir_id) {
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
| Node::TraitItem(&hir::TraitItem {
kind: hir::TraitItemKind::Fn(ref m, ..), ..
})
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(ref m, ..), .. }) => {
&m.decl
}
_ => return None,
};
nested_visitor.visit_ty(arg);
nested_visitor.found_type
fndecl
.inputs
.iter()
.find_map(|arg| find_component_for_bound_region(tcx, arg, br))
.map(|ty| (ty, &**fndecl))
} else {
None
}
}
// This method creates a FindNestedTypeVisitor which returns the type corresponding
// to the anonymous region.
fn find_component_for_bound_region(
tcx: TyCtxt<'tcx>,
arg: &'tcx hir::Ty<'tcx>,
br: &ty::BoundRegionKind,
) -> Option<&'tcx hir::Ty<'tcx>> {
let mut nested_visitor = FindNestedTypeVisitor {
tcx,
bound_region: *br,
found_type: None,
current_index: ty::INNERMOST,
};
nested_visitor.visit_ty(arg);
nested_visitor.found_type
}
// The FindNestedTypeVisitor captures the corresponding `hir::Ty` of the
// anonymous region. The example above would lead to a conflict between
// the two anonymous lifetimes for &u8 in x and y respectively. This visitor

View File

@ -6,7 +6,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_span::source_map::Span;
mod different_lifetimes;
mod find_anon_type;
pub mod find_anon_type;
mod named_anon_conflict;
mod placeholder_error;
mod static_impl_trait;

View File

@ -1,5 +1,6 @@
//! Error Reporting for Anonymous Region Lifetime Errors
//! where one region is named and the other is anonymous.
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir::intravisit::Visitor;
@ -74,7 +75,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
return None;
}
if let Some((_, fndecl)) = self.find_anon_type(anon, &br) {
if let Some((_, fndecl)) = find_anon_type(self.tcx(), anon, &br) {
if self.is_self_anon(is_first, scope_def_id) {
return None;
}

View File

@ -513,32 +513,33 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let id = id.expect_local();
let tables = tcx.typeck(id);
let hir_id = tcx.hir().local_def_id_to_hir_id(id);
let (span, place) = &tables.closure_kind_origins()[hir_id];
let reason = if let PlaceBase::Upvar(upvar_id) = place.base {
let upvar = ty::place_to_string_for_capture(tcx, place);
match tables.upvar_capture(upvar_id) {
ty::UpvarCapture::ByRef(ty::UpvarBorrow {
kind: ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow,
..
}) => {
format!("mutable borrow of `{}`", upvar)
if let Some((span, place)) = tables.closure_kind_origins().get(hir_id) {
let reason = if let PlaceBase::Upvar(upvar_id) = place.base {
let upvar = ty::place_to_string_for_capture(tcx, place);
match tables.upvar_capture(upvar_id) {
ty::UpvarCapture::ByRef(ty::UpvarBorrow {
kind: ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow,
..
}) => {
format!("mutable borrow of `{}`", upvar)
}
ty::UpvarCapture::ByValue(_) => {
format!("possible mutation of `{}`", upvar)
}
val => bug!("upvar `{}` borrowed, but not mutably: {:?}", upvar, val),
}
ty::UpvarCapture::ByValue(_) => {
format!("possible mutation of `{}`", upvar)
}
val => bug!("upvar `{}` borrowed, but not mutably: {:?}", upvar, val),
}
} else {
bug!("not an upvar")
};
err.span_label(
*span,
format!(
"calling `{}` requires mutable binding due to {}",
self.describe_place(the_place_err).unwrap(),
reason
),
);
} else {
bug!("not an upvar")
};
err.span_label(
*span,
format!(
"calling `{}` requires mutable binding due to {}",
self.describe_place(the_place_err).unwrap(),
reason
),
);
}
}
// Attempt to search similar mutable associated items for suggestion.

View File

@ -1,4 +1,5 @@
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::mir::TerminatorKind;
@ -140,7 +141,7 @@ crate fn mir_inliner_callees<'tcx>(
// Functions from other crates and MIR shims
_ => tcx.instance_mir(instance),
};
let mut calls = Vec::new();
let mut calls = SsoHashSet::new();
for bb_data in body.basic_blocks() {
let terminator = bb_data.terminator();
if let TerminatorKind::Call { func, .. } = &terminator.kind {
@ -149,12 +150,8 @@ crate fn mir_inliner_callees<'tcx>(
ty::FnDef(def_id, substs) => (*def_id, *substs),
_ => continue,
};
// We've seen this before
if calls.contains(&call) {
continue;
}
calls.push(call);
calls.insert(call);
}
}
tcx.arena.alloc_slice(&calls)
tcx.arena.alloc_from_iter(calls.iter().copied())
}

View File

@ -371,6 +371,11 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
span: Span,
) -> &'tcx Const<'tcx> {
bad_placeholder_type(self.tcx(), vec![span]).emit();
// Typeck doesn't expect erased regions to be returned from `type_of`.
let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match r {
ty::ReErased => self.tcx.lifetimes.re_static,
_ => r,
});
self.tcx().const_error(ty)
}
@ -1647,6 +1652,12 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
match get_infer_ret_ty(&sig.decl.output) {
Some(ty) => {
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
// Typeck doesn't expect erased regions to be returned from `type_of`.
let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match r {
ty::ReErased => tcx.lifetimes.re_static,
_ => r,
});
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_ty(ty);
let mut diag = bad_placeholder_type(tcx, visitor.0);
@ -1675,6 +1686,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
}
}
diag.emit();
ty::Binder::bind(fn_sig)
}
None => AstConv::ty_of_fn(

View File

@ -16,7 +16,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
libc = { version = "0.2.79", default-features = false, features = ['rustc-dep-of-std'] }
libc = { version = "0.2.85", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.39" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }

View File

@ -3,7 +3,7 @@
#![stable(feature = "os", since = "1.0.0")]
#![allow(missing_docs, nonstandard_style, missing_debug_implementations)]
// When documenting libstd we want to show unix/windows/linux modules as these are the "main
// When documenting libstd we want to show unix/windows/linux/wasi modules as these are the "main
// modules" that are used across platforms, so all modules are enabled when `cfg(doc)` is set.
// This should help show platform-specific functionality in a hopefully cross-platform way in the
// documentation.
@ -22,6 +22,9 @@ pub use crate::sys::windows_ext as windows;
#[doc(cfg(target_os = "linux"))]
pub mod linux;
#[cfg(doc)]
pub use crate::sys::wasi_ext as wasi;
// If we're not documenting libstd then we just expose the main modules as we otherwise would.
#[cfg(not(doc))]
@ -38,6 +41,10 @@ pub use crate::sys::ext as windows;
#[cfg(any(target_os = "linux", target_os = "l4re"))]
pub mod linux;
#[cfg(not(doc))]
#[cfg(target_os = "wasi")]
pub mod wasi;
#[cfg(target_os = "android")]
pub mod android;
#[cfg(target_os = "dragonfly")]
@ -68,7 +75,5 @@ pub mod redox;
pub mod solaris;
#[cfg(target_os = "vxworks")]
pub mod vxworks;
#[cfg(target_os = "wasi")]
pub mod wasi;
pub mod raw;

View File

@ -61,9 +61,9 @@ cfg_if::cfg_if! {
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::ext as unix_ext;
} else if #[cfg(any(target_os = "hermit",
target_arch = "wasm32",
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")))] {
// On wasm right now the module below doesn't compile
// On non-WASI wasm right now the module below doesn't compile
// (missing things in `libc` which is empty) so just omit everything
// with an empty module
#[unstable(issue = "none", feature = "std_internals")]
@ -85,9 +85,9 @@ cfg_if::cfg_if! {
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::ext as windows_ext;
} else if #[cfg(any(target_os = "hermit",
target_arch = "wasm32",
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")))] {
// On wasm right now the shim below doesn't compile, so
// On non-WASI wasm right now the shim below doesn't compile, so
// just omit it
#[unstable(issue = "none", feature = "std_internals")]
#[allow(missing_docs)]
@ -106,3 +106,25 @@ cfg_if::cfg_if! {
pub mod windows_ext;
}
}
#[cfg(doc)]
cfg_if::cfg_if! {
if #[cfg(target_os = "wasi")] {
// On WASI we'll document what's already available
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::ext as wasi_ext;
} else if #[cfg(any(target_os = "hermit",
target_arch = "wasm32",
all(target_vendor = "fortanix", target_env = "sgx")))] {
// On non-WASI wasm right now the module below doesn't compile
// (missing things in `libc` which is empty) so just omit everything
// with an empty module
#[unstable(issue = "none", feature = "std_internals")]
#[allow(missing_docs)]
pub mod wasi_ext {}
} else {
// On other platforms like Windows document the bare bones of WASI
#[path = "wasi/ext/mod.rs"]
pub mod wasi_ext;
}
}

View File

@ -195,6 +195,7 @@ impl Socket {
// glibc 2.10 and musl 0.9.5.
cfg_if::cfg_if! {
if #[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
@ -206,13 +207,6 @@ impl Socket {
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
})?;
Ok(Socket(FileDesc::new(fd)))
// While the Android kernel supports the syscall,
// it is not included in all versions of Android's libc.
} else if #[cfg(target_os = "android")] {
let fd = cvt_r(|| unsafe {
libc::syscall(libc::SYS_accept4, self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
})?;
Ok(Socket(FileDesc::new(fd as c_int)))
} else {
let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
let fd = FileDesc::new(fd);

View File

@ -3,11 +3,14 @@
#![deny(unsafe_op_in_unsafe_fn)]
#![unstable(feature = "wasi_ext", issue = "none")]
use crate::ffi::OsStr;
use crate::fs::{self, File, Metadata, OpenOptions};
use crate::io::{self, IoSlice, IoSliceMut};
use crate::path::{Path, PathBuf};
use crate::sys::fs::osstr2str;
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
// Used for `File::read` on intra-doc links
#[allow(unused_imports)]
use io::{Read, Write};
/// WASI-specific extensions to [`File`].
pub trait FileExt {
@ -54,11 +57,11 @@ pub trait FileExt {
/// # Errors
///
/// If this function encounters an error of the kind
/// [`ErrorKind::Interrupted`] then the error is ignored and the operation
/// [`io::ErrorKind::Interrupted`] then the error is ignored and the operation
/// will continue.
///
/// If this function encounters an "end of file" before completely filling
/// the buffer, it returns an error of the kind [`ErrorKind::UnexpectedEof`].
/// the buffer, it returns an error of the kind [`io::ErrorKind::UnexpectedEof`].
/// The contents of `buf` are unspecified in this case.
///
/// If any other read error is encountered then this function immediately
@ -131,16 +134,16 @@ pub trait FileExt {
/// The current file cursor is not affected by this function.
///
/// This method will continuously call [`write_at`] until there is no more data
/// to be written or an error of non-[`ErrorKind::Interrupted`] kind is
/// to be written or an error of non-[`io::ErrorKind::Interrupted`] kind is
/// returned. This method will not return until the entire buffer has been
/// successfully written or such an error occurs. The first error that is
/// not of [`ErrorKind::Interrupted`] kind generated from this method will be
/// not of [`io::ErrorKind::Interrupted`] kind generated from this method will be
/// returned.
///
/// # Errors
///
/// This function will return the first error of
/// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns.
/// non-[`io::ErrorKind::Interrupted`] kind that [`write_at`] returns.
///
/// [`write_at`]: FileExt::write_at
#[stable(feature = "rw_exact_all_at", since = "1.33.0")]
@ -397,6 +400,8 @@ pub trait MetadataExt {
fn ino(&self) -> u64;
/// Returns the `st_nlink` field of the internal `filestat_t`
fn nlink(&self) -> u64;
/// Returns the `st_size` field of the internal `filestat_t`
fn size(&self) -> u64;
/// Returns the `st_atim` field of the internal `filestat_t`
fn atim(&self) -> u64;
/// Returns the `st_mtim` field of the internal `filestat_t`
@ -415,6 +420,9 @@ impl MetadataExt for fs::Metadata {
fn nlink(&self) -> u64 {
self.as_inner().as_wasi().nlink
}
fn size(&self) -> u64 {
self.as_inner().as_wasi().size
}
fn atim(&self) -> u64 {
self.as_inner().as_wasi().atim
}
@ -426,7 +434,7 @@ impl MetadataExt for fs::Metadata {
}
}
/// WASI-specific extensions for [`FileType`].
/// WASI-specific extensions for [`fs::FileType`].
///
/// Adds support for special WASI file types such as block/character devices,
/// pipes, and sockets.
@ -517,8 +525,12 @@ pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>(
/// Create a symbolic link.
///
/// This is a convenience API similar to [`std::os::unix::fs::symlink`] and
/// [`std::os::windows::fs::symlink_file`] and [`symlink_dir`](std::os::windows::fs::symlink_dir).
/// This is a convenience API similar to `std::os::unix::fs::symlink` and
/// `std::os::windows::fs::symlink_file` and `std::os::windows::fs::symlink_dir`.
pub fn symlink_path<P: AsRef<Path>, U: AsRef<Path>>(old_path: P, new_path: U) -> io::Result<()> {
crate::sys::fs::symlink(old_path.as_ref(), new_path.as_ref())
}
fn osstr2str(f: &OsStr) -> io::Result<&str> {
f.to_str().ok_or_else(|| io::Error::new(io::ErrorKind::Other, "input must be utf-8"))
}

View File

@ -145,36 +145,36 @@ impl IntoRawFd for fs::File {
impl AsRawFd for io::Stdin {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdin.as_raw_fd()
libc::STDIN_FILENO as RawFd
}
}
impl AsRawFd for io::Stdout {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdout.as_raw_fd()
libc::STDOUT_FILENO as RawFd
}
}
impl AsRawFd for io::Stderr {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stderr.as_raw_fd()
libc::STDERR_FILENO as RawFd
}
}
impl<'a> AsRawFd for io::StdinLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdin.as_raw_fd()
libc::STDIN_FILENO as RawFd
}
}
impl<'a> AsRawFd for io::StdoutLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdout.as_raw_fd()
libc::STDOUT_FILENO as RawFd
}
}
impl<'a> AsRawFd for io::StderrLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stderr.as_raw_fd()
libc::STDERR_FILENO as RawFd
}
}

View File

@ -1,4 +1,32 @@
//! Platform-specific extensions to `std` for WASI.
//!
//! Provides access to platform-level information on WASI, and exposes
//! WASI-specific functions that would otherwise be inappropriate as
//! part of the core `std` library.
//!
//! It exposes more ways to deal with platform-specific strings (`OsStr`,
//! `OsString`), allows to set permissions more granularly, extract low-level
//! file descriptors from files and sockets, and has platform-specific helpers
//! for spawning processes.
//!
//! # Examples
//!
//! ```no_run
//! use std::fs::File;
//! use std::os::wasi::prelude::*;
//!
//! fn main() -> std::io::Result<()> {
//! let f = File::create("foo.txt")?;
//! let fd = f.as_raw_fd();
//!
//! // use fd with native WASI bindings
//!
//! Ok(())
//! }
//! ```
#![deny(unsafe_op_in_unsafe_fn)]
#![doc(cfg(target_os = "wasi"))]
pub mod ffi;
pub mod fs;
@ -11,14 +39,14 @@ pub mod io;
pub mod prelude {
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext::ffi::{OsStrExt, OsStringExt};
pub use super::ffi::{OsStrExt, OsStringExt};
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext::fs::FileTypeExt;
pub use super::fs::FileTypeExt;
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext::fs::{DirEntryExt, FileExt, MetadataExt, OpenOptionsExt};
pub use super::fs::{DirEntryExt, FileExt, MetadataExt, OpenOptionsExt};
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys::ext::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
}

View File

@ -1,5 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]
use super::fd::WasiFd;
use crate::ffi::{CStr, CString, OsStr, OsString};
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut, SeekFrom};
@ -9,7 +10,6 @@ use crate::os::wasi::ffi::{OsStrExt, OsStringExt};
use crate::path::{Path, PathBuf};
use crate::ptr;
use crate::sync::Arc;
use crate::sys::fd::WasiFd;
use crate::sys::time::SystemTime;
use crate::sys::unsupported;
use crate::sys_common::FromInner;

View File

@ -1,10 +1,10 @@
#![deny(unsafe_op_in_unsafe_fn)]
use super::fd::WasiFd;
use crate::convert::TryFrom;
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
use crate::sys::fd::WasiFd;
use crate::sys::{unsupported, Void};
use crate::sys_common::FromInner;
use crate::time::Duration;

View File

@ -1,8 +1,8 @@
#![deny(unsafe_op_in_unsafe_fn)]
use super::fd::WasiFd;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::mem::ManuallyDrop;
use crate::sys::fd::WasiFd;
pub struct Stdin;
pub struct Stdout;

View File

@ -5,8 +5,8 @@ The tracking issue for this feature is: [#45040]
The `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute,
to "spotlight" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]`
attribute to a trait definition will make rustdoc print extra information for functions which return
a type that implements that trait. This attribute is applied to the `Iterator`, `io::Read`, and
`io::Write` traits in the standard library.
a type that implements that trait. For example, this attribute is applied to the `Iterator`,
`io::Read`, `io::Write`, and `Future` traits in the standard library.
You can do this on your own traits, like this:

View File

@ -0,0 +1,28 @@
use std::error::Error;
struct A {
}
impl A {
pub fn new() -> A {
A {
}
}
pub fn f<'a>(
&'a self,
team_name: &'a str,
c: &'a mut dyn FnMut(String, String, u64, u64)
) -> Result<(), Box<dyn Error>> {
Ok(())
}
}
fn main() {
let A = A::new();
let participant_name = "A";
let c = |a, b, c, d| {};
A.f(participant_name, &mut c); //~ ERROR cannot borrow
}

View File

@ -0,0 +1,12 @@
error[E0596]: cannot borrow `c` as mutable, as it is not declared as mutable
--> $DIR/issue-82438-mut-without-upvar.rs:27:27
|
LL | let c = |a, b, c, d| {};
| - help: consider changing this to be mutable: `mut c`
LL |
LL | A.f(participant_name, &mut c);
| ^^^^^^ cannot borrow as mutable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0596`.

View File

@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflictin
LL | self.a();
| ^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 3:5...
--> $DIR/issue-16683.rs:3:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 3:10...
--> $DIR/issue-16683.rs:3:10
|
LL | fn b(&self) {
| ^^^^^^^^^^^
| ^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-16683.rs:4:9
|

View File

@ -6,11 +6,11 @@ LL | fn bar(self: &mut Foo) {
|
= note: expected struct `Foo<'a>`
found struct `Foo<'_>`
note: the anonymous lifetime #2 defined on the method body at 6:5...
--> $DIR/issue-17740.rs:6:5
note: the anonymous lifetime defined on the method body at 6:23...
--> $DIR/issue-17740.rs:6:23
|
LL | fn bar(self: &mut Foo) {
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^
note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 5:7
--> $DIR/issue-17740.rs:5:7
|
@ -30,11 +30,11 @@ note: the lifetime `'a` as defined on the impl at 5:7...
|
LL | impl <'a> Foo<'a>{
| ^^
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 6:5
--> $DIR/issue-17740.rs:6:5
note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 6:23
--> $DIR/issue-17740.rs:6:23
|
LL | fn bar(self: &mut Foo) {
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^
error: aborting due to 2 previous errors

View File

@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflictin
LL | self.foo();
| ^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 6:5...
--> $DIR/issue-17758.rs:6:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 6:12...
--> $DIR/issue-17758.rs:6:12
|
LL | fn bar(&self) {
| ^^^^^^^^^^^^^
| ^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-17758.rs:7:9
|

View File

@ -6,11 +6,11 @@ LL | fn say(self: &Pair<&str, isize>) {
|
= note: expected struct `Pair<&str, _>`
found struct `Pair<&str, _>`
note: the anonymous lifetime #2 defined on the method body at 8:5...
--> $DIR/issue-17905-2.rs:8:5
note: the anonymous lifetime defined on the method body at 8:24...
--> $DIR/issue-17905-2.rs:8:24
|
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^
note: ...does not necessarily outlive the lifetime `'_` as defined on the impl at 5:5
--> $DIR/issue-17905-2.rs:5:5
|
@ -30,11 +30,11 @@ note: the lifetime `'_` as defined on the impl at 5:5...
|
LL | &str,
| ^
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 8:5
--> $DIR/issue-17905-2.rs:8:5
note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 8:24
--> $DIR/issue-17905-2.rs:8:24
|
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^
error: aborting due to 2 previous errors

View File

@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5...
--> $DIR/issue-20831-debruijn.rs:28:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 28:58...
--> $DIR/issue-20831-debruijn.rs:28:58
|
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6...
--> $DIR/issue-20831-debruijn.rs:26:6
|

View File

@ -6,11 +6,11 @@ LL | fn select(&self) -> BufferViewHandle<R>;
|
= note: expected type `Resources<'_>`
found type `Resources<'a>`
note: the anonymous lifetime #1 defined on the method body at 5:5...
--> $DIR/issue-27942.rs:5:5
note: the anonymous lifetime defined on the method body at 5:15...
--> $DIR/issue-27942.rs:5:15
|
LL | fn select(&self) -> BufferViewHandle<R>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^
note: ...does not necessarily outlive the lifetime `'a` as defined on the trait at 3:18
--> $DIR/issue-27942.rs:3:18
|
@ -30,11 +30,11 @@ note: the lifetime `'a` as defined on the trait at 3:18...
|
LL | pub trait Buffer<'a, R: Resources<'a>> {
| ^^
note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 5:5
--> $DIR/issue-27942.rs:5:5
note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 5:15
--> $DIR/issue-27942.rs:5:15
|
LL | fn select(&self) -> BufferViewHandle<R>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^
error: aborting due to 2 previous errors

View File

@ -1,4 +1,5 @@
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon
//
// Verify that the hexagon targets implement the repr(C) for enums correctly.
//

View File

@ -81,7 +81,7 @@ error: layout_of(A) = Layout {
raw: 1,
},
}
--> $DIR/hexagon-enum.rs:15:1
--> $DIR/hexagon-enum.rs:16:1
|
LL | enum A { Apple }
| ^^^^^^^^^^^^^^^^
@ -169,7 +169,7 @@ error: layout_of(B) = Layout {
raw: 1,
},
}
--> $DIR/hexagon-enum.rs:19:1
--> $DIR/hexagon-enum.rs:20:1
|
LL | enum B { Banana = 255, }
| ^^^^^^^^^^^^^^^^^^^^^^^^
@ -257,7 +257,7 @@ error: layout_of(C) = Layout {
raw: 2,
},
}
--> $DIR/hexagon-enum.rs:23:1
--> $DIR/hexagon-enum.rs:24:1
|
LL | enum C { Chaenomeles = 256, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -345,7 +345,7 @@ error: layout_of(P) = Layout {
raw: 4,
},
}
--> $DIR/hexagon-enum.rs:27:1
--> $DIR/hexagon-enum.rs:28:1
|
LL | enum P { Peach = 0x1000_0000isize, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -433,7 +433,7 @@ error: layout_of(T) = Layout {
raw: 4,
},
}
--> $DIR/hexagon-enum.rs:33:1
--> $DIR/hexagon-enum.rs:34:1
|
LL | enum T { Tangerine = TANGERINE as isize }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -9,11 +9,11 @@ note: ...the reference is valid for the lifetime `'_` as defined on the impl at
|
LL | impl Foo<'_, '_> {
| ^^
note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 13:5
--> $DIR/issue-52742.rs:13:5
note: ...but the borrowed content is only valid for the anonymous lifetime defined on the method body at 13:31
--> $DIR/issue-52742.rs:13:31
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: aborting due to previous error

View File

@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'s` d
LL | Foo { bar }
| ^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 8:5...
--> $DIR/issue-55394.rs:8:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 8:17...
--> $DIR/issue-55394.rs:8:17
|
LL | fn new(bar: &mut Bar) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-55394.rs:9:15
|

View File

@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
LL | C { f: b }
| ^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 16:5...
--> $DIR/type-alias-free-regions.rs:16:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 16:24...
--> $DIR/type-alias-free-regions.rs:16:24
|
LL | fn from_box(b: Box<B>) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:17:16
|
@ -35,11 +35,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 26:5...
--> $DIR/type-alias-free-regions.rs:26:5
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 26:23...
--> $DIR/type-alias-free-regions.rs:26:23
|
LL | fn from_tuple(b: (B,)) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:27:25
|

View File

@ -7,7 +7,7 @@
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro::{TokenStream, TokenTree};
// Macro that return empty token stream.
@ -80,6 +80,10 @@ pub fn recollect_derive(input: TokenStream) -> TokenStream {
// Macros that print their input in the original and re-collected forms (if they differ).
fn print_helper(input: TokenStream, kind: &str) -> TokenStream {
print_helper_ext(input, kind, true)
}
fn print_helper_ext(input: TokenStream, kind: &str, debug: bool) -> TokenStream {
let input_display = format!("{}", input);
let input_debug = format!("{:#?}", input);
let recollected = input.into_iter().collect();
@ -89,9 +93,11 @@ fn print_helper(input: TokenStream, kind: &str) -> TokenStream {
if recollected_display != input_display {
println!("PRINT-{} RE-COLLECTED (DISPLAY): {}", kind, recollected_display);
}
println!("PRINT-{} INPUT (DEBUG): {}", kind, input_debug);
if recollected_debug != input_debug {
println!("PRINT-{} RE-COLLECTED (DEBUG): {}", kind, recollected_debug);
if debug {
println!("PRINT-{} INPUT (DEBUG): {}", kind, input_debug);
if recollected_debug != input_debug {
println!("PRINT-{} RE-COLLECTED (DEBUG): {}", kind, recollected_debug);
}
}
recollected
}
@ -108,8 +114,12 @@ pub fn print_bang_consume(input: TokenStream) -> TokenStream {
}
#[proc_macro_attribute]
pub fn print_attr(_: TokenStream, input: TokenStream) -> TokenStream {
print_helper(input, "ATTR")
pub fn print_attr(args: TokenStream, input: TokenStream) -> TokenStream {
let debug = match &args.into_iter().collect::<Vec<_>>()[..] {
[TokenTree::Ident(ident)] if ident.to_string() == "nodebug" => false,
_ => true,
};
print_helper_ext(input, "ATTR", debug)
}
#[proc_macro_attribute]

View File

@ -0,0 +1,12 @@
// aux-build:test-macros.rs
#![dummy] //~ ERROR cannot find attribute `dummy` in this scope
#[macro_use]
extern crate test_macros;
#[derive(Empty)] //~ ERROR cannot determine resolution for the attribute macro `derive`
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
struct Foo {}
fn main() {}

View File

@ -0,0 +1,22 @@
error: cannot find attribute `dummy` in this scope
--> $DIR/derive-helper-legacy-spurious.rs:3:4
|
LL | #![dummy]
| ^^^^^
error: cannot determine resolution for the attribute macro `derive`
--> $DIR/derive-helper-legacy-spurious.rs:8:3
|
LL | #[derive(Empty)]
| ^^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot find attribute `empty_helper` in this scope
--> $DIR/derive-helper-legacy-spurious.rs:9:3
|
LL | #[empty_helper]
| ^^^^^^^^^^^^
error: aborting due to 3 previous errors

View File

@ -0,0 +1,23 @@
// Order of inert attributes, both built-in and custom is preserved during expansion.
// check-pass
// compile-flags: -Z span-debug
// aux-build:test-macros.rs
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
/// 1
#[rustfmt::attr2]
#[doc = "3"]
#[print_attr(nodebug)]
#[doc = "4"]
#[rustfmt::attr5]
/// 6
#[print_attr(nodebug)]
struct S;
fn main() {}

View File

@ -0,0 +1,7 @@
PRINT-ATTR INPUT (DISPLAY): /// 1
#[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] /// 6
#[print_attr(nodebug)] struct S ;
PRINT-ATTR RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"]
#[rustfmt :: attr5] #[doc = " 6"] #[print_attr(nodebug)] struct S ;
PRINT-ATTR INPUT (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"]
#[rustfmt :: attr5] #[doc = " 6"] struct S ;

View File

@ -1,4 +1,4 @@
PRINT-ATTR INPUT (DISPLAY): #[allow(dead_code)] #[derive(Print)] #[print_helper(b)] #[print_helper(a)]
PRINT-ATTR INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[derive(Print)] #[print_helper(b)]
struct Foo < #[cfg(FALSE)] A, B >
{
#[cfg(FALSE)] first : String, #[cfg_attr(FALSE, deny(warnings))] second :
@ -23,6 +23,31 @@ struct Foo < #[cfg(FALSE)] A, B >
}], #[print_helper(d)] fourth : B
}
PRINT-ATTR INPUT (DEBUG): TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: $DIR/issue-75930-derive-cfg.rs:16:1: 16:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_helper",
span: $DIR/issue-75930-derive-cfg.rs:16:3: 16:15 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "a",
span: $DIR/issue-75930-derive-cfg.rs:16:16: 16:17 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:16:15: 16:18 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:16:2: 16:19 (#0),
},
Punct {
ch: '#',
spacing: Alone,
@ -98,31 +123,6 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
],
span: $DIR/issue-75930-derive-cfg.rs:21:2: 21:19 (#0),
},
Punct {
ch: '#',
spacing: Alone,
span: $DIR/issue-75930-derive-cfg.rs:16:1: 16:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_helper",
span: $DIR/issue-75930-derive-cfg.rs:16:3: 16:15 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "a",
span: $DIR/issue-75930-derive-cfg.rs:16:16: 16:17 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:16:15: 16:18 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:16:2: 16:19 (#0),
},
Ident {
ident: "struct",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 22:7 (#0),
@ -1194,7 +1194,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/issue-75930-derive-cfg.rs:22:32: 65:2 (#0),
},
]
PRINT-DERIVE INPUT (DISPLAY): #[allow(dead_code)] #[print_helper(b)] #[print_helper(a)] struct Foo < B >
PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_helper(b)] struct Foo < B >
{
second : bool, third :
[u8 ;
@ -1208,6 +1208,31 @@ PRINT-DERIVE INPUT (DISPLAY): #[allow(dead_code)] #[print_helper(b)] #[print_hel
}], #[print_helper(d)] fourth : B,
}
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_helper",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "a",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Punct {
ch: '#',
spacing: Alone,
@ -1258,31 +1283,6 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
],
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Punct {
ch: '#',
spacing: Alone,
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "print_helper",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "a",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
},
Ident {
ident: "struct",
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),

View File

@ -6,11 +6,11 @@ LL | self.f = b;
|
= note: expected struct `Box<Box<&'a isize>>`
found struct `Box<Box<&isize>>`
note: the anonymous lifetime #2 defined on the method body at 21:5...
--> $DIR/regions-infer-paramd-indirect.rs:21:5
note: the anonymous lifetime defined on the method body at 21:36...
--> $DIR/regions-infer-paramd-indirect.rs:21:36
|
LL | fn set_f_bad(&mut self, b: Box<B>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^
note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 16:6
--> $DIR/regions-infer-paramd-indirect.rs:16:6
|

View File

@ -7,11 +7,11 @@ LL | | t.test();
LL | | });
| |______^
|
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
--> $DIR/missing-lifetimes-in-signature-2.rs:19:1
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
--> $DIR/missing-lifetimes-in-signature-2.rs:19:24
|
LL | fn func<T: Test>(foo: &Foo, t: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^
error: aborting due to previous error

View File

@ -6,11 +6,11 @@ LL | fn func<T: Test>(foo: &Foo, t: T) {
LL | foo.bar(move |_| {
| ^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
--> $DIR/missing-lifetimes-in-signature-2.rs:19:1
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
--> $DIR/missing-lifetimes-in-signature-2.rs:19:24
|
LL | fn func<T: Test>(foo: &Foo, t: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds
--> $DIR/missing-lifetimes-in-signature-2.rs:20:9
|

View File

@ -25,14 +25,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
--> $DIR/missing-lifetimes-in-signature.rs:25:1
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
--> $DIR/missing-lifetimes-in-signature.rs:25:26
|
LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
LL | |
LL | | where
LL | | G: Get<T>
| |_____________^
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:47:45
@ -40,14 +37,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
--> $DIR/missing-lifetimes-in-signature.rs:47:1
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
--> $DIR/missing-lifetimes-in-signature.rs:47:34
|
LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
LL | |
LL | | where
LL | | G: Get<T>
| |_____________^
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:59:58
@ -55,11 +49,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
--> $DIR/missing-lifetimes-in-signature.rs:59:5
note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
--> $DIR/missing-lifetimes-in-signature.rs:59:47
|
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:68:45
@ -67,14 +61,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 68:1...
--> $DIR/missing-lifetimes-in-signature.rs:68:1
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 68:34...
--> $DIR/missing-lifetimes-in-signature.rs:68:34
|
LL | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
LL | |
LL | | where
LL | | G: Get<T>
| |_____________^
LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
| ^^^^^^
error[E0621]: explicit lifetime required in the type of `dest`
--> $DIR/missing-lifetimes-in-signature.rs:73:5

View File

@ -33,14 +33,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
--> $DIR/missing-lifetimes-in-signature.rs:25:1
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
--> $DIR/missing-lifetimes-in-signature.rs:25:26
|
LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
LL | |
LL | | where
LL | | G: Get<T>
| |_____________^
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:30:5: 32:6]` will meet its required lifetime bounds
--> $DIR/missing-lifetimes-in-signature.rs:25:37
|
@ -57,14 +54,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
--> $DIR/missing-lifetimes-in-signature.rs:47:1
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
--> $DIR/missing-lifetimes-in-signature.rs:47:34
|
LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
LL | |
LL | | where
LL | | G: Get<T>
| |_____________^
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ^^^^^^
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:52:5: 54:6]` will meet its required lifetime bounds
--> $DIR/missing-lifetimes-in-signature.rs:47:45
|
@ -81,11 +75,11 @@ error[E0311]: the parameter type `G` may not live long enough
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
| ^^^^^^^^^^^^^^^^^^
|
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
--> $DIR/missing-lifetimes-in-signature.rs:59:5
note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
--> $DIR/missing-lifetimes-in-signature.rs:59:47
|
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:61:9: 63:10]` will meet its required lifetime bounds
--> $DIR/missing-lifetimes-in-signature.rs:59:58
|

View File

@ -208,3 +208,15 @@ impl Qux for Struct {
const D: _ = 42;
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
}
fn map<T>(_: fn() -> Option<&'static T>) -> Option<T> {
None
}
fn value() -> Option<&'static _> {
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
Option::<&'static u8>::None
}
const _: Option<_> = map(value);
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures

View File

@ -158,7 +158,7 @@ LL | fn test11(x: &usize) -> &_ {
| -^
| ||
| |not allowed in type signatures
| help: replace with the correct return type: `&&usize`
| help: replace with the correct return type: `&'static &'static usize`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:52:52
@ -410,6 +410,24 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
LL | type Y = impl Trait<_>;
| ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:216:31
|
LL | fn value() -> Option<&'static _> {
| ----------------^-
| | |
| | not allowed in type signatures
| help: replace with the correct return type: `Option<&'static u8>`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:221:10
|
LL | const _: Option<_> = map(value);
| ^^^^^^^^^
| |
| not allowed in type signatures
| help: replace `_` with the correct type: `Option<u8>`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:140:31
|
@ -614,7 +632,7 @@ LL | const D: _ = 42;
| not allowed in type signatures
| help: replace `_` with the correct type: `i32`
error: aborting due to 67 previous errors
error: aborting due to 69 previous errors
Some errors have detailed explanations: E0121, E0282, E0403.
For more information about an error, try `rustc --explain E0121`.

View File

@ -33,11 +33,11 @@ LL | fn dummy2(self: &Bar<T>) {}
|
= note: expected reference `&'a Bar<T>`
found reference `&Bar<T>`
note: the anonymous lifetime #1 defined on the method body at 37:5...
--> $DIR/ufcs-explicit-self-bad.rs:37:5
note: the anonymous lifetime defined on the method body at 37:21...
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar<T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 35:6
--> $DIR/ufcs-explicit-self-bad.rs:35:6
|
@ -57,11 +57,11 @@ note: the lifetime `'a` as defined on the impl at 35:6...
|
LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^
note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 37:5
--> $DIR/ufcs-explicit-self-bad.rs:37:5
note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 37:21
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar<T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:39:21
@ -71,11 +71,11 @@ LL | fn dummy3(self: &&Bar<T>) {}
|
= note: expected reference `&'a Bar<T>`
found reference `&Bar<T>`
note: the anonymous lifetime #2 defined on the method body at 39:5...
--> $DIR/ufcs-explicit-self-bad.rs:39:5
note: the anonymous lifetime defined on the method body at 39:22...
--> $DIR/ufcs-explicit-self-bad.rs:39:22
|
LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 35:6
--> $DIR/ufcs-explicit-self-bad.rs:35:6
|
@ -95,11 +95,11 @@ note: the lifetime `'a` as defined on the impl at 35:6...
|
LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 39:5
--> $DIR/ufcs-explicit-self-bad.rs:39:5
note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 39:22
--> $DIR/ufcs-explicit-self-bad.rs:39:22
|
LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: aborting due to 7 previous errors

@ -1 +1 @@
Subproject commit bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070
Subproject commit 572e201536dc2e4920346e28037b63c0f4d88b3c

@ -1 +1 @@
Subproject commit 7435b9e98c9280043605748c11a1f450669e04d6
Subproject commit 14de9e54a6d9ef070399b34a11634294a8cc3ca5

View File

@ -85,6 +85,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
"cstr",
"datafrog",
"difference",
"digest",