Skip to content

Rollup of 8 pull requests #101026

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 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e540425
Add a `File::create_new` constructor
joshtriplett Jul 2, 2022
fab36d1
Add comments about stdout locking
sigaloid Jul 26, 2022
bafb10d
fix an outdated machine hook name
RalfJung Jul 27, 2022
d34df43
remove enforce_number_init machine hook that Miri no longer needs
RalfJung Jul 27, 2022
c542245
remove some now-unnecessary parameters from check_bytes
RalfJung Jul 27, 2022
8654522
make read_immediate error immediately on uninit, so ImmTy can carry i…
RalfJung Aug 1, 2022
c11fa89
remove now-unused ScalarMaybeUninit
RalfJung Aug 2, 2022
73ae38b
Migrate ast_lowering::path to SessionDiagnostic
JeanCASPAR Aug 16, 2022
0043d10
Migrate ast_lowering::lib and ast_lowering::item to SessionDiagnostic
JeanCASPAR Aug 17, 2022
1382d30
Migrate ast_lowering::expr to SessionDiagnostic
JeanCASPAR Aug 17, 2022
d75fd91
Migrate ast_lowering::ast to SessionDiagnostic
JeanCASPAR Aug 17, 2022
5164966
Migrate ast_lowering::pat to SessionDiagnostic
JeanCASPAR Aug 18, 2022
e701c72
Migrate all span_err(...) in ast_lowering to SessionDiagnostic
JeanCASPAR Aug 18, 2022
9472df1
Changes made in response to feedback
JeanCASPAR Aug 19, 2022
5fef1b8
Resolve conflicts
JeanCASPAR Aug 22, 2022
cb4cd73
extra sanity check against consts pointing to mutable memory
RalfJung Aug 23, 2022
4e97626
Call them constants instead of types
compiler-errors Aug 12, 2022
4ff5872
Note binding obligation causes for const equate errors
compiler-errors Aug 12, 2022
d464d3a
Add test for #100414
compiler-errors Aug 12, 2022
8189a45
Use ExprItemObligation and ExprBindingObligation too
compiler-errors Aug 23, 2022
d82e6b3
Add `IsTerminal` trait to determine if a descriptor or handle is a te…
joshtriplett Jun 12, 2022
a7e5dc2
Make is_terminal fail fast if a process has no console at all
joshtriplett Jun 20, 2022
6c5c32b
Rewrite FILE_NAME_INFO handling to avoid enlarging slice reference
joshtriplett Aug 24, 2022
8c65478
rustdoc: remove unused CSS for `.variants_table`
notriddle Aug 25, 2022
f489703
Rollup merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc
Dylan-DPC Aug 26, 2022
5050988
Rollup merge of #98801 - joshtriplett:file-create-new, r=thomcc
Dylan-DPC Aug 26, 2022
b464d5f
Rollup merge of #99742 - sigaloid:master, r=thomcc
Dylan-DPC Aug 26, 2022
6a5521f
Rollup merge of #100043 - RalfJung:scalar-always-init, r=oli-obk
Dylan-DPC Aug 26, 2022
57d438f
Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, …
Dylan-DPC Aug 26, 2022
ef95092
Rollup merge of #100724 - JeanCASPAR:migrate-ast_lowering-to-session-…
Dylan-DPC Aug 26, 2022
2122c6e
Rollup merge of #100897 - RalfJung:const-not-to-mutable, r=lcnr
Dylan-DPC Aug 26, 2022
b125b05
Rollup merge of #101012 - notriddle:notriddle/variants_table, r=jsha
Dylan-DPC Aug 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
Migrate ast_lowering::path to SessionDiagnostic
  • Loading branch information
JeanCASPAR committed Aug 22, 2022
commit 73ae38bac10e010aee20fc2f56735fdada86e5dd
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3575,6 +3575,7 @@ dependencies = [
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_middle",
"rustc_query_system",
"rustc_session",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rustc_target = { path = "../rustc_target" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" }
rustc_macros = { path = "../rustc_macros" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_span = { path = "../rustc_span" }
rustc_errors = { path = "../rustc_errors" }
Expand Down
29 changes: 29 additions & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;

#[derive(SessionDiagnostic, Clone, Copy)]
#[error(ast_lowering::generic_type_with_parentheses, code = "E0214")]
pub struct GenericTypeWithParentheses {
#[primary_span]
#[label]
pub span: Span,
#[subdiagnostic]
pub sub: Option<UseAngleBrackets>,
}

#[derive(Clone, Copy)]
pub struct UseAngleBrackets {
pub open_param: Span,
pub close_param: Span,
}

impl AddSubdiagnostic for UseAngleBrackets {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
diag.multipart_suggestion(
fluent::ast_lowering::use_angle_brackets,
vec![(self.open_param, String::from("<")), (self.close_param, String::from(">"))],
Applicability::MaybeIncorrect,
);
}
}
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ macro_rules! arena_vec {

mod asm;
mod block;
mod errors;
mod expr;
mod index;
mod item;
Expand Down
23 changes: 8 additions & 15 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::ImplTraitPosition;

use super::errors::{GenericTypeWithParentheses, UseAngleBrackets};
use super::ResolverAstLoweringExt;
use super::{GenericArgsCtor, LifetimeRes, ParenthesizedGenericArgs};
use super::{ImplTraitContext, LoweringContext, ParamMode};

use rustc_ast::{self as ast, *};
use rustc_errors::{struct_span_err, Applicability};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::GenericArg;
Expand Down Expand Up @@ -185,18 +185,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
) -> hir::PathSegment<'hir> {
debug!("path_span: {:?}, lower_path_segment(segment: {:?})", path_span, segment,);
let (mut generic_args, infer_args) = if let Some(ref generic_args) = segment.args {
let msg = "parenthesized type parameters may only be used with a `Fn` trait";
match **generic_args {
GenericArgs::AngleBracketed(ref data) => {
self.lower_angle_bracketed_parameter_data(data, param_mode, itctx)
}
GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
ParenthesizedGenericArgs::Err => {
let mut err = struct_span_err!(self.tcx.sess, data.span, E0214, "{}", msg);
err.span_label(data.span, "only `Fn` traits may use parentheses");
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
if !data.inputs.is_empty() {
let sub = if !data.inputs.is_empty() {
// Start of the span to the 1st character of 1st argument
let open_param = data.inputs_span.shrink_to_lo().to(data
.inputs
Expand All @@ -212,16 +209,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.span
.shrink_to_hi()
.to(data.inputs_span.shrink_to_hi());
err.multipart_suggestion(
&format!("use angle brackets instead",),
vec![
(open_param, String::from("<")),
(close_param, String::from(">")),
],
Applicability::MaybeIncorrect,
);
}
err.emit();

Some(UseAngleBrackets { open_param, close_param })
} else {
None
};
self.tcx.sess.emit_err(GenericTypeWithParentheses { span: data.span, sub });
(
self.lower_angle_bracketed_parameter_data(
&data.as_angle_bracketed_args(),
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ast_lowering_generic_type_with_parentheses =
parenthesized type parameters may only be used with a `Fn` trait
.label = only `Fn` traits may use parentheses

ast_lowering_use_angle_brackets = use angle brackets instead
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub use unic_langid::{langid, LanguageIdentifier};

// Generates `DEFAULT_LOCALE_RESOURCES` static and `fluent_generated` module.
fluent_messages! {
ast_lowering => "../locales/en-US/ast_lowering.ftl",
ast_passes => "../locales/en-US/ast_passes.ftl",
borrowck => "../locales/en-US/borrowck.ftl",
builtin_macros => "../locales/en-US/builtin_macros.ftl",
Expand Down