Skip to content

[beta] Rollup backports #62065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .azure-pipelines/auto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

pr: none
trigger:
- auto

pool:
vmImage: 'Ubuntu 16.04'

steps:
- script: echo Done
displayName: 'Dummy build'
2 changes: 1 addition & 1 deletion src/liballoc/macros.rs
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ macro_rules! vec {
($($x:expr),*) => (
<[_]>::into_vec(box [$($x),*])
);
($($x:expr,)*) => (vec![$($x),*])
($($x:expr,)*) => ($crate::vec![$($x),*])
}

// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is
22 changes: 11 additions & 11 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
@@ -6,13 +6,13 @@
#[stable(feature = "core", since = "1.6.0")]
macro_rules! panic {
() => (
panic!("explicit panic")
$crate::panic!("explicit panic")
);
($msg:expr) => ({
$crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!()))
});
($msg:expr,) => (
panic!($msg)
$crate::panic!($msg)
);
($fmt:expr, $($arg:tt)+) => ({
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
@@ -58,7 +58,7 @@ macro_rules! assert_eq {
}
});
($left:expr, $right:expr,) => ({
assert_eq!($left, $right)
$crate::assert_eq!($left, $right)
});
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
@@ -115,7 +115,7 @@ macro_rules! assert_ne {
}
});
($left:expr, $right:expr,) => {
assert_ne!($left, $right)
$crate::assert_ne!($left, $right)
};
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
@@ -208,7 +208,7 @@ macro_rules! debug_assert {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! debug_assert_eq {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); })
}

/// Asserts that two expressions are not equal to each other.
@@ -235,7 +235,7 @@ macro_rules! debug_assert_eq {
#[macro_export]
#[stable(feature = "assert_ne", since = "1.13.0")]
macro_rules! debug_assert_ne {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); })
}

/// Unwraps a result or propagates its error.
@@ -310,7 +310,7 @@ macro_rules! r#try {
return $crate::result::Result::Err($crate::convert::From::from(err))
}
});
($expr:expr,) => (r#try!($expr));
($expr:expr,) => ($crate::r#try!($expr));
}

/// Writes formatted data into a buffer.
@@ -425,10 +425,10 @@ macro_rules! write {
#[allow_internal_unstable(format_args_nl)]
macro_rules! writeln {
($dst:expr) => (
write!($dst, "\n")
$crate::write!($dst, "\n")
);
($dst:expr,) => (
writeln!($dst)
$crate::writeln!($dst)
);
($dst:expr, $($arg:tt)*) => (
$dst.write_fmt(format_args_nl!($($arg)*))
@@ -493,10 +493,10 @@ macro_rules! unreachable {
panic!("internal error: entered unreachable code")
});
($msg:expr) => ({
unreachable!("{}", $msg)
$crate::unreachable!("{}", $msg)
});
($msg:expr,) => ({
unreachable!($msg)
$crate::unreachable!($msg)
});
($fmt:expr, $($arg:tt)*) => ({
panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
6 changes: 3 additions & 3 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
@@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
/// impl Foo for Impl { }
/// impl Bar for Impl { }
///
/// let x: &Foo = &Impl; // OK
/// // let y: &Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// let x: &dyn Foo = &Impl; // OK
/// // let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// ```
///
/// [trait object]: ../../book/ch17-02-trait-objects.html
2 changes: 1 addition & 1 deletion src/libcore/mem.rs
Original file line number Diff line number Diff line change
@@ -1071,7 +1071,7 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
/// optimizations, potentially resulting in a larger size:
///
/// ```rust
/// # use std::mem::{MaybeUninit, size_of, align_of};
/// # use std::mem::{MaybeUninit, size_of};
/// assert_eq!(size_of::<Option<bool>>(), 1);
/// assert_eq!(size_of::<Option<MaybeUninit<bool>>>(), 2);
/// ```
4 changes: 2 additions & 2 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@
/// let value: i32 = 123;
///
/// // let the compiler make a trait object
/// let object: &Foo = &value;
/// let object: &dyn Foo = &value;
///
/// // look at the raw representation
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
@@ -65,7 +65,7 @@
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// let synthesized: &dyn Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable,
15 changes: 9 additions & 6 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
@@ -658,12 +658,15 @@ impl<'tcx> ScopeTree {
// The lifetime was defined on node that doesn't own a body,
// which in practice can only mean a trait or an impl, that
// is the parent of a method, and that is enforced below.
assert_eq!(Some(param_owner_id), self.root_parent,
"free_scope: {:?} not recognized by the \
region scope tree for {:?} / {:?}",
param_owner,
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
if Some(param_owner_id) != self.root_parent {
tcx.sess.delay_span_bug(
DUMMY_SP,
&format!("free_scope: {:?} not recognized by the \
region scope tree for {:?} / {:?}",
param_owner,
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
}

// The trait/impl lifetime is in scope for the method's body.
self.root_body.unwrap().local_id
2 changes: 1 addition & 1 deletion src/librustc/traits/query/evaluate_obligation.rs
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
Err(OverflowError) => {
let mut selcx =
SelectionContext::with_query_mode(&self, TraitQueryMode::Standard);
selcx.evaluate_obligation_recursively(obligation)
selcx.evaluate_root_obligation(obligation)
.unwrap_or_else(|r| {
span_bug!(
obligation.cause.span,
486 changes: 405 additions & 81 deletions src/librustc/traits/select.rs

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
@@ -479,21 +479,22 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
// the specialized routine `ty::replace_late_regions()`.
match *r {
ty::ReEarlyBound(data) => {
let r = self.substs.get(data.index as usize).map(|k| k.unpack());
match r {
let rk = self.substs.get(data.index as usize).map(|k| k.unpack());
match rk {
Some(UnpackedKind::Lifetime(lt)) => {
self.shift_region_through_binders(lt)
}
_ => {
let span = self.span.unwrap_or(DUMMY_SP);
span_bug!(
span,
let msg = format!(
"Region parameter out of range \
when substituting in region {} (root type={:?}) \
(index={})",
data.name,
self.root_ty,
data.index);
self.tcx.sess.delay_span_bug(span, &msg);
r
}
}
}
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1094,7 +1094,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {

(Reservation(WriteKind::MutableBorrow(bk)), BorrowKind::Shallow)
| (Reservation(WriteKind::MutableBorrow(bk)), BorrowKind::Shared) if {
tcx.migrate_borrowck()
tcx.migrate_borrowck() && this.borrow_set.location_map.contains_key(&location)
} => {
let bi = this.borrow_set.location_map[&location];
debug!(
8 changes: 6 additions & 2 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
@@ -361,8 +361,12 @@ where
offsets[usize::try_from(field).unwrap()],
layout::FieldPlacement::Array { stride, .. } => {
let len = base.len(self)?;
assert!(field < len, "Tried to access element {} of array/slice with length {}",
field, len);
if field >= len {
// This can be violated because this runs during promotion on code where the
// type system has not yet ensured that such things don't happen.
debug!("Tried to access element {} of array/slice with length {}", field, len);
return err!(BoundsCheck { len, index: field });
}
stride * field
}
layout::FieldPlacement::Union(count) => {
2 changes: 1 addition & 1 deletion src/librustc_traits/evaluate_obligation.rs
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ fn evaluate_obligation<'tcx>(
let mut selcx = SelectionContext::with_query_mode(&infcx, TraitQueryMode::Canonical);
let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate);

selcx.evaluate_obligation_recursively(&obligation)
selcx.evaluate_root_obligation(&obligation)
},
)
}
96 changes: 43 additions & 53 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
@@ -5190,52 +5190,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Some(original_span.with_lo(original_span.hi() - BytePos(1)))
}

// Rewrite `SelfCtor` to `Ctor`
pub fn rewrite_self_ctor(
&self,
res: Res,
span: Span,
) -> Result<Res, ErrorReported> {
let tcx = self.tcx;
if let Res::SelfCtor(impl_def_id) = res {
let ty = self.impl_self_ty(span, impl_def_id).ty;
let adt_def = ty.ty_adt_def();

match adt_def {
Some(adt_def) if adt_def.has_ctor() => {
let variant = adt_def.non_enum_variant();
let ctor_def_id = variant.ctor_def_id.unwrap();
Ok(Res::Def(DefKind::Ctor(CtorOf::Struct, variant.ctor_kind), ctor_def_id))
}
_ => {
let mut err = tcx.sess.struct_span_err(span,
"the `Self` constructor can only be used with tuple or unit structs");
if let Some(adt_def) = adt_def {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.help("did you mean to use one of the enum's variants?");
},
AdtKind::Struct |
AdtKind::Union => {
err.span_suggestion(
span,
"use curly brackets",
String::from("Self { /* fields */ }"),
Applicability::HasPlaceholders,
);
}
}
}
err.emit();

Err(ErrorReported)
}
}
} else {
Ok(res)
}
}

// Instantiates the given path, which must refer to an item with the given
// number of type parameters and type.
pub fn instantiate_value_path(&self,
@@ -5255,12 +5209,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let tcx = self.tcx;

let res = match self.rewrite_self_ctor(res, span) {
Ok(res) => res,
Err(ErrorReported) => return (tcx.types.err, res),
};
let path_segs = match res {
Res::Local(_) | Res::Upvar(..) => Vec::new(),
Res::Local(_) | Res::Upvar(..) | Res::SelfCtor(_) => vec![],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, FWIW, Local | Upvar became just Local in between the beta and master branches.

Res::Def(kind, def_id) =>
AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id),
_ => bug!("instantiate_value_path on {:?}", res),
@@ -5368,13 +5318,53 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
tcx.generics_of(*def_id).has_self
}).unwrap_or(false);

let (res, self_ctor_substs) = if let Res::SelfCtor(impl_def_id) = res {
let ty = self.impl_self_ty(span, impl_def_id).ty;
let adt_def = ty.ty_adt_def();

match ty.sty {
ty::Adt(adt_def, substs) if adt_def.has_ctor() => {
let variant = adt_def.non_enum_variant();
let ctor_def_id = variant.ctor_def_id.unwrap();
(
Res::Def(DefKind::Ctor(CtorOf::Struct, variant.ctor_kind), ctor_def_id),
Some(substs),
)
}
_ => {
let mut err = tcx.sess.struct_span_err(span,
"the `Self` constructor can only be used with tuple or unit structs");
if let Some(adt_def) = adt_def {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.help("did you mean to use one of the enum's variants?");
},
AdtKind::Struct |
AdtKind::Union => {
err.span_suggestion(
span,
"use curly brackets",
String::from("Self { /* fields */ }"),
Applicability::HasPlaceholders,
);
}
}
}
err.emit();

return (tcx.types.err, res)
}
}
} else {
(res, None)
};
let def_id = res.def_id();

// The things we are substituting into the type should not contain
// escaping late-bound regions, and nor should the base type scheme.
let ty = tcx.type_of(def_id);

let substs = AstConv::create_substs_for_generic_args(
let substs = self_ctor_substs.unwrap_or_else(|| AstConv::create_substs_for_generic_args(
tcx,
def_id,
&[][..],
@@ -5444,7 +5434,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
},
);
));
assert!(!substs.has_escaping_bound_vars());
assert!(!ty.has_escaping_bound_vars());

3 changes: 0 additions & 3 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
@@ -351,9 +351,6 @@ impl Options {
.unwrap_or_else(|| PathBuf::from("doc"));
let mut cfgs = matches.opt_strs("cfg");
cfgs.push("rustdoc".to_string());
if should_test {
cfgs.push("test".to_string());
}

let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));

3 changes: 2 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
@@ -223,7 +223,8 @@
#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"),
feature(global_asm, slice_index_methods,
decl_macro, coerce_unsized, sgx_platform, ptr_wrapping_offset_from))]
#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"), feature(fixed_size_array))]
#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"),
feature(fixed_size_array, maybe_uninit_extra))]

// std is implemented with unstable features, many of which are internal
// compiler details that will never be stable
16 changes: 8 additions & 8 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
@@ -56,13 +56,13 @@
#[allow_internal_unstable(__rust_unstable_column, libstd_sys_internals)]
macro_rules! panic {
() => ({
panic!("explicit panic")
$crate::panic!("explicit panic")
});
($msg:expr) => ({
$crate::rt::begin_panic($msg, &(file!(), line!(), __rust_unstable_column!()))
});
($msg:expr,) => ({
panic!($msg)
$crate::panic!($msg)
});
($fmt:expr, $($arg:tt)+) => ({
$crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+),
@@ -145,7 +145,7 @@ macro_rules! print {
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(print_internals, format_args_nl)]
macro_rules! println {
() => (print!("\n"));
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
$crate::io::_print(format_args_nl!($($arg)*));
})
@@ -204,7 +204,7 @@ macro_rules! eprint {
#[stable(feature = "eprint", since = "1.19.0")]
#[allow_internal_unstable(print_internals, format_args_nl)]
macro_rules! eprintln {
() => (eprint!("\n"));
() => ($crate::eprint!("\n"));
($($arg:tt)*) => ({
$crate::io::_eprint(format_args_nl!($($arg)*));
})
@@ -337,23 +337,23 @@ macro_rules! eprintln {
#[stable(feature = "dbg_macro", since = "1.32.0")]
macro_rules! dbg {
() => {
eprintln!("[{}:{}]", file!(), line!());
$crate::eprintln!("[{}:{}]", file!(), line!());
};
($val:expr) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
eprintln!("[{}:{}] {} = {:#?}",
$crate::eprintln!("[{}:{}] {} = {:#?}",
file!(), line!(), stringify!($val), &tmp);
tmp
}
}
};
// Trailing comma with single argument is ignored
($val:expr,) => { dbg!($val) };
($val:expr,) => { $crate::dbg!($val) };
($($val:expr),+ $(,)?) => {
($(dbg!($val)),+,)
($($crate::dbg!($val)),+,)
};
}

7 changes: 5 additions & 2 deletions src/test/rustdoc-ui/cfg-test.rs
Original file line number Diff line number Diff line change
@@ -2,18 +2,21 @@
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"

// Crates like core have doctests gated on `cfg(not(test))` so we need to make
// sure `cfg(test)` is not active when running `rustdoc --test`.

/// this doctest will be ignored:
///
/// ```
/// assert!(false);
/// ```
#[cfg(not(test))]
#[cfg(test)]
pub struct Foo;

/// this doctest will be tested:
///
/// ```
/// assert!(true);
/// ```
#[cfg(test)]
#[cfg(not(test))]
pub struct Foo;
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/cfg-test.stdout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

running 1 test
test $DIR/cfg-test.rs - Foo (line 15) ... ok
test $DIR/cfg-test.rs - Foo (line 18) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

5 changes: 5 additions & 0 deletions src/test/ui/consts/array-literal-index-oob.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
&{[1, 2, 3][4]};
//~^ ERROR index out of bounds
//~| ERROR reaching this expression at runtime will panic or abort
}
18 changes: 18 additions & 0 deletions src/test/ui/consts/array-literal-index-oob.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: index out of bounds: the len is 3 but the index is 4
--> $DIR/array-literal-index-oob.rs:2:7
|
LL | &{[1, 2, 3][4]};
| ^^^^^^^^^^^^
|
= note: #[deny(const_err)] on by default

error: reaching this expression at runtime will panic or abort
--> $DIR/array-literal-index-oob.rs:2:7
|
LL | &{[1, 2, 3][4]};
| --^^^^^^^^^^^^-
| |
| index out of bounds: the len is 3 but the index is 4

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/hygiene/no_implicit_prelude.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ mod bar {
}
fn f() {
::foo::m!();
println!(); //~ ERROR cannot find macro `print!` in this scope
assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope
}
}

6 changes: 3 additions & 3 deletions src/test/ui/hygiene/no_implicit_prelude.stderr
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@ LL | fn f() { ::bar::m!(); }
LL | Vec::new();
| ^^^ use of undeclared type or module `Vec`

error: cannot find macro `print!` in this scope
error: cannot find macro `panic!` in this scope
--> $DIR/no_implicit_prelude.rs:16:9
|
LL | println!();
| ^^^^^^^^^^^
LL | assert_eq!(0, 0);
| ^^^^^^^^^^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1 change: 0 additions & 1 deletion src/test/ui/imports/local-modularized-tricky-fail-1.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ mod inner2 {

fn main() {
panic!(); //~ ERROR `panic` is ambiguous
//~| ERROR `panic` is ambiguous
}

mod inner3 {
24 changes: 2 additions & 22 deletions src/test/ui/imports/local-modularized-tricky-fail-1.stderr
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ LL | use inner1::*;
= help: consider adding an explicit import of `exported` to disambiguate

error[E0659]: `include` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
--> $DIR/local-modularized-tricky-fail-1.rs:47:1
--> $DIR/local-modularized-tricky-fail-1.rs:46:1
|
LL | include!();
| ^^^^^^^ ambiguous name
@@ -59,26 +59,6 @@ LL | define_panic!();
| ---------------- in this macro invocation
= help: use `crate::panic` to refer to this macro unambiguously

error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
--> $DIR/local-modularized-tricky-fail-1.rs:35:5
|
LL | panic!();
| ^^^^^^^^^ ambiguous name
|
= note: `panic` could refer to a macro from prelude
note: `panic` could also refer to the macro defined here
--> $DIR/local-modularized-tricky-fail-1.rs:11:5
|
LL | / macro_rules! panic {
LL | | () => ()
LL | | }
| |_____^
...
LL | define_panic!();
| ---------------- in this macro invocation
= help: use `crate::panic` to refer to this macro unambiguously
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0659`.
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ pub struct Gcm<E>(E);
impl<E> Gcm<E> {
pub fn crash(e: E) -> Self {
Self::<E>(e)
//~^ ERROR type arguments are not allowed for this type
}
}

9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-57924.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0109]: type arguments are not allowed for this type
--> $DIR/issue-57924.rs:5:16
|
LL | Self::<E>(e)
| ^ type argument not allowed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0109`.
11 changes: 11 additions & 0 deletions src/test/ui/issues/issue-61623.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn f1<'a>(_: &'a mut ()) {}

fn f2<P>(_: P, _: ()) {}

fn f3<'a>(x: &'a ((), &'a mut ())) {
f2(|| x.0, f1(x.1))
//~^ ERROR cannot borrow `*x.1` as mutable, as it is behind a `&` reference
//~| ERROR cannot borrow `*x.1` as mutable because it is also borrowed as immutable
}

fn main() {}
22 changes: 22 additions & 0 deletions src/test/ui/issues/issue-61623.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0596]: cannot borrow `*x.1` as mutable, as it is behind a `&` reference
--> $DIR/issue-61623.rs:6:19
|
LL | fn f3<'a>(x: &'a ((), &'a mut ())) {
| -------------------- help: consider changing this to be a mutable reference: `&'a mut ((), &'a mut ())`
LL | f2(|| x.0, f1(x.1))
| ^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0502]: cannot borrow `*x.1` as mutable because it is also borrowed as immutable
--> $DIR/issue-61623.rs:6:19
|
LL | f2(|| x.0, f1(x.1))
| -- -- - ^^^ mutable borrow occurs here
| | | |
| | | first borrow occurs due to use of `x` in closure
| | immutable borrow occurs here
| immutable borrow later used by call

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0502, E0596.
For more information about an error, try `rustc --explain E0502`.
11 changes: 11 additions & 0 deletions src/test/ui/issues/issue-61882-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct A<T>(T);

impl A<&'static u8> {
fn f() {
let x = 0;
Self(&x);
//~^ ERROR `x` does not live long enough
}
}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-61882-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0597]: `x` does not live long enough
--> $DIR/issue-61882-2.rs:6:14
|
LL | Self(&x);
| ^^
| |
| borrowed value does not live long enough
| requires that `x` is borrowed for `'static`
LL |
LL | }
| - `x` dropped here while still borrowed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-61882.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct A<T>(T);

impl A<bool> {
const B: A<u8> = Self(0);
//~^ ERROR mismatched types
//~| ERROR mismatched types
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/ui/issues/issue-61882.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/issue-61882.rs:4:27
|
LL | const B: A<u8> = Self(0);
| ^ expected bool, found integer
|
= note: expected type `bool`
found type `{integer}`

error[E0308]: mismatched types
--> $DIR/issue-61882.rs:4:22
|
LL | const B: A<u8> = Self(0);
| ^^^^^^^ expected u8, found bool
|
= note: expected type `A<u8>`
found type `A<bool>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// rust-lang/rust#60654: Do not ICE on an attempt to use GATs that is
// missing the feature gate.

struct Foo;

impl Iterator for Foo {
type Item<'b> = &'b Foo; //~ ERROR generic associated types are unstable [E0658]

fn next(&mut self) -> Option<Self::Item> {
None
}
}

fn main() { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0658]: generic associated types are unstable
--> $DIR/gat-dont-ice-on-absent-feature.rs:7:5
|
LL | type Item<'b> = &'b Foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44265
= help: add #![feature(generic_associated_types)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.