Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #101366 (Restore old behaviour on broken UNC paths) - #101492 (Suggest adding array lengths to references to arrays if possible) - #101529 (Fix the example code and doctest for Formatter::sign_plus) - #101573 (update `ParamKindOrd`) - #101612 (Fix code generation of `Rvalue::Repeat` with 128 bit values) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
395e56f398
44 changed files with 165 additions and 182 deletions
|
@ -33,7 +33,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||||
use rustc_span::source_map::{respan, Spanned};
|
use rustc_span::source_map::{respan, Spanned};
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -324,46 +323,17 @@ pub type GenericBounds = Vec<GenericBound>;
|
||||||
/// Specifies the enforced ordering for generic parameters. In the future,
|
/// Specifies the enforced ordering for generic parameters. In the future,
|
||||||
/// if we wanted to relax this order, we could override `PartialEq` and
|
/// if we wanted to relax this order, we could override `PartialEq` and
|
||||||
/// `PartialOrd`, to allow the kinds to be unordered.
|
/// `PartialOrd`, to allow the kinds to be unordered.
|
||||||
#[derive(Hash, Clone, Copy)]
|
#[derive(Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum ParamKindOrd {
|
pub enum ParamKindOrd {
|
||||||
Lifetime,
|
Lifetime,
|
||||||
Type,
|
TypeOrConst,
|
||||||
Const,
|
|
||||||
// `Infer` is not actually constructed directly from the AST, but is implicitly constructed
|
|
||||||
// during HIR lowering, and `ParamKindOrd` will implicitly order inferred variables last.
|
|
||||||
Infer,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for ParamKindOrd {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
|
||||||
use ParamKindOrd::*;
|
|
||||||
let to_int = |v| match v {
|
|
||||||
Lifetime => 0,
|
|
||||||
Infer | Type | Const => 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
to_int(*self).cmp(&to_int(*other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl PartialOrd for ParamKindOrd {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
Some(self.cmp(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl PartialEq for ParamKindOrd {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.cmp(other) == Ordering::Equal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Eq for ParamKindOrd {}
|
|
||||||
|
|
||||||
impl fmt::Display for ParamKindOrd {
|
impl fmt::Display for ParamKindOrd {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ParamKindOrd::Lifetime => "lifetime".fmt(f),
|
ParamKindOrd::Lifetime => "lifetime".fmt(f),
|
||||||
ParamKindOrd::Type => "type".fmt(f),
|
ParamKindOrd::TypeOrConst => "type and const".fmt(f),
|
||||||
ParamKindOrd::Const { .. } => "const".fmt(f),
|
|
||||||
ParamKindOrd::Infer => "infer".fmt(f),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,10 +839,10 @@ fn validate_generic_param_order(
|
||||||
let (kind, bounds, span) = (¶m.kind, ¶m.bounds, ident.span);
|
let (kind, bounds, span) = (¶m.kind, ¶m.bounds, ident.span);
|
||||||
let (ord_kind, ident) = match ¶m.kind {
|
let (ord_kind, ident) = match ¶m.kind {
|
||||||
GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident.to_string()),
|
GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident.to_string()),
|
||||||
GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident.to_string()),
|
GenericParamKind::Type { default: _ } => (ParamKindOrd::TypeOrConst, ident.to_string()),
|
||||||
GenericParamKind::Const { ref ty, kw_span: _, default: _ } => {
|
GenericParamKind::Const { ref ty, kw_span: _, default: _ } => {
|
||||||
let ty = pprust::ty_to_string(ty);
|
let ty = pprust::ty_to_string(ty);
|
||||||
(ParamKindOrd::Const, format!("const {}: {}", ident, ty))
|
(ParamKindOrd::TypeOrConst, format!("const {}: {}", ident, ty))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
param_idents.push((kind, ord_kind, bounds, idx, ident));
|
param_idents.push((kind, ord_kind, bounds, idx, ident));
|
||||||
|
|
|
@ -215,7 +215,11 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_to_opt_uint(&self, v: &'ll Value) -> Option<u64> {
|
fn const_to_opt_uint(&self, v: &'ll Value) -> Option<u64> {
|
||||||
try_as_const_integral(v).map(|v| unsafe { llvm::LLVMConstIntGetZExtValue(v) })
|
try_as_const_integral(v).and_then(|v| unsafe {
|
||||||
|
let mut i = 0u64;
|
||||||
|
let success = llvm::LLVMRustConstIntGetZExtValue(v, &mut i);
|
||||||
|
success.then_some(i)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
|
fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ extern "C" {
|
||||||
pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
|
pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
|
||||||
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
|
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
|
||||||
pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
|
pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
|
||||||
pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
|
pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
|
||||||
pub fn LLVMRustConstInt128Get(
|
pub fn LLVMRustConstInt128Get(
|
||||||
ConstantVal: &ConstantInt,
|
ConstantVal: &ConstantInt,
|
||||||
SExt: bool,
|
SExt: bool,
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let size = bx.const_usize(dest.layout.size.bytes());
|
let size = bx.const_usize(dest.layout.size.bytes());
|
||||||
|
|
||||||
// Use llvm.memset.p0i8.* to initialize all zero arrays
|
// Use llvm.memset.p0i8.* to initialize all zero arrays
|
||||||
if bx.cx().const_to_opt_uint(v) == Some(0) {
|
if bx.cx().const_to_opt_u128(v, false) == Some(0) {
|
||||||
let fill = bx.cx().const_u8(0);
|
let fill = bx.cx().const_u8(0);
|
||||||
bx.memset(start, fill, size, dest.align, MemFlags::empty());
|
bx.memset(start, fill, size, dest.align, MemFlags::empty());
|
||||||
return bx;
|
return bx;
|
||||||
|
|
|
@ -300,9 +300,9 @@ impl GenericArg<'_> {
|
||||||
pub fn to_ord(&self) -> ast::ParamKindOrd {
|
pub fn to_ord(&self) -> ast::ParamKindOrd {
|
||||||
match self {
|
match self {
|
||||||
GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
|
GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
|
||||||
GenericArg::Type(_) => ast::ParamKindOrd::Type,
|
GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
|
||||||
GenericArg::Const(_) => ast::ParamKindOrd::Const,
|
ast::ParamKindOrd::TypeOrConst
|
||||||
GenericArg::Infer(_) => ast::ParamKindOrd::Infer,
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1618,6 +1618,14 @@ extern "C" LLVMValueRef LLVMRustConstInBoundsGEP2(LLVMTypeRef Ty,
|
||||||
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
|
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
|
||||||
|
auto C = unwrap<llvm::ConstantInt>(CV);
|
||||||
|
if (C->getBitWidth() > 64)
|
||||||
|
return false;
|
||||||
|
*value = C->getZExtValue();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if both high and low were successfully set. Fails in case constant wasn’t any of
|
// Returns true if both high and low were successfully set. Fails in case constant wasn’t any of
|
||||||
// the common sizes (1, 8, 16, 32, 64, 128 bits)
|
// the common sizes (1, 8, 16, 32, 64, 128 bits)
|
||||||
extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)
|
extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)
|
||||||
|
|
|
@ -27,8 +27,9 @@ impl GenericParamDefKind {
|
||||||
pub fn to_ord(&self) -> ast::ParamKindOrd {
|
pub fn to_ord(&self) -> ast::ParamKindOrd {
|
||||||
match self {
|
match self {
|
||||||
GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime,
|
GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime,
|
||||||
GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type,
|
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
|
||||||
GenericParamDefKind::Const { .. } => ast::ParamKindOrd::Const,
|
ast::ParamKindOrd::TypeOrConst
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,8 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
||||||
let ty = item_ctxt.ast_ty_to_ty(hir_ty);
|
let ty = item_ctxt.ast_ty_to_ty(hir_ty);
|
||||||
|
|
||||||
// Iterate through the generics of the projection to find the one that corresponds to
|
// Iterate through the generics of the projection to find the one that corresponds to
|
||||||
// the def_id that this query was called with. We filter to only const args here as a
|
// the def_id that this query was called with. We filter to only type and const args here
|
||||||
// precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't
|
// as a precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't
|
||||||
// but it can't hurt to be safe ^^
|
// but it can't hurt to be safe ^^
|
||||||
if let ty::Projection(projection) = ty.kind() {
|
if let ty::Projection(projection) = ty.kind() {
|
||||||
let generics = tcx.generics_of(projection.item_def_id);
|
let generics = tcx.generics_of(projection.item_def_id);
|
||||||
|
|
|
@ -198,14 +198,7 @@ fn parse_next_component(path: &OsStr, verbatim: bool) -> (&OsStr, &OsStr) {
|
||||||
|
|
||||||
match path.bytes().iter().position(|&x| separator(x)) {
|
match path.bytes().iter().position(|&x| separator(x)) {
|
||||||
Some(separator_start) => {
|
Some(separator_start) => {
|
||||||
let mut separator_end = separator_start + 1;
|
let separator_end = separator_start + 1;
|
||||||
|
|
||||||
// a series of multiple separator characters is treated as a single separator,
|
|
||||||
// except in verbatim paths
|
|
||||||
while !verbatim && separator_end < path.len() && separator(path.bytes()[separator_end])
|
|
||||||
{
|
|
||||||
separator_end += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let component = &path.bytes()[..separator_start];
|
let component = &path.bytes()[..separator_start];
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,6 @@ fn test_parse_next_component() {
|
||||||
parse_next_component(OsStr::new(r"servershare"), false),
|
parse_next_component(OsStr::new(r"servershare"), false),
|
||||||
(OsStr::new(r"servershare"), OsStr::new(""))
|
(OsStr::new(r"servershare"), OsStr::new(""))
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
parse_next_component(OsStr::new(r"server/\//\/\\\\/////\/share"), false),
|
|
||||||
(OsStr::new(r"server"), OsStr::new(r"share"))
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
parse_next_component(OsStr::new(r"server\\\\\\\\\\\\\\share"), true),
|
|
||||||
(OsStr::new(r"server"), OsStr::new(r"\\\\\\\\\\\\\share"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -126,3 +116,22 @@ fn test_windows_prefix_components() {
|
||||||
assert_eq!(drive.as_os_str(), OsStr::new("C:"));
|
assert_eq!(drive.as_os_str(), OsStr::new("C:"));
|
||||||
assert_eq!(components.as_path(), Path::new(""));
|
assert_eq!(components.as_path(), Path::new(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// See #101358.
|
||||||
|
///
|
||||||
|
/// Note that the exact behaviour here may change in the future.
|
||||||
|
/// In which case this test will need to adjusted.
|
||||||
|
#[test]
|
||||||
|
fn broken_unc_path() {
|
||||||
|
use crate::path::Component;
|
||||||
|
|
||||||
|
let mut components = Path::new(r"\\foo\\bar\\").components();
|
||||||
|
assert_eq!(components.next(), Some(Component::RootDir));
|
||||||
|
assert_eq!(components.next(), Some(Component::Normal("foo".as_ref())));
|
||||||
|
assert_eq!(components.next(), Some(Component::Normal("bar".as_ref())));
|
||||||
|
|
||||||
|
let mut components = Path::new("//foo//bar//").components();
|
||||||
|
assert_eq!(components.next(), Some(Component::RootDir));
|
||||||
|
assert_eq!(components.next(), Some(Component::Normal("foo".as_ref())));
|
||||||
|
assert_eq!(components.next(), Some(Component::Normal("bar".as_ref())));
|
||||||
|
}
|
||||||
|
|
14
src/test/ui/codegen/issue-101585-128bit-repeat.rs
Normal file
14
src/test/ui/codegen/issue-101585-128bit-repeat.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Regression test for issue 101585.
|
||||||
|
// run-pass
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
fn min_array_ok() -> [i128; 1] {
|
||||||
|
[i128::MIN]
|
||||||
|
}
|
||||||
|
assert_eq!(min_array_ok(), [-170141183460469231731687303715884105728i128]);
|
||||||
|
|
||||||
|
fn min_array_nok() -> [i128; 1] {
|
||||||
|
[i128::MIN; 1]
|
||||||
|
}
|
||||||
|
assert_eq!(min_array_nok(), [-170141183460469231731687303715884105728i128]);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to const parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/argument_order.rs:6:32
|
--> $DIR/argument_order.rs:6:32
|
||||||
|
|
|
|
||||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||||
|
@ -11,7 +11,7 @@ LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
= note: lifetime arguments must be provided before type arguments
|
= note: lifetime arguments must be provided before type arguments
|
||||||
= help: reorder the arguments: lifetimes, then consts: `<'a, 'b, N, T, M, U>`
|
= help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, N, T, M, U>`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn bar<const X: u8, 'a>(_: &'a ()) {
|
fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo<const X: u8, T>(_: &T) {}
|
fn foo<const X: u8, T>(_: &T) {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to const parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/const-param-before-other-params.rs:1:21
|
--> $DIR/const-param-before-other-params.rs:1:21
|
||||||
|
|
|
|
||||||
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
|
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// Checks that lifetimes cannot be interspersed between consts and types.
|
// Checks that lifetimes cannot be interspersed between consts and types.
|
||||||
|
|
||||||
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||||
//~^ Error lifetime parameters must be declared prior to const parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
||||||
//~^ Error lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: lifetime parameters must be declared prior to const parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/intermixed-lifetime.rs:3:28
|
--> $DIR/intermixed-lifetime.rs:3:28
|
||||||
|
|
|
|
||||||
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||||
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/intermixed-lifetime.rs:6:37
|
--> $DIR/intermixed-lifetime.rs:6:37
|
||||||
|
|
|
|
||||||
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct Foo<const M: usize = 10, 'a>(&'a u32);
|
struct Foo<const M: usize = 10, 'a>(&'a u32);
|
||||||
//~^ Error lifetime parameters must be declared prior to const parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to const parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/param-order-err-pretty-prints-default.rs:1:33
|
--> $DIR/param-order-err-pretty-prints-default.rs:1:33
|
||||||
|
|
|
|
||||||
LL | struct Foo<const M: usize = 10, 'a>(&'a u32);
|
LL | struct Foo<const M: usize = 10, 'a>(&'a u32);
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct A;
|
||||||
|
|
||||||
impl A {
|
impl A {
|
||||||
pub fn do_things<T, 'a, 'b: 'a>() {
|
pub fn do_things<T, 'a, 'b: 'a>() {
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
println!("panic");
|
println!("panic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/issue-59508-1.rs:10:25
|
--> $DIR/issue-59508-1.rs:10:25
|
||||||
|
|
|
|
||||||
LL | pub fn do_things<T, 'a, 'b: 'a>() {
|
LL | pub fn do_things<T, 'a, 'b: 'a>() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct A;
|
||||||
|
|
||||||
impl A {
|
impl A {
|
||||||
pub fn do_things<'a, 'b: 'a, T>() {
|
pub fn do_things<'a, 'b: 'a, T>() {
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
println!("panic");
|
println!("panic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct A;
|
||||||
|
|
||||||
impl A {
|
impl A {
|
||||||
pub fn do_things<T, 'a, 'b: 'a>() {
|
pub fn do_things<T, 'a, 'b: 'a>() {
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
println!("panic");
|
println!("panic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/issue-59508.rs:10:25
|
--> $DIR/issue-59508.rs:10:25
|
||||||
|
|
|
|
||||||
LL | pub fn do_things<T, 'a, 'b: 'a>() {
|
LL | pub fn do_things<T, 'a, 'b: 'a>() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
struct S<T = (), 'a>(&'a T);
|
struct S<T = (), 'a>(&'a T);
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18
|
--> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18
|
||||||
|
|
|
|
||||||
LL | struct S<T = (), 'a>(&'a T);
|
LL | struct S<T = (), 'a>(&'a T);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
fn first<T, 'a, 'b>() {}
|
fn first<T, 'a, 'b>() {}
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
fn second<'a, T, 'b>() {}
|
fn second<'a, T, 'b>() {}
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
fn third<T, U, 'a>() {}
|
fn third<T, U, 'a>() {}
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
fn fourth<'a, T, 'b, U, 'c, V>() {}
|
fn fourth<'a, T, 'b, U, 'c, V>() {}
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/lifetime-before-type-params.rs:2:13
|
--> $DIR/lifetime-before-type-params.rs:2:13
|
||||||
|
|
|
|
||||||
LL | fn first<T, 'a, 'b>() {}
|
LL | fn first<T, 'a, 'b>() {}
|
||||||
| ----^^--^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
| ----^^--^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/lifetime-before-type-params.rs:4:18
|
--> $DIR/lifetime-before-type-params.rs:4:18
|
||||||
|
|
|
|
||||||
LL | fn second<'a, T, 'b>() {}
|
LL | fn second<'a, T, 'b>() {}
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/lifetime-before-type-params.rs:6:16
|
--> $DIR/lifetime-before-type-params.rs:6:16
|
||||||
|
|
|
|
||||||
LL | fn third<T, U, 'a>() {}
|
LL | fn third<T, U, 'a>() {}
|
||||||
| -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
| -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/lifetime-before-type-params.rs:8:18
|
--> $DIR/lifetime-before-type-params.rs:8:18
|
||||||
|
|
|
|
||||||
LL | fn fourth<'a, T, 'b, U, 'c, V>() {}
|
LL | fn fourth<'a, T, 'b, U, 'c, V>() {}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
enum X<'a, T, 'b> {
|
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
|
||||||
A(&'a &'b T)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
|
||||||
--> $DIR/issue-14303-enum.rs:1:15
|
|
||||||
|
|
|
||||||
LL | enum X<'a, T, 'b> {
|
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
fn foo<'a, T, 'b>(x: &'a T) {}
|
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
|
||||||
--> $DIR/issue-14303-fn-def.rs:1:15
|
|
||||||
|
|
|
||||||
LL | fn foo<'a, T, 'b>(x: &'a T) {}
|
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
struct X<T>(T);
|
|
||||||
|
|
||||||
impl<'a, T, 'b> X<T> {}
|
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
|
||||||
--> $DIR/issue-14303-impl.rs:3:13
|
|
||||||
|
|
|
||||||
LL | impl<'a, T, 'b> X<T> {}
|
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
mod foo {
|
|
||||||
pub struct X<'a, 'b, 'c, T> {
|
|
||||||
a: &'a str,
|
|
||||||
b: &'b str,
|
|
||||||
c: &'c str,
|
|
||||||
t: T,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
|
|
||||||
//~^ ERROR type provided when a lifetime was expected
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,9 +0,0 @@
|
||||||
error[E0747]: type provided when a lifetime was expected
|
|
||||||
--> $DIR/issue-14303-path.rs:10:37
|
|
||||||
|
|
|
||||||
LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0747`.
|
|
|
@ -1,6 +0,0 @@
|
||||||
struct X<'a, T, 'b> {
|
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
|
||||||
x: &'a &'b T
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
|
||||||
--> $DIR/issue-14303-struct.rs:1:17
|
|
||||||
|
|
|
||||||
LL | struct X<'a, T, 'b> {
|
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
trait Foo<'a, T, 'b> {}
|
|
||||||
//~^ ERROR lifetime parameters must be declared prior to type parameters
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
|
||||||
--> $DIR/issue-14303-trait.rs:1:18
|
|
||||||
|
|
|
||||||
LL | trait Foo<'a, T, 'b> {}
|
|
||||||
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
33
src/test/ui/parser/issues/issue-14303.rs
Normal file
33
src/test/ui/parser/issues/issue-14303.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
enum Enum<'a, T, 'b> {
|
||||||
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
A(&'a &'b T)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct<'a, T, 'b> {
|
||||||
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
x: &'a &'b T
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Trait<'a, T, 'b> {}
|
||||||
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
|
fn foo<'a, T, 'b>(x: &'a T) {}
|
||||||
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
|
struct Y<T>(T);
|
||||||
|
impl<'a, T, 'b> Y<T> {}
|
||||||
|
//~^ ERROR lifetime parameters must be declared prior to type and const parameters
|
||||||
|
|
||||||
|
mod bar {
|
||||||
|
pub struct X<'a, 'b, 'c, T> {
|
||||||
|
a: &'a str,
|
||||||
|
b: &'b str,
|
||||||
|
c: &'c str,
|
||||||
|
t: T,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar<'a, 'b, 'c, T>(x: bar::X<'a, T, 'b, 'c>) {}
|
||||||
|
//~^ ERROR type provided when a lifetime was expected
|
||||||
|
|
||||||
|
fn main() {}
|
39
src/test/ui/parser/issues/issue-14303.stderr
Normal file
39
src/test/ui/parser/issues/issue-14303.stderr
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
|
--> $DIR/issue-14303.rs:1:18
|
||||||
|
|
|
||||||
|
LL | enum Enum<'a, T, 'b> {
|
||||||
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
|
--> $DIR/issue-14303.rs:6:22
|
||||||
|
|
|
||||||
|
LL | struct Struct<'a, T, 'b> {
|
||||||
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
|
--> $DIR/issue-14303.rs:11:20
|
||||||
|
|
|
||||||
|
LL | trait Trait<'a, T, 'b> {}
|
||||||
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
|
--> $DIR/issue-14303.rs:14:15
|
||||||
|
|
|
||||||
|
LL | fn foo<'a, T, 'b>(x: &'a T) {}
|
||||||
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
|
--> $DIR/issue-14303.rs:18:13
|
||||||
|
|
|
||||||
|
LL | impl<'a, T, 'b> Y<T> {}
|
||||||
|
| --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
|
||||||
|
|
||||||
|
error[E0747]: type provided when a lifetime was expected
|
||||||
|
--> $DIR/issue-14303.rs:30:37
|
||||||
|
|
|
||||||
|
LL | fn bar<'a, 'b, 'c, T>(x: bar::X<'a, T, 'b, 'c>) {}
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0747`.
|
|
@ -1,22 +1,22 @@
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/suggest-move-lifetimes.rs:1:13
|
--> $DIR/suggest-move-lifetimes.rs:1:13
|
||||||
|
|
|
|
||||||
LL | struct A<T, 'a> {
|
LL | struct A<T, 'a> {
|
||||||
| ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>`
|
| ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/suggest-move-lifetimes.rs:5:13
|
--> $DIR/suggest-move-lifetimes.rs:5:13
|
||||||
|
|
|
|
||||||
LL | struct B<T, 'a, U> {
|
LL | struct B<T, 'a, U> {
|
||||||
| ----^^---- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
| ----^^---- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/suggest-move-lifetimes.rs:10:16
|
--> $DIR/suggest-move-lifetimes.rs:10:16
|
||||||
|
|
|
|
||||||
LL | struct C<T, U, 'a> {
|
LL | struct C<T, U, 'a> {
|
||||||
| -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
| -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
|
||||||
|
|
||||||
error: lifetime parameters must be declared prior to type parameters
|
error: lifetime parameters must be declared prior to type and const parameters
|
||||||
--> $DIR/suggest-move-lifetimes.rs:15:16
|
--> $DIR/suggest-move-lifetimes.rs:15:16
|
||||||
|
|
|
|
||||||
LL | struct D<T, U, 'a, 'b, V, 'c> {
|
LL | struct D<T, U, 'a, 'b, V, 'c> {
|
||||||
|
|
|
@ -121,7 +121,7 @@ LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=()
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
= note: lifetime arguments must be provided before type arguments
|
= note: lifetime arguments must be provided before type arguments
|
||||||
= help: reorder the arguments: lifetimes, then types: `<'a, 'b, 'c, T, U, V>`
|
= help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, 'c, T, U, V>`
|
||||||
|
|
||||||
error[E0747]: lifetime provided when a type was expected
|
error[E0747]: lifetime provided when a type was expected
|
||||||
--> $DIR/suggest-move-types.rs:82:56
|
--> $DIR/suggest-move-types.rs:82:56
|
||||||
|
@ -130,7 +130,7 @@ LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, '
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
= note: lifetime arguments must be provided before type arguments
|
= note: lifetime arguments must be provided before type arguments
|
||||||
= help: reorder the arguments: lifetimes, then types: `<'a, 'b, 'c, T, U, V>`
|
= help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, 'c, T, U, V>`
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue