1
Fork 0

Auto merge of #66021 - tmandry:rollup-y13l6n9, r=tmandry

Rollup of 16 pull requests

Successful merges:

 - #65112 (Add lint and tests for unnecessary parens around types)
 - #65470 (Don't hide ICEs from previous incremental compiles)
 - #65471 (Add long error explanation for E0578)
 - #65857 (rustdoc: Resolve module-level doc references more locally)
 - #65902 (Make ItemContext available for better diagnositcs)
 - #65914 (Use structured suggestion for unnecessary bounds in type aliases)
 - #65946 (Make `promote_consts` emit the errors when required promotion fails)
 - #65960 (doc: reword iter module example and mention other methods)
 - #65963 (update submodules to rust-lang)
 - #65972 (Fix libunwind build: Define __LITTLE_ENDIAN__ for LE targets)
 - #65977 (Fix incorrect diagnostics for expected type in E0271 with an associated type)
 - #65995 (Add error code E0743 for "C-variadic has been used on a non-foreign function")
 - #65997 (Fix outdated rustdoc of Once::init_locking function)
 - #66002 (Stabilize float_to_from_bytes feature)
 - #66005 (vxWorks: remove code related unix socket)
 - #66018 (Revert PR 64324: dylibs export generics again (for now))

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-11-01 18:23:04 +00:00
commit 87cbf0a547
75 changed files with 789 additions and 2110 deletions

6
.gitmodules vendored
View file

@ -3,13 +3,13 @@
url = https://github.com/rust-lang/rust-installer.git
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang-nursery/nomicon.git
url = https://github.com/rust-lang/nomicon.git
[submodule "src/tools/cargo"]
path = src/tools/cargo
url = https://github.com/rust-lang/cargo.git
[submodule "src/doc/reference"]
path = src/doc/reference
url = https://github.com/rust-lang-nursery/reference.git
url = https://github.com/rust-lang/reference.git
[submodule "src/doc/book"]
path = src/doc/book
url = https://github.com/rust-lang/book.git
@ -36,7 +36,7 @@
url = https://github.com/rust-lang/rustc-guide.git
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide.git
url = https://github.com/rust-lang/edition-guide.git
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git

View file

@ -118,26 +118,16 @@
//!
//! let mut counter = Counter::new();
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//! assert_eq!(counter.next(), Some(1));
//! assert_eq!(counter.next(), Some(2));
//! assert_eq!(counter.next(), Some(3));
//! assert_eq!(counter.next(), Some(4));
//! assert_eq!(counter.next(), Some(5));
//! assert_eq!(counter.next(), None);
//! ```
//!
//! This will print `1` through `5`, each on their own line.
//!
//! Calling `next()` this way gets repetitive. Rust has a construct which can
//! call `next()` on your iterator, until it reaches `None`. Let's go over that
//! Calling [`next`] this way gets repetitive. Rust has a construct which can
//! call [`next`] on your iterator, until it reaches `None`. Let's go over that
//! next.
//!
//! Also note that `Iterator` provides a default implementation of methods such as `nth` and `fold`
@ -253,20 +243,23 @@
//! ```
//!
//! The idiomatic way to write a [`map`] for its side effects is to use a
//! `for` loop instead:
//! `for` loop or call the [`for_each`] method:
//!
//! ```
//! let v = vec![1, 2, 3, 4, 5];
//!
//! v.iter().for_each(|x| println!("{}", x));
//! // or
//! for x in &v {
//! println!("{}", x);
//! }
//! ```
//!
//! [`map`]: trait.Iterator.html#method.map
//! [`for_each`]: trait.Iterator.html#method.for_each
//!
//! The two most common ways to evaluate an iterator are to use a `for` loop
//! like this, or using the [`collect`] method to produce a new collection.
//! Another common way to evaluate an iterator is to use the [`collect`]
//! method to produce a new collection.
//!
//! [`collect`]: trait.Iterator.html#method.collect
//!

View file

@ -466,11 +466,10 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f32.to_be_bytes();
/// assert_eq!(bytes, [0x41, 0x48, 0x00, 0x00]);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_be_bytes(self) -> [u8; 4] {
self.to_bits().to_be_bytes()
@ -482,11 +481,10 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f32.to_le_bytes();
/// assert_eq!(bytes, [0x00, 0x00, 0x48, 0x41]);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_le_bytes(self) -> [u8; 4] {
self.to_bits().to_le_bytes()
@ -504,7 +502,6 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f32.to_ne_bytes();
/// assert_eq!(
/// bytes,
@ -515,7 +512,7 @@ impl f32 {
/// }
/// );
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_ne_bytes(self) -> [u8; 4] {
self.to_bits().to_ne_bytes()
@ -526,11 +523,10 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f32::from_be_bytes([0x41, 0x48, 0x00, 0x00]);
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_be_bytes(bytes: [u8; 4]) -> Self {
Self::from_bits(u32::from_be_bytes(bytes))
@ -541,11 +537,10 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f32::from_le_bytes([0x00, 0x00, 0x48, 0x41]);
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_le_bytes(bytes: [u8; 4]) -> Self {
Self::from_bits(u32::from_le_bytes(bytes))
@ -563,7 +558,6 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f32::from_ne_bytes(if cfg!(target_endian = "big") {
/// [0x41, 0x48, 0x00, 0x00]
/// } else {
@ -571,7 +565,7 @@ impl f32 {
/// });
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_ne_bytes(bytes: [u8; 4]) -> Self {
Self::from_bits(u32::from_ne_bytes(bytes))

View file

@ -479,11 +479,10 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f64.to_be_bytes();
/// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_be_bytes(self) -> [u8; 8] {
self.to_bits().to_be_bytes()
@ -495,11 +494,10 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f64.to_le_bytes();
/// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_le_bytes(self) -> [u8; 8] {
self.to_bits().to_le_bytes()
@ -517,7 +515,6 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let bytes = 12.5f64.to_ne_bytes();
/// assert_eq!(
/// bytes,
@ -528,7 +525,7 @@ impl f64 {
/// }
/// );
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn to_ne_bytes(self) -> [u8; 8] {
self.to_bits().to_ne_bytes()
@ -539,11 +536,10 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f64::from_be_bytes([0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_be_bytes(bytes: [u8; 8]) -> Self {
Self::from_bits(u64::from_be_bytes(bytes))
@ -554,11 +550,10 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f64::from_le_bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_le_bytes(bytes: [u8; 8]) -> Self {
Self::from_bits(u64::from_le_bytes(bytes))
@ -576,7 +571,6 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(float_to_from_bytes)]
/// let value = f64::from_ne_bytes(if cfg!(target_endian = "big") {
/// [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
/// } else {
@ -584,7 +578,7 @@ impl f64 {
/// });
/// assert_eq!(value, 12.5);
/// ```
#[unstable(feature = "float_to_from_bytes", issue = "60446")]
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
#[inline]
pub fn from_ne_bytes(bytes: [u8; 8]) -> Self {
Self::from_bits(u64::from_ne_bytes(bytes))

View file

@ -5,7 +5,7 @@
/// extracting those success or failure values from an existing instance and
/// creating a new instance from a success or failure value.
#[unstable(feature = "try_trait", issue = "42327")]
#[rustc_on_unimplemented(
#[cfg_attr(bootstrap, rustc_on_unimplemented(
on(all(
any(from_method="from_error", from_method="from_ok"),
from_desugaring="QuestionMark"),
@ -17,7 +17,20 @@
message="the `?` operator can only be applied to values \
that implement `{Try}`",
label="the `?` operator cannot be applied to type `{Self}`")
)]
))]
#[cfg_attr(not(bootstrap), rustc_on_unimplemented(
on(all(
any(from_method="from_error", from_method="from_ok"),
from_desugaring="QuestionMark"),
message="the `?` operator can only be used in {ItemContext} \
that returns `Result` or `Option` \
(or another type that implements `{Try}`)",
label="cannot use the `?` operator in {ItemContext} that returns `{Self}`"),
on(all(from_method="into_result", from_desugaring="QuestionMark"),
message="the `?` operator can only be applied to values \
that implement `{Try}`",
label="the `?` operator cannot be applied to type `{Self}`")
))]
#[doc(alias = "?")]
pub trait Try {
/// The type of this value when viewed as successful.

View file

@ -62,7 +62,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
&self,
arg: &'tcx hir::Ty,
br: &ty::BoundRegion,
) -> Option<(&'tcx hir::Ty)> {
) -> Option<&'tcx hir::Ty> {
let mut nested_visitor = FindNestedTypeVisitor {
tcx: self.tcx(),
bound_region: *br,

View file

@ -312,6 +312,9 @@ impl Session {
pub fn has_errors(&self) -> bool {
self.diagnostic().has_errors()
}
pub fn has_errors_or_delayed_span_bugs(&self) -> bool {
self.diagnostic().has_errors_or_delayed_span_bugs()
}
pub fn abort_if_errors(&self) {
self.diagnostic().abort_if_errors();
}

View file

@ -226,13 +226,26 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
0,
&mut obligations
);
debug!("report_projection_error obligation.cause={:?} obligation.param_env={:?}",
obligation.cause, obligation.param_env);
debug!("report_projection_error normalized_ty={:?} data.ty={:?}",
normalized_ty, data.ty);
let is_normalized_ty_expected = match &obligation.cause.code {
ObligationCauseCode::ItemObligation(_) |
ObligationCauseCode::BindingObligation(_, _) |
ObligationCauseCode::ObjectCastObligation(_) => false,
_ => true,
};
if let Err(error) = self.at(&obligation.cause, obligation.param_env)
.eq(normalized_ty, data.ty)
.eq_exp(is_normalized_ty_expected, normalized_ty, data.ty)
{
values = Some(infer::ValuePairs::Types(ExpectedFound {
expected: normalized_ty,
found: data.ty,
}));
values = Some(infer::ValuePairs::Types(
ExpectedFound::new(is_normalized_ty_expected, normalized_ty, data.ty)));
err_buf = error;
err = &err_buf;
}
@ -353,6 +366,52 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}
fn describe_generator(&self, body_id: hir::BodyId) -> Option<&'static str> {
self.tcx.hir().body(body_id).generator_kind.map(|gen_kind| {
match gen_kind {
hir::GeneratorKind::Gen => "a generator",
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "an async block",
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "an async function",
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "an async closure",
}
})
}
/// Used to set on_unimplemented's `ItemContext`
/// to be the enclosing (async) block/function/closure
fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
let hir = &self.tcx.hir();
let node = hir.find(hir_id)?;
if let hir::Node::Item(
hir::Item{kind: hir::ItemKind::Fn(_ ,fn_header ,_ , body_id), .. }) = &node {
self.describe_generator(*body_id).or_else(||
Some(if let hir::FnHeader{ asyncness: hir::IsAsync::Async, .. } = fn_header {
"an async function"
} else {
"a function"
})
)
} else if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability), .. }) = &node {
self.describe_generator(*body_id).or_else(||
Some(if gen_movability.is_some() {
"an async closure"
} else {
"a closure"
})
)
} else if let hir::Node::Expr(hir::Expr { .. }) = &node {
let parent_hid = hir.get_parent_node(hir_id);
if parent_hid != hir_id {
return self.describe_enclosure(parent_hid);
} else {
None
}
} else {
None
}
}
fn on_unimplemented_note(
&self,
trait_ref: ty::PolyTraitRef<'tcx>,
@ -363,6 +422,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let trait_ref = *trait_ref.skip_binder();
let mut flags = vec![];
flags.push((sym::item_context,
self.describe_enclosure(obligation.cause.body_id).map(|s|s.to_owned())));
match obligation.cause.code {
ObligationCauseCode::BuiltinDerivedObligation(..) |
ObligationCauseCode::ImplDerivedObligation(..) => {}

View file

@ -248,6 +248,8 @@ impl<'tcx> OnUnimplementedFormatString {
Position::ArgumentNamed(s) if s == sym::from_method => (),
// `{from_desugaring}` is allowed
Position::ArgumentNamed(s) if s == sym::from_desugaring => (),
// `{ItemContext}` is allowed
Position::ArgumentNamed(s) if s == sym::item_context => (),
// So is `{A}` if A is a type parameter
Position::ArgumentNamed(s) => match generics.params.iter().find(|param| {
param.name == s
@ -296,6 +298,7 @@ impl<'tcx> OnUnimplementedFormatString {
let s = self.0.as_str();
let parser = Parser::new(&s, None, vec![], false);
let item_context = (options.get(&sym::item_context)).unwrap_or(&empty_string);
parser.map(|p|
match p {
Piece::String(s) => s,
@ -311,6 +314,8 @@ impl<'tcx> OnUnimplementedFormatString {
} else if s == sym::from_desugaring || s == sym::from_method {
// don't break messages using these two arguments incorrectly
&empty_string
} else if s == sym::item_context {
&item_context
} else {
bug!("broken on_unimplemented {:?} for {:?}: \
no argument matching {:?}",

View file

@ -1514,8 +1514,14 @@ impl<'tcx> TyCtxt<'tcx> {
CrateType::Executable |
CrateType::Staticlib |
CrateType::ProcMacro |
CrateType::Dylib |
CrateType::Cdylib => false,
// FIXME rust-lang/rust#64319, rust-lang/rust#64872:
// We want to block export of generics from dylibs,
// but we must fix rust-lang/rust#65890 before we can
// do that robustly.
CrateType::Dylib => true,
CrateType::Rlib => true,
}
})

View file

@ -14,7 +14,6 @@ use rustc::middle::dependency_format::Linkage;
use rustc::session::Session;
use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
LinkerPluginLto, Lto};
use rustc::middle::exported_symbols::ExportedSymbol;
use rustc::ty::TyCtxt;
use rustc_target::spec::{LinkerFlavor, LldFlavor};
use rustc_serialize::{json, Encoder};
@ -1112,20 +1111,10 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
continue;
}
// Do not export generic symbols from upstream crates in linked
// artifact (notably the `dylib` crate type). The main reason
// for this is that `symbol_name` is actually wrong for generic
// symbols because it guesses the name we'd give them locally
// rather than the name it has upstream (depending on
// `share_generics` settings and such).
//
// To fix that issue we just say that linked artifacts, aka
// `dylib`s, never export generic symbols and they aren't
// available to downstream crates. (the not available part is
// handled elsewhere).
if let ExportedSymbol::Generic(..) = symbol {
continue;
}
// FIXME rust-lang/rust#64319, rust-lang/rust#64872:
// We want to block export of generics from dylibs,
// but we must fix rust-lang/rust#65890 before we can
// do that robustly.
symbols.push(symbol.symbol_name(tcx).to_string());
}

View file

@ -1046,14 +1046,14 @@ unsafe impl<O, T: ?Sized> CloneStableAddress for OwningRef<O, T>
where O: CloneStableAddress {}
unsafe impl<O, T: ?Sized> Send for OwningRef<O, T>
where O: Send, for<'a> (&'a T): Send {}
where O: Send, for<'a> &'a T: Send {}
unsafe impl<O, T: ?Sized> Sync for OwningRef<O, T>
where O: Sync, for<'a> (&'a T): Sync {}
where O: Sync, for<'a> &'a T: Sync {}
unsafe impl<O, T: ?Sized> Send for OwningRefMut<O, T>
where O: Send, for<'a> (&'a mut T): Send {}
where O: Send, for<'a> &'a mut T: Send {}
unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
where O: Sync, for<'a> (&'a mut T): Sync {}
where O: Sync, for<'a> &'a mut T: Sync {}
impl Debug for dyn Erased {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View file

@ -492,10 +492,10 @@ impl<T> Once<T> {
assert!(self.try_set(value).is_none());
}
/// Tries to initialize the inner value by calling the closure while ensuring that no-one else
/// can access the value in the mean time by holding a lock for the duration of the closure.
/// If the value was already initialized the closure is not called and `false` is returned,
/// otherwise if the value from the closure initializes the inner value, `true` is returned
/// Initializes the inner value if it wasn't already done by calling the provided closure. It
/// ensures that no-one else can access the value in the mean time by holding a lock for the
/// duration of the closure.
/// A reference to the inner value is returned.
#[inline]
pub fn init_locking<F: FnOnce() -> T>(&self, f: F) -> &T {
{

View file

@ -704,6 +704,9 @@ impl Handler {
pub fn has_errors(&self) -> bool {
self.inner.borrow().has_errors()
}
pub fn has_errors_or_delayed_span_bugs(&self) -> bool {
self.inner.borrow().has_errors_or_delayed_span_bugs()
}
pub fn print_error_count(&self, registry: &Registry) {
self.inner.borrow_mut().print_error_count(registry)
@ -862,6 +865,9 @@ impl HandlerInner {
fn has_errors(&self) -> bool {
self.err_count() > 0
}
fn has_errors_or_delayed_span_bugs(&self) -> bool {
self.has_errors() || !self.delayed_span_bugs.is_empty()
}
fn abort_if_errors_and_should_abort(&mut self) {
self.emit_stashed_diagnostics();

View file

@ -307,7 +307,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Svh) {
let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone();
if sess.has_errors() {
if sess.has_errors_or_delayed_span_bugs() {
// If there have been any errors during compilation, we don't want to
// publish this session directory. Rather, we'll just delete it.

View file

@ -22,6 +22,10 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) {
if sess.opts.incremental.is_none() {
return;
}
// This is going to be deleted in finalize_session_directory, so let's not create it
if sess.has_errors_or_delayed_span_bugs() {
return;
}
let query_cache_path = query_cache_path(sess);
let dep_graph_path = dep_graph_path(sess);
@ -60,6 +64,10 @@ pub fn save_work_product_index(sess: &Session,
if sess.opts.incremental.is_none() {
return;
}
// This is going to be deleted in finalize_session_directory, so let's not create it
if sess.has_errors_or_delayed_span_bugs() {
return;
}
debug!("save_work_product_index()");
dep_graph.assert_ignored();

View file

@ -1125,8 +1125,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
.map(|pred| pred.span()).collect();
let mut err = cx.struct_span_lint(TYPE_ALIAS_BOUNDS, spans,
"where clauses are not enforced in type aliases");
err.help("the clause will not be checked when the type alias is used, \
and should be removed");
err.span_suggestion(
type_alias_generics.where_clause.span_for_predicates_or_empty_place(),
"the clause will not be checked when the type alias is used, and should be removed",
String::new(),
Applicability::MachineApplicable,
);
if !suggested_changing_assoc_types {
TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err);
suggested_changing_assoc_types = true;
@ -1136,14 +1140,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
// The parameters must not have bounds
for param in type_alias_generics.params.iter() {
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
let suggestion = spans.iter().map(|sp| {
let start = param.span.between(*sp); // Include the `:` in `T: Bound`.
(start.to(*sp), String::new())
}).collect();
if !spans.is_empty() {
let mut err = cx.struct_span_lint(
TYPE_ALIAS_BOUNDS,
spans,
"bounds on generic parameters are not enforced in type aliases",
);
err.help("the bound will not be checked when the type alias is used, \
and should be removed");
let msg = "the bound will not be checked when the type alias is used, \
and should be removed";
err.multipart_suggestion(&msg, suggestion, Applicability::MachineApplicable);
if !suggested_changing_assoc_types {
TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err);
suggested_changing_assoc_types = true;

View file

@ -598,6 +598,25 @@ impl EarlyLintPass for UnusedParens {
fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
self.check_unused_parens_pat(cx, &arm.pat, false, false);
}
fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) {
if let &ast::TyKind::Paren(ref r) = &ty.kind {
match &r.kind {
&ast::TyKind::TraitObject(..) => {}
&ast::TyKind::ImplTrait(_, ref bounds) if bounds.len() > 1 => {}
_ => {
let pattern_text = if let Ok(snippet) = cx.sess().source_map()
.span_to_snippet(ty.span) {
snippet
} else {
pprust::ty_to_string(ty)
};
Self::remove_outer_parens(cx, ty.span, &pattern_text, "type", (false, false));
}
}
}
}
}
declare_lint! {

View file

@ -9,7 +9,6 @@ use rustc::ty::query::QueryConfig;
use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind};
use rustc::middle::exported_symbols::ExportedSymbol;
use rustc::middle::stability::DeprecationEntry;
use rustc::middle::dependency_format::Linkage;
use rustc::hir::def;
use rustc::hir;
use rustc::session::{CrateDisambiguator, Session};
@ -235,26 +234,11 @@ provide! { <'tcx> tcx, def_id, other, cdata,
used_crate_source => { Lrc::new(cdata.source.clone()) }
exported_symbols => {
let mut syms = cdata.exported_symbols(tcx);
let syms = cdata.exported_symbols(tcx);
// When linked into a dylib crates don't export their generic symbols,
// so if that's happening then we can't load upstream monomorphizations
// from this crate.
let formats = tcx.dependency_formats(LOCAL_CRATE);
let remove_generics = formats.iter().any(|(_ty, list)| {
match list.get(def_id.krate.as_usize() - 1) {
Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
_ => false,
}
});
if remove_generics {
syms.retain(|(sym, _threshold)| {
match sym {
ExportedSymbol::Generic(..) => false,
_ => return true,
}
});
}
// FIXME rust-lang/rust#64319, rust-lang/rust#64872: We want
// to block export of generics from dylibs, but we must fix
// rust-lang/rust#65890 before we can do that robustly.
Arc::new(syms)
}

View file

@ -29,7 +29,7 @@ pub(super) struct Prefixes<'cx, 'tcx> {
body: &'cx Body<'tcx>,
tcx: TyCtxt<'tcx>,
kind: PrefixSet,
next: Option<(PlaceRef<'cx, 'tcx>)>,
next: Option<PlaceRef<'cx, 'tcx>>,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]

View file

@ -2545,7 +2545,7 @@ There are some known bugs that trigger this message.
// E0471, // constant evaluation error (in pattern)
// E0385, // {} in an aliasable location
E0521, // borrowed data escapes outside of closure
E0526, // shuffle indices are not constant
// E0526, // shuffle indices are not constant
E0594, // cannot assign to {}
// E0598, // lifetime of {} is too short to guarantee its contents can be...
E0625, // thread-local statics cannot be accessed at compile-time

View file

@ -80,6 +80,17 @@ pub enum Candidate {
Argument { bb: BasicBlock, index: usize },
}
impl Candidate {
/// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
fn forces_explicit_promotion(&self) -> bool {
match self {
Candidate::Ref(_) |
Candidate::Repeat(_) => false,
Candidate::Argument { .. } => true,
}
}
}
fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Vec<usize>> {
let attrs = tcx.get_attrs(def_id);
let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?;
@ -727,16 +738,22 @@ pub fn validate_candidates(
};
candidates.iter().copied().filter(|&candidate| {
validator.explicit = match candidate {
Candidate::Ref(_) |
Candidate::Repeat(_) => false,
Candidate::Argument { .. } => true,
};
validator.explicit = candidate.forces_explicit_promotion();
// FIXME(eddyb) also emit the errors for shuffle indices
// and `#[rustc_args_required_const]` arguments here.
validator.validate_candidate(candidate).is_ok()
let is_promotable = validator.validate_candidate(candidate).is_ok();
match candidate {
Candidate::Argument { bb, index } if !is_promotable => {
let span = body[bb].terminator().source_info.span;
let msg = format!("argument {} is required to be a constant", index + 1);
tcx.sess.span_err(span, &msg);
}
_ => ()
}
is_promotable
}).collect()
}

View file

@ -1606,20 +1606,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
// This is not a problem, because the argument explicitly
// requests constness, in contrast to regular promotion
// which happens even without the user requesting it.
// We can error out with a hard error if the argument is not
// constant here.
//
// `promote_consts` is responsible for emitting the error if
// the argument is not promotable.
if !IsNotPromotable::in_operand(self, arg) {
debug!("visit_terminator_kind: candidate={:?}", candidate);
self.promotion_candidates.push(candidate);
} else {
if is_shuffle {
span_err!(self.tcx.sess, self.span, E0526,
"shuffle indices are not constant");
} else {
self.tcx.sess.span_err(self.span,
&format!("argument {} is required to be a constant",
i + 1));
}
}
}
}

View file

@ -1850,6 +1850,34 @@ fn main() {}
```
"##,
E0578: r##"
A module cannot be found and therefore, the visibility cannot be determined.
Erroneous code example:
```compile_fail,E0578,edition2018
foo!();
pub (in ::Sea) struct Shark; // error!
fn main() {}
```
Because of the call to the `foo` macro, the compiler guesses that the missing
module could be inside it and fails because the macro definition cannot be
found.
To fix this error, please be sure that the module is in scope:
```edition2018
pub mod Sea {
pub (in crate::Sea) struct Shark;
}
fn main() {}
```
"##,
E0603: r##"
A private item was used outside its scope.
@ -2017,5 +2045,4 @@ fn main() {}
// E0427, merged into 530
// E0467, removed
// E0470, removed
E0578,
}

View file

@ -322,9 +322,26 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
continue;
}
// In order to correctly resolve intra-doc-links we need to
// pick a base AST node to work from. If the documentation for
// this module came from an inner comment (//!) then we anchor
// our name resolution *inside* the module. If, on the other
// hand it was an outer comment (///) then we anchor the name
// resolution in the parent module on the basis that the names
// used are more likely to be intended to be parent names. For
// this, we set base_node to None for inner comments since
// we've already pushed this node onto the resolution stack but
// for outer comments we explicitly try and resolve against the
// parent_node first.
let base_node = if item.is_mod() && item.attrs.inner_docs {
None
} else {
parent_node
};
match kind {
Some(ns @ ValueNS) => {
if let Ok(res) = self.resolve(path_str, ns, &current_item, parent_node) {
if let Ok(res) = self.resolve(path_str, ns, &current_item, base_node) {
res
} else {
resolution_failure(cx, &item, path_str, &dox, link_range);
@ -335,7 +352,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
}
}
Some(ns @ TypeNS) => {
if let Ok(res) = self.resolve(path_str, ns, &current_item, parent_node) {
if let Ok(res) = self.resolve(path_str, ns, &current_item, base_node) {
res
} else {
resolution_failure(cx, &item, path_str, &dox, link_range);
@ -348,10 +365,10 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
let candidates = PerNS {
macro_ns: macro_resolve(cx, path_str).map(|res| (res, None)),
type_ns: self
.resolve(path_str, TypeNS, &current_item, parent_node)
.resolve(path_str, TypeNS, &current_item, base_node)
.ok(),
value_ns: self
.resolve(path_str, ValueNS, &current_item, parent_node)
.resolve(path_str, ValueNS, &current_item, base_node)
.ok()
.and_then(|(res, fragment)| {
// Constructors are picked up in the type namespace.

View file

@ -1818,7 +1818,7 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
type Item = &'a K;
#[inline]
fn next(&mut self) -> Option<(&'a K)> {
fn next(&mut self) -> Option<&'a K> {
self.inner.next().map(|(k, _)| k)
}
#[inline]
@ -1841,7 +1841,7 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
type Item = &'a V;
#[inline]
fn next(&mut self) -> Option<(&'a V)> {
fn next(&mut self) -> Option<&'a V> {
self.inner.next().map(|(_, v)| v)
}
#[inline]
@ -1864,7 +1864,7 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
type Item = &'a mut V;
#[inline]
fn next(&mut self) -> Option<(&'a mut V)> {
fn next(&mut self) -> Option<&'a mut V> {
self.inner.next().map(|(_, v)| v)
}
#[inline]

View file

@ -6,7 +6,8 @@ use crate::fs;
use crate::os::raw;
use crate::sys;
use crate::io;
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::sys_common::{self, AsInner, FromInner, IntoInner};
use crate::net;
/// Raw file descriptors.
#[stable(feature = "rust1", since = "1.0.0")]
@ -110,3 +111,61 @@ impl<'a> AsRawFd for io::StdoutLock<'a> {
impl<'a> AsRawFd for io::StderrLock<'a> {
fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for net::TcpStream {
fn as_raw_fd(&self) -> RawFd { *self.as_inner().socket().as_inner() }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for net::TcpListener {
fn as_raw_fd(&self) -> RawFd { *self.as_inner().socket().as_inner() }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for net::UdpSocket {
fn as_raw_fd(&self) -> RawFd { *self.as_inner().socket().as_inner() }
}
#[stable(feature = "from_raw_os", since = "1.1.0")]
impl FromRawFd for net::TcpStream {
unsafe fn from_raw_fd(fd: RawFd) -> net::TcpStream {
let socket = sys::net::Socket::from_inner(fd);
net::TcpStream::from_inner(sys_common::net::TcpStream::from_inner(socket))
}
}
#[stable(feature = "from_raw_os", since = "1.1.0")]
impl FromRawFd for net::TcpListener {
unsafe fn from_raw_fd(fd: RawFd) -> net::TcpListener {
let socket = sys::net::Socket::from_inner(fd);
net::TcpListener::from_inner(sys_common::net::TcpListener::from_inner(socket))
}
}
#[stable(feature = "from_raw_os", since = "1.1.0")]
impl FromRawFd for net::UdpSocket {
unsafe fn from_raw_fd(fd: RawFd) -> net::UdpSocket {
let socket = sys::net::Socket::from_inner(fd);
net::UdpSocket::from_inner(sys_common::net::UdpSocket::from_inner(socket))
}
}
#[stable(feature = "into_raw_os", since = "1.4.0")]
impl IntoRawFd for net::TcpStream {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_socket().into_inner()
}
}
#[stable(feature = "into_raw_os", since = "1.4.0")]
impl IntoRawFd for net::TcpListener {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_socket().into_inner()
}
}
#[stable(feature = "into_raw_os", since = "1.4.0")]
impl IntoRawFd for net::UdpSocket {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_socket().into_inner()
}
}

View file

@ -1,4 +1,3 @@
// Uhhh
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]
@ -7,7 +6,6 @@ pub mod ffi;
pub mod fs;
pub mod raw;
pub mod process;
pub mod net;
#[stable(feature = "rust1", since = "1.0.0")]
pub mod prelude {

File diff suppressed because it is too large Load diff

View file

@ -487,7 +487,6 @@ Erroneous code example:
// `test_2018_feature` is
// included in the Rust 2018 edition
```
"##,
E0725: r##"
@ -505,6 +504,20 @@ Delete the offending feature attribute, or add it to the list of allowed
features in the `-Z allow_features` flag.
"##,
E0743: r##"
C-variadic has been used on a non-foreign function.
Erroneous code example:
```compile_fail,E0743
fn foo2(x: u8, ...) {} // error!
```
Only foreign functions can use C-variadic (`...`). It is used to give an
undefined number of parameters to a given function (like `printf` in C). The
equivalent in Rust would be to use macros directly.
"##,
;
E0539, // incorrect meta item

View file

@ -197,8 +197,11 @@ impl<'a> Parser<'a> {
self.eat(&token::DotDotDot);
TyKind::CVarArgs
} else {
return Err(self.fatal(
"only foreign functions are allowed to be C-variadic"
return Err(struct_span_fatal!(
self.sess.span_diagnostic,
self.token.span,
E0743,
"only foreign functions are allowed to be C-variadic",
));
}
} else {

View file

@ -370,6 +370,7 @@ symbols! {
issue_5723_bootstrap,
issue_tracker_base_url,
item,
item_context: "ItemContext",
item_like_imports,
iter,
Iterator,

View file

@ -56,12 +56,18 @@ mod llvm_libunwind {
pub fn compile() {
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
let target_endian_little = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap() != "big";
let cfg = &mut cc::Build::new();
cfg.cpp(true);
cfg.cpp_set_stdlib(None);
cfg.warnings(false);
// libunwind expects a __LITTLE_ENDIAN__ macro to be set for LE archs, cf. #65765
if target_endian_little {
cfg.define("__LITTLE_ENDIAN__", Some("1"));
}
if target_env == "msvc" {
// Don't pull in extra libraries on MSVC
cfg.flag("/Zl");

View file

@ -1,39 +0,0 @@
-include ../tools.mk
# Different optimization levels imply different values for `-Zshare-generics`,
# so try out a whole bunch of combinations to make sure everything is compatible
all:
# First up, try some defaults
$(RUSTC) --crate-type rlib foo.rs
$(RUSTC) --crate-type dylib bar.rs -C opt-level=3
# Next try mixing up some things explicitly
$(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
$(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
$(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
$(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
# Now combine a whole bunch of options together
$(RUSTC) --crate-type rlib foo.rs
$(RUSTC) --crate-type dylib bar.rs
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -C opt-level=1
$(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -C opt-level=2
$(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -C opt-level=3
$(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -C opt-level=s
$(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=yes
$(RUSTC) --crate-type dylib bar.rs -C opt-level=z
$(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=no
$(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=yes

View file

@ -1,5 +0,0 @@
extern crate foo;
pub fn bar() {
foo::foo();
}

View file

@ -1,9 +0,0 @@
pub fn foo() {
bar::<usize>();
}
pub fn bar<T>() {
baz();
}
fn baz() {}

View file

@ -79,12 +79,12 @@ all:
# Check that a Rust dylib exports its monomorphic functions, including generics this time
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
# Check that a Rust dylib exports the monomorphic functions from its dependencies
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
# Check that an executable does not export any dynamic symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]

View file

@ -0,0 +1,88 @@
// ignore-tidy-linelength
// First a module with inner documentation
// @has issue_55364/subone/index.html
// These foo/bar links in the module's documentation should refer inside `subone`
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subone/fn.foo.html"]' 'foo'
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subone/fn.bar.html"]' 'bar'
pub mod subone {
//! See either [foo] or [bar].
// This should refer to subone's `bar`
// @has issue_55364/subone/fn.foo.html
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subone/fn.bar.html"]' 'bar'
/// See [bar]
pub fn foo() {}
// This should refer to subone's `foo`
// @has issue_55364/subone/fn.bar.html
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subone/fn.foo.html"]' 'foo'
/// See [foo]
pub fn bar() {}
}
// A module with outer documentation
// @has issue_55364/subtwo/index.html
// These foo/bar links in the module's documentation should not reference inside `subtwo`
// @!has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subtwo/fn.foo.html"]' 'foo'
// @!has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subtwo/fn.bar.html"]' 'bar'
// Instead it should be referencing the top level functions
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/fn.foo.html"]' 'foo'
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/fn.bar.html"]' 'bar'
// Though there should be such links later
// @has - '//section[@id="main"]/table//tr[@class="module-item"]/td/a[@class="fn"][@href="fn.foo.html"]' 'foo'
// @has - '//section[@id="main"]/table//tr[@class="module-item"]/td/a[@class="fn"][@href="fn.bar.html"]' 'bar'
/// See either [foo] or [bar].
pub mod subtwo {
// Despite the module's docs referring to the top level foo/bar,
// this should refer to subtwo's `bar`
// @has issue_55364/subtwo/fn.foo.html
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subtwo/fn.bar.html"]' 'bar'
/// See [bar]
pub fn foo() {}
// Despite the module's docs referring to the top level foo/bar,
// this should refer to subtwo's `foo`
// @has issue_55364/subtwo/fn.bar.html
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/subtwo/fn.foo.html"]' 'foo'
/// See [foo]
pub fn bar() {}
}
// These are the function referred to by the module above with outer docs
/// See [bar]
pub fn foo() {}
/// See [foo]
pub fn bar() {}
// This module refers to the outer foo/bar by means of `super::`
// @has issue_55364/subthree/index.html
// This module should also refer to the top level foo/bar
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/fn.foo.html"]' 'foo'
// @has - '//section[@id="main"]/div[@class="docblock"]//a[@href="../../issue_55364/fn.bar.html"]' 'bar'
pub mod subthree {
//! See either [foo][super::foo] or [bar][super::bar]
}
// Next we go *deeper* - In order to ensure it's not just "this or parent"
// we test `crate::` and a `super::super::...` chain
// @has issue_55364/subfour/subfive/subsix/subseven/subeight/index.html
// @has - '//section[@id="main"]/table//tr[@class="module-item"]/td[@class="docblock-short"]//a[@href="../../../../../../issue_55364/subone/fn.foo.html"]' 'other foo'
// @has - '//section[@id="main"]/table//tr[@class="module-item"]/td[@class="docblock-short"]//a[@href="../../../../../../issue_55364/subtwo/fn.bar.html"]' 'other bar'
pub mod subfour {
pub mod subfive {
pub mod subsix {
pub mod subseven {
pub mod subeight {
/// See [other foo][crate::subone::foo]
pub fn foo() {}
/// See [other bar][super::super::super::super::super::subtwo::bar]
pub fn bar() {}
}
}
}
}
}

View file

@ -28,7 +28,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
box Invoker {
a: a,
b: b,
} as (Box<dyn Invokable<A>+'static>)
} as Box<dyn Invokable<A>+'static>
}
pub fn main() {

View file

@ -1,5 +1,6 @@
// run-pass
#[allow(unused_parens)]
fn main() {
assert_eq!(3 as usize * 3, 9);
assert_eq!(3 as (usize) * 3, 9);

View file

@ -5,7 +5,10 @@ LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(type_alias_bounds)]` on by default
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere1<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:6:25
@ -13,7 +16,10 @@ warning: where clauses are not enforced in type aliases
LL | type _TaWhere2<T> where T: Iterator<Item: 'static> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere2<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:7:25
@ -21,7 +27,10 @@ warning: where clauses are not enforced in type aliases
LL | type _TaWhere3<T> where T: Iterator<Item: 'static> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere3<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:8:25
@ -29,7 +38,10 @@ warning: where clauses are not enforced in type aliases
LL | type _TaWhere4<T> where T: Iterator<Item: 'static + Copy + Send> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere4<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:9:25
@ -37,7 +49,10 @@ warning: where clauses are not enforced in type aliases
LL | type _TaWhere5<T> where T: Iterator<Item: for<'a> Into<&'a u8>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere5<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:10:25
@ -45,7 +60,10 @@ warning: where clauses are not enforced in type aliases
LL | type _TaWhere6<T> where T: Iterator<Item: Iterator<Item: Copy>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type _TaWhere6<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:12:20
@ -53,7 +71,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline1<T: Iterator<Item: Copy>> = T;
| ^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline1<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:13:20
@ -61,7 +82,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline2<T: Iterator<Item: 'static>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline2<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:14:20
@ -69,7 +93,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline3<T: Iterator<Item: 'static>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline3<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:15:20
@ -77,7 +104,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline4<T: Iterator<Item: 'static + Copy + Send>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline4<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:16:20
@ -85,7 +115,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline5<T: Iterator<Item: for<'a> Into<&'a u8>>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline5<T> = T;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:17:20
@ -93,5 +126,8 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type _TaInline6<T: Iterator<Item: Iterator<Item: Copy>>> = T;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type _TaInline6<T> = T;
| --

View file

@ -5,10 +5,10 @@ LL | fn blue_car<C:Car<Color=Blue>>(c: C) {
| -------- ---------- required by this bound in `blue_car`
...
LL | fn b() { blue_car(ModelT); }
| ^^^^^^^^ expected struct `Black`, found struct `Blue`
| ^^^^^^^^ expected struct `Blue`, found struct `Black`
|
= note: expected type `Black`
found type `Blue`
= note: expected type `Blue`
found type `Black`
error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black`
--> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:32:10
@ -17,10 +17,10 @@ LL | fn black_car<C:Car<Color=Black>>(c: C) {
| --------- ----------- required by this bound in `black_car`
...
LL | fn c() { black_car(ModelU); }
| ^^^^^^^^^ expected struct `Blue`, found struct `Black`
| ^^^^^^^^^ expected struct `Black`, found struct `Blue`
|
= note: expected type `Blue`
found type `Black`
= note: expected type `Black`
found type `Blue`
error: aborting due to 2 previous errors

View file

@ -37,8 +37,8 @@ pub fn main() {
let a = 42;
foo1(a);
//~^ ERROR type mismatch resolving
//~| expected usize, found struct `Bar`
//~| expected struct `Bar`, found usize
baz(&a);
//~^ ERROR type mismatch resolving
//~| expected usize, found struct `Bar`
//~| expected struct `Bar`, found usize
}

View file

@ -16,19 +16,19 @@ LL | fn foo1<I: Foo<A=Bar>>(x: I) {
| ---- ----- required by this bound in `foo1`
...
LL | foo1(a);
| ^^^^ expected usize, found struct `Bar`
| ^^^^ expected struct `Bar`, found usize
|
= note: expected type `usize`
found type `Bar`
= note: expected type `Bar`
found type `usize`
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
--> $DIR/associated-types-eq-3.rs:41:9
|
LL | baz(&a);
| ^^ expected usize, found struct `Bar`
| ^^ expected struct `Bar`, found usize
|
= note: expected type `usize`
found type `Bar`
= note: expected type `Bar`
found type `usize`
= note: required for the cast to the object type `dyn Foo<A = Bar>`
error: aborting due to 3 previous errors

View file

@ -7,10 +7,10 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize>
| ------------- required by this bound in `foo`
...
LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ expected usize, found isize
| ^^^^^^^^^^^^^^^^^ expected isize, found usize
|
= note: expected type `&usize`
found type `&isize`
= note: expected type `&isize`
found type `&usize`
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
--> $DIR/associated-types-eq-hr.rs:86:5
@ -21,10 +21,10 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize>
| ------------- required by this bound in `bar`
...
LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ expected isize, found usize
| ^^^^^^^^^^^^^^^^ expected usize, found isize
|
= note: expected type `&isize`
found type `&usize`
= note: expected type `&usize`
found type `&isize`
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
--> $DIR/associated-types-eq-hr.rs:91:17

View file

@ -5,10 +5,10 @@ LL | fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {}
| -------------- ------ required by this bound in `is_iterator_of`
...
LL | is_iterator_of::<Option<T>, _>(&adapter);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found enum `std::option::Option`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found type parameter
|
= note: expected type `T`
found type `std::option::Option<T>`
= note: expected type `std::option::Option<T>`
found type `T`
= help: type parameters must be constrained to match other types
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

View file

@ -2,28 +2,28 @@ error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
--> $DIR/associated-types-multiple-types-one-trait.rs:13:5
|
LL | want_y(t);
| ^^^^^^ expected associated type, found i32
| ^^^^^^ expected i32, found associated type
...
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
| ------ ----- required by this bound in `want_y`
|
= note: expected type `<T as Foo>::Y`
found type `i32`
= note: consider constraining the associated type `<T as Foo>::Y` to `i32` or calling a method that returns `<T as Foo>::Y`
= note: expected type `i32`
found type `<T as Foo>::Y`
= note: consider constraining the associated type `<T as Foo>::Y` to `i32`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
error[E0271]: type mismatch resolving `<T as Foo>::X == u32`
--> $DIR/associated-types-multiple-types-one-trait.rs:18:5
|
LL | want_x(t);
| ^^^^^^ expected associated type, found u32
| ^^^^^^ expected u32, found associated type
...
LL | fn want_x<T:Foo<X=u32>>(t: &T) { }
| ------ ----- required by this bound in `want_x`
|
= note: expected type `<T as Foo>::X`
found type `u32`
= note: consider constraining the associated type `<T as Foo>::X` to `u32` or calling a method that returns `<T as Foo>::X`
= note: expected type `u32`
found type `<T as Foo>::X`
= note: consider constraining the associated type `<T as Foo>::X` to `u32`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
error: aborting due to 2 previous errors

View file

@ -2,10 +2,10 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as std::iter::It
--> $DIR/associated-types-overridden-binding-2.rs:6:43
|
LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();
| ^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32
| ^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
|
= note: expected type `u32`
found type `i32`
= note: expected type `i32`
found type `u32`
= note: required for the cast to the object type `dyn std::iter::Iterator<Item = u32, Item = i32>`
error: aborting due to previous error

View file

@ -33,10 +33,10 @@ error[E0271]: type mismatch resolving `<impl std::future::Future as std::future:
--> $DIR/async-block-control-flow-static-semantics.rs:18:39
|
LL | let _: &dyn Future<Output = ()> = &block;
| ^^^^^^ expected u8, found ()
| ^^^^^^ expected (), found u8
|
= note: expected type `u8`
found type `()`
= note: expected type `()`
found type `u8`
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
error[E0308]: mismatched types
@ -59,10 +59,10 @@ error[E0271]: type mismatch resolving `<impl std::future::Future as std::future:
--> $DIR/async-block-control-flow-static-semantics.rs:27:39
|
LL | let _: &dyn Future<Output = ()> = &block;
| ^^^^^^ expected u8, found ()
| ^^^^^^ expected (), found u8
|
= note: expected type `u8`
found type `()`
= note: expected type `()`
found type `u8`
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
error[E0308]: mismatched types

View file

@ -0,0 +1,27 @@
#![feature(try_trait, async_closure)]
// edition:2018
fn main() {}
async fn an_async_block() -> u32 {
async {
let x: Option<u32> = None;
x?; //~ ERROR the `?` operator
22
}.await
}
async fn async_closure_containing_fn() -> u32 {
let async_closure = async || {
let x: Option<u32> = None;
x?; //~ ERROR the `?` operator
22_u32
};
async_closure().await
}
async fn an_async_function() -> u32 {
let x: Option<u32> = None;
x?; //~ ERROR the `?` operator
22
}

View file

@ -0,0 +1,30 @@
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option-in-async.rs:8:9
|
LL | x?;
| ^^ cannot use the `?` operator in an async block that returns `{integer}`
|
= help: the trait `std::ops::Try` is not implemented for `{integer}`
= note: required by `std::ops::Try::from_error`
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option-in-async.rs:16:9
|
LL | x?;
| ^^ cannot use the `?` operator in an async closure that returns `u32`
|
= help: the trait `std::ops::Try` is not implemented for `u32`
= note: required by `std::ops::Try::from_error`
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option-in-async.rs:25:5
|
LL | x?;
| ^^ cannot use the `?` operator in an async function that returns `u32`
|
= help: the trait `std::ops::Try` is not implemented for `u32`
= note: required by `std::ops::Try::from_error`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -30,7 +30,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
box Invoker {
a: a,
b: b,
} as (Box<dyn Invokable<A>+'static>)
} as Box<dyn Invokable<A>+'static>
}
pub fn main() {

View file

@ -0,0 +1,16 @@
// compile-flags: -C debuginfo=2
// no-prefer-dynamic
#![crate_type = "rlib"]
pub trait Object { fn method(&self) { } }
impl Object for u32 { }
impl Object for () { }
impl<T> Object for &T { }
pub fn unused() {
let ref u = 0_u32;
let _d = &u as &dyn crate::Object;
_d.method()
}

View file

@ -0,0 +1,7 @@
// compile-flags: -C debuginfo=2 -C prefer-dynamic
#![crate_type="dylib"]
extern crate a_def_obj;
pub use a_def_obj::Object;

View file

@ -0,0 +1,12 @@
// no-prefer-dynamic
// compile-flags: -C debuginfo=2
#![crate_type="rlib"]
extern crate b_reexport_obj;
use b_reexport_obj::Object;
pub fn another_dyn_debug() {
let ref u = 1_u32;
let _d = &u as &dyn crate::Object;
_d.method()
}

View file

@ -0,0 +1,9 @@
// compile-flags: -C debuginfo=2 -C prefer-dynamic
#![crate_type="rlib"]
extern crate c_another_vtable_for_obj;
pub fn chain() {
c_another_vtable_for_obj::another_dyn_debug();
}

View file

@ -0,0 +1,17 @@
// run-pass
// note that these aux-build directives must be in this order: the
// later crates depend on the earlier ones. (The particular bug that
// is being exercised here used to exhibit itself during the build of
// `chain_of_rlibs_and_dylibs.dylib`)
// aux-build:a_def_obj.rs
// aux-build:b_reexport_obj.rs
// aux-build:c_another_vtable_for_obj.rs
// aux-build:d_chain_of_rlibs_and_dylibs.rs
extern crate d_chain_of_rlibs_and_dylibs;
pub fn main() {
d_chain_of_rlibs_and_dylibs::chain();
}

View file

@ -5,10 +5,10 @@ LL | fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
| --- ------------------ required by this bound in `foo`
...
LL | foo(3_i8);
| ^^^ expected reference, found u32
| ^^^ expected u32, found reference
|
= note: expected type `&'static str`
found type `u32`
= note: expected type `u32`
found type `&'static str`
error: aborting due to previous error

View file

@ -10,7 +10,7 @@ const BAR: [fn(&mut u32); 5] = [
|v: &mut u32| *v += 3,
|v: &mut u32| *v += 4,
];
fn func_specific() -> (fn() -> u32) {
fn func_specific() -> fn() -> u32 {
|| return 42
}

View file

@ -1,4 +1,4 @@
error: only foreign functions are allowed to be C-variadic
error[E0743]: only foreign functions are allowed to be C-variadic
--> $DIR/invalid-variadic-function.rs:1:26
|
LL | extern "C" fn foo(x: u8, ...);
@ -12,3 +12,4 @@ LL | extern "C" fn foo(x: u8, ...);
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0743`.

View file

@ -5,10 +5,10 @@ LL | trait Trait: Sized {
| ------------------ required by `Trait`
...
LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found type parameter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found associated type
|
= note: expected type `<<T as Trait>::A as MultiDispatch<i32>>::O`
found type `T`
= note: expected type `T`
found type `<<T as Trait>::A as MultiDispatch<i32>>::O`
= note: you might be missing a type parameter or trait bound
error: aborting due to previous error

View file

@ -13,6 +13,18 @@ fn bar(y: bool) -> X {
return (X { y }); //~ ERROR unnecessary parentheses around `return` value
}
fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parentheses around type
panic!()
}
trait Trait {
fn test(&self);
}
fn passes_unused_parens_lint() -> &'static (dyn Trait) {
panic!()
}
fn main() {
foo();
bar((true)); //~ ERROR unnecessary parentheses around function argument

View file

@ -16,26 +16,32 @@ error: unnecessary parentheses around `return` value
LL | return (X { y });
| ^^^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around type
--> $DIR/lint-unnecessary-parens.rs:16:42
|
LL | fn unused_parens_around_return_type() -> (u32) {
| ^^^^^ help: remove these parentheses
error: unnecessary parentheses around function argument
--> $DIR/lint-unnecessary-parens.rs:18:9
--> $DIR/lint-unnecessary-parens.rs:30:9
|
LL | bar((true));
| ^^^^^^ help: remove these parentheses
error: unnecessary parentheses around `if` condition
--> $DIR/lint-unnecessary-parens.rs:20:8
--> $DIR/lint-unnecessary-parens.rs:32:8
|
LL | if (true) {}
| ^^^^^^ help: remove these parentheses
error: unnecessary parentheses around `while` condition
--> $DIR/lint-unnecessary-parens.rs:21:11
--> $DIR/lint-unnecessary-parens.rs:33:11
|
LL | while (true) {}
| ^^^^^^ help: remove these parentheses
warning: denote infinite loops with `loop { ... }`
--> $DIR/lint-unnecessary-parens.rs:21:5
--> $DIR/lint-unnecessary-parens.rs:33:5
|
LL | while (true) {}
| ^^^^^^^^^^^^ help: use `loop`
@ -43,46 +49,46 @@ LL | while (true) {}
= note: `#[warn(while_true)]` on by default
error: unnecessary parentheses around `match` head expression
--> $DIR/lint-unnecessary-parens.rs:23:11
--> $DIR/lint-unnecessary-parens.rs:35:11
|
LL | match (true) {
| ^^^^^^ help: remove these parentheses
error: unnecessary parentheses around `let` head expression
--> $DIR/lint-unnecessary-parens.rs:26:16
--> $DIR/lint-unnecessary-parens.rs:38:16
|
LL | if let 1 = (1) {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around `let` head expression
--> $DIR/lint-unnecessary-parens.rs:27:19
--> $DIR/lint-unnecessary-parens.rs:39:19
|
LL | while let 1 = (2) {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around method argument
--> $DIR/lint-unnecessary-parens.rs:41:24
--> $DIR/lint-unnecessary-parens.rs:53:24
|
LL | X { y: false }.foo((true));
| ^^^^^^ help: remove these parentheses
error: unnecessary parentheses around assigned value
--> $DIR/lint-unnecessary-parens.rs:43:18
--> $DIR/lint-unnecessary-parens.rs:55:18
|
LL | let mut _a = (0);
| ^^^ help: remove these parentheses
error: unnecessary parentheses around assigned value
--> $DIR/lint-unnecessary-parens.rs:44:10
--> $DIR/lint-unnecessary-parens.rs:56:10
|
LL | _a = (0);
| ^^^ help: remove these parentheses
error: unnecessary parentheses around assigned value
--> $DIR/lint-unnecessary-parens.rs:45:11
--> $DIR/lint-unnecessary-parens.rs:57:11
|
LL | _a += (1);
| ^^^ help: remove these parentheses
error: aborting due to 12 previous errors
error: aborting due to 13 previous errors

View file

@ -1,4 +1,4 @@
error: only foreign functions are allowed to be C-variadic
error[E0743]: only foreign functions are allowed to be C-variadic
--> $DIR/variadic-ffi-3.rs:1:18
|
LL | fn foo(x: isize, ...) {
@ -6,3 +6,4 @@ LL | fn foo(x: isize, ...) {
error: aborting due to previous error
For more information about this error, try `rustc --explain E0743`.

View file

@ -1,4 +1,4 @@
error: only foreign functions are allowed to be C-variadic
error[E0743]: only foreign functions are allowed to be C-variadic
--> $DIR/variadic-ffi-4.rs:1:29
|
LL | extern "C" fn foo(x: isize, ...) {
@ -6,3 +6,4 @@ LL | extern "C" fn foo(x: isize, ...) {
error: aborting due to previous error
For more information about this error, try `rustc --explain E0743`.

View file

@ -340,7 +340,10 @@ LL | pub type Alias<T: PrivTr> = T;
| ^^^^^^
|
= note: `#[warn(type_alias_bounds)]` on by default
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | pub type Alias<T> = T;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/private-in-public-warn.rs:75:29
@ -348,7 +351,10 @@ warning: where clauses are not enforced in type aliases
LL | pub type Alias<T> where T: PrivTr = T;
| ^^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | pub type Alias<T> = T;
| --
error: aborting due to 36 previous errors

View file

@ -12,3 +12,4 @@ LL | foo!();
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0578`.

View file

@ -15,7 +15,7 @@ fn october<'b, T>(s: &'b T) -> &'b T {
s
}
fn november<'a>(s: &'a str) -> (&'a str) {
fn november<'a>(s: &'a str) -> &'a str {
//~^ ERROR lifetime parameter `'b` never used
//~| HELP elide the unused lifetime
s

View file

@ -15,7 +15,7 @@ fn october<'a, 'b, T>(s: &'b T) -> &'b T {
s
}
fn november<'a, 'b>(s: &'a str) -> (&'a str) {
fn november<'a, 'b>(s: &'a str) -> &'a str {
//~^ ERROR lifetime parameter `'b` never used
//~| HELP elide the unused lifetime
s

View file

@ -21,7 +21,7 @@ LL | fn october<'a, 'b, T>(s: &'b T) -> &'b T {
error: lifetime parameter `'b` never used
--> $DIR/zero-uses-in-fn.rs:18:17
|
LL | fn november<'a, 'b>(s: &'a str) -> (&'a str) {
LL | fn november<'a, 'b>(s: &'a str) -> &'a str {
| --^^
| |
| help: elide the unused lifetime

View file

@ -31,7 +31,10 @@ LL | type Y where i32: Foo = ();
| ^^^^^^^^
|
= note: `#[warn(type_alias_bounds)]` on by default
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type Y = ();
| --
warning: Trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/trivial-bounds-inconsistent.rs:22:19

View file

@ -0,0 +1,18 @@
#![feature(try_trait)]
// edition:2018
fn main() {}
fn a_function() -> u32 {
let x: Option<u32> = None;
x?; //~ ERROR the `?` operator
22
}
fn a_closure() -> u32 {
let a_closure = || {
let x: Option<u32> = None;
x?; //~ ERROR the `?` operator
22
};
a_closure()
}

View file

@ -0,0 +1,21 @@
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option-diagnostics.rs:7:5
|
LL | x?;
| ^^ cannot use the `?` operator in a function that returns `u32`
|
= help: the trait `std::ops::Try` is not implemented for `u32`
= note: required by `std::ops::Try::from_error`
error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option-diagnostics.rs:14:9
|
LL | x?;
| ^^ cannot use the `?` operator in a closure that returns `{integer}`
|
= help: the trait `std::ops::Try` is not implemented for `{integer}`
= note: required by `std::ops::Try::from_error`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -5,7 +5,10 @@ LL | type SVec<T: Send + Send> = Vec<T>;
| ^^^^ ^^^^
|
= note: `#[warn(type_alias_bounds)]` on by default
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type SVec<T> = Vec<T>;
| -- --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:10:21
@ -13,7 +16,10 @@ warning: where clauses are not enforced in type aliases
LL | type S2Vec<T> where T: Send = Vec<T>;
| ^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type S2Vec<T> = Vec<T>;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:12:19
@ -21,7 +27,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>);
| ^^ ^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type VVec<'b, 'a> = (&'b u32, Vec<&'a i32>);
| -- --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:14:18
@ -29,7 +38,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type WVec<'b, T: 'b + 'b> = (&'b u32, Vec<T>);
| ^^ ^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type WVec<'b, T> = (&'b u32, Vec<T>);
| -- --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:16:25
@ -37,7 +49,10 @@ warning: where clauses are not enforced in type aliases
LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec<T>);
| ^^^^^ ^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type W2Vec<'b, T> = (&'b u32, Vec<T>);
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:47:12
@ -45,12 +60,15 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type T1<U: Bound> = U::Assoc;
| ^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to associated types in type aliases
--> $DIR/type-alias-bounds.rs:47:21
|
LL | type T1<U: Bound> = U::Assoc;
| ^^^^^^^^
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type T1<U> = U::Assoc;
| --
warning: where clauses are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:48:18
@ -58,12 +76,15 @@ warning: where clauses are not enforced in type aliases
LL | type T2<U> where U: Bound = U::Assoc;
| ^^^^^^^^
|
= help: the clause will not be checked when the type alias is used, and should be removed
help: use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to associated types in type aliases
--> $DIR/type-alias-bounds.rs:48:29
|
LL | type T2<U> where U: Bound = U::Assoc;
| ^^^^^^^^
help: the clause will not be checked when the type alias is used, and should be removed
|
LL | type T2<U> = U::Assoc;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:56:12
@ -71,7 +92,10 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type T5<U: Bound> = <U as Bound>::Assoc;
| ^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type T5<U> = <U as Bound>::Assoc;
| --
warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias-bounds.rs:57:12
@ -79,5 +103,8 @@ warning: bounds on generic parameters are not enforced in type aliases
LL | type T6<U: Bound> = ::std::vec::Vec<U>;
| ^^^^^
|
= help: the bound will not be checked when the type alias is used, and should be removed
help: the bound will not be checked when the type alias is used, and should be removed
|
LL | type T6<U> = ::std::vec::Vec<U>;
| --

View file

@ -40,7 +40,6 @@ const WHITELIST: &[&str] = &[
"E0514",
"E0519",
"E0523",
"E0526",
"E0554",
"E0570",
"E0629",