提交 f6840f33 编写于 作者: B bors

Auto merge of #67060 - Centril:rollup-hwhdx4h, r=Centril

Rollup of 9 pull requests

Successful merges:

 - #66710 (weak-into-raw: Clarify some details in Safety)
 - #66863 (Check break target availability when checking breaks with values)
 - #67002 (Fix documentation of pattern for str::matches())
 - #67005 (capitalize Rust)
 - #67010 (Accurately portray raw identifiers in error messages)
 - #67011 (Include a span in more `expected...found` notes)
 - #67044 (E0023: handle expected != tuple pattern type)
 - #67045 (rustc_parser: cleanup imports)
 - #67055 (Make const-qualification look at more `const fn`s)

Failed merges:

r? @ghost
......@@ -3806,7 +3806,6 @@ dependencies = [
"rustc_errors",
"rustc_feature",
"rustc_lexer",
"rustc_target",
"smallvec 1.0.0",
"syntax",
"syntax_pos",
......
......@@ -1648,10 +1648,8 @@ pub fn new() -> Weak<T> {
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
///
/// It is up to the caller to ensure that the object is still alive when accessing it through
/// the pointer.
///
/// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
/// The pointer is valid only if there are some strong references. The pointer may be dangling
/// or even [`null`] otherwise.
///
/// # Examples
///
......@@ -1731,14 +1729,18 @@ pub fn into_raw(self) -> *const T {
/// This can be used to safely get a strong reference (by calling [`upgrade`]
/// later) or to deallocate the weak count by dropping the `Weak<T>`.
///
/// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is
/// returned.
/// It takes ownership of one weak count (with the exception of pointers created by [`new`],
/// as these don't have any corresponding weak count).
///
/// # Safety
///
/// The pointer must represent one valid weak count. In other words, it must point to `T` which
/// is or *was* managed by an [`Rc`] and the weak count of that [`Rc`] must not have reached
/// 0. It is allowed for the strong count to be 0.
/// The pointer must have originated from the [`into_raw`] (or [`as_raw`], provided there was
/// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
/// count.
///
/// It is allowed for the strong count to be 0 at the time of calling this, but the weak count
/// must be non-zero or the pointer must have originated from a dangling `Weak<T>` (one created
/// by [`new`]).
///
/// # Examples
///
......@@ -1763,11 +1765,13 @@ pub fn into_raw(self) -> *const T {
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
/// ```
///
/// [`null`]: ../../std/ptr/fn.null.html
/// [`into_raw`]: struct.Weak.html#method.into_raw
/// [`upgrade`]: struct.Weak.html#method.upgrade
/// [`Rc`]: struct.Rc.html
/// [`Weak`]: struct.Weak.html
/// [`as_raw`]: struct.Weak.html#method.as_raw
/// [`new`]: struct.Weak.html#method.new
/// [`forget`]: ../../std/mem/fn.forget.html
#[unstable(feature = "weak_into_raw", issue = "60728")]
pub unsafe fn from_raw(ptr: *const T) -> Self {
if ptr.is_null() {
......
......@@ -1324,10 +1324,8 @@ pub fn new() -> Weak<T> {
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
///
/// It is up to the caller to ensure that the object is still alive when accessing it through
/// the pointer.
///
/// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
/// The pointer is valid only if there are some strong references. The pointer may be dangling
/// or even [`null`] otherwise.
///
/// # Examples
///
......@@ -1408,14 +1406,18 @@ pub fn into_raw(self) -> *const T {
/// This can be used to safely get a strong reference (by calling [`upgrade`]
/// later) or to deallocate the weak count by dropping the `Weak<T>`.
///
/// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is
/// returned.
/// It takes ownership of one weak count (with the exception of pointers created by [`new`],
/// as these don't have any corresponding weak count).
///
/// # Safety
///
/// The pointer must represent one valid weak count. In other words, it must point to `T` which
/// is or *was* managed by an [`Arc`] and the weak count of that [`Arc`] must not have reached
/// 0. It is allowed for the strong count to be 0.
/// The pointer must have originated from the [`into_raw`] (or [`as_raw'], provided there was
/// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
/// count.
///
/// It is allowed for the strong count to be 0 at the time of calling this, but the weak count
/// must be non-zero or the pointer must have originated from a dangling `Weak<T>` (one created
/// by [`new`]).
///
/// # Examples
///
......@@ -1440,11 +1442,13 @@ pub fn into_raw(self) -> *const T {
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
/// ```
///
/// [`null`]: ../../std/ptr/fn.null.html
/// [`as_raw`]: struct.Weak.html#method.as_raw
/// [`new`]: struct.Weak.html#method.new
/// [`into_raw`]: struct.Weak.html#method.into_raw
/// [`upgrade`]: struct.Weak.html#method.upgrade
/// [`Weak`]: struct.Weak.html
/// [`Arc`]: struct.Arc.html
/// [`forget`]: ../../std/mem/fn.forget.html
#[unstable(feature = "weak_into_raw", issue = "60728")]
pub unsafe fn from_raw(ptr: *const T) -> Self {
if ptr.is_null() {
......
......@@ -74,6 +74,8 @@
#![feature(const_fn)]
#![feature(const_fn_union)]
#![feature(const_generics)]
#![cfg_attr(not(bootstrap), feature(const_ptr_offset_from))]
#![cfg_attr(not(bootstrap), feature(const_type_name))]
#![feature(custom_inner_attributes)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
......
......@@ -3371,8 +3371,8 @@ pub fn rsplitn<'a, P>(&'a self, n: usize, pat: P) -> RSplitN<'a, P>
/// An iterator over the disjoint matches of a pattern within the given string
/// slice.
///
/// The pattern can be any type that implements the Pattern trait. Notable
/// examples are `&str`, [`char`], and closures that determines the split.
/// The pattern can be a `&str`, [`char`], or a closure that determines if
/// a character matches.
///
/// # Iterator behavior
///
......
......@@ -27,7 +27,7 @@
//!
//! Atomic variables are safe to share between threads (they implement [`Sync`])
//! but they do not themselves provide the mechanism for sharing and follow the
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
//! [threading model](../../../std/thread/index.html#the-threading-model) of Rust.
//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
//! atomically-reference-counted shared pointer).
//!
......
......@@ -1809,12 +1809,17 @@ fn report_sub_sup_conflict(
sub_region,
"...",
);
err.note(&format!(
"...so that the {}:\nexpected {}\n found {}",
sup_trace.cause.as_requirement_str(),
sup_expected.content(),
sup_found.content()
err.span_note(sup_trace.cause.span, &format!(
"...so that the {}",
sup_trace.cause.as_requirement_str()
));
err.note_expected_found(
&"",
sup_expected,
&"",
sup_found
);
err.emit();
return;
}
......
......@@ -13,12 +13,20 @@ pub(super) fn note_region_origin(&self,
match *origin {
infer::Subtype(ref trace) => {
if let Some((expected, found)) = self.values_str(&trace.values) {
let expected = expected.content();
let found = found.content();
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
trace.cause.as_requirement_str(),
err.span_note(
trace.cause.span,
&format!(
"...so that the {}",
trace.cause.as_requirement_str()
)
);
err.note_expected_found(
&"",
expected,
found));
&"",
found
);
} else {
// FIXME: this really should be handled at some earlier stage. Our
// handling of region checking when type errors are present is
......
......@@ -1282,6 +1282,9 @@ fn path_append(
if !self.empty_path {
write!(self, "::")?;
}
if ast::Ident::from_str(&name).is_raw_guess() {
write!(self, "r#")?;
}
write!(self, "{}", name)?;
// FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it
......
......@@ -77,7 +77,12 @@ pub fn for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Self> {
let mode = match tcx.hir().body_owner_kind(hir_id) {
HirKind::Closure => return None,
HirKind::Fn if tcx.is_const_fn(def_id) => ConstKind::ConstFn,
// Note: this is deliberately checking for `is_const_fn_raw`, as the `is_const_fn`
// checks take into account the `rustc_const_unstable` attribute combined with enabled
// feature gates. Otherwise, const qualification would _not check_ whether this
// function body follows the `const fn` rules, as an unstable `const fn` would
// be considered "not const". More details are available in issue #67053.
HirKind::Fn if tcx.is_const_fn_raw(def_id) => ConstKind::ConstFn,
HirKind::Fn => return None,
HirKind::Const => ConstKind::Const,
......
......@@ -12,12 +12,11 @@ doctest = false
[dependencies]
bitflags = "1.0"
log = "0.4"
syntax_pos = { path = "../libsyntax_pos" }
syntax = { path = "../libsyntax" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_feature = { path = "../librustc_feature" }
rustc_lexer = { path = "../librustc_lexer" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_errors = { path = "../librustc_errors" }
rustc_error_codes = { path = "../librustc_error_codes" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
syntax_pos = { path = "../libsyntax_pos" }
syntax = { path = "../libsyntax" }
......@@ -10,6 +10,7 @@
use crate::validate_attr;
use rustc_feature::Features;
use rustc_errors::Applicability;
use syntax::attr::HasAttrs;
use syntax::feature_gate::{feature_err, get_features};
use syntax::attr;
......@@ -21,7 +22,6 @@
use syntax::util::map_in_place::MapInPlace;
use syntax_pos::symbol::sym;
use errors::Applicability;
use smallvec::SmallVec;
/// A folder that strips out items that do not belong in the current configuration.
......
use rustc_data_structures::sync::Lrc;
use rustc_errors::{FatalError, DiagnosticBuilder};
use rustc_lexer::Base;
use rustc_lexer::unescape;
use syntax::token::{self, Token, TokenKind};
use syntax::sess::ParseSess;
use syntax::symbol::{sym, Symbol};
use syntax::util::comments;
use errors::{FatalError, DiagnosticBuilder};
use syntax_pos::symbol::{sym, Symbol};
use syntax_pos::{BytePos, Pos, Span};
use rustc_lexer::Base;
use rustc_lexer::unescape;
use std::char;
use std::convert::TryInto;
use rustc_data_structures::sync::Lrc;
use log::debug;
mod tokentrees;
......
use rustc_data_structures::fx::FxHashMap;
use syntax_pos::Span;
use super::{StringReader, UnmatchedBrace};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::PResult;
use syntax::print::pprust::token_to_string;
use syntax::token::{self, Token};
use syntax::tokenstream::{DelimSpan, IsJoint::{self, *}, TokenStream, TokenTree, TreeAndJoint};
use errors::PResult;
use syntax_pos::Span;
impl<'a> StringReader<'a> {
crate fn into_token_trees(self) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>) {
......
......@@ -2,9 +2,9 @@
// http://www.unicode.org/Public/security/10.0.0/confusables.txt
use super::StringReader;
use errors::{Applicability, DiagnosticBuilder};
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
use crate::token;
use rustc_errors::{Applicability, DiagnosticBuilder};
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
#[rustfmt::skip] // for line breaks
const UNICODE_ARRAY: &[(char, &str, char)] = &[
......
......@@ -8,7 +8,7 @@
use syntax::token::{self, Nonterminal};
use syntax::tokenstream::{self, TokenStream, TokenTree};
use errors::{PResult, FatalError, Level, Diagnostic};
use rustc_errors::{PResult, FatalError, Level, Diagnostic};
use rustc_data_structures::sync::Lrc;
use syntax_pos::{Span, SourceFile, FileName};
......@@ -53,7 +53,7 @@ pub enum DirectoryOwnership {
macro_rules! panictry_buffer {
($handler:expr, $e:expr) => ({
use std::result::Result::{Ok, Err};
use errors::FatalError;
use rustc_errors::FatalError;
match $e {
Ok(e) => e,
Err(errs) => {
......
use super::{SeqSep, Parser, TokenType, PathStyle};
use rustc_errors::PResult;
use syntax::attr;
use syntax::ast;
use syntax::util::comments;
use syntax::token::{self, Nonterminal};
use syntax_pos::{Span, Symbol};
use errors::PResult;
use log::debug;
......
use super::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType, SeqSep, Parser};
use syntax::ast::{
self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, ItemKind,
Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
use rustc_error_codes::*;
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
use syntax::token::{self, TokenKind, token_can_begin_expr};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::symbol::{kw, sym};
use syntax::ThinVec;
use syntax::util::parser::AssocOp;
use syntax::struct_span_err;
use errors::{PResult, Applicability, DiagnosticBuilder, pluralize};
use rustc_data_structures::fx::FxHashSet;
use syntax_pos::symbol::{kw, sym};
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
use log::{debug, trace};
use std::mem;
use rustc_error_codes::*;
const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
/// Creates a placeholder argument.
......@@ -61,10 +58,10 @@ pub enum Error {
}
impl Error {
fn span_err<S: Into<MultiSpan>>(
fn span_err(
self,
sp: S,
handler: &errors::Handler,
sp: impl Into<MultiSpan>,
handler: &Handler,
) -> DiagnosticBuilder<'_> {
match self {
Error::FileNotFoundForModule {
......@@ -212,7 +209,7 @@ pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(sp, m)
}
pub(super) fn diagnostic(&self) -> &'a errors::Handler {
pub(super) fn diagnostic(&self) -> &'a Handler {
&self.sess.span_diagnostic
}
......
......@@ -4,23 +4,20 @@
use super::diagnostics::Error;
use crate::maybe_recover_from_interpolated_ty_qpath;
use syntax::ast::{
self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode,
Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind,
FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit,
};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{PResult, Applicability};
use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
use syntax::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind};
use syntax::ast::{FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit};
use syntax::token::{self, Token, TokenKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::source_map::{self, Span};
use syntax::util::classify;
use syntax::util::literal::LitError;
use syntax::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
use syntax_pos::symbol::{kw, sym};
use syntax_pos::Symbol;
use errors::{PResult, Applicability};
use syntax_pos::source_map::{self, Span};
use syntax_pos::symbol::{kw, sym, Symbol};
use std::mem;
use rustc_data_structures::thin_vec::ThinVec;
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
/// dropped into the token stream, which happens while parsing the result of
......
use super::Parser;
use rustc_errors::PResult;
use syntax::ast::{self, WhereClause, GenericParam, GenericParamKind, GenericBounds, Attribute};
use syntax::token;
use syntax::source_map::DUMMY_SP;
use syntax_pos::symbol::{kw, sym};
use errors::PResult;
impl<'a> Parser<'a> {
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
......
......@@ -3,6 +3,8 @@
use crate::maybe_whole;
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
use rustc_error_codes::*;
use syntax::ast::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item};
use syntax::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, UseTree, UseTreeKind};
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
......@@ -14,16 +16,13 @@
use syntax::ThinVec;
use syntax::token;
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
use syntax::source_map::{self, respan, Span};
use syntax::struct_span_err;
use syntax_pos::BytePos;
use syntax_pos::source_map::{self, respan, Span};
use syntax_pos::symbol::{kw, sym, Symbol};
use rustc_error_codes::*;
use log::debug;
use std::mem;
use errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
pub(super) type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);
......
......@@ -14,23 +14,20 @@
use crate::{Directory, DirectoryOwnership};
use crate::lexer::UnmatchedBrace;
use syntax::ast::{
self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit,
IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety,
};
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
use rustc_data_structures::thin_vec::ThinVec;
use syntax::ast::{self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit};
use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, Token, TokenKind, DelimToken};
use syntax::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint};
use syntax::sess::ParseSess;
use syntax::source_map::respan;
use syntax::struct_span_err;
use syntax::util::comments::{doc_comment_style, strip_doc_comment_decoration};
use syntax_pos::source_map::respan;
use syntax_pos::symbol::{kw, sym, Symbol};
use syntax_pos::{Span, BytePos, DUMMY_SP, FileName};
use rustc_data_structures::thin_vec::ThinVec;
use errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
use log::debug;
use std::borrow::Cow;
......
......@@ -4,13 +4,12 @@
use crate::{new_sub_parser_from_file, DirectoryOwnership};
use rustc_errors::PResult;
use syntax::attr;
use syntax::ast::{self, Ident, Attribute, ItemKind, Mod, Crate};
use syntax::token::{self, TokenKind};
use syntax::source_map::{SourceMap, Span, DUMMY_SP, FileName};
use syntax_pos::source_map::{SourceMap, Span, DUMMY_SP, FileName};
use syntax_pos::symbol::sym;
use errors::PResult;
use std::path::{self, Path, PathBuf};
......@@ -212,13 +211,13 @@ pub(super) fn default_submod_path(
// `./<id>.rs` and `./<id>/mod.rs`.
let relative_prefix_string;
let relative_prefix = if let Some(ident) = relative {
relative_prefix_string = format!("{}{}", ident, path::MAIN_SEPARATOR);
relative_prefix_string = format!("{}{}", ident.name, path::MAIN_SEPARATOR);
&relative_prefix_string
} else {
""
};
let mod_name = id.to_string();
let mod_name = id.name.to_string();
let default_path_str = format!("{}{}.rs", relative_prefix, mod_name);
let secondary_path_str = format!("{}{}{}mod.rs",
relative_prefix, mod_name, path::MAIN_SEPARATOR);
......
use super::{Parser, PathStyle};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_errors::{PResult, Applicability, DiagnosticBuilder};
use syntax::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
......@@ -7,9 +8,8 @@
use syntax::print::pprust;
use syntax::ThinVec;
use syntax::token;
use syntax::source_map::{respan, Span, Spanned};
use syntax_pos::source_map::{respan, Span, Spanned};
use syntax_pos::symbol::{kw, sym};
use errors::{PResult, Applicability, DiagnosticBuilder};
type Expected = Option<&'static str>;
......
use super::{Parser, TokenType};
use crate::maybe_whole;
use rustc_errors::{PResult, Applicability, pluralize};
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
use syntax::ast::MacArgs;
use syntax::ThinVec;
use syntax::token::{self, Token};
use syntax::source_map::{Span, BytePos};
use syntax_pos::source_map::{Span, BytePos};
use syntax_pos::symbol::{kw, sym};
use std::mem;
use log::debug;
use errors::{PResult, Applicability, pluralize};
/// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq)]
......
......@@ -6,6 +6,7 @@
use crate::maybe_whole;
use crate::DirectoryOwnership;
use rustc_errors::{PResult, Applicability};
use syntax::ThinVec;
use syntax::ptr::P;
use syntax::ast;
......@@ -13,11 +14,10 @@
use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
use syntax::util::classify;
use syntax::token;
use syntax::source_map::{respan, Span};
use syntax::symbol::{kw, sym};
use syntax_pos::source_map::{respan, Span};
use syntax_pos::symbol::{kw, sym};
use std::mem;
use errors::{PResult, Applicability};
impl<'a> Parser<'a> {
/// Parses a statement. This stops just before trailing semicolons on everything but items.
......
......@@ -3,19 +3,17 @@
use crate::{maybe_whole, maybe_recover_from_interpolated_ty_qpath};
use rustc_errors::{PResult, Applicability, pluralize};
use rustc_error_codes::*;
use syntax::ptr::P;
use syntax::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
use syntax::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
use syntax::ast::{Mutability, AnonConst, Mac};
use syntax::token::{self, Token};
use syntax::source_map::Span;
use syntax::struct_span_fatal;
use syntax_pos::source_map::Span;
use syntax_pos::symbol::kw;
use errors::{PResult, Applicability, pluralize};
use rustc_error_codes::*;
/// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT<u8, u8>`,
/// `IDENT<<u8 as Trait>::AssocTy>`.
///
......
//! Meta-syntax validation logic of attributes for post-expansion.
use errors::{PResult, Applicability};
use rustc_errors::{PResult, Applicability};
use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP};
use syntax::ast::{self, Attribute, AttrKind, Ident, MacArgs, MetaItem, MetaItemKind};
use syntax::attr::mk_name_value_item_str;
......
......@@ -65,13 +65,13 @@ pub fn demand_eqtype_with_origin(&self,
}
}
pub fn demand_eqtype_pat(
pub fn demand_eqtype_pat_diag(
&self,
cause_span: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
match_expr_span: Option<Span>,
) {
) -> Option<DiagnosticBuilder<'tcx>> {
let cause = if let Some(span) = match_expr_span {
self.cause(
cause_span,
......@@ -80,9 +80,19 @@ pub fn demand_eqtype_pat(
} else {
self.misc(cause_span)
};
self.demand_eqtype_with_origin(&cause, expected, actual).map(|mut err| err.emit());
self.demand_eqtype_with_origin(&cause, expected, actual)
}
pub fn demand_eqtype_pat(
&self,
cause_span: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
match_expr_span: Option<Span>,
) {
self.demand_eqtype_pat_diag(cause_span, expected, actual, match_expr_span)
.map(|mut err| err.emit());
}
pub fn demand_coerce(&self,
expr: &hir::Expr,
......
......@@ -582,11 +582,21 @@ fn check_expr_break(
// If this is a break with a value, we need to type-check
// the expression. Get an expected type from the loop context.
let opt_coerce_to = {
// We should release `enclosing_breakables` before the `check_expr_with_hint`
// below, so can't move this block of code to the enclosing scope and share
// `ctxt` with the second `encloding_breakables` borrow below.
let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
enclosing_breakables.find_breakable(target_id)
.coerce
.as_ref()
.map(|coerce| coerce.expected_ty())
match enclosing_breakables.opt_find_breakable(target_id) {
Some(ctxt) =>
ctxt.coerce.as_ref().map(|coerce| coerce.expected_ty()),
None => { // Avoid ICE when `break` is inside a closure (#65383).
self.tcx.sess.delay_span_bug(
expr.span,
"break was outside loop, but no error was emitted",
);
return tcx.types.err;
}
}
};
// If the loop context is not a `loop { }`, then break with
......
......@@ -703,7 +703,10 @@ fn check_pat_tuple_struct(
let pat_ty = pat_ty.fn_sig(tcx).output();
let pat_ty = pat_ty.no_bound_vars().expect("expected fn type");
self.demand_eqtype_pat(pat.span, expected, pat_ty, match_arm_pat_span);
// Type-check the tuple struct pattern against the expected type.
let diag = self.demand_eqtype_pat_diag(pat.span, expected, pat_ty, match_arm_pat_span);
let had_err = diag.is_some();
diag.map(|mut err| err.emit());
// Type-check subpatterns.
if subpats.len() == variant.fields.len()
......@@ -721,7 +724,7 @@ fn check_pat_tuple_struct(
}
} else {
// Pattern has wrong number of fields.
self.e0023(pat.span, res, qpath, subpats, &variant.fields, expected);
self.e0023(pat.span, res, qpath, subpats, &variant.fields, expected, had_err);
on_error();
return tcx.types.err;
}
......@@ -734,8 +737,9 @@ fn e0023(
res: Res,
qpath: &hir::QPath,
subpats: &'tcx [P<Pat>],
fields: &[ty::FieldDef],
expected: Ty<'tcx>
fields: &'tcx [ty::FieldDef],
expected: Ty<'tcx>,
had_err: bool,
) {
let subpats_ending = pluralize!(subpats.len());
let fields_ending = pluralize!(fields.len());
......@@ -763,9 +767,12 @@ fn e0023(
// More generally, the expected type wants a tuple variant with one field of an
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
let missing_parenthesis = match expected.kind {
ty::Adt(_, substs) if fields.len() == 1 => {
let field_ty = fields[0].ty(self.tcx, substs);
let missing_parenthesis = match (&expected.kind, fields, had_err) {
// #67037: only do this if we could sucessfully type-check the expected type against
// the tuple struct pattern. Otherwise the substs could get out of range on e.g.,
// `let P() = U;` where `P != U` with `struct P<T>(T);`.
(ty::Adt(_, substs), [field], false) => {
let field_ty = self.field_ty(pat_span, field, substs);
match field_ty.kind {
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
_ => false,
......
......@@ -869,12 +869,18 @@ fn hash<H: Hasher>(&self, state: &mut H) {
impl fmt::Debug for Ident {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_raw_guess() {
write!(f, "r#")?;
}
write!(f, "{}{:?}", self.name, self.span.ctxt())
}
}
impl fmt::Display for Ident {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_raw_guess() {
write!(f, "r#")?;
}
fmt::Display::fmt(&self.name, f)
}
}
......
......@@ -9,13 +9,21 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
| ^^
= note: ...so that the expression is assignable:
expected Type<'_>
found Type<'a>
note: ...so that the expression is assignable
--> $DIR/project-fn-ret-invariant.rs:48:13
|
LL | bar(foo, x)
| ^
= note: expected `Type<'_>`
found `Type<'a>`
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected Type<'static>
found Type<'_>
note: ...so that the expression is assignable
--> $DIR/project-fn-ret-invariant.rs:48:4
|
LL | bar(foo, x)
| ^^^^^^^^^^^
= note: expected `Type<'static>`
found `Type<'_>`
error: aborting due to previous error
......
......@@ -49,9 +49,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
|
LL | let _ = ap.with_copy(|ap| { ap });
| ^^^^^^^^^^^
= note: ...so that the expression is assignable:
expected core::ffi::VaList<'_, '_>
found core::ffi::VaList<'_, '_>
note: ...so that the expression is assignable
--> $DIR/variadic-ffi-4.rs:16:33
|
LL | let _ = ap.with_copy(|ap| { ap });
| ^^
= note: expected `core::ffi::VaList<'_, '_>`
found `core::ffi::VaList<'_, '_>`
note: but, the lifetime must be valid for the method call at 16:13...
--> $DIR/variadic-ffi-4.rs:16:13
|
......
// This is a non-regression test for const-qualification of unstable items in libcore
// as explained in issue #67053.
// const-qualification could miss some `const fn`s if they were unstable and the feature
// gate was not enabled in libcore.
#![stable(feature = "core", since = "1.6.0")]
#![feature(const_if_match)]
#![feature(rustc_const_unstable)]
#![feature(staged_api)]
enum Opt<T> {
Some(T),
None,
}
impl<T> Opt<T> {
#[rustc_const_unstable(feature = "foo")]
#[stable(feature = "rust1", since = "1.0.0")]
const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
//~^ ERROR destructors cannot be evaluated at compile-time
//~| ERROR destructors cannot be evaluated at compile-time
match self {
Opt::Some(t) => t,
Opt::None => f(), //~ ERROR E0015
}
}
}
fn main() {}
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/unstable-const-fn-in-libcore.rs:24:26
|
LL | Opt::None => f(),
| ^^^
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:53
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^ constant functions cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:47
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^^^^ constant functions cannot evaluate destructors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0493.
For more information about an error, try `rustc --explain E0015`.
......@@ -9,13 +9,21 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| ^^
= note: ...so that the expression is assignable:
expected std::boxed::Box<dyn std::fmt::Debug>
found std::boxed::Box<(dyn std::fmt::Debug + 'a)>
note: ...so that the expression is assignable
--> $DIR/dyn-trait.rs:20:16
|
LL | static_val(x);
| ^
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the types are compatible:
expected StaticTrait
found StaticTrait
note: ...so that the types are compatible
--> $DIR/dyn-trait.rs:20:5
|
LL | static_val(x);
| ^^^^^^^^^^
= note: expected `StaticTrait`
found `StaticTrait`
error: aborting due to previous error
......
......@@ -21,9 +21,13 @@ note: but, the lifetime must be valid for the lifetime `'a` as defined on the tr
|
LL | trait T<'a> {
| ^^
= note: ...so that the types are compatible:
expected &'a Self
found &Self
note: ...so that the types are compatible
--> $DIR/issue-16683.rs:4:14
|
LL | self.a();
| ^
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error
......
......@@ -22,9 +22,13 @@ note: but, the lifetime must be valid for the lifetime `'a` as defined on the tr
|
LL | trait Foo<'a> {
| ^^
= note: ...so that the types are compatible:
expected &'a Self
found &Self
note: ...so that the types are compatible
--> $DIR/issue-17758.rs:7:14
|
LL | self.foo();
| ^^^
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error
......
......@@ -88,9 +88,19 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on
|
LL | impl<'a> Publisher<'a> for MyStruct<'a> {
| ^^
= note: ...so that the types are compatible:
expected Publisher<'_>
found Publisher<'_>
note: ...so that the types are compatible
--> $DIR/issue-20831-debruijn.rs:28:5
|
LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
LL | | // Not obvious, but there is an implicit lifetime here -------^
LL | |
LL | |
... |
LL | | self.sub = t;
LL | | }
| |_____^
= note: expected `Publisher<'_>`
found `Publisher<'_>`
error: aborting due to 3 previous errors
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
| ^^
= note: ...so that the types are compatible:
expected (&&(T,),)
found (&&'a (T,),)
note: ...so that the types are compatible
--> $DIR/issue-52213.rs:2:11
|
LL | match (&t,) {
| ^^^^^
= note: expected `(&&(T,),)`
found `(&&'a (T,),)`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 1:27...
--> $DIR/issue-52213.rs:1:27
|
......
......@@ -15,9 +15,13 @@ note: ...so that the type `std::iter::Map<<Self as Graph<'a>>::EdgesIter, [closu
LL | Box::new(self.out_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
note: ...so that the expression is assignable
--> $DIR/issue-55796.rs:16:9
|
LL | Box::new(self.out_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/issue-55796.rs:21:9
......@@ -36,9 +40,13 @@ note: ...so that the type `std::iter::Map<<Self as Graph<'a>>::EdgesIter, [closu
LL | Box::new(self.in_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
note: ...so that the expression is assignable
--> $DIR/issue-55796.rs:21:9
|
LL | Box::new(self.in_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error: aborting due to 2 previous errors
......
#![allow(non_camel_case_types)]
trait r#async {
fn r#struct(&self) {
println!("async");
}
}
trait r#await {
fn r#struct(&self) {
println!("await");
}
}
struct r#fn {}
impl r#async for r#fn {}
impl r#await for r#fn {}
fn main() {
r#fn {}.r#struct(); //~ ERROR multiple applicable items in scope
}
error[E0034]: multiple applicable items in scope
--> $DIR/issue-65634-raw-ident-suggestion.rs:21:13
|
LL | r#fn {}.r#struct();
| ^^^^^^^^ multiple `r#struct` found
|
note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
--> $DIR/issue-65634-raw-ident-suggestion.rs:4:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
= help: to disambiguate the method call, write `async::r#struct(r#fn {})` instead
note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn`
--> $DIR/issue-65634-raw-ident-suggestion.rs:10:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
= help: to disambiguate the method call, write `await::r#struct(r#fn {})` instead
error: aborting due to previous error
For more information about this error, try `rustc --explain E0034`.
// Breaks with values inside closures used to ICE (#66863)
fn main() {
'some_label: loop {
|| break 'some_label (); //~ ERROR: `break` inside of a closure
}
}
error[E0267]: `break` inside of a closure
--> $DIR/issue-66702-break-outside-loop-val.rs:5:12
|
LL | || break 'some_label ();
| -- ^^^^^^^^^^^^^^^^^^^^ cannot `break` inside of a closure
| |
| enclosing closure
error: aborting due to previous error
For more information about this error, try `rustc --explain E0267`.
// Regression test for #67037.
//
// In type checking patterns, E0023 occurs when the tuple pattern and the expected
// tuple pattern have different number of fields. For example, as below, `P()`,
// the tuple struct pattern, has 0 fields, but requires 1 field.
//
// In emitting E0023, we try to see if this is a case of e.g., `Some(a, b, c)` but where
// the scrutinee was of type `Some((a, b, c))`, and suggest that parenthesis be added.
//
// However, we did not account for the expected type being different than the tuple pattern type.
// This caused an issue when the tuple pattern type (`P<T>`) was generic.
// Specifically, we tried deriving the 0th field's type using the `substs` of the expected type.
// When attempting to substitute `T`, there was no such substitution, so "out of range" occured.
struct U {} // 0 type parameters offered
struct P<T>(T); // 1 type parameter wanted
fn main() {
let P() = U {}; //~ ERROR mismatched types
//~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 1 field
}
error[E0308]: mismatched types
--> $DIR/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs:19:9
|
LL | let P() = U {};
| ^^^ expected struct `U`, found struct `P`
|
= note: expected struct `U`
found struct `P<_>`
error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 1 field
--> $DIR/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs:19:9
|
LL | struct P<T>(T); // 1 type parameter wanted
| --------------- tuple struct defined here
...
LL | let P() = U {};
| ^^^ expected 1 field, found 0
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0023, E0308.
For more information about an error, try `rustc --explain E0023`.
......@@ -21,9 +21,13 @@ note: but, the lifetime must be valid for the lifetime `'_` as defined on the im
|
LL | impl Foo<'_> {
| ^^
= note: ...so that the expression is assignable:
expected Foo<'_>
found Foo<'_>
note: ...so that the expression is assignable
--> $DIR/issue-55394.rs:9:9
|
LL | Foo { bar }
| ^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'_>`
error: aborting due to previous error
......
......@@ -14,9 +14,13 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
| ^^
= note: ...so that the types are compatible:
expected Visitor<'d>
found Visitor<'_>
note: ...so that the types are compatible
--> $DIR/normalization-bounds-error.rs:12:1
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Visitor<'d>`
found `Visitor<'_>`
error: aborting due to previous error
......
......@@ -11,17 +11,25 @@ LL | / fn from_box(b: Box<B>) -> Self {
LL | | C { f: b }
LL | | }
| |_____^
= note: ...so that the expression is assignable:
expected std::boxed::Box<std::boxed::Box<&isize>>
found std::boxed::Box<std::boxed::Box<&isize>>
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:17:16
|
LL | C { f: b }
| ^
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
found `std::boxed::Box<std::boxed::Box<&isize>>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 15:6...
--> $DIR/type-alias-free-regions.rs:15:6
|
LL | impl<'a> FromBox<'a> for C<'a> {
| ^^
= note: ...so that the expression is assignable:
expected C<'a>
found C<'_>
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:17:9
|
LL | C { f: b }
| ^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:27:16
......@@ -36,17 +44,25 @@ LL | / fn from_tuple(b: (B,)) -> Self {
LL | | C { f: Box::new(b.0) }
LL | | }
| |_____^
= note: ...so that the expression is assignable:
expected std::boxed::Box<&isize>
found std::boxed::Box<&isize>
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:27:25
|
LL | C { f: Box::new(b.0) }
| ^^^
= note: expected `std::boxed::Box<&isize>`
found `std::boxed::Box<&isize>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 25:6...
--> $DIR/type-alias-free-regions.rs:25:6
|
LL | impl<'a> FromTuple<'a> for C<'a> {
| ^^
= note: ...so that the expression is assignable:
expected C<'a>
found C<'_>
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:27:9
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
error: aborting due to 2 previous errors
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| ^^
= note: ...so that the types are compatible:
expected Foo<'_>
found Foo<'a>
note: ...so that the types are compatible
--> $DIR/constant-in-expr-inherent-1.rs:8:5
|
LL | <Foo<'a>>::C
| ^^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-inherent-1.rs:8:5
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
| ^^
= note: ...so that the types are compatible:
expected Foo<'_>
found Foo<'a>
note: ...so that the types are compatible
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
|
LL | T::C
| ^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
......
......@@ -19,9 +19,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
|
LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
| ^^
= note: ...so that the expression is assignable:
expected &'b (dyn SomeTrait + 'b)
found &dyn SomeTrait
note: ...so that the expression is assignable
--> $DIR/object-lifetime-default-elision.rs:71:5
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/object-lifetime-default-elision.rs:71:5
......@@ -44,9 +48,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
|
LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
| ^^
= note: ...so that the expression is assignable:
expected &'b (dyn SomeTrait + 'b)
found &dyn SomeTrait
note: ...so that the expression is assignable
--> $DIR/object-lifetime-default-elision.rs:71:5
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error: aborting due to 2 previous errors
......
......@@ -11,11 +11,11 @@ fn test_union() {
}
fn test_if_2() {
let _ = r#if; //~ ERROR cannot find value `if` in this scope
let _ = r#if; //~ ERROR cannot find value `r#if` in this scope
}
fn test_struct_2() {
let _ = r#struct; //~ ERROR cannot find value `struct` in this scope
let _ = r#struct; //~ ERROR cannot find value `r#struct` in this scope
}
fn test_union_2() {
......
......@@ -16,13 +16,13 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
LL | r#union Test;
| ^^^^ expected one of 8 possible tokens
error[E0425]: cannot find value `if` in this scope
error[E0425]: cannot find value `r#if` in this scope
--> $DIR/raw-literal-keywords.rs:14:13
|
LL | let _ = r#if;
| ^^^^ not found in this scope
error[E0425]: cannot find value `struct` in this scope
error[E0425]: cannot find value `r#struct` in this scope
--> $DIR/raw-literal-keywords.rs:18:13
|
LL | let _ = r#struct;
......
......@@ -34,17 +34,25 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
expected &[u8]
found &'a [u8]
note: ...so that the expression is assignable
--> $DIR/region-object-lifetime-in-coercion.rs:26:14
|
LL | Box::new(v)
| ^
= note: expected `&[u8]`
found `&'a [u8]`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9...
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn Foo + 'b)>
found std::boxed::Box<dyn Foo>
note: ...so that the expression is assignable
--> $DIR/region-object-lifetime-in-coercion.rs:26:5
|
LL | Box::new(v)
| ^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
found `std::boxed::Box<dyn Foo>`
error: aborting due to 4 previous errors
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
|
LL | impl<'a> Foo<'static> for &'a i32 {
| ^^
= note: ...so that the types are compatible:
expected Foo<'static>
found Foo<'static>
note: ...so that the types are compatible
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
|
LL | impl<'a> Foo<'static> for &'a i32 {
| ^^^^^^^^^^^^
= note: expected `Foo<'static>`
found `Foo<'static>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
......@@ -30,9 +34,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
|
LL | impl<'a,'b> Foo<'b> for &'a i64 {
| ^^
= note: ...so that the types are compatible:
expected Foo<'b>
found Foo<'_>
note: ...so that the types are compatible
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
|
LL | impl<'a,'b> Foo<'b> for &'a i64 {
| ^^^^^^^
= note: expected `Foo<'b>`
found `Foo<'_>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
|
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
|
LL | impl<'a> Foo for &'a i32 {
| ^^
= note: ...so that the types are compatible:
expected Foo
found Foo
note: ...so that the types are compatible
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
|
LL | impl<'a> Foo for &'a i32 {
| ^^^
= note: expected `Foo`
found `Foo`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
......
......@@ -15,9 +15,13 @@ note: ...so that the type `(dyn A<T> + 'a)` is not borrowed for too long
LL | box B(&*v) as Box<dyn X>
| ^^^
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn X + 'static)>
found std::boxed::Box<dyn X>
note: ...so that the expression is assignable
--> $DIR/regions-close-object-into-object-2.rs:10:5
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error
......
......@@ -15,9 +15,13 @@ note: ...so that the type `(dyn A<U> + 'a)` is not borrowed for too long
LL | box B(&*v) as Box<dyn X>
| ^^^
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn X + 'static)>
found std::boxed::Box<dyn X>
note: ...so that the expression is assignable
--> $DIR/regions-close-object-into-object-4.rs:10:5
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error
......
......@@ -19,9 +19,13 @@ note: but, the lifetime must be valid for the lifetime `'c` as defined on the fu
|
LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
| ^^
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn SomeTrait + 'c)>
found std::boxed::Box<dyn SomeTrait>
note: ...so that the expression is assignable
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
LL | box v as Box<dyn SomeTrait + 'a>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
found `std::boxed::Box<dyn SomeTrait>`
error: aborting due to previous error
......
......@@ -9,17 +9,25 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
|
LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
| ^^
= note: ...so that the expression is assignable:
expected &Ast<'_>
found &Ast<'a>
note: ...so that the expression is assignable
--> $DIR/regions-creating-enums4.rs:7:14
|
LL | Ast::Add(x, y)
| ^
= note: expected `&Ast<'_>`
found `&Ast<'a>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 6:19...
--> $DIR/regions-creating-enums4.rs:6:19
|
LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
| ^^
= note: ...so that the expression is assignable:
expected Ast<'b>
found Ast<'_>
note: ...so that the expression is assignable
--> $DIR/regions-creating-enums4.rs:7:5
|
LL | Ast::Add(x, y)
| ^^^^^^^^^^^^^^
= note: expected `Ast<'b>`
found `Ast<'_>`
error: aborting due to previous error
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
|
LL | s.f(|p| p)
| ^^^^^
= note: ...so that the expression is assignable:
expected &i32
found &i32
note: ...so that the expression is assignable
--> $DIR/regions-escape-method.rs:15:13
|
LL | s.f(|p| p)
| ^
= note: expected `&i32`
found `&i32`
note: but, the lifetime must be valid for the method call at 15:5...
--> $DIR/regions-escape-method.rs:15:5
|
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
|
LL | with(|o| o)
| ^^^^^
= note: ...so that the expression is assignable:
expected &isize
found &isize
note: ...so that the expression is assignable
--> $DIR/regions-escape-via-trait-or-not.rs:18:14
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the expression at 18:5...
--> $DIR/regions-escape-via-trait-or-not.rs:18:5
|
......
......@@ -29,9 +29,18 @@ LL | | if false { return ay; }
LL | | return z;
LL | | }));
| |_____^
= note: ...so that the types are compatible:
expected &isize
found &isize
note: ...so that the types are compatible
--> $DIR/regions-nested-fns.rs:13:76
|
LL | ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
| ____________________________________________________________________________^
LL | | if false { return x; }
LL | | if false { return ay; }
LL | | return z;
LL | | }));
| |_____^
= note: expected `&isize`
found `&isize`
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/regions-nested-fns.rs:14:27
......
......@@ -17,9 +17,16 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined on
|
LL | fn bar<'a, 'b>()
| ^^
= note: ...so that the types are compatible:
expected Project<'a, 'b>
found Project<'_, '_>
note: ...so that the types are compatible
--> $DIR/regions-normalize-in-where-clause-list.rs:22:1
|
LL | / fn bar<'a, 'b>()
LL | | where <() as Project<'a, 'b>>::Item : Eq
LL | | {
LL | | }
| |_^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error: aborting due to previous error
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
|
LL | with(|o| o)
| ^^^^^
= note: ...so that the expression is assignable:
expected &isize
found &isize
note: ...so that the expression is assignable
--> $DIR/regions-ret-borrowed-1.rs:10:14
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 9:14...
--> $DIR/regions-ret-borrowed-1.rs:9:14
|
......
......@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
|
LL | with(|o| o)
| ^^^^^
= note: ...so that the expression is assignable:
expected &isize
found &isize
note: ...so that the expression is assignable
--> $DIR/regions-ret-borrowed.rs:13:14
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 12:14...
--> $DIR/regions-ret-borrowed.rs:12:14
|
......
......@@ -36,9 +36,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
|
LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
| ^^
= note: ...so that the expression is assignable:
expected &'b mut (dyn Dummy + 'b)
found &mut (dyn Dummy + 'b)
note: ...so that the expression is assignable
--> $DIR/regions-trait-object-subtyping.rs:15:5
|
LL | x
| ^
= note: expected `&'b mut (dyn Dummy + 'b)`
found `&mut (dyn Dummy + 'b)`
error[E0308]: mismatched types
--> $DIR/regions-trait-object-subtyping.rs:22:5
......
......@@ -105,9 +105,13 @@ note: ...but the lifetime must also be valid for the lifetime `'l2` as defined o
|
LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
| ^^^
= note: ...so that the types are compatible:
expected W<'l1, 'l2>
found W<'_, '_>
note: ...so that the types are compatible
--> $DIR/reject-specialized-drops-8142.rs:54:1
|
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `W<'l1, 'l2>`
found `W<'_, '_>`
error: aborting due to 8 previous errors
......
......@@ -5,5 +5,5 @@ pub fn break() {} //~ ERROR expected identifier, found keyword `break`
fn main() {
foo::let(); //~ ERROR expected identifier, found keyword `let`
r#break(); //~ ERROR cannot find function `break` in this scope
r#break(); //~ ERROR cannot find function `r#break` in this scope
}
......@@ -20,7 +20,7 @@ help: you can escape reserved keywords to use them as identifiers
LL | foo::r#let();
| ^^^^^
error[E0425]: cannot find function `break` in this scope
error[E0425]: cannot find function `r#break` in this scope
--> $DIR/raw-name-use-suggestion.rs:8:5
|
LL | r#break();
......
......@@ -14,9 +14,13 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined on
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^
= note: ...so that the types are compatible:
expected T1<'a>
found T1<'_>
note: ...so that the types are compatible
--> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^^^^^^^^^
= note: expected `T1<'a>`
found `T1<'_>`
error: aborting due to previous error
......
......@@ -18,9 +18,13 @@ note: ...so that reference does not outlive borrowed content
LL | Box::new(items.iter())
| ^^^^^
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>
found std::boxed::Box<dyn std::iter::Iterator<Item = &T>>
note: ...so that the expression is assignable
--> $DIR/dyn-trait-underscore.rs:8:5
|
LL | Box::new(items.iter())
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
error: aborting due to previous error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册