diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index c07ba88ae204..3f4911c4ecfc 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -33,7 +33,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; -use std::cmp::Ordering; use std::convert::TryFrom; use std::fmt; use std::mem; @@ -324,46 +323,17 @@ pub type GenericBounds = Vec; /// Specifies the enforced ordering for generic parameters. In the future, /// if we wanted to relax this order, we could override `PartialEq` and /// `PartialOrd`, to allow the kinds to be unordered. -#[derive(Hash, Clone, Copy)] +#[derive(Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum ParamKindOrd { Lifetime, - Type, - 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 { - Some(self.cmp(other)) - } -} -impl PartialEq for ParamKindOrd { - fn eq(&self, other: &Self) -> bool { - self.cmp(other) == Ordering::Equal - } + TypeOrConst, } -impl Eq for ParamKindOrd {} impl fmt::Display for ParamKindOrd { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ParamKindOrd::Lifetime => "lifetime".fmt(f), - ParamKindOrd::Type => "type".fmt(f), - ParamKindOrd::Const { .. } => "const".fmt(f), - ParamKindOrd::Infer => "infer".fmt(f), + ParamKindOrd::TypeOrConst => "type and const".fmt(f), } } } diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 6c754f38d144..6a0a1b083601 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -839,10 +839,10 @@ fn validate_generic_param_order( let (kind, bounds, span) = (¶m.kind, ¶m.bounds, ident.span); let (ord_kind, ident) = match ¶m.kind { 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: _ } => { 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)); diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 488ea72c3b77..acee9134fb96 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -215,7 +215,11 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn const_to_opt_uint(&self, v: &'ll Value) -> Option { - 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 { diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 172684414fc5..ce27dc5a5d1e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1096,7 +1096,7 @@ extern "C" { 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 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( ConstantVal: &ConstantInt, SExt: bool, diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 26b9fbf44284..574746e340b7 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let size = bx.const_usize(dest.layout.size.bytes()); // 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); bx.memset(start, fill, size, dest.align, MemFlags::empty()); return bx; diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 0de99f7a3dbb..c0f93b7c3382 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -300,9 +300,9 @@ impl GenericArg<'_> { pub fn to_ord(&self) -> ast::ParamKindOrd { match self { GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime, - GenericArg::Type(_) => ast::ParamKindOrd::Type, - GenericArg::Const(_) => ast::ParamKindOrd::Const, - GenericArg::Infer(_) => ast::ParamKindOrd::Infer, + GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => { + ast::ParamKindOrd::TypeOrConst + } } } diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 931ce78721cb..6ee3c7d68213 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1618,6 +1618,14 @@ extern "C" LLVMValueRef LLVMRustConstInBoundsGEP2(LLVMTypeRef Ty, return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList)); } +extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) { + auto C = unwrap(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 // the common sizes (1, 8, 16, 32, 64, 128 bits) extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low) diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 8631ee91fa45..0c8bdde9c8bc 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -27,8 +27,9 @@ impl GenericParamDefKind { pub fn to_ord(&self) -> ast::ParamKindOrd { match self { GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime, - GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type, - GenericParamDefKind::Const { .. } => ast::ParamKindOrd::Const, + GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { + ast::ParamKindOrd::TypeOrConst + } } } diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index a26e26cb3899..70e259b46bf2 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -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); // 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 - // precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't + // the def_id that this query was called with. We filter to only type and const args here + // 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 ^^ if let ty::Projection(projection) = ty.kind() { let generics = tcx.generics_of(projection.item_def_id); diff --git a/library/std/src/sys/windows/path.rs b/library/std/src/sys/windows/path.rs index a0f822070992..beeca1917a9a 100644 --- a/library/std/src/sys/windows/path.rs +++ b/library/std/src/sys/windows/path.rs @@ -198,14 +198,7 @@ fn parse_next_component(path: &OsStr, verbatim: bool) -> (&OsStr, &OsStr) { match path.bytes().iter().position(|&x| separator(x)) { Some(separator_start) => { - let mut 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 separator_end = separator_start + 1; let component = &path.bytes()[..separator_start]; diff --git a/library/std/src/sys/windows/path/tests.rs b/library/std/src/sys/windows/path/tests.rs index a71175069052..623c6236166d 100644 --- a/library/std/src/sys/windows/path/tests.rs +++ b/library/std/src/sys/windows/path/tests.rs @@ -31,16 +31,6 @@ fn test_parse_next_component() { parse_next_component(OsStr::new(r"servershare"), false), (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] @@ -126,3 +116,22 @@ fn test_windows_prefix_components() { assert_eq!(drive.as_os_str(), OsStr::new("C:")); 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()))); +} diff --git a/src/test/ui/codegen/issue-101585-128bit-repeat.rs b/src/test/ui/codegen/issue-101585-128bit-repeat.rs new file mode 100644 index 000000000000..c6a686597e9c --- /dev/null +++ b/src/test/ui/codegen/issue-101585-128bit-repeat.rs @@ -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]); +} diff --git a/src/test/ui/const-generics/argument_order.stderr b/src/test/ui/const-generics/argument_order.stderr index 6b33dffb434e..99122c6f5e36 100644 --- a/src/test/ui/const-generics/argument_order.stderr +++ b/src/test/ui/const-generics/argument_order.stderr @@ -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 | LL | struct AlsoBad { @@ -11,7 +11,7 @@ LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ | = 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 diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs index da06aca308e1..cb1cebe1f68a 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.rs +++ b/src/test/ui/const-generics/const-param-before-other-params.rs @@ -1,5 +1,5 @@ fn bar(_: &'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(_: &T) {} diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.stderr index 607d20c4a25f..2c7a47bbc78c 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.stderr +++ b/src/test/ui/const-generics/const-param-before-other-params.stderr @@ -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 | LL | fn bar(_: &'a ()) { diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs index 578938db4c43..beaf7fc6001a 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs @@ -1,9 +1,9 @@ // Checks that lifetimes cannot be interspersed between consts and types. struct Foo(&'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(&'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() {} diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.stderr index e27976deb2b5..5cff61dd9fb9 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.stderr +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.stderr @@ -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 | LL | struct Foo(&'a (), T); | -----------------^^---------- 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 | LL | struct Bar(&'a (), T); diff --git a/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.rs b/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.rs index da087ffc3c4a..f928fc9e75b7 100644 --- a/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.rs +++ b/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.rs @@ -1,4 +1,4 @@ struct Foo(&'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() {} diff --git a/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.stderr b/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.stderr index 55f5a5353853..ba08b4646d0f 100644 --- a/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.stderr +++ b/src/test/ui/const-generics/defaults/param-order-err-pretty-prints-default.stderr @@ -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 | LL | struct Foo(&'a u32); diff --git a/src/test/ui/generics/issue-59508-1.rs b/src/test/ui/generics/issue-59508-1.rs index 7e1dd7707044..8e27749e8fc6 100644 --- a/src/test/ui/generics/issue-59508-1.rs +++ b/src/test/ui/generics/issue-59508-1.rs @@ -8,7 +8,7 @@ struct A; impl A { pub fn do_things() { - //~^ ERROR lifetime parameters must be declared prior to type parameters + //~^ ERROR lifetime parameters must be declared prior to type and const parameters println!("panic"); } } diff --git a/src/test/ui/generics/issue-59508-1.stderr b/src/test/ui/generics/issue-59508-1.stderr index d162365ea4bf..1c510044f806 100644 --- a/src/test/ui/generics/issue-59508-1.stderr +++ b/src/test/ui/generics/issue-59508-1.stderr @@ -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 | LL | pub fn do_things() { diff --git a/src/test/ui/generics/issue-59508.fixed b/src/test/ui/generics/issue-59508.fixed index b5c60a1626f5..de8f47d4cff8 100644 --- a/src/test/ui/generics/issue-59508.fixed +++ b/src/test/ui/generics/issue-59508.fixed @@ -8,7 +8,7 @@ struct A; impl A { 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"); } } diff --git a/src/test/ui/generics/issue-59508.rs b/src/test/ui/generics/issue-59508.rs index 0b39c5d8f2ae..a4c7d4ff2626 100644 --- a/src/test/ui/generics/issue-59508.rs +++ b/src/test/ui/generics/issue-59508.rs @@ -8,7 +8,7 @@ struct A; impl A { pub fn do_things() { - //~^ ERROR lifetime parameters must be declared prior to type parameters + //~^ ERROR lifetime parameters must be declared prior to type and const parameters println!("panic"); } } diff --git a/src/test/ui/generics/issue-59508.stderr b/src/test/ui/generics/issue-59508.stderr index c52ae4182b86..fd23b6276f92 100644 --- a/src/test/ui/generics/issue-59508.stderr +++ b/src/test/ui/generics/issue-59508.stderr @@ -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 | LL | pub fn do_things() { diff --git a/src/test/ui/generics/issue-80512-param-reordering-with-defaults.rs b/src/test/ui/generics/issue-80512-param-reordering-with-defaults.rs index fe3e4fbc7e0b..0e208818ed45 100644 --- a/src/test/ui/generics/issue-80512-param-reordering-with-defaults.rs +++ b/src/test/ui/generics/issue-80512-param-reordering-with-defaults.rs @@ -1,4 +1,4 @@ #![crate_type = "lib"] struct S(&'a T); -//~^ ERROR lifetime parameters must be declared prior to type parameters +//~^ ERROR lifetime parameters must be declared prior to type and const parameters diff --git a/src/test/ui/generics/issue-80512-param-reordering-with-defaults.stderr b/src/test/ui/generics/issue-80512-param-reordering-with-defaults.stderr index 119b1a0d2070..70793a9c9208 100644 --- a/src/test/ui/generics/issue-80512-param-reordering-with-defaults.stderr +++ b/src/test/ui/generics/issue-80512-param-reordering-with-defaults.stderr @@ -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 | LL | struct S(&'a T); diff --git a/src/test/ui/generics/lifetime-before-type-params.rs b/src/test/ui/generics/lifetime-before-type-params.rs index 5a71d6efeda6..d64b1b0b44f6 100644 --- a/src/test/ui/generics/lifetime-before-type-params.rs +++ b/src/test/ui/generics/lifetime-before-type-params.rs @@ -1,11 +1,11 @@ #![allow(unused)] fn first() {} -//~^ 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>() {} -//~^ ERROR lifetime parameters must be declared prior to type parameters +//~^ ERROR lifetime parameters must be declared prior to type and const parameters fn third() {} -//~^ 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>() {} -//~^ ERROR lifetime parameters must be declared prior to type parameters +//~^ ERROR lifetime parameters must be declared prior to type and const parameters fn main() {} diff --git a/src/test/ui/generics/lifetime-before-type-params.stderr b/src/test/ui/generics/lifetime-before-type-params.stderr index 62d95e45329f..84825eb4ceb2 100644 --- a/src/test/ui/generics/lifetime-before-type-params.stderr +++ b/src/test/ui/generics/lifetime-before-type-params.stderr @@ -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 | LL | fn first() {} | ----^^--^^- 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 | LL | fn second<'a, T, 'b>() {} | --------^^- 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 | LL | fn third() {} | -------^^- 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 | LL | fn fourth<'a, T, 'b, U, 'c, V>() {} diff --git a/src/test/ui/parser/issues/issue-14303-enum.rs b/src/test/ui/parser/issues/issue-14303-enum.rs deleted file mode 100644 index a6106159805b..000000000000 --- a/src/test/ui/parser/issues/issue-14303-enum.rs +++ /dev/null @@ -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() {} diff --git a/src/test/ui/parser/issues/issue-14303-enum.stderr b/src/test/ui/parser/issues/issue-14303-enum.stderr deleted file mode 100644 index 55cef4cabacf..000000000000 --- a/src/test/ui/parser/issues/issue-14303-enum.stderr +++ /dev/null @@ -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 - diff --git a/src/test/ui/parser/issues/issue-14303-fn-def.rs b/src/test/ui/parser/issues/issue-14303-fn-def.rs deleted file mode 100644 index 221bd311e747..000000000000 --- a/src/test/ui/parser/issues/issue-14303-fn-def.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn foo<'a, T, 'b>(x: &'a T) {} -//~^ ERROR lifetime parameters must be declared prior to type parameters - -fn main() {} diff --git a/src/test/ui/parser/issues/issue-14303-fn-def.stderr b/src/test/ui/parser/issues/issue-14303-fn-def.stderr deleted file mode 100644 index bacc922969d9..000000000000 --- a/src/test/ui/parser/issues/issue-14303-fn-def.stderr +++ /dev/null @@ -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 - diff --git a/src/test/ui/parser/issues/issue-14303-impl.rs b/src/test/ui/parser/issues/issue-14303-impl.rs deleted file mode 100644 index 4dc2c6660180..000000000000 --- a/src/test/ui/parser/issues/issue-14303-impl.rs +++ /dev/null @@ -1,6 +0,0 @@ -struct X(T); - -impl<'a, T, 'b> X {} -//~^ ERROR lifetime parameters must be declared prior to type parameters - -fn main() {} diff --git a/src/test/ui/parser/issues/issue-14303-impl.stderr b/src/test/ui/parser/issues/issue-14303-impl.stderr deleted file mode 100644 index d6be02f70fd2..000000000000 --- a/src/test/ui/parser/issues/issue-14303-impl.stderr +++ /dev/null @@ -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 {} - | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` - -error: aborting due to previous error - diff --git a/src/test/ui/parser/issues/issue-14303-path.rs b/src/test/ui/parser/issues/issue-14303-path.rs deleted file mode 100644 index 89ef914aba23..000000000000 --- a/src/test/ui/parser/issues/issue-14303-path.rs +++ /dev/null @@ -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() {} diff --git a/src/test/ui/parser/issues/issue-14303-path.stderr b/src/test/ui/parser/issues/issue-14303-path.stderr deleted file mode 100644 index 841e63ecbe9d..000000000000 --- a/src/test/ui/parser/issues/issue-14303-path.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/parser/issues/issue-14303-struct.rs b/src/test/ui/parser/issues/issue-14303-struct.rs deleted file mode 100644 index 0bd10b4d0851..000000000000 --- a/src/test/ui/parser/issues/issue-14303-struct.rs +++ /dev/null @@ -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() {} diff --git a/src/test/ui/parser/issues/issue-14303-struct.stderr b/src/test/ui/parser/issues/issue-14303-struct.stderr deleted file mode 100644 index fa62a39f2416..000000000000 --- a/src/test/ui/parser/issues/issue-14303-struct.stderr +++ /dev/null @@ -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 - diff --git a/src/test/ui/parser/issues/issue-14303-trait.rs b/src/test/ui/parser/issues/issue-14303-trait.rs deleted file mode 100644 index f253de92d92d..000000000000 --- a/src/test/ui/parser/issues/issue-14303-trait.rs +++ /dev/null @@ -1,4 +0,0 @@ -trait Foo<'a, T, 'b> {} -//~^ ERROR lifetime parameters must be declared prior to type parameters - -fn main() {} diff --git a/src/test/ui/parser/issues/issue-14303-trait.stderr b/src/test/ui/parser/issues/issue-14303-trait.stderr deleted file mode 100644 index 75cd67a9ded8..000000000000 --- a/src/test/ui/parser/issues/issue-14303-trait.stderr +++ /dev/null @@ -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 - diff --git a/src/test/ui/parser/issues/issue-14303.rs b/src/test/ui/parser/issues/issue-14303.rs new file mode 100644 index 000000000000..82850d77aa92 --- /dev/null +++ b/src/test/ui/parser/issues/issue-14303.rs @@ -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); +impl<'a, T, 'b> Y {} +//~^ 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() {} diff --git a/src/test/ui/parser/issues/issue-14303.stderr b/src/test/ui/parser/issues/issue-14303.stderr new file mode 100644 index 000000000000..f121107c0958 --- /dev/null +++ b/src/test/ui/parser/issues/issue-14303.stderr @@ -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 {} + | --------^^- 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`. diff --git a/src/test/ui/suggestions/suggest-move-lifetimes.stderr b/src/test/ui/suggestions/suggest-move-lifetimes.stderr index f52631caed17..b1a49447d460 100644 --- a/src/test/ui/suggestions/suggest-move-lifetimes.stderr +++ b/src/test/ui/suggestions/suggest-move-lifetimes.stderr @@ -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 | LL | struct A { | ----^^- 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 | LL | struct B { | ----^^---- 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 | LL | struct C { | -------^^- 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 | LL | struct D { diff --git a/src/test/ui/suggestions/suggest-move-types.stderr b/src/test/ui/suggestions/suggest-move-types.stderr index 1a6032db0010..b222e8142bab 100644 --- a/src/test/ui/suggestions/suggest-move-types.stderr +++ b/src/test/ui/suggestions/suggest-move-types.stderr @@ -121,7 +121,7 @@ LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime` + = help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, 'c, T, U, V>` error[E0747]: lifetime provided when a type was expected --> $DIR/suggest-move-types.rs:82:56 @@ -130,7 +130,7 @@ LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime` + = help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, 'c, T, U, V>` error: aborting due to 12 previous errors