8000 Rollup of 8 pull requests by matthiaskrgr · Pull Request #98537 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 8 pull requests #98537

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fd76552
std: use an event flag based thread parker on SOLID
joboet May 18, 2022
3b6ae15
std: fix deadlock in `Parker`
joboet May 19, 2022
b9660de
std: solve priority issue for Parker
joboet Jun 4, 2022
5823d7b
Partial stabilization of "nonzero_unchecked_ops".
iago-lito May 30, 2022
69e8e7e
Stabilize NonZero* checked operations constness.
iago-lito Jun 9, 2022
caff723
std: relax memory orderings in `Parker`
joboet Jun 7, 2022
cc4f804
Move help popup into a pocket menu as well
GuillaumeGomez Jun 20, 2022
3eb9e1a
Add/update GUI tests for help pocket menu
GuillaumeGomez Jun 20, 2022
e4b2b41
Merge all popover hide functions into one
GuillaumeGomez Jun 22, 2022
99bc979
macros: use typed identifiers in diag derive
davidtwco Jun 23, 2022
abd3467
macros: use typed identifiers in subdiag derive
davidtwco Jun 23, 2022
dc90d1d
errors: remove diagnostic message ctors
davidtwco Jun 23, 2022
7475867
[rustc_parse] Forbid lets in certain places
c410-f3r Jun 25, 2022
dc2cc10
make const_err show up in future breakage reports
RalfJung Jun 4, 2022
af58692
bless remaining tests
RalfJung Jun 4, 2022
24b66da
Support setting file accessed/modified timestamps
joshtriplett Jun 19, 2022
e2b5729
Add alias `File::set_modified` as shorthand
joshtriplett Jun 20, 2022
3899914
bless after rebase
RalfJung Jun 25, 2022
1d32fed
Return an error if trying to set a file timestamp to 0 on Windows
joshtriplett Jun 25, 2022
2339bb2
Update `since` to 1.64 (since we're after 1.63)
scottmcm Jun 26, 2022
0398aa8
Add regression test for #92859
GuillaumeGomez Jun 26, 2022
03edb85
Rollup merge of #97140 - joboet:solid_parker, r=m-ou-se
matthiaskrgr Jun 26, 2022
8df0f4a
Rollup merge of #97295 - c410-f3r:yet-another-let-chain, r=compiler-e…
matthiaskrgr Jun 26, 2022
3fb4a87
Rollup merge of #97743 - RalfJung:const-err-future-breakage, r=estebank
matthiaskrgr Jun 26, 2022
f8e3771
Rollup merge of #97908 - iago-lito:stabilize_nonzero_checked_ops_cons…
matthiaskrgr Jun 26, 2022
b843ac5
Rollup merge of #98246 - joshtriplett:times, r=m-ou-se
matthiaskrgr Jun 26, 2022
4b59173
Rollup merge of #98297 - GuillaumeGomez:help-pocket-menu, r=notriddle
matthiaskrgr Jun 26, 2022
14859a5
Rollup merge of #98428 - davidtwco:translation-derive-typed-identifie…
matthiaskrgr Jun 26, 2022
45f9740
Rollup merge of #98535 - GuillaumeGomez:regression-test-92859, r=lcnr
matthiaskrgr Jun 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
macros: use typed identifiers in diag derive
Using typed identifiers instead of strings with the Fluent identifier
enables the diagnostic derive to benefit from the compile-time
validation that comes with typed identifiers - use of a non-existent
Fluent identifier will not compile.

Signed-off-by: David Wood <david.wood@huawei.com>
  • Loading branch information
davidtwco committed Jun 24, 2022
commit 99bc97940314176bc6ed38cea11723cc1fd9ee3b
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ pub fn expand_cfg(
}

#[derive(SessionDiagnostic)]
#[error(slug = "builtin-macros-requires-cfg-pattern")]
#[error(builtin_macros::requires_cfg_pattern)]
struct RequiresCfgPattern {
#[primary_span]
#[label]
span: Span,
}

#[derive(SessionDiagnostic)]
#[error(slug = "builtin-macros-expected-one-cfg-pattern")]
#[error(builtin_macros::expected_one_cfg_pattern)]
struct OneCfgPattern {
#[primary_span]
span: Span,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
builtin-macros-requires-cfg-pattern =
builtin_macros-requires-cfg-pattern =
macro requires a cfg-pattern as an argument
.label = cfg-pattern required

builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern
builtin_macros-expected-one-cfg-pattern = expected 1 cfg-pattern
460 changes: 284 additions & 176 deletions compiler/rustc_macros/src/diagnostics/diagnostic.rs

Large diffs are not rendered by default.

37 changes: 23 additions & 14 deletions compiler/rustc_macros/src/diagnostics/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ pub(crate) fn _throw_err(
SessionDiagnosticDeriveError::ErrorHandled
}

/// Helper function for printing `syn::Path` - doesn't handle arguments in paths and these are
/// unlikely to come up much in use of the macro.
fn path_to_string(path: &syn::Path) -> String {
let mut out = String::new();
for (i, segment) in path.segments.iter().enumerate() {
if i > 0 || path.leading_colon.is_some() {
out.push_str("::");
}
out.push_str(&segment.ident.to_string());
}
out
}

/// Returns an error diagnostic on span `span` with msg `msg`.
pub(crate) fn span_err(span: impl MultiSpan, msg: &str) -> Diagnostic {
Diagnostic::spanned(span, Level::Error, msg)
Expand All @@ -61,15 +74,13 @@ pub(crate) use throw_span_err;
/// Returns an error diagnostic for an invalid attribute.
pub(crate) fn invalid_attr(attr: &Attribute, meta: &Meta) -> Diagnostic {
let span = attr.span().unwrap();
let name = attr.path.segments.last().unwrap().ident.to_string();
let name = name.as_str();

let path = path_to_string(&attr.path);
match meta {
Meta::Path(_) => span_err(span, &format!("`#[{}]` is not a valid attribute", name)),
Meta::Path(_) => span_err(span, &format!("`#[{}]` is not a valid attribute", path)),
Meta::NameValue(_) => {
span_err(span, &format!("`#[{} = ...]` is not a valid attribute", name))
span_err(span, &format!("`#[{} = ...]` is not a valid attribute", path))
}
Meta::List(_) => span_err(span, &format!("`#[{}(...)]` is not a valid attribute", name)),
Meta::List(_) => span_err(span, &format!("`#[{}(...)]` is not a valid attribute", path)),
}
}

Expand Down Expand Up @@ -101,18 +112,16 @@ pub(crate) fn invalid_nested_attr(attr: &Attribute, nested: &NestedMeta) -> Diag
};

let span = meta.span().unwrap();
let nested_name = meta.path().segments.last().unwrap().ident.to_string();
let nested_name = nested_name.as_str();
let path = path_to_string(meta.path());
match meta {
Meta::NameValue(..) => span_err(
span,
&format!("`#[{}({} = ...)]` is not a valid attribute", name, nested_name),
),
Meta::NameValue(..) => {
span_err(span, &format!("`#[{}({} = ...)]` is not a valid attribute", name, path))
}
Meta::Path(..) => {
span_err(span, &format!("`#[{}({})]` is not a valid attribute", name, nested_name))
span_err(span, &format!("`#[{}({})]` is not a valid attribute", name, path))
}
Meta::List(..) => {
span_err(span, &format!("`#[{}({}(...))]` is not a valid attribute", name, nested_name))
span_err(span, &format!("`#[{}({}(...))]` is not a valid attribute", name, path))
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_macros/src/diagnostics/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
];

#generated

pub mod _subdiag {
pub const note: crate::SubdiagnosticMessage =
6D40 crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
pub const help: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
pub const label: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
pub const suggestion: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
}
}
}
.into()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_macros/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use synstructure::Structure;
/// # extern crate rust_middle;
/// # use rustc_middle::ty::Ty;
/// #[derive(SessionDiagnostic)]
/// #[error(code = "E0505", slug = "borrowck-move-out-of-borrow")]
/// #[error(borrowck::move_out_of_borrow, code = "E0505")]
/// pub struct MoveOutOfBorrowError<'tcx> {
/// pub name: Ident,
/// pub ty: Ty<'tcx>,
/// #[primary_span]
/// #[label]
/// pub span: Span,
/// #[label = "first-borrow-label"]
/// #[label(borrowck::first_borrow_label)]
/// pub first_borrow_span: Span,
/// #[suggestion(code = "{name}.clone()")]
/// pub clone_sugg: Option<(Span, Applicability)>
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl MultiSugg {
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-maybe-report-ambiguous-plus")]
#[error(parser::maybe_report_ambiguous_plus)]
struct AmbiguousPlus {
pub sum_ty: String,
#[primary_span]
Expand All @@ -253,7 +253,7 @@ struct AmbiguousPlus {
}

#[derive(SessionDiagnostic)]
#[error(code = "E0178", slug = "parser-maybe-recover-from-bad-type-plus")]
#[error(parser::maybe_recover_from_bad_type_plus, code = "E0178")]
struct BadTypePlus {
pub ty: String,
#[primary_span]
Expand Down Expand Up @@ -287,7 +287,7 @@ pub enum BadTypePlusSub {
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-maybe-recover-from-bad-qpath-stage-2")]
#[error(parser::maybe_recover_from_bad_qpath_stage_2)]
struct BadQPathStage2 {
#[primary_span]
#[suggestion(applicability = "maybe-incorrect")]
Expand All @@ -296,7 +296,7 @@ struct BadQPathStage2 {
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-incorrect-semicolon")]
#[error(parser::incorrect_semicolon)]
struct IncorrectSemicolon<'a> {
#[primary_span]
#[suggestion_short(applicability = "machine-applicable")]
Expand All @@ -307,26 +307,26 @@ struct IncorrectSemicolon<'a> {
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-incorrect-use-of-await")]
#[error(parser::incorrect_use_of_await)]
struct IncorrectUseOfAwait {
#[primary_span]
#[suggestion(message = "parentheses-suggestion", applicability = "machine-applicable")]
#[suggestion(parser::parentheses_suggestion, applicability = "machine-applicable")]
span: Span,
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-incorrect-use-of-await")]
#[error(parser::incorrect_use_of_await)]
struct IncorrectAwait {
#[primary_span]
span: Span,
#[suggestion(message = "postfix-suggestion", code = "{expr}.await{question_mark}")]
#[suggestion(parser::postfix_suggestion, code = "{expr}.await{question_mark}")]
sugg_span: (Span, Applicability),
expr: String,
question_mark: &'static str,
}

#[derive(SessionDiagnostic)]
#[error(slug = "parser-in-in-typo")]
#[error(parser::in_in_typo)]
struct InInTypo {
#[primary_span]
span: Span,
Expand Down
Loading
0