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
This commit is contained in:
commit
f6840f33e6
75 changed files with 638 additions and 258 deletions
|
@ -3806,7 +3806,6 @@ dependencies = [
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
"rustc_feature",
|
"rustc_feature",
|
||||||
"rustc_lexer",
|
"rustc_lexer",
|
||||||
"rustc_target",
|
|
||||||
"smallvec 1.0.0",
|
"smallvec 1.0.0",
|
||||||
"syntax",
|
"syntax",
|
||||||
"syntax_pos",
|
"syntax_pos",
|
||||||
|
|
|
@ -1648,10 +1648,8 @@ impl<T> Weak<T> {
|
||||||
|
|
||||||
/// Returns a raw pointer to the object `T` pointed to by this `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 is valid only if there are some strong references. The pointer may be dangling
|
||||||
/// the pointer.
|
/// or even [`null`] otherwise.
|
||||||
///
|
|
||||||
/// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1731,14 +1729,18 @@ impl<T> Weak<T> {
|
||||||
/// This can be used to safely get a strong reference (by calling [`upgrade`]
|
/// 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>`.
|
/// 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
|
/// It takes ownership of one weak count (with the exception of pointers created by [`new`],
|
||||||
/// returned.
|
/// as these don't have any corresponding weak count).
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The pointer must represent one valid weak count. In other words, it must point to `T` which
|
/// The pointer must have originated from the [`into_raw`] (or [`as_raw`], provided there was
|
||||||
/// is or *was* managed by an [`Rc`] and the weak count of that [`Rc`] must not have reached
|
/// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
|
||||||
/// 0. It is allowed for the strong count to be 0.
|
/// 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
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1763,11 +1765,13 @@ impl<T> Weak<T> {
|
||||||
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
|
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`null`]: ../../std/ptr/fn.null.html
|
|
||||||
/// [`into_raw`]: struct.Weak.html#method.into_raw
|
/// [`into_raw`]: struct.Weak.html#method.into_raw
|
||||||
/// [`upgrade`]: struct.Weak.html#method.upgrade
|
/// [`upgrade`]: struct.Weak.html#method.upgrade
|
||||||
/// [`Rc`]: struct.Rc.html
|
/// [`Rc`]: struct.Rc.html
|
||||||
/// [`Weak`]: struct.Weak.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")]
|
#[unstable(feature = "weak_into_raw", issue = "60728")]
|
||||||
pub unsafe fn from_raw(ptr: *const T) -> Self {
|
pub unsafe fn from_raw(ptr: *const T) -> Self {
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
|
|
|
@ -1324,10 +1324,8 @@ impl<T> Weak<T> {
|
||||||
|
|
||||||
/// Returns a raw pointer to the object `T` pointed to by this `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 is valid only if there are some strong references. The pointer may be dangling
|
||||||
/// the pointer.
|
/// or even [`null`] otherwise.
|
||||||
///
|
|
||||||
/// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1408,14 +1406,18 @@ impl<T> Weak<T> {
|
||||||
/// This can be used to safely get a strong reference (by calling [`upgrade`]
|
/// 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>`.
|
/// 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
|
/// It takes ownership of one weak count (with the exception of pointers created by [`new`],
|
||||||
/// returned.
|
/// as these don't have any corresponding weak count).
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The pointer must represent one valid weak count. In other words, it must point to `T` which
|
/// The pointer must have originated from the [`into_raw`] (or [`as_raw'], provided there was
|
||||||
/// is or *was* managed by an [`Arc`] and the weak count of that [`Arc`] must not have reached
|
/// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
|
||||||
/// 0. It is allowed for the strong count to be 0.
|
/// 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
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1440,11 +1442,13 @@ impl<T> Weak<T> {
|
||||||
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
|
/// 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
|
/// [`into_raw`]: struct.Weak.html#method.into_raw
|
||||||
/// [`upgrade`]: struct.Weak.html#method.upgrade
|
/// [`upgrade`]: struct.Weak.html#method.upgrade
|
||||||
/// [`Weak`]: struct.Weak.html
|
/// [`Weak`]: struct.Weak.html
|
||||||
/// [`Arc`]: struct.Arc.html
|
/// [`Arc`]: struct.Arc.html
|
||||||
|
/// [`forget`]: ../../std/mem/fn.forget.html
|
||||||
#[unstable(feature = "weak_into_raw", issue = "60728")]
|
#[unstable(feature = "weak_into_raw", issue = "60728")]
|
||||||
pub unsafe fn from_raw(ptr: *const T) -> Self {
|
pub unsafe fn from_raw(ptr: *const T) -> Self {
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
|
|
|
@ -74,6 +74,8 @@
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(const_fn_union)]
|
#![feature(const_fn_union)]
|
||||||
#![feature(const_generics)]
|
#![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(custom_inner_attributes)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(doc_cfg)]
|
#![feature(doc_cfg)]
|
||||||
|
|
|
@ -3371,8 +3371,8 @@ impl str {
|
||||||
/// An iterator over the disjoint matches of a pattern within the given string
|
/// An iterator over the disjoint matches of a pattern within the given string
|
||||||
/// slice.
|
/// slice.
|
||||||
///
|
///
|
||||||
/// The pattern can be any type that implements the Pattern trait. Notable
|
/// The pattern can be a `&str`, [`char`], or a closure that determines if
|
||||||
/// examples are `&str`, [`char`], and closures that determines the split.
|
/// a character matches.
|
||||||
///
|
///
|
||||||
/// # Iterator behavior
|
/// # Iterator behavior
|
||||||
///
|
///
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
//!
|
//!
|
||||||
//! Atomic variables are safe to share between threads (they implement [`Sync`])
|
//! Atomic variables are safe to share between threads (they implement [`Sync`])
|
||||||
//! but they do not themselves provide the mechanism for sharing and follow the
|
//! 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
|
//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
|
||||||
//! atomically-reference-counted shared pointer).
|
//! atomically-reference-counted shared pointer).
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -1809,12 +1809,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
sub_region,
|
sub_region,
|
||||||
"...",
|
"...",
|
||||||
);
|
);
|
||||||
err.note(&format!(
|
err.span_note(sup_trace.cause.span, &format!(
|
||||||
"...so that the {}:\nexpected {}\n found {}",
|
"...so that the {}",
|
||||||
sup_trace.cause.as_requirement_str(),
|
sup_trace.cause.as_requirement_str()
|
||||||
sup_expected.content(),
|
|
||||||
sup_found.content()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
|
err.note_expected_found(
|
||||||
|
&"",
|
||||||
|
sup_expected,
|
||||||
|
&"",
|
||||||
|
sup_found
|
||||||
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
match *origin {
|
match *origin {
|
||||||
infer::Subtype(ref trace) => {
|
infer::Subtype(ref trace) => {
|
||||||
if let Some((expected, found)) = self.values_str(&trace.values) {
|
if let Some((expected, found)) = self.values_str(&trace.values) {
|
||||||
let expected = expected.content();
|
err.span_note(
|
||||||
let found = found.content();
|
trace.cause.span,
|
||||||
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
|
&format!(
|
||||||
trace.cause.as_requirement_str(),
|
"...so that the {}",
|
||||||
expected,
|
trace.cause.as_requirement_str()
|
||||||
found));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
err.note_expected_found(
|
||||||
|
&"",
|
||||||
|
expected,
|
||||||
|
&"",
|
||||||
|
found
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: this really should be handled at some earlier stage. Our
|
// FIXME: this really should be handled at some earlier stage. Our
|
||||||
// handling of region checking when type errors are present is
|
// handling of region checking when type errors are present is
|
||||||
|
|
|
@ -1282,6 +1282,9 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
||||||
if !self.empty_path {
|
if !self.empty_path {
|
||||||
write!(self, "::")?;
|
write!(self, "::")?;
|
||||||
}
|
}
|
||||||
|
if ast::Ident::from_str(&name).is_raw_guess() {
|
||||||
|
write!(self, "r#")?;
|
||||||
|
}
|
||||||
write!(self, "{}", name)?;
|
write!(self, "{}", name)?;
|
||||||
|
|
||||||
// FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it
|
// FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it
|
||||||
|
|
|
@ -77,7 +77,12 @@ impl ConstKind {
|
||||||
let mode = match tcx.hir().body_owner_kind(hir_id) {
|
let mode = match tcx.hir().body_owner_kind(hir_id) {
|
||||||
HirKind::Closure => return None,
|
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::Fn => return None,
|
||||||
|
|
||||||
HirKind::Const => ConstKind::Const,
|
HirKind::Const => ConstKind::Const,
|
||||||
|
|
|
@ -12,12 +12,11 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
log = "0.4"
|
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_data_structures = { path = "../librustc_data_structures" }
|
||||||
rustc_feature = { path = "../librustc_feature" }
|
rustc_feature = { path = "../librustc_feature" }
|
||||||
rustc_lexer = { path = "../librustc_lexer" }
|
rustc_lexer = { path = "../librustc_lexer" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
rustc_errors = { path = "../librustc_errors" }
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
|
||||||
rustc_error_codes = { path = "../librustc_error_codes" }
|
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 crate::validate_attr;
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
|
use rustc_errors::Applicability;
|
||||||
use syntax::attr::HasAttrs;
|
use syntax::attr::HasAttrs;
|
||||||
use syntax::feature_gate::{feature_err, get_features};
|
use syntax::feature_gate::{feature_err, get_features};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
@ -21,7 +22,6 @@ use syntax::sess::ParseSess;
|
||||||
use syntax::util::map_in_place::MapInPlace;
|
use syntax::util::map_in_place::MapInPlace;
|
||||||
use syntax_pos::symbol::sym;
|
use syntax_pos::symbol::sym;
|
||||||
|
|
||||||
use errors::Applicability;
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
/// A folder that strips out items that do not belong in the current configuration.
|
/// A folder that strips out items that do not belong in the current configuration.
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
use syntax::token::{self, Token, TokenKind};
|
use rustc_data_structures::sync::Lrc;
|
||||||
use syntax::sess::ParseSess;
|
use rustc_errors::{FatalError, DiagnosticBuilder};
|
||||||
use syntax::symbol::{sym, Symbol};
|
|
||||||
use syntax::util::comments;
|
|
||||||
|
|
||||||
use errors::{FatalError, DiagnosticBuilder};
|
|
||||||
use syntax_pos::{BytePos, Pos, Span};
|
|
||||||
use rustc_lexer::Base;
|
use rustc_lexer::Base;
|
||||||
use rustc_lexer::unescape;
|
use rustc_lexer::unescape;
|
||||||
|
use syntax::token::{self, Token, TokenKind};
|
||||||
|
use syntax::sess::ParseSess;
|
||||||
|
use syntax::util::comments;
|
||||||
|
use syntax_pos::symbol::{sym, Symbol};
|
||||||
|
use syntax_pos::{BytePos, Pos, Span};
|
||||||
|
|
||||||
use std::char;
|
use std::char;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use rustc_data_structures::sync::Lrc;
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
mod tokentrees;
|
mod tokentrees;
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
|
||||||
use syntax_pos::Span;
|
|
||||||
|
|
||||||
use super::{StringReader, UnmatchedBrace};
|
use super::{StringReader, UnmatchedBrace};
|
||||||
|
|
||||||
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
use rustc_errors::PResult;
|
||||||
use syntax::print::pprust::token_to_string;
|
use syntax::print::pprust::token_to_string;
|
||||||
use syntax::token::{self, Token};
|
use syntax::token::{self, Token};
|
||||||
use syntax::tokenstream::{DelimSpan, IsJoint::{self, *}, TokenStream, TokenTree, TreeAndJoint};
|
use syntax::tokenstream::{DelimSpan, IsJoint::{self, *}, TokenStream, TokenTree, TreeAndJoint};
|
||||||
|
use syntax_pos::Span;
|
||||||
use errors::PResult;
|
|
||||||
|
|
||||||
impl<'a> StringReader<'a> {
|
impl<'a> StringReader<'a> {
|
||||||
crate fn into_token_trees(self) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>) {
|
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
|
// http://www.unicode.org/Public/security/10.0.0/confusables.txt
|
||||||
|
|
||||||
use super::StringReader;
|
use super::StringReader;
|
||||||
use errors::{Applicability, DiagnosticBuilder};
|
|
||||||
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
|
|
||||||
use crate::token;
|
use crate::token;
|
||||||
|
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||||
|
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
|
||||||
|
|
||||||
#[rustfmt::skip] // for line breaks
|
#[rustfmt::skip] // for line breaks
|
||||||
const UNICODE_ARRAY: &[(char, &str, char)] = &[
|
const UNICODE_ARRAY: &[(char, &str, char)] = &[
|
||||||
|
|
|
@ -8,7 +8,7 @@ use syntax::sess::ParseSess;
|
||||||
use syntax::token::{self, Nonterminal};
|
use syntax::token::{self, Nonterminal};
|
||||||
use syntax::tokenstream::{self, TokenStream, TokenTree};
|
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 rustc_data_structures::sync::Lrc;
|
||||||
use syntax_pos::{Span, SourceFile, FileName};
|
use syntax_pos::{Span, SourceFile, FileName};
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ pub enum DirectoryOwnership {
|
||||||
macro_rules! panictry_buffer {
|
macro_rules! panictry_buffer {
|
||||||
($handler:expr, $e:expr) => ({
|
($handler:expr, $e:expr) => ({
|
||||||
use std::result::Result::{Ok, Err};
|
use std::result::Result::{Ok, Err};
|
||||||
use errors::FatalError;
|
use rustc_errors::FatalError;
|
||||||
match $e {
|
match $e {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
Err(errs) => {
|
Err(errs) => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use super::{SeqSep, Parser, TokenType, PathStyle};
|
use super::{SeqSep, Parser, TokenType, PathStyle};
|
||||||
|
use rustc_errors::PResult;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::util::comments;
|
use syntax::util::comments;
|
||||||
use syntax::token::{self, Nonterminal};
|
use syntax::token::{self, Nonterminal};
|
||||||
use syntax_pos::{Span, Symbol};
|
use syntax_pos::{Span, Symbol};
|
||||||
use errors::PResult;
|
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
use super::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType, SeqSep, Parser};
|
use super::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType, SeqSep, Parser};
|
||||||
|
|
||||||
use syntax::ast::{
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, ItemKind,
|
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
|
||||||
Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind,
|
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::token::{self, TokenKind, token_can_begin_expr};
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::{kw, sym};
|
|
||||||
use syntax::ThinVec;
|
use syntax::ThinVec;
|
||||||
use syntax::util::parser::AssocOp;
|
use syntax::util::parser::AssocOp;
|
||||||
use syntax::struct_span_err;
|
use syntax::struct_span_err;
|
||||||
|
use syntax_pos::symbol::{kw, sym};
|
||||||
use errors::{PResult, Applicability, DiagnosticBuilder, pluralize};
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
|
||||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
|
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
|
||||||
|
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_error_codes::*;
|
|
||||||
|
|
||||||
const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
|
const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
|
||||||
|
|
||||||
/// Creates a placeholder argument.
|
/// Creates a placeholder argument.
|
||||||
|
@ -61,10 +58,10 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
fn span_err<S: Into<MultiSpan>>(
|
fn span_err(
|
||||||
self,
|
self,
|
||||||
sp: S,
|
sp: impl Into<MultiSpan>,
|
||||||
handler: &errors::Handler,
|
handler: &Handler,
|
||||||
) -> DiagnosticBuilder<'_> {
|
) -> DiagnosticBuilder<'_> {
|
||||||
match self {
|
match self {
|
||||||
Error::FileNotFoundForModule {
|
Error::FileNotFoundForModule {
|
||||||
|
@ -212,7 +209,7 @@ impl<'a> Parser<'a> {
|
||||||
self.sess.span_diagnostic.span_bug(sp, m)
|
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
|
&self.sess.span_diagnostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,23 +4,20 @@ use super::pat::{GateOr, PARAM_EXPECTED};
|
||||||
use super::diagnostics::Error;
|
use super::diagnostics::Error;
|
||||||
use crate::maybe_recover_from_interpolated_ty_qpath;
|
use crate::maybe_recover_from_interpolated_ty_qpath;
|
||||||
|
|
||||||
use syntax::ast::{
|
use rustc_data_structures::thin_vec::ThinVec;
|
||||||
self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode,
|
use rustc_errors::{PResult, Applicability};
|
||||||
Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind,
|
use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
|
||||||
FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit,
|
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::token::{self, Token, TokenKind};
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::source_map::{self, Span};
|
|
||||||
use syntax::util::classify;
|
use syntax::util::classify;
|
||||||
use syntax::util::literal::LitError;
|
use syntax::util::literal::LitError;
|
||||||
use syntax::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
|
use syntax::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
|
||||||
use syntax_pos::symbol::{kw, sym};
|
use syntax_pos::source_map::{self, Span};
|
||||||
use syntax_pos::Symbol;
|
use syntax_pos::symbol::{kw, sym, Symbol};
|
||||||
use errors::{PResult, Applicability};
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
|
|
||||||
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
|
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
|
||||||
/// dropped into the token stream, which happens while parsing the result of
|
/// dropped into the token stream, which happens while parsing the result of
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use super::Parser;
|
use super::Parser;
|
||||||
|
|
||||||
|
use rustc_errors::PResult;
|
||||||
use syntax::ast::{self, WhereClause, GenericParam, GenericParamKind, GenericBounds, Attribute};
|
use syntax::ast::{self, WhereClause, GenericParam, GenericParamKind, GenericBounds, Attribute};
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax::source_map::DUMMY_SP;
|
use syntax::source_map::DUMMY_SP;
|
||||||
use syntax_pos::symbol::{kw, sym};
|
use syntax_pos::symbol::{kw, sym};
|
||||||
|
|
||||||
use errors::PResult;
|
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
|
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
|
||||||
|
|
|
@ -3,6 +3,8 @@ use super::diagnostics::{Error, dummy_arg, ConsumeClosingDelim};
|
||||||
|
|
||||||
use crate::maybe_whole;
|
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::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item};
|
||||||
use syntax::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, UseTree, UseTreeKind};
|
use syntax::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, UseTree, UseTreeKind};
|
||||||
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
|
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
|
||||||
|
@ -14,16 +16,13 @@ use syntax::ptr::P;
|
||||||
use syntax::ThinVec;
|
use syntax::ThinVec;
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
|
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
|
||||||
use syntax::source_map::{self, respan, Span};
|
|
||||||
use syntax::struct_span_err;
|
use syntax::struct_span_err;
|
||||||
use syntax_pos::BytePos;
|
use syntax_pos::BytePos;
|
||||||
|
use syntax_pos::source_map::{self, respan, Span};
|
||||||
use syntax_pos::symbol::{kw, sym, Symbol};
|
use syntax_pos::symbol::{kw, sym, Symbol};
|
||||||
|
|
||||||
use rustc_error_codes::*;
|
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
|
|
||||||
|
|
||||||
pub(super) type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);
|
pub(super) type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);
|
||||||
|
|
||||||
|
|
|
@ -14,23 +14,20 @@ use diagnostics::Error;
|
||||||
use crate::{Directory, DirectoryOwnership};
|
use crate::{Directory, DirectoryOwnership};
|
||||||
use crate::lexer::UnmatchedBrace;
|
use crate::lexer::UnmatchedBrace;
|
||||||
|
|
||||||
use syntax::ast::{
|
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
|
||||||
self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit,
|
use rustc_data_structures::thin_vec::ThinVec;
|
||||||
IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety,
|
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::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::token::{self, Token, TokenKind, DelimToken};
|
use syntax::token::{self, Token, TokenKind, DelimToken};
|
||||||
use syntax::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint};
|
use syntax::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint};
|
||||||
use syntax::sess::ParseSess;
|
use syntax::sess::ParseSess;
|
||||||
use syntax::source_map::respan;
|
|
||||||
use syntax::struct_span_err;
|
use syntax::struct_span_err;
|
||||||
use syntax::util::comments::{doc_comment_style, strip_doc_comment_decoration};
|
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::symbol::{kw, sym, Symbol};
|
||||||
use syntax_pos::{Span, BytePos, DUMMY_SP, FileName};
|
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 log::debug;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
|
@ -4,13 +4,12 @@ use super::diagnostics::Error;
|
||||||
|
|
||||||
use crate::{new_sub_parser_from_file, DirectoryOwnership};
|
use crate::{new_sub_parser_from_file, DirectoryOwnership};
|
||||||
|
|
||||||
|
use rustc_errors::PResult;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ast::{self, Ident, Attribute, ItemKind, Mod, Crate};
|
use syntax::ast::{self, Ident, Attribute, ItemKind, Mod, Crate};
|
||||||
use syntax::token::{self, TokenKind};
|
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 syntax_pos::symbol::sym;
|
||||||
use errors::PResult;
|
|
||||||
|
|
||||||
use std::path::{self, Path, PathBuf};
|
use std::path::{self, Path, PathBuf};
|
||||||
|
|
||||||
|
@ -212,13 +211,13 @@ impl<'a> Parser<'a> {
|
||||||
// `./<id>.rs` and `./<id>/mod.rs`.
|
// `./<id>.rs` and `./<id>/mod.rs`.
|
||||||
let relative_prefix_string;
|
let relative_prefix_string;
|
||||||
let relative_prefix = if let Some(ident) = relative {
|
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
|
&relative_prefix_string
|
||||||
} else {
|
} 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 default_path_str = format!("{}{}.rs", relative_prefix, mod_name);
|
||||||
let secondary_path_str = format!("{}{}{}mod.rs",
|
let secondary_path_str = format!("{}{}{}mod.rs",
|
||||||
relative_prefix, mod_name, path::MAIN_SEPARATOR);
|
relative_prefix, mod_name, path::MAIN_SEPARATOR);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::{Parser, PathStyle};
|
use super::{Parser, PathStyle};
|
||||||
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
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::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
|
||||||
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
|
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
|
||||||
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
|
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
|
||||||
|
@ -7,9 +8,8 @@ use syntax::ptr::P;
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ThinVec;
|
use syntax::ThinVec;
|
||||||
use syntax::token;
|
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 syntax_pos::symbol::{kw, sym};
|
||||||
use errors::{PResult, Applicability, DiagnosticBuilder};
|
|
||||||
|
|
||||||
type Expected = Option<&'static str>;
|
type Expected = Option<&'static str>;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use super::{Parser, TokenType};
|
use super::{Parser, TokenType};
|
||||||
use crate::maybe_whole;
|
use crate::maybe_whole;
|
||||||
|
use rustc_errors::{PResult, Applicability, pluralize};
|
||||||
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
|
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
|
||||||
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
|
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
|
||||||
use syntax::ast::MacArgs;
|
use syntax::ast::MacArgs;
|
||||||
use syntax::ThinVec;
|
use syntax::ThinVec;
|
||||||
use syntax::token::{self, Token};
|
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 syntax_pos::symbol::{kw, sym};
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use errors::{PResult, Applicability, pluralize};
|
|
||||||
|
|
||||||
/// Specifies how to parse a path.
|
/// Specifies how to parse a path.
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
|
@ -6,6 +6,7 @@ use super::diagnostics::Error;
|
||||||
use crate::maybe_whole;
|
use crate::maybe_whole;
|
||||||
use crate::DirectoryOwnership;
|
use crate::DirectoryOwnership;
|
||||||
|
|
||||||
|
use rustc_errors::{PResult, Applicability};
|
||||||
use syntax::ThinVec;
|
use syntax::ThinVec;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
@ -13,11 +14,10 @@ use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, E
|
||||||
use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
|
use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
|
||||||
use syntax::util::classify;
|
use syntax::util::classify;
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax::source_map::{respan, Span};
|
use syntax_pos::source_map::{respan, Span};
|
||||||
use syntax::symbol::{kw, sym};
|
use syntax_pos::symbol::{kw, sym};
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use errors::{PResult, Applicability};
|
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
/// Parses a statement. This stops just before trailing semicolons on everything but items.
|
/// Parses a statement. This stops just before trailing semicolons on everything but items.
|
||||||
|
|
|
@ -3,19 +3,17 @@ use super::item::ParamCfg;
|
||||||
|
|
||||||
use crate::{maybe_whole, maybe_recover_from_interpolated_ty_qpath};
|
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::ptr::P;
|
||||||
use syntax::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
|
use syntax::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
|
||||||
use syntax::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
|
use syntax::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
|
||||||
use syntax::ast::{Mutability, AnonConst, Mac};
|
use syntax::ast::{Mutability, AnonConst, Mac};
|
||||||
use syntax::token::{self, Token};
|
use syntax::token::{self, Token};
|
||||||
use syntax::source_map::Span;
|
|
||||||
use syntax::struct_span_fatal;
|
use syntax::struct_span_fatal;
|
||||||
|
use syntax_pos::source_map::Span;
|
||||||
use syntax_pos::symbol::kw;
|
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>`,
|
/// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT<u8, u8>`,
|
||||||
/// `IDENT<<u8 as Trait>::AssocTy>`.
|
/// `IDENT<<u8 as Trait>::AssocTy>`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Meta-syntax validation logic of attributes for post-expansion.
|
//! 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 rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP};
|
||||||
use syntax::ast::{self, Attribute, AttrKind, Ident, MacArgs, MetaItem, MetaItemKind};
|
use syntax::ast::{self, Attribute, AttrKind, Ident, MacArgs, MetaItem, MetaItemKind};
|
||||||
use syntax::attr::mk_name_value_item_str;
|
use syntax::attr::mk_name_value_item_str;
|
||||||
|
|
|
@ -65,13 +65,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn demand_eqtype_pat(
|
pub fn demand_eqtype_pat_diag(
|
||||||
&self,
|
&self,
|
||||||
cause_span: Span,
|
cause_span: Span,
|
||||||
expected: Ty<'tcx>,
|
expected: Ty<'tcx>,
|
||||||
actual: Ty<'tcx>,
|
actual: Ty<'tcx>,
|
||||||
match_expr_span: Option<Span>,
|
match_expr_span: Option<Span>,
|
||||||
) {
|
) -> Option<DiagnosticBuilder<'tcx>> {
|
||||||
let cause = if let Some(span) = match_expr_span {
|
let cause = if let Some(span) = match_expr_span {
|
||||||
self.cause(
|
self.cause(
|
||||||
cause_span,
|
cause_span,
|
||||||
|
@ -80,9 +80,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
self.misc(cause_span)
|
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,
|
pub fn demand_coerce(&self,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
|
|
|
@ -582,11 +582,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// If this is a break with a value, we need to type-check
|
// If this is a break with a value, we need to type-check
|
||||||
// the expression. Get an expected type from the loop context.
|
// the expression. Get an expected type from the loop context.
|
||||||
let opt_coerce_to = {
|
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();
|
let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
|
||||||
enclosing_breakables.find_breakable(target_id)
|
match enclosing_breakables.opt_find_breakable(target_id) {
|
||||||
.coerce
|
Some(ctxt) =>
|
||||||
.as_ref()
|
ctxt.coerce.as_ref().map(|coerce| coerce.expected_ty()),
|
||||||
.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
|
// If the loop context is not a `loop { }`, then break with
|
||||||
|
|
|
@ -703,7 +703,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let pat_ty = pat_ty.fn_sig(tcx).output();
|
let pat_ty = pat_ty.fn_sig(tcx).output();
|
||||||
let pat_ty = pat_ty.no_bound_vars().expect("expected fn type");
|
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.
|
// Type-check subpatterns.
|
||||||
if subpats.len() == variant.fields.len()
|
if subpats.len() == variant.fields.len()
|
||||||
|
@ -721,7 +724,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Pattern has wrong number of fields.
|
// 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();
|
on_error();
|
||||||
return tcx.types.err;
|
return tcx.types.err;
|
||||||
}
|
}
|
||||||
|
@ -734,8 +737,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
res: Res,
|
res: Res,
|
||||||
qpath: &hir::QPath,
|
qpath: &hir::QPath,
|
||||||
subpats: &'tcx [P<Pat>],
|
subpats: &'tcx [P<Pat>],
|
||||||
fields: &[ty::FieldDef],
|
fields: &'tcx [ty::FieldDef],
|
||||||
expected: Ty<'tcx>
|
expected: Ty<'tcx>,
|
||||||
|
had_err: bool,
|
||||||
) {
|
) {
|
||||||
let subpats_ending = pluralize!(subpats.len());
|
let subpats_ending = pluralize!(subpats.len());
|
||||||
let fields_ending = pluralize!(fields.len());
|
let fields_ending = pluralize!(fields.len());
|
||||||
|
@ -763,9 +767,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// More generally, the expected type wants a tuple variant with one field of an
|
// 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
|
// 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)`.
|
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
|
||||||
let missing_parenthesis = match expected.kind {
|
let missing_parenthesis = match (&expected.kind, fields, had_err) {
|
||||||
ty::Adt(_, substs) if fields.len() == 1 => {
|
// #67037: only do this if we could sucessfully type-check the expected type against
|
||||||
let field_ty = fields[0].ty(self.tcx, substs);
|
// 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 {
|
match field_ty.kind {
|
||||||
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
|
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -869,12 +869,18 @@ impl Hash for Ident {
|
||||||
|
|
||||||
impl fmt::Debug for Ident {
|
impl fmt::Debug for Ident {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if self.is_raw_guess() {
|
||||||
|
write!(f, "r#")?;
|
||||||
|
}
|
||||||
write!(f, "{}{:?}", self.name, self.span.ctxt())
|
write!(f, "{}{:?}", self.name, self.span.ctxt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Ident {
|
impl fmt::Display for Ident {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if self.is_raw_guess() {
|
||||||
|
write!(f, "r#")?;
|
||||||
|
}
|
||||||
fmt::Display::fmt(&self.name, f)
|
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> {
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected Type<'_>
|
--> $DIR/project-fn-ret-invariant.rs:48:13
|
||||||
found Type<'a>
|
|
|
||||||
|
LL | bar(foo, x)
|
||||||
|
| ^
|
||||||
|
= note: expected `Type<'_>`
|
||||||
|
found `Type<'a>`
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected Type<'static>
|
--> $DIR/project-fn-ret-invariant.rs:48:4
|
||||||
found Type<'_>
|
|
|
||||||
|
LL | bar(foo, x)
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
= note: expected `Type<'static>`
|
||||||
|
found `Type<'_>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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 });
|
LL | let _ = ap.with_copy(|ap| { ap });
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected core::ffi::VaList<'_, '_>
|
--> $DIR/variadic-ffi-4.rs:16:33
|
||||||
found core::ffi::VaList<'_, '_>
|
|
|
||||||
|
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...
|
note: but, the lifetime must be valid for the method call at 16:13...
|
||||||
--> $DIR/variadic-ffi-4.rs:16:13
|
--> $DIR/variadic-ffi-4.rs:16:13
|
||||||
|
|
|
|
||||||
|
|
29
src/test/ui/consts/unstable-const-fn-in-libcore.rs
Normal file
29
src/test/ui/consts/unstable-const-fn-in-libcore.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// 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() {}
|
22
src/test/ui/consts/unstable-const-fn-in-libcore.stderr
Normal file
22
src/test/ui/consts/unstable-const-fn-in-libcore.stderr
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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>) {
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<dyn std::fmt::Debug>
|
--> $DIR/dyn-trait.rs:20:16
|
||||||
found std::boxed::Box<(dyn std::fmt::Debug + 'a)>
|
|
|
||||||
|
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: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected StaticTrait
|
--> $DIR/dyn-trait.rs:20:5
|
||||||
found StaticTrait
|
|
|
||||||
|
LL | static_val(x);
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
= note: expected `StaticTrait`
|
||||||
|
found `StaticTrait`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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> {
|
LL | trait T<'a> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected &'a Self
|
--> $DIR/issue-16683.rs:4:14
|
||||||
found &Self
|
|
|
||||||
|
LL | self.a();
|
||||||
|
| ^
|
||||||
|
= note: expected `&'a Self`
|
||||||
|
found `&Self`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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> {
|
LL | trait Foo<'a> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected &'a Self
|
--> $DIR/issue-17758.rs:7:14
|
||||||
found &Self
|
|
|
||||||
|
LL | self.foo();
|
||||||
|
| ^^^
|
||||||
|
= note: expected `&'a Self`
|
||||||
|
found `&Self`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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> {
|
LL | impl<'a> Publisher<'a> for MyStruct<'a> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Publisher<'_>
|
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||||
found Publisher<'_>
|
|
|
||||||
|
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
|
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 {
|
LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected (&&(T,),)
|
--> $DIR/issue-52213.rs:2:11
|
||||||
found (&&'a (T,),)
|
|
|
||||||
|
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...
|
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
|
--> $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()))
|
LL | Box::new(self.out_edges(u).map(|e| e.target()))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
|
--> $DIR/issue-55796.rs:16:9
|
||||||
found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
|
|
|
||||||
|
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
|
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||||
--> $DIR/issue-55796.rs:21:9
|
--> $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()))
|
LL | Box::new(self.in_edges(u).map(|e| e.target()))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
|
--> $DIR/issue-55796.rs:21:9
|
||||||
found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
|
|
|
||||||
|
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
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
22
src/test/ui/issues/issue-65634-raw-ident-suggestion.rs
Normal file
22
src/test/ui/issues/issue-65634-raw-ident-suggestion.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#![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
|
||||||
|
}
|
22
src/test/ui/issues/issue-65634-raw-ident-suggestion.stderr
Normal file
22
src/test/ui/issues/issue-65634-raw-ident-suggestion.stderr
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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`.
|
7
src/test/ui/issues/issue-66702-break-outside-loop-val.rs
Normal file
7
src/test/ui/issues/issue-66702-break-outside-loop-val.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// Breaks with values inside closures used to ICE (#66863)
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
'some_label: loop {
|
||||||
|
|| break 'some_label (); //~ ERROR: `break` inside of a closure
|
||||||
|
}
|
||||||
|
}
|
11
src/test/ui/issues/issue-66702-break-outside-loop-val.stderr
Normal file
11
src/test/ui/issues/issue-66702-break-outside-loop-val.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
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`.
|
|
@ -0,0 +1,21 @@
|
||||||
|
// 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
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
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<'_> {
|
LL | impl Foo<'_> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected Foo<'_>
|
--> $DIR/issue-55394.rs:9:9
|
||||||
found Foo<'_>
|
|
|
||||||
|
LL | Foo { bar }
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
= note: expected `Foo<'_>`
|
||||||
|
found `Foo<'_>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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 {}
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Visitor<'d>
|
--> $DIR/normalization-bounds-error.rs:12:1
|
||||||
found Visitor<'_>
|
|
|
||||||
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= note: expected `Visitor<'d>`
|
||||||
|
found `Visitor<'_>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,25 @@ LL | / fn from_box(b: Box<B>) -> Self {
|
||||||
LL | | C { f: b }
|
LL | | C { f: b }
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____^
|
| |_____^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<std::boxed::Box<&isize>>
|
--> $DIR/type-alias-free-regions.rs:17:16
|
||||||
found std::boxed::Box<std::boxed::Box<&isize>>
|
|
|
||||||
|
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...
|
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
|
--> $DIR/type-alias-free-regions.rs:15:6
|
||||||
|
|
|
|
||||||
LL | impl<'a> FromBox<'a> for C<'a> {
|
LL | impl<'a> FromBox<'a> for C<'a> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected C<'a>
|
--> $DIR/type-alias-free-regions.rs:17:9
|
||||||
found C<'_>
|
|
|
||||||
|
LL | C { f: b }
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
= note: expected `C<'a>`
|
||||||
|
found `C<'_>`
|
||||||
|
|
||||||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||||
--> $DIR/type-alias-free-regions.rs:27:16
|
--> $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 | | C { f: Box::new(b.0) }
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____^
|
| |_____^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<&isize>
|
--> $DIR/type-alias-free-regions.rs:27:25
|
||||||
found std::boxed::Box<&isize>
|
|
|
||||||
|
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...
|
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
|
--> $DIR/type-alias-free-regions.rs:25:6
|
||||||
|
|
|
|
||||||
LL | impl<'a> FromTuple<'a> for C<'a> {
|
LL | impl<'a> FromTuple<'a> for C<'a> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected C<'a>
|
--> $DIR/type-alias-free-regions.rs:27:9
|
||||||
found C<'_>
|
|
|
||||||
|
LL | C { f: Box::new(b.0) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= note: expected `C<'a>`
|
||||||
|
found `C<'_>`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
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 {
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Foo<'_>
|
--> $DIR/constant-in-expr-inherent-1.rs:8:5
|
||||||
found Foo<'a>
|
|
|
||||||
|
LL | <Foo<'a>>::C
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
= note: expected `Foo<'_>`
|
||||||
|
found `Foo<'a>`
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
note: ...so that reference does not outlive borrowed content
|
note: ...so that reference does not outlive borrowed content
|
||||||
--> $DIR/constant-in-expr-inherent-1.rs:8:5
|
--> $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 {
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Foo<'_>
|
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
|
||||||
found Foo<'a>
|
|
|
||||||
|
LL | T::C
|
||||||
|
| ^^^^
|
||||||
|
= note: expected `Foo<'_>`
|
||||||
|
found `Foo<'a>`
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
note: ...so that reference does not outlive borrowed content
|
note: ...so that reference does not outlive borrowed content
|
||||||
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
|
--> $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 {
|
LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &'b (dyn SomeTrait + 'b)
|
--> $DIR/object-lifetime-default-elision.rs:71:5
|
||||||
found &dyn SomeTrait
|
|
|
||||||
|
LL | ss
|
||||||
|
| ^^
|
||||||
|
= note: expected `&'b (dyn SomeTrait + 'b)`
|
||||||
|
found `&dyn SomeTrait`
|
||||||
|
|
||||||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||||
--> $DIR/object-lifetime-default-elision.rs:71:5
|
--> $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 {
|
LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &'b (dyn SomeTrait + 'b)
|
--> $DIR/object-lifetime-default-elision.rs:71:5
|
||||||
found &dyn SomeTrait
|
|
|
||||||
|
LL | ss
|
||||||
|
| ^^
|
||||||
|
= note: expected `&'b (dyn SomeTrait + 'b)`
|
||||||
|
found `&dyn SomeTrait`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ fn test_union() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_2() {
|
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() {
|
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() {
|
fn test_union_2() {
|
||||||
|
|
|
@ -16,13 +16,13 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
|
||||||
LL | r#union Test;
|
LL | r#union Test;
|
||||||
| ^^^^ expected one of 8 possible tokens
|
| ^^^^ 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
|
--> $DIR/raw-literal-keywords.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let _ = r#if;
|
LL | let _ = r#if;
|
||||||
| ^^^^ not found in this scope
|
| ^^^^ 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
|
--> $DIR/raw-literal-keywords.rs:18:13
|
||||||
|
|
|
|
||||||
LL | let _ = r#struct;
|
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> {
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &[u8]
|
--> $DIR/region-object-lifetime-in-coercion.rs:26:14
|
||||||
found &'a [u8]
|
|
|
||||||
|
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...
|
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
|
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
|
||||||
|
|
|
|
||||||
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn Foo + 'b)>
|
--> $DIR/region-object-lifetime-in-coercion.rs:26:5
|
||||||
found std::boxed::Box<dyn Foo>
|
|
|
||||||
|
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
|
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 {
|
LL | impl<'a> Foo<'static> for &'a i32 {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Foo<'static>
|
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
|
||||||
found Foo<'static>
|
|
|
||||||
|
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: but, the lifetime must be valid for the static lifetime...
|
||||||
note: ...so that the type `&i32` will meet its required lifetime bounds
|
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
|
--> $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 {
|
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Foo<'b>
|
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
|
||||||
found Foo<'_>
|
|
|
||||||
|
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...
|
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
|
--> $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 {
|
LL | impl<'a> Foo for &'a i32 {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Foo
|
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
|
||||||
found Foo
|
|
|
||||||
|
LL | impl<'a> Foo for &'a i32 {
|
||||||
|
| ^^^
|
||||||
|
= note: expected `Foo`
|
||||||
|
found `Foo`
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
note: ...so that the type `&i32` will meet its required lifetime bounds
|
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
|
--> $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>
|
LL | box B(&*v) as Box<dyn X>
|
||||||
| ^^^
|
| ^^^
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn X + 'static)>
|
--> $DIR/regions-close-object-into-object-2.rs:10:5
|
||||||
found std::boxed::Box<dyn X>
|
|
|
||||||
|
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
|
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>
|
LL | box B(&*v) as Box<dyn X>
|
||||||
| ^^^
|
| ^^^
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn X + 'static)>
|
--> $DIR/regions-close-object-into-object-4.rs:10:5
|
||||||
found std::boxed::Box<dyn X>
|
|
|
||||||
|
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
|
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> {
|
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:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn SomeTrait + 'c)>
|
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
||||||
found std::boxed::Box<dyn SomeTrait>
|
|
|
||||||
|
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
|
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> {
|
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:
|
note: ...so that the expression is assignable
|
||||||
expected &Ast<'_>
|
--> $DIR/regions-creating-enums4.rs:7:14
|
||||||
found &Ast<'a>
|
|
|
||||||
|
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...
|
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
|
--> $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> {
|
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:
|
note: ...so that the expression is assignable
|
||||||
expected Ast<'b>
|
--> $DIR/regions-creating-enums4.rs:7:5
|
||||||
found Ast<'_>
|
|
|
||||||
|
LL | Ast::Add(x, y)
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
= note: expected `Ast<'b>`
|
||||||
|
found `Ast<'_>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
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)
|
LL | s.f(|p| p)
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &i32
|
--> $DIR/regions-escape-method.rs:15:13
|
||||||
found &i32
|
|
|
||||||
|
LL | s.f(|p| p)
|
||||||
|
| ^
|
||||||
|
= note: expected `&i32`
|
||||||
|
found `&i32`
|
||||||
note: but, the lifetime must be valid for the method call at 15:5...
|
note: but, the lifetime must be valid for the method call at 15:5...
|
||||||
--> $DIR/regions-escape-method.rs: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)
|
LL | with(|o| o)
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &isize
|
--> $DIR/regions-escape-via-trait-or-not.rs:18:14
|
||||||
found &isize
|
|
|
||||||
|
LL | with(|o| o)
|
||||||
|
| ^
|
||||||
|
= note: expected `&isize`
|
||||||
|
found `&isize`
|
||||||
note: but, the lifetime must be valid for the expression at 18:5...
|
note: but, the lifetime must be valid for the expression at 18:5...
|
||||||
--> $DIR/regions-escape-via-trait-or-not.rs: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 | | return z;
|
||||||
LL | | }));
|
LL | | }));
|
||||||
| |_____^
|
| |_____^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected &isize
|
--> $DIR/regions-nested-fns.rs:13:76
|
||||||
found &isize
|
|
|
||||||
|
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...
|
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
|
||||||
--> $DIR/regions-nested-fns.rs:14:27
|
--> $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>()
|
LL | fn bar<'a, 'b>()
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected Project<'a, 'b>
|
--> $DIR/regions-normalize-in-where-clause-list.rs:22:1
|
||||||
found Project<'_, '_>
|
|
|
||||||
|
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
|
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)
|
LL | with(|o| o)
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &isize
|
--> $DIR/regions-ret-borrowed-1.rs:10:14
|
||||||
found &isize
|
|
|
||||||
|
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...
|
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
|
--> $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)
|
LL | with(|o| o)
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &isize
|
--> $DIR/regions-ret-borrowed.rs:13:14
|
||||||
found &isize
|
|
|
||||||
|
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...
|
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
|
--> $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 {
|
LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected &'b mut (dyn Dummy + 'b)
|
--> $DIR/regions-trait-object-subtyping.rs:15:5
|
||||||
found &mut (dyn Dummy + 'b)
|
|
|
||||||
|
LL | x
|
||||||
|
| ^
|
||||||
|
= note: expected `&'b mut (dyn Dummy + 'b)`
|
||||||
|
found `&mut (dyn Dummy + 'b)`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/regions-trait-object-subtyping.rs:22:5
|
--> $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 }
|
LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
|
||||||
| ^^^
|
| ^^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected W<'l1, 'l2>
|
--> $DIR/reject-specialized-drops-8142.rs:54:1
|
||||||
found W<'_, '_>
|
|
|
||||||
|
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
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,5 @@ mod foo {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo::let(); //~ ERROR expected identifier, found keyword `let`
|
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();
|
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
|
--> $DIR/raw-name-use-suggestion.rs:8:5
|
||||||
|
|
|
|
||||||
LL | r#break();
|
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> {
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...so that the types are compatible:
|
note: ...so that the types are compatible
|
||||||
expected T1<'a>
|
--> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
|
||||||
found T1<'_>
|
|
|
||||||
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
= note: expected `T1<'a>`
|
||||||
|
found `T1<'_>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,13 @@ note: ...so that reference does not outlive borrowed content
|
||||||
LL | Box::new(items.iter())
|
LL | Box::new(items.iter())
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= note: but, the lifetime must be valid for the static lifetime...
|
= note: but, the lifetime must be valid for the static lifetime...
|
||||||
= note: ...so that the expression is assignable:
|
note: ...so that the expression is assignable
|
||||||
expected std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>
|
--> $DIR/dyn-trait-underscore.rs:8:5
|
||||||
found std::boxed::Box<dyn std::iter::Iterator<Item = &T>>
|
|
|
||||||
|
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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue