From be1ed00712ce0b884e1fc9779f25b1758e994d0b Mon Sep 17 00:00:00 2001 From: kadmin Date: Sat, 13 Feb 2021 07:53:28 +0000 Subject: [PATCH 01/11] Add additional type info to mismatch err --- compiler/rustc_typeck/src/astconv/generics.rs | 51 ++++++++++++++----- src/test/ui/const-generics/diagnostics.rs | 13 +++++ src/test/ui/const-generics/diagnostics.stderr | 27 ++++++++++ .../ui/const-generics/invalid-enum.stderr | 20 -------- 4 files changed, 79 insertions(+), 32 deletions(-) create mode 100644 src/test/ui/const-generics/diagnostics.rs create mode 100644 src/test/ui/const-generics/diagnostics.stderr diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 67e37ca8d8e49..341f6fadba174 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -24,6 +24,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { tcx: TyCtxt<'_>, arg: &GenericArg<'_>, param: &GenericParamDef, + // DefId of the function + //body_def_id: DefId, possible_ordering_error: bool, help: Option<&str>, ) { @@ -46,19 +48,44 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // Specific suggestion set for diagnostics match (arg, ¶m.kind) { ( - GenericArg::Type(hir::Ty { kind: hir::TyKind::Path { .. }, .. }), - GenericParamDefKind::Const { .. }, + GenericArg::Type(hir::Ty { + kind: hir::TyKind::Path(rustc_hir::QPath::Resolved(_, path)), + .. + }), + GenericParamDefKind::Const, ) => { - let suggestions = vec![ - (arg.span().shrink_to_lo(), String::from("{ ")), - (arg.span().shrink_to_hi(), String::from(" }")), - ]; - err.multipart_suggestion( - "if this generic argument was intended as a const parameter, \ - try surrounding it with braces:", - suggestions, - Applicability::MaybeIncorrect, - ); + use rustc_hir::def::{DefKind, Res}; + match path.res { + Res::Err => {} + Res::Def(DefKind::TyParam, src_def_id) => (|| { + let param_hir_id = match param.def_id.as_local() { + Some(x) => tcx.hir().local_def_id_to_hir_id(x), + None => return, + }; + let param_name = tcx.hir().ty_param_name(param_hir_id); + let param_type = tcx.type_of(param.def_id); + if param_type.is_suggestable() { + err.span_suggestion( + tcx.def_span(src_def_id), + &format!("try changing to a const-generic parameter:"), + format!("const {}: {}", param_name, param_type), + Applicability::MaybeIncorrect, + ); + } + })(), + _ => { + let suggestions = vec![ + (arg.span().shrink_to_lo(), String::from("{ ")), + (arg.span().shrink_to_hi(), String::from(" }")), + ]; + err.multipart_suggestion( + "if this generic argument was intended as a const parameter, \ + try surrounding it with braces:", + suggestions, + Applicability::MaybeIncorrect, + ); + } + } } ( GenericArg::Type(hir::Ty { kind: hir::TyKind::Array(_, len), .. }), diff --git a/src/test/ui/const-generics/diagnostics.rs b/src/test/ui/const-generics/diagnostics.rs new file mode 100644 index 0000000000000..c90e3d0e0eba9 --- /dev/null +++ b/src/test/ui/const-generics/diagnostics.rs @@ -0,0 +1,13 @@ +#![crate_type="lib"] +#![feature(const_generics)] +#![allow(incomplete_features)] + +struct A; +trait Foo {} +impl Foo for A {} +//~^ ERROR type provided when a constant +//~| ERROR cannot find type + +struct B; +impl Foo for B {} +//~^ ERROR type provided when a constant diff --git a/src/test/ui/const-generics/diagnostics.stderr b/src/test/ui/const-generics/diagnostics.stderr new file mode 100644 index 0000000000000..a66858a310c85 --- /dev/null +++ b/src/test/ui/const-generics/diagnostics.stderr @@ -0,0 +1,27 @@ +error[E0412]: cannot find type `N` in this scope + --> $DIR/diagnostics.rs:7:16 + | +LL | struct A; + | ---------------------- similarly named struct `A` defined here +LL | trait Foo {} +LL | impl Foo for A {} + | ^ help: a struct with a similar name exists: `A` + +error[E0747]: type provided when a constant was expected + --> $DIR/diagnostics.rs:7:16 + | +LL | impl Foo for A {} + | ^ + +error[E0747]: type provided when a constant was expected + --> $DIR/diagnostics.rs:12:19 + | +LL | impl Foo for B {} + | - ^ + | | + | help: try changing to a const-generic parameter:: `const N: u8` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0412, E0747. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/const-generics/invalid-enum.stderr b/src/test/ui/const-generics/invalid-enum.stderr index 7822fc072e35c..c062fc9ac88b3 100644 --- a/src/test/ui/const-generics/invalid-enum.stderr +++ b/src/test/ui/const-generics/invalid-enum.stderr @@ -30,44 +30,24 @@ error[E0747]: type provided when a constant was expected | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^ - | -help: if this generic argument was intended as a const parameter, try surrounding it with braces: - | -LL | let _: Example<{ CompileFlag::A }, _> = Example { x: 0 }; - | ^ ^ error[E0747]: type provided when a constant was expected --> $DIR/invalid-enum.rs:33:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^^^^^^ - | -help: if this generic argument was intended as a const parameter, try surrounding it with braces: - | -LL | let _: Example<{ Example::ASSOC_FLAG }, _> = Example { x: 0 }; - | ^ ^ error[E0747]: type provided when a constant was expected --> $DIR/invalid-enum.rs:21:12 | LL | test_1::(); | ^^^^^^^^^^^^^^ - | -help: if this generic argument was intended as a const parameter, try surrounding it with braces: - | -LL | test_1::<{ CompileFlag::A }>(); - | ^ ^ error[E0747]: type provided when a constant was expected --> $DIR/invalid-enum.rs:25:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ - | -help: if this generic argument was intended as a const parameter, try surrounding it with braces: - | -LL | test_2::<_, { CompileFlag::A }>(0); - | ^ ^ error: aborting due to 7 previous errors From 64b5b75e65f010d88175fbb98b4396ccede5c32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Mon, 15 Feb 2021 00:00:00 +0000 Subject: [PATCH 02/11] Use !Sync std::lazy::OnceCell in usefulness checking The `rustc_data_structures::sync::OnceCell` is thread-safe when building a parallel compiler. This is unnecessary for the purposes of pattern usefulness checking. Use `!Sync` `std::lazy::OnceCell` instead. --- compiler/rustc_mir_build/src/thir/pattern/usefulness.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index 010fe4fd524d4..38b7e50d78672 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -289,7 +289,6 @@ use super::{PatternFoldable, PatternFolder}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::sync::OnceCell; use rustc_arena::TypedArena; use rustc_hir::def_id::DefId; @@ -300,6 +299,7 @@ use rustc_span::Span; use smallvec::{smallvec, SmallVec}; use std::fmt; use std::iter::{FromIterator, IntoIterator}; +use std::lazy::OnceCell; crate struct MatchCheckCtxt<'a, 'tcx> { crate tcx: TyCtxt<'tcx>, From b97951b50f81862ccd997d48b20f50d05cd5157e Mon Sep 17 00:00:00 2001 From: kadmin Date: Sun, 14 Feb 2021 04:35:18 +0000 Subject: [PATCH 03/11] Update w/ comments --- compiler/rustc_typeck/src/astconv/generics.rs | 60 ++++++++++--------- .../const-param-shadowing.stderr | 2 +- src/test/ui/const-generics/diagnostics.rs | 11 +++- src/test/ui/const-generics/diagnostics.stderr | 33 +++++++++- src/test/ui/const-generics/invalid-enum.rs | 12 ++-- .../ui/const-generics/invalid-enum.stderr | 26 +++++++- 6 files changed, 101 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 341f6fadba174..b421adbf9eab1 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -6,8 +6,9 @@ use crate::astconv::{ use crate::errors::AssocTypeBindingNotAllowed; use crate::structured_errors::{StructuredDiagnostic, WrongNumberOfGenericArgs}; use rustc_ast::ast::ParamKindOrd; -use rustc_errors::{struct_span_err, Applicability, ErrorReported}; +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_hir as hir; +use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::GenericArg; use rustc_middle::ty::{ @@ -24,8 +25,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { tcx: TyCtxt<'_>, arg: &GenericArg<'_>, param: &GenericParamDef, - // DefId of the function - //body_def_id: DefId, possible_ordering_error: bool, help: Option<&str>, ) { @@ -45,6 +44,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } + let add_braces_suggestion = |arg: &GenericArg<'_>, err: &mut DiagnosticBuilder<'_>| { + let suggestions = vec![ + (arg.span().shrink_to_lo(), String::from("{ ")), + (arg.span().shrink_to_hi(), String::from(" }")), + ]; + err.multipart_suggestion( + "if this generic argument was intended as a const parameter, \ + surround it with braces", + suggestions, + Applicability::MaybeIncorrect, + ); + }; + // Specific suggestion set for diagnostics match (arg, ¶m.kind) { ( @@ -53,40 +65,34 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .. }), GenericParamDefKind::Const, - ) => { - use rustc_hir::def::{DefKind, Res}; - match path.res { - Res::Err => {} - Res::Def(DefKind::TyParam, src_def_id) => (|| { - let param_hir_id = match param.def_id.as_local() { - Some(x) => tcx.hir().local_def_id_to_hir_id(x), - None => return, - }; + ) => match path.res { + Res::Err => { + add_braces_suggestion(arg, &mut err); + err.set_primary_message( + "unresolved item provided when a constant was expected", + ); + } + Res::Def(DefKind::TyParam, src_def_id) => { + if let Some(param_local_id) = param.def_id.as_local() { + let param_hir_id = tcx.hir().local_def_id_to_hir_id(param_local_id); let param_name = tcx.hir().ty_param_name(param_hir_id); let param_type = tcx.type_of(param.def_id); if param_type.is_suggestable() { err.span_suggestion( tcx.def_span(src_def_id), - &format!("try changing to a const-generic parameter:"), + "consider changing this type paramater to a `const`-generic", format!("const {}: {}", param_name, param_type), Applicability::MaybeIncorrect, ); - } - })(), - _ => { - let suggestions = vec![ - (arg.span().shrink_to_lo(), String::from("{ ")), - (arg.span().shrink_to_hi(), String::from(" }")), - ]; - err.multipart_suggestion( - "if this generic argument was intended as a const parameter, \ - try surrounding it with braces:", - suggestions, - Applicability::MaybeIncorrect, - ); + }; } } - } + _ => add_braces_suggestion(arg, &mut err), + }, + ( + GenericArg::Type(hir::Ty { kind: hir::TyKind::Path(_), .. }), + GenericParamDefKind::Const, + ) => add_braces_suggestion(arg, &mut err), ( GenericArg::Type(hir::Ty { kind: hir::TyKind::Array(_, len), .. }), GenericParamDefKind::Const { .. }, diff --git a/src/test/ui/const-generics/const-param-shadowing.stderr b/src/test/ui/const-generics/const-param-shadowing.stderr index 7447ca3ff3631..17ccd2f3527b0 100644 --- a/src/test/ui/const-generics/const-param-shadowing.stderr +++ b/src/test/ui/const-generics/const-param-shadowing.stderr @@ -4,7 +4,7 @@ error[E0747]: type provided when a constant was expected LL | fn test() -> Foo { | ^ | -help: if this generic argument was intended as a const parameter, try surrounding it with braces: +help: if this generic argument was intended as a const parameter, surround it with braces | LL | fn test() -> Foo<{ N }> { | ^ ^ diff --git a/src/test/ui/const-generics/diagnostics.rs b/src/test/ui/const-generics/diagnostics.rs index c90e3d0e0eba9..1581af5ab2751 100644 --- a/src/test/ui/const-generics/diagnostics.rs +++ b/src/test/ui/const-generics/diagnostics.rs @@ -1,13 +1,18 @@ #![crate_type="lib"] -#![feature(const_generics)] +#![feature(min_const_generics)] #![allow(incomplete_features)] struct A; trait Foo {} impl Foo for A {} -//~^ ERROR type provided when a constant -//~| ERROR cannot find type +//~^ ERROR cannot find type +//~| unresolved item provided when a constant struct B; impl Foo for B {} //~^ ERROR type provided when a constant + +struct C; +impl Foo for C {} +//~^ ERROR cannot find type +//~| unresolved item provided when a constant diff --git a/src/test/ui/const-generics/diagnostics.stderr b/src/test/ui/const-generics/diagnostics.stderr index a66858a310c85..33f5337eb8072 100644 --- a/src/test/ui/const-generics/diagnostics.stderr +++ b/src/test/ui/const-generics/diagnostics.stderr @@ -7,11 +7,25 @@ LL | trait Foo {} LL | impl Foo for A {} | ^ help: a struct with a similar name exists: `A` -error[E0747]: type provided when a constant was expected +error[E0412]: cannot find type `T` in this scope + --> $DIR/diagnostics.rs:16:32 + | +LL | struct A; + | ---------------------- similarly named struct `A` defined here +... +LL | impl Foo for C {} + | ^ help: a struct with a similar name exists: `A` + +error[E0747]: unresolved item provided when a constant was expected --> $DIR/diagnostics.rs:7:16 | LL | impl Foo for A {} | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | impl Foo for A<{ N }> {} + | ^ ^ error[E0747]: type provided when a constant was expected --> $DIR/diagnostics.rs:12:19 @@ -19,9 +33,22 @@ error[E0747]: type provided when a constant was expected LL | impl Foo for B {} | - ^ | | - | help: try changing to a const-generic parameter:: `const N: u8` + | help: consider changing this type paramater to a `const`-generic: `const N: u8` + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/diagnostics.rs:16:32 + | +LL | impl Foo for C {} + | ^ + | + = note: type arguments must be provided before constant arguments + = help: reorder the arguments: consts: `` +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | impl Foo for C {} + | ^ ^ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0412, E0747. For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/const-generics/invalid-enum.rs b/src/test/ui/const-generics/invalid-enum.rs index 4ca10ed8b71a2..32939dcd2861b 100644 --- a/src/test/ui/const-generics/invalid-enum.rs +++ b/src/test/ui/const-generics/invalid-enum.rs @@ -3,14 +3,14 @@ #[derive(PartialEq, Eq)] enum CompileFlag { - A, - B, + A, + B, } pub fn test_1() {} pub fn test_2(x: T) {} pub struct Example{ - x: T, + x: T, } impl Example { @@ -20,15 +20,15 @@ impl Example { pub fn main() { test_1::(); //~^ ERROR: expected type, found variant - //~| ERROR: type provided when a constant was expected + //~| ERROR: unresolved item provided when a constant was expected test_2::<_, CompileFlag::A>(0); //~^ ERROR: expected type, found variant - //~| ERROR: type provided when a constant was expected + //~| ERROR: unresolved item provided when a constant was expected let _: Example = Example { x: 0 }; //~^ ERROR: expected type, found variant - //~| ERROR: type provided when a constant was expected + //~| ERROR: unresolved item provided when a constant was expected let _: Example = Example { x: 0 }; //~^ ERROR: type provided when a constant was expected diff --git a/src/test/ui/const-generics/invalid-enum.stderr b/src/test/ui/const-generics/invalid-enum.stderr index c062fc9ac88b3..cfbc61f02543b 100644 --- a/src/test/ui/const-generics/invalid-enum.stderr +++ b/src/test/ui/const-generics/invalid-enum.stderr @@ -25,29 +25,49 @@ LL | let _: Example = Example { x: 0 }; | not a type | help: try using the variant's enum: `CompileFlag` -error[E0747]: type provided when a constant was expected +error[E0747]: unresolved item provided when a constant was expected --> $DIR/invalid-enum.rs:29:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _: Example<{ CompileFlag::A }, _> = Example { x: 0 }; + | ^ ^ error[E0747]: type provided when a constant was expected --> $DIR/invalid-enum.rs:33:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^^^^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _: Example<{ Example::ASSOC_FLAG }, _> = Example { x: 0 }; + | ^ ^ -error[E0747]: type provided when a constant was expected +error[E0747]: unresolved item provided when a constant was expected --> $DIR/invalid-enum.rs:21:12 | LL | test_1::(); | ^^^^^^^^^^^^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | test_1::<{ CompileFlag::A }>(); + | ^ ^ -error[E0747]: type provided when a constant was expected +error[E0747]: unresolved item provided when a constant was expected --> $DIR/invalid-enum.rs:25:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | test_2::<_, { CompileFlag::A }>(0); + | ^ ^ error: aborting due to 7 previous errors From f52029553fa97153eb7f3fc724523cc1a61dfaba Mon Sep 17 00:00:00 2001 From: kadmin Date: Tue, 16 Feb 2021 19:03:22 +0000 Subject: [PATCH 04/11] Remove ordering hint --- compiler/rustc_typeck/src/astconv/generics.rs | 4 +++- src/test/ui/const-generics/diagnostics.stderr | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index b421adbf9eab1..0ea0ccaceabd4 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -70,7 +70,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { add_braces_suggestion(arg, &mut err); err.set_primary_message( "unresolved item provided when a constant was expected", - ); + ) + .emit(); + return; } Res::Def(DefKind::TyParam, src_def_id) => { if let Some(param_local_id) = param.def_id.as_local() { diff --git a/src/test/ui/const-generics/diagnostics.stderr b/src/test/ui/const-generics/diagnostics.stderr index 33f5337eb8072..7d038ff955d6c 100644 --- a/src/test/ui/const-generics/diagnostics.stderr +++ b/src/test/ui/const-generics/diagnostics.stderr @@ -41,8 +41,6 @@ error[E0747]: unresolved item provided when a constant was expected LL | impl Foo for C {} | ^ | - = note: type arguments must be provided before constant arguments - = help: reorder the arguments: consts: `` help: if this generic argument was intended as a const parameter, surround it with braces | LL | impl Foo for C {} From e7e93717ce8e6f5cec217ebfcda2d8c8b76f6b49 Mon Sep 17 00:00:00 2001 From: Caio Date: Tue, 16 Feb 2021 21:22:21 -0300 Subject: [PATCH 05/11] Move some tests to more reasonable directories --- .../ui/{issues => associated-types}/issue-21726.rs | 0 .../ui/{issues => associated-types}/issue-22560.rs | 0 .../issue-22560.stderr | 0 .../{issues => associated-types}/issue-23595-2.rs | 0 .../issue-23595-2.stderr | 0 .../ui/{issues => associated-types}/issue-24204.rs | 0 .../issue-43784-associated-type.rs | 0 .../issue-43784-associated-type.stderr | 0 .../project-defer-unification.rs | 0 .../ui/{issues => async-await}/issue-77993-2.rs | 0 .../{issues => async-await}/issue-77993-2.stderr | 0 .../repeat_count_const_in_async_fn.rs | 0 src/test/ui/{issues => consts}/issue-13837.rs | 0 .../{issues => consts}/issue-17718-references.rs | 0 .../issue-17718-references.stderr | 0 src/test/ui/{issues => consts}/issue-32829.rs | 0 src/test/ui/{issues => consts}/issue-32829.stderr | 0 src/test/ui/{issues => consts}/issue-33537.rs | 0 .../ui/{ => consts}/rvalue-static-promotion.rs | 0 .../{ => consts}/write-to-static-mut-in-static.rs | 0 .../write-to-static-mut-in-static.stderr | 0 src/test/ui/emit-artifact-notifications.nll.stderr | 1 - .../ui/emit-artifact-notifications.polonius.stderr | 1 - src/test/ui/emit-artifact-notifications.stderr | 1 - .../if/expr-if-panic-pass.rs} | 0 src/test/ui/{issues => expr/if}/issue-4201.rs | 0 src/test/ui/{issues => expr/if}/issue-4201.stderr | 0 .../cleanup-rvalue-during-if-and-while.rs | 0 src/test/ui/{issues => hygiene}/issue-40847.rs | 0 src/test/ui/{issues => }/issue-6157.rs | 0 .../{issues => lint}/issue-31924-non-snake-ffi.rs | 0 src/test/ui/{ => macros}/html-literals.rs | 0 src/test/ui/{ => parser}/dotdotdot-expr.rs | 0 src/test/ui/{ => parser}/dotdotdot-expr.stderr | 0 src/test/ui/{issues => parser}/issue-20616-3.rs | 0 .../ui/{issues => parser}/issue-20616-3.stderr | 0 src/test/ui/{issues => parser}/issue-44406.rs | 0 src/test/ui/{issues => parser}/issue-44406.stderr | 0 .../old-suffixes-are-really-forbidden.rs | 0 .../old-suffixes-are-really-forbidden.stderr | 0 .../{ => parser}/struct-literal-variant-in-if.rs | 0 .../struct-literal-variant-in-if.stderr | 0 src/test/ui/range_inclusive_gate.rs | 14 -------------- ...ions-fn-subtyping-return-static-fail.nll.stderr | 0 .../regions-fn-subtyping-return-static-fail.rs | 0 .../regions-fn-subtyping-return-static-fail.stderr | 0 .../rmeta/emit-artifact-notifications.nll.stderr | 1 + .../emit-artifact-notifications.polonius.stderr | 1 + .../ui/{ => rmeta}/emit-artifact-notifications.rs | 0 .../ui/rmeta/emit-artifact-notifications.stderr | 1 + src/test/ui/{ => rmeta}/emit-metadata-obj.rs | 0 src/test/ui/{ => structs-enums}/type-sizes.rs | 0 src/test/ui/{ => tuple}/one-tuple.rs | 0 .../{ => unboxed-closures}/type-id-higher-rank.rs | 0 src/tools/tidy/src/ui_tests.rs | 4 ++-- 55 files changed, 5 insertions(+), 19 deletions(-) rename src/test/ui/{issues => associated-types}/issue-21726.rs (100%) rename src/test/ui/{issues => associated-types}/issue-22560.rs (100%) rename src/test/ui/{issues => associated-types}/issue-22560.stderr (100%) rename src/test/ui/{issues => associated-types}/issue-23595-2.rs (100%) rename src/test/ui/{issues => associated-types}/issue-23595-2.stderr (100%) rename src/test/ui/{issues => associated-types}/issue-24204.rs (100%) rename src/test/ui/{issues => associated-types}/issue-43784-associated-type.rs (100%) rename src/test/ui/{issues => associated-types}/issue-43784-associated-type.stderr (100%) rename src/test/ui/{ => associated-types}/project-defer-unification.rs (100%) rename src/test/ui/{issues => async-await}/issue-77993-2.rs (100%) rename src/test/ui/{issues => async-await}/issue-77993-2.stderr (100%) rename src/test/ui/{ => async-await}/repeat_count_const_in_async_fn.rs (100%) rename src/test/ui/{issues => consts}/issue-13837.rs (100%) rename src/test/ui/{issues => consts}/issue-17718-references.rs (100%) rename src/test/ui/{issues => consts}/issue-17718-references.stderr (100%) rename src/test/ui/{issues => consts}/issue-32829.rs (100%) rename src/test/ui/{issues => consts}/issue-32829.stderr (100%) rename src/test/ui/{issues => consts}/issue-33537.rs (100%) rename src/test/ui/{ => consts}/rvalue-static-promotion.rs (100%) rename src/test/ui/{ => consts}/write-to-static-mut-in-static.rs (100%) rename src/test/ui/{ => consts}/write-to-static-mut-in-static.stderr (100%) delete mode 100644 src/test/ui/emit-artifact-notifications.nll.stderr delete mode 100644 src/test/ui/emit-artifact-notifications.polonius.stderr delete mode 100644 src/test/ui/emit-artifact-notifications.stderr rename src/test/ui/{expr-if-panic.rs => expr/if/expr-if-panic-pass.rs} (100%) rename src/test/ui/{issues => expr/if}/issue-4201.rs (100%) rename src/test/ui/{issues => expr/if}/issue-4201.stderr (100%) rename src/test/ui/{ => for-loop-while}/cleanup-rvalue-during-if-and-while.rs (100%) rename src/test/ui/{issues => hygiene}/issue-40847.rs (100%) rename src/test/ui/{issues => }/issue-6157.rs (100%) rename src/test/ui/{issues => lint}/issue-31924-non-snake-ffi.rs (100%) rename src/test/ui/{ => macros}/html-literals.rs (100%) rename src/test/ui/{ => parser}/dotdotdot-expr.rs (100%) rename src/test/ui/{ => parser}/dotdotdot-expr.stderr (100%) rename src/test/ui/{issues => parser}/issue-20616-3.rs (100%) rename src/test/ui/{issues => parser}/issue-20616-3.stderr (100%) rename src/test/ui/{issues => parser}/issue-44406.rs (100%) rename src/test/ui/{issues => parser}/issue-44406.stderr (100%) rename src/test/ui/{ => parser}/old-suffixes-are-really-forbidden.rs (100%) rename src/test/ui/{ => parser}/old-suffixes-are-really-forbidden.stderr (100%) rename src/test/ui/{ => parser}/struct-literal-variant-in-if.rs (100%) rename src/test/ui/{ => parser}/struct-literal-variant-in-if.stderr (100%) delete mode 100644 src/test/ui/range_inclusive_gate.rs rename src/test/ui/{ => regions}/regions-fn-subtyping-return-static-fail.nll.stderr (100%) rename src/test/ui/{ => regions}/regions-fn-subtyping-return-static-fail.rs (100%) rename src/test/ui/{ => regions}/regions-fn-subtyping-return-static-fail.stderr (100%) create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.nll.stderr create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr rename src/test/ui/{ => rmeta}/emit-artifact-notifications.rs (100%) create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.stderr rename src/test/ui/{ => rmeta}/emit-metadata-obj.rs (100%) rename src/test/ui/{ => structs-enums}/type-sizes.rs (100%) rename src/test/ui/{ => tuple}/one-tuple.rs (100%) rename src/test/ui/{ => unboxed-closures}/type-id-higher-rank.rs (100%) diff --git a/src/test/ui/issues/issue-21726.rs b/src/test/ui/associated-types/issue-21726.rs similarity index 100% rename from src/test/ui/issues/issue-21726.rs rename to src/test/ui/associated-types/issue-21726.rs diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/associated-types/issue-22560.rs similarity index 100% rename from src/test/ui/issues/issue-22560.rs rename to src/test/ui/associated-types/issue-22560.rs diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/associated-types/issue-22560.stderr similarity index 100% rename from src/test/ui/issues/issue-22560.stderr rename to src/test/ui/associated-types/issue-22560.stderr diff --git a/src/test/ui/issues/issue-23595-2.rs b/src/test/ui/associated-types/issue-23595-2.rs similarity index 100% rename from src/test/ui/issues/issue-23595-2.rs rename to src/test/ui/associated-types/issue-23595-2.rs diff --git a/src/test/ui/issues/issue-23595-2.stderr b/src/test/ui/associated-types/issue-23595-2.stderr similarity index 100% rename from src/test/ui/issues/issue-23595-2.stderr rename to src/test/ui/associated-types/issue-23595-2.stderr diff --git a/src/test/ui/issues/issue-24204.rs b/src/test/ui/associated-types/issue-24204.rs similarity index 100% rename from src/test/ui/issues/issue-24204.rs rename to src/test/ui/associated-types/issue-24204.rs diff --git a/src/test/ui/issues/issue-43784-associated-type.rs b/src/test/ui/associated-types/issue-43784-associated-type.rs similarity index 100% rename from src/test/ui/issues/issue-43784-associated-type.rs rename to src/test/ui/associated-types/issue-43784-associated-type.rs diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/associated-types/issue-43784-associated-type.stderr similarity index 100% rename from src/test/ui/issues/issue-43784-associated-type.stderr rename to src/test/ui/associated-types/issue-43784-associated-type.stderr diff --git a/src/test/ui/project-defer-unification.rs b/src/test/ui/associated-types/project-defer-unification.rs similarity index 100% rename from src/test/ui/project-defer-unification.rs rename to src/test/ui/associated-types/project-defer-unification.rs diff --git a/src/test/ui/issues/issue-77993-2.rs b/src/test/ui/async-await/issue-77993-2.rs similarity index 100% rename from src/test/ui/issues/issue-77993-2.rs rename to src/test/ui/async-await/issue-77993-2.rs diff --git a/src/test/ui/issues/issue-77993-2.stderr b/src/test/ui/async-await/issue-77993-2.stderr similarity index 100% rename from src/test/ui/issues/issue-77993-2.stderr rename to src/test/ui/async-await/issue-77993-2.stderr diff --git a/src/test/ui/repeat_count_const_in_async_fn.rs b/src/test/ui/async-await/repeat_count_const_in_async_fn.rs similarity index 100% rename from src/test/ui/repeat_count_const_in_async_fn.rs rename to src/test/ui/async-await/repeat_count_const_in_async_fn.rs diff --git a/src/test/ui/issues/issue-13837.rs b/src/test/ui/consts/issue-13837.rs similarity index 100% rename from src/test/ui/issues/issue-13837.rs rename to src/test/ui/consts/issue-13837.rs diff --git a/src/test/ui/issues/issue-17718-references.rs b/src/test/ui/consts/issue-17718-references.rs similarity index 100% rename from src/test/ui/issues/issue-17718-references.rs rename to src/test/ui/consts/issue-17718-references.rs diff --git a/src/test/ui/issues/issue-17718-references.stderr b/src/test/ui/consts/issue-17718-references.stderr similarity index 100% rename from src/test/ui/issues/issue-17718-references.stderr rename to src/test/ui/consts/issue-17718-references.stderr diff --git a/src/test/ui/issues/issue-32829.rs b/src/test/ui/consts/issue-32829.rs similarity index 100% rename from src/test/ui/issues/issue-32829.rs rename to src/test/ui/consts/issue-32829.rs diff --git a/src/test/ui/issues/issue-32829.stderr b/src/test/ui/consts/issue-32829.stderr similarity index 100% rename from src/test/ui/issues/issue-32829.stderr rename to src/test/ui/consts/issue-32829.stderr diff --git a/src/test/ui/issues/issue-33537.rs b/src/test/ui/consts/issue-33537.rs similarity index 100% rename from src/test/ui/issues/issue-33537.rs rename to src/test/ui/consts/issue-33537.rs diff --git a/src/test/ui/rvalue-static-promotion.rs b/src/test/ui/consts/rvalue-static-promotion.rs similarity index 100% rename from src/test/ui/rvalue-static-promotion.rs rename to src/test/ui/consts/rvalue-static-promotion.rs diff --git a/src/test/ui/write-to-static-mut-in-static.rs b/src/test/ui/consts/write-to-static-mut-in-static.rs similarity index 100% rename from src/test/ui/write-to-static-mut-in-static.rs rename to src/test/ui/consts/write-to-static-mut-in-static.rs diff --git a/src/test/ui/write-to-static-mut-in-static.stderr b/src/test/ui/consts/write-to-static-mut-in-static.stderr similarity index 100% rename from src/test/ui/write-to-static-mut-in-static.stderr rename to src/test/ui/consts/write-to-static-mut-in-static.stderr diff --git a/src/test/ui/emit-artifact-notifications.nll.stderr b/src/test/ui/emit-artifact-notifications.nll.stderr deleted file mode 100644 index 5547631a4b022..0000000000000 --- a/src/test/ui/emit-artifact-notifications.nll.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-artifact-notifications.polonius.stderr b/src/test/ui/emit-artifact-notifications.polonius.stderr deleted file mode 100644 index 47b48b399c25c..0000000000000 --- a/src/test/ui/emit-artifact-notifications.polonius.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.polonius/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-artifact-notifications.stderr b/src/test/ui/emit-artifact-notifications.stderr deleted file mode 100644 index 260d41b8f15cc..0000000000000 --- a/src/test/ui/emit-artifact-notifications.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/expr-if-panic.rs b/src/test/ui/expr/if/expr-if-panic-pass.rs similarity index 100% rename from src/test/ui/expr-if-panic.rs rename to src/test/ui/expr/if/expr-if-panic-pass.rs diff --git a/src/test/ui/issues/issue-4201.rs b/src/test/ui/expr/if/issue-4201.rs similarity index 100% rename from src/test/ui/issues/issue-4201.rs rename to src/test/ui/expr/if/issue-4201.rs diff --git a/src/test/ui/issues/issue-4201.stderr b/src/test/ui/expr/if/issue-4201.stderr similarity index 100% rename from src/test/ui/issues/issue-4201.stderr rename to src/test/ui/expr/if/issue-4201.stderr diff --git a/src/test/ui/cleanup-rvalue-during-if-and-while.rs b/src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs similarity index 100% rename from src/test/ui/cleanup-rvalue-during-if-and-while.rs rename to src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs diff --git a/src/test/ui/issues/issue-40847.rs b/src/test/ui/hygiene/issue-40847.rs similarity index 100% rename from src/test/ui/issues/issue-40847.rs rename to src/test/ui/hygiene/issue-40847.rs diff --git a/src/test/ui/issues/issue-6157.rs b/src/test/ui/issue-6157.rs similarity index 100% rename from src/test/ui/issues/issue-6157.rs rename to src/test/ui/issue-6157.rs diff --git a/src/test/ui/issues/issue-31924-non-snake-ffi.rs b/src/test/ui/lint/issue-31924-non-snake-ffi.rs similarity index 100% rename from src/test/ui/issues/issue-31924-non-snake-ffi.rs rename to src/test/ui/lint/issue-31924-non-snake-ffi.rs diff --git a/src/test/ui/html-literals.rs b/src/test/ui/macros/html-literals.rs similarity index 100% rename from src/test/ui/html-literals.rs rename to src/test/ui/macros/html-literals.rs diff --git a/src/test/ui/dotdotdot-expr.rs b/src/test/ui/parser/dotdotdot-expr.rs similarity index 100% rename from src/test/ui/dotdotdot-expr.rs rename to src/test/ui/parser/dotdotdot-expr.rs diff --git a/src/test/ui/dotdotdot-expr.stderr b/src/test/ui/parser/dotdotdot-expr.stderr similarity index 100% rename from src/test/ui/dotdotdot-expr.stderr rename to src/test/ui/parser/dotdotdot-expr.stderr diff --git a/src/test/ui/issues/issue-20616-3.rs b/src/test/ui/parser/issue-20616-3.rs similarity index 100% rename from src/test/ui/issues/issue-20616-3.rs rename to src/test/ui/parser/issue-20616-3.rs diff --git a/src/test/ui/issues/issue-20616-3.stderr b/src/test/ui/parser/issue-20616-3.stderr similarity index 100% rename from src/test/ui/issues/issue-20616-3.stderr rename to src/test/ui/parser/issue-20616-3.stderr diff --git a/src/test/ui/issues/issue-44406.rs b/src/test/ui/parser/issue-44406.rs similarity index 100% rename from src/test/ui/issues/issue-44406.rs rename to src/test/ui/parser/issue-44406.rs diff --git a/src/test/ui/issues/issue-44406.stderr b/src/test/ui/parser/issue-44406.stderr similarity index 100% rename from src/test/ui/issues/issue-44406.stderr rename to src/test/ui/parser/issue-44406.stderr diff --git a/src/test/ui/old-suffixes-are-really-forbidden.rs b/src/test/ui/parser/old-suffixes-are-really-forbidden.rs similarity index 100% rename from src/test/ui/old-suffixes-are-really-forbidden.rs rename to src/test/ui/parser/old-suffixes-are-really-forbidden.rs diff --git a/src/test/ui/old-suffixes-are-really-forbidden.stderr b/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr similarity index 100% rename from src/test/ui/old-suffixes-are-really-forbidden.stderr rename to src/test/ui/parser/old-suffixes-are-really-forbidden.stderr diff --git a/src/test/ui/struct-literal-variant-in-if.rs b/src/test/ui/parser/struct-literal-variant-in-if.rs similarity index 100% rename from src/test/ui/struct-literal-variant-in-if.rs rename to src/test/ui/parser/struct-literal-variant-in-if.rs diff --git a/src/test/ui/struct-literal-variant-in-if.stderr b/src/test/ui/parser/struct-literal-variant-in-if.stderr similarity index 100% rename from src/test/ui/struct-literal-variant-in-if.stderr rename to src/test/ui/parser/struct-literal-variant-in-if.stderr diff --git a/src/test/ui/range_inclusive_gate.rs b/src/test/ui/range_inclusive_gate.rs deleted file mode 100644 index e26e31b44a079..0000000000000 --- a/src/test/ui/range_inclusive_gate.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![allow(unused_comparisons)] -// Test that you only need the syntax gate if you don't mention the structs. -// (Obsoleted since both features are stabilized) - -fn main() { - let mut count = 0; - for i in 0_usize..=10 { - assert!(i >= 0 && i <= 10); - count += i; - } - assert_eq!(count, 55); -} diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr similarity index 100% rename from src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr rename to src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.rs b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs similarity index 100% rename from src/test/ui/regions-fn-subtyping-return-static-fail.rs rename to src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr similarity index 100% rename from src/test/ui/regions-fn-subtyping-return-static-fail.stderr rename to src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr diff --git a/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr b/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr new file mode 100644 index 0000000000000..ed62f30028491 --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr b/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr new file mode 100644 index 0000000000000..255c7b370f9fd --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.polonius/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-artifact-notifications.rs b/src/test/ui/rmeta/emit-artifact-notifications.rs similarity index 100% rename from src/test/ui/emit-artifact-notifications.rs rename to src/test/ui/rmeta/emit-artifact-notifications.rs diff --git a/src/test/ui/rmeta/emit-artifact-notifications.stderr b/src/test/ui/rmeta/emit-artifact-notifications.stderr new file mode 100644 index 0000000000000..b2f0aa7575c06 --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-metadata-obj.rs b/src/test/ui/rmeta/emit-metadata-obj.rs similarity index 100% rename from src/test/ui/emit-metadata-obj.rs rename to src/test/ui/rmeta/emit-metadata-obj.rs diff --git a/src/test/ui/type-sizes.rs b/src/test/ui/structs-enums/type-sizes.rs similarity index 100% rename from src/test/ui/type-sizes.rs rename to src/test/ui/structs-enums/type-sizes.rs diff --git a/src/test/ui/one-tuple.rs b/src/test/ui/tuple/one-tuple.rs similarity index 100% rename from src/test/ui/one-tuple.rs rename to src/test/ui/tuple/one-tuple.rs diff --git a/src/test/ui/type-id-higher-rank.rs b/src/test/ui/unboxed-closures/type-id-higher-rank.rs similarity index 100% rename from src/test/ui/type-id-higher-rank.rs rename to src/test/ui/unboxed-closures/type-id-higher-rank.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 74ed236675208..659d5ae03c9d8 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,8 +7,8 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 1459; -const ISSUES_ENTRY_LIMIT: usize = 2615; +const ROOT_ENTRY_LIMIT: usize = 1418; +const ISSUES_ENTRY_LIMIT: usize = 2582; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) From f049e2735458ddc84adb03a982edb0b99a66fc37 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 16 Feb 2021 16:18:53 -0800 Subject: [PATCH 06/11] add specs for riscv32/riscv64 musl targets Signed-off-by: Khem Raj --- compiler/rustc_target/src/spec/mod.rs | 2 ++ .../src/spec/riscv32gc_unknown_linux_musl.rs | 19 +++++++++++++++++++ .../src/spec/riscv64gc_unknown_linux_musl.rs | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index c5dbd3ed08961..5b14795f5457c 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -783,9 +783,11 @@ supported_targets! { ("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf), ("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf), ("riscv32gc-unknown-linux-gnu", riscv32gc_unknown_linux_gnu), + ("riscv32gc-unknown-linux-musl", riscv32gc_unknown_linux_musl), ("riscv64imac-unknown-none-elf", riscv64imac_unknown_none_elf), ("riscv64gc-unknown-none-elf", riscv64gc_unknown_none_elf), ("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu), + ("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl), ("aarch64-unknown-none", aarch64_unknown_none), ("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat), diff --git a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs new file mode 100644 index 0000000000000..e5fbd09297f65 --- /dev/null +++ b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs @@ -0,0 +1,19 @@ +use crate::spec::{CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv32-unknown-linux-musl".to_string(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), + arch: "riscv32".to_string(), + options: TargetOptions { + unsupported_abis: super::riscv_base::unsupported_abis(), + code_model: Some(CodeModel::Medium), + cpu: "generic-rv32".to_string(), + features: "+m,+a,+f,+d,+c".to_string(), + llvm_abiname: "ilp32d".to_string(), + max_atomic_width: Some(32), + ..super::linux_musl_base::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs new file mode 100644 index 0000000000000..0232b15e8c269 --- /dev/null +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs @@ -0,0 +1,19 @@ +use crate::spec::{CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-linux-musl".to_string(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), + arch: "riscv64".to_string(), + options: TargetOptions { + unsupported_abis: super::riscv_base::unsupported_abis(), + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".to_string(), + features: "+m,+a,+f,+d,+c".to_string(), + llvm_abiname: "lp64d".to_string(), + max_atomic_width: Some(64), + ..super::linux_musl_base::opts() + }, + } +} From 8b38a5020f3fa09b106514841b1d7258faa7d01c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 16 Feb 2021 16:44:39 -0800 Subject: [PATCH 07/11] Add riscv32 and riscv64 musl to supported platform targets Signed-off-by: Khem Raj --- src/doc/rustc/src/platform-support.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index eb74041964701..8198dbaa5278c 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -204,7 +204,9 @@ target | std | host | notes `powerpc64-unknown-linux-musl` | ? | | `powerpc64-wrs-vxworks` | ? | | `powerpc64le-unknown-linux-musl` | ? | | +`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0) `riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33) +`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl + RISCV32 support patches) `sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux `sparc64-unknown-netbsd` | ✓ | ✓ | NetBSD/sparc64 `sparc64-unknown-openbsd` | ? | | From e13f25cd6635adf4788953cf9a42144e1fe64742 Mon Sep 17 00:00:00 2001 From: Henry Boisdequin <65845077+henryboisdequin@users.noreply.github.com> Date: Wed, 17 Feb 2021 12:26:02 +0530 Subject: [PATCH 08/11] make suggest setup help messages better --- src/bootstrap/bin/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs index 07e582d4d2941..e730a2557e0bf 100644 --- a/src/bootstrap/bin/main.rs +++ b/src/bootstrap/bin/main.rs @@ -15,14 +15,17 @@ fn main() { // check_version warnings are not printed during setup let changelog_suggestion = - if matches!(config.cmd, Subcommand::Setup {..}) { None } else { check_version(&config) }; + if matches!(config.cmd, Subcommand::Setup { .. }) { None } else { check_version(&config) }; // NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the // changelog warning, not the `x.py setup` message. let suggest_setup = !config.config.exists() && !matches!(config.cmd, Subcommand::Setup { .. }); if suggest_setup { println!("warning: you have not made a `config.toml`"); - println!("help: consider running `x.py setup` or copying `config.toml.example`"); + println!( + "help: consider running `./x.py setup` or copying `config.toml.example` by running \ + `cp config.toml.example config.toml`" + ); } else if let Some(suggestion) = &changelog_suggestion { println!("{}", suggestion); } @@ -31,7 +34,10 @@ fn main() { if suggest_setup { println!("warning: you have not made a `config.toml`"); - println!("help: consider running `x.py setup` or copying `config.toml.example`"); + println!( + "help: consider running `./x.py setup` or copying `config.toml.example` by running \ + `cp config.toml.example config.toml`" + ); } else if let Some(suggestion) = &changelog_suggestion { println!("{}", suggestion); } From 6460205031f571e863fa903b1745a00b62a3545a Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 17 Feb 2021 09:30:08 +0100 Subject: [PATCH 09/11] Remove redundant rustc_data_structures path component --- compiler/rustc_mir/src/util/generic_graphviz.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir/src/util/generic_graphviz.rs b/compiler/rustc_mir/src/util/generic_graphviz.rs index fd55a4dfc4c92..fd41e28226632 100644 --- a/compiler/rustc_mir/src/util/generic_graphviz.rs +++ b/compiler/rustc_mir/src/util/generic_graphviz.rs @@ -6,8 +6,8 @@ use std::io::{self, Write}; pub struct GraphvizWriter< 'a, G: graph::DirectedGraph + graph::WithSuccessors + graph::WithStartNode + graph::WithNumNodes, - NodeContentFn: Fn(::Node) -> Vec, - EdgeLabelsFn: Fn(::Node) -> Vec, + NodeContentFn: Fn(::Node) -> Vec, + EdgeLabelsFn: Fn(::Node) -> Vec, > { graph: &'a G, is_subgraph: bool, @@ -20,8 +20,8 @@ pub struct GraphvizWriter< impl< 'a, G: graph::DirectedGraph + graph::WithSuccessors + graph::WithStartNode + graph::WithNumNodes, - NodeContentFn: Fn(::Node) -> Vec, - EdgeLabelsFn: Fn(::Node) -> Vec, + NodeContentFn: Fn(::Node) -> Vec, + EdgeLabelsFn: Fn(::Node) -> Vec, > GraphvizWriter<'a, G, NodeContentFn, EdgeLabelsFn> { pub fn new( From f7b834831f3475df2ee6b9d1637eb981db599eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Feb 2021 23:23:57 +0100 Subject: [PATCH 10/11] remove useless ?s (clippy::needless_question_marks) Example code: ``` fn opts() -> Option { let s: Option = Some(String::new()); Some(s?) // this can just be "s" } ``` --- .../rustc_infer/src/infer/canonical/query_response.rs | 7 +------ compiler/rustc_middle/src/ty/codec.rs | 8 +++----- compiler/rustc_middle/src/ty/print/pretty.rs | 4 ++-- compiler/rustc_middle/src/ty/relate.rs | 4 ++-- compiler/rustc_mir/src/interpret/traits.rs | 2 +- .../src/traits/query/type_op/custom.rs | 2 +- compiler/rustc_typeck/src/check/method/suggest.rs | 2 +- 7 files changed, 11 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 074c9252481aa..2ec9b9e0be4a8 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -507,12 +507,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { // Unify the original value for each variable with the value // taken from `query_response` (after applying `result_subst`). - Ok(self.unify_canonical_vars( - cause, - param_env, - original_values, - substituted_query_response, - )?) + self.unify_canonical_vars(cause, param_env, original_values, substituted_query_response) } /// Converts the region constraints resulting from a query into an diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 0dad5df48551e..73ad87a9ef219 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -253,7 +253,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable for SubstsRef<'tcx> { fn decode(decoder: &mut D) -> Result { let len = decoder.read_usize()?; let tcx = decoder.tcx(); - Ok(tcx.mk_substs((0..len).map(|_| Decodable::decode(decoder)))?) + tcx.mk_substs((0..len).map(|_| Decodable::decode(decoder))) } } @@ -314,7 +314,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::AdtDef { impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List> { fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> { let len = decoder.read_usize()?; - Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?) + decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder))) } } @@ -323,9 +323,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> { fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> { let len = decoder.read_usize()?; - Ok(decoder - .tcx() - .mk_poly_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))?) + decoder.tcx().mk_poly_existential_predicates((0..len).map(|_| Decodable::decode(decoder))) } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 286041a7c548b..64604b6459f27 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -607,7 +607,7 @@ pub trait PrettyPrinter<'tcx>: return Ok(self); } - return Ok(with_no_queries(|| { + return with_no_queries(|| { let def_key = self.tcx().def_key(def_id); if let Some(name) = def_key.disambiguated_data.data.get_opt_name() { p!(write("{}", name)); @@ -649,7 +649,7 @@ pub trait PrettyPrinter<'tcx>: p!(" Sized"); } Ok(self) - })?); + }); } ty::Str => p!("str"), ty::Generator(did, substs, movability) => { diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 293b3c6b0470a..315e5d63d2bb3 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -154,7 +154,7 @@ pub fn relate_substs>( relation.relate_with_variance(variance, a, b) }); - Ok(tcx.mk_substs(params)?) + tcx.mk_substs(params) } impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> { @@ -647,7 +647,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))), } }); - Ok(tcx.mk_poly_existential_predicates(v)?) + tcx.mk_poly_existential_predicates(v) } } diff --git a/compiler/rustc_mir/src/interpret/traits.rs b/compiler/rustc_mir/src/interpret/traits.rs index 09ce6bc0fb754..50603bdd45b40 100644 --- a/compiler/rustc_mir/src/interpret/traits.rs +++ b/compiler/rustc_mir/src/interpret/traits.rs @@ -118,7 +118,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .get_raw(vtable_slot.alloc_id)? .read_ptr_sized(self, vtable_slot)? .check_init()?; - Ok(self.memory.get_fn(fn_ptr)?) + self.memory.get_fn(fn_ptr) } /// Returns the drop fn instance as well as the actual dynamic type. diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index 1688539165ab5..68356ce73aacd 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -43,7 +43,7 @@ where info!("fully_perform({:?})", self); } - scrape_region_constraints(infcx, || Ok((self.closure)(infcx)?)) + scrape_region_constraints(infcx, || (self.closure)(infcx)) } } diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index faa47230d3a06..16c3dd696abee 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let trait_def_ids: FxHashSet = param .bounds .iter() - .filter_map(|bound| Some(bound.trait_ref()?.trait_def_id()?)) + .filter_map(|bound| bound.trait_ref()?.trait_def_id()) .collect(); if !candidates.iter().any(|t| trait_def_ids.contains(&t.def_id)) { err.span_suggestions( From 250eeb4c3c00b7831226cf5266aacb5fca1e13f3 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Thu, 18 Feb 2021 09:58:15 +0800 Subject: [PATCH 11/11] Add missing link from stdio doc --- library/std/src/io/stdio.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 1160011f35287..e736bf19e8f93 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -231,7 +231,7 @@ pub struct Stdin { inner: &'static Mutex>, } -/// A locked reference to the `Stdin` handle. +/// A locked reference to the [`Stdin`] handle. /// /// This handle implements both the [`Read`] and [`BufRead`] traits, and /// is constructed via the [`Stdin::lock`] method. @@ -494,7 +494,7 @@ pub struct Stdout { inner: Pin<&'static ReentrantMutex>>>, } -/// A locked reference to the `Stdout` handle. +/// A locked reference to the [`Stdout`] handle. /// /// This handle implements the [`Write`] trait, and is constructed via /// the [`Stdout::lock`] method. @@ -708,9 +708,9 @@ pub struct Stderr { inner: Pin<&'static ReentrantMutex>>, } -/// A locked reference to the `Stderr` handle. +/// A locked reference to the [`Stderr`] handle. /// -/// This handle implements the `Write` trait and is constructed via +/// This handle implements the [`Write`] trait and is constructed via /// the [`Stderr::lock`] method. /// /// ### Note: Windows Portability Consideration