Skip to content

Rollup of 6 pull requests #96502

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 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
54daf49
std: directly use pthread in UNIX parker implementation
joboet Apr 25, 2022
eb55cdc
use `ParseSess` instead of `Session` in `into_diagnostic`
pvdrz Apr 25, 2022
519dd8e
migrate ambiguous plus diagnostic
pvdrz Apr 25, 2022
d6da5fb
update lockfile
pvdrz Apr 25, 2022
5874b09
fix formatting
pvdrz Apr 25, 2022
530f4dc
remove old code
pvdrz Apr 25, 2022
2e261a8
add `struct_warn` method
pvdrz Apr 25, 2022
35b42cb
avoid `format!`
pvdrz Apr 26, 2022
6c3e793
move `AmbigousPlus` outside
pvdrz Apr 26, 2022
1e35bab
separate messages by a newline
pvdrz Apr 26, 2022
2a6a370
Add more diagnostic items
Serial-ATA Apr 26, 2022
a1e0cfa
Update ui test
Serial-ATA Apr 27, 2022
e7ae9eb
rename `sum_with_parens`
pvdrz Apr 27, 2022
332f326
Fixed grammatical error in example comment
user-simon Apr 27, 2022
2b71201
std: simplify UNIX parker timeouts
joboet Apr 27, 2022
2c94218
Recover suggestions to introduce named lifetime under NLL
marmeladema Apr 25, 2022
d9240d7
Ensure that `'_` and GAT yields errors
marmeladema Mar 25, 2022
a67b394
Rollup merge of #95312 - marmeladema:tests-for-issue-95305, r=jackh726
Dylan-DPC Apr 28, 2022
bccac01
Rollup merge of #96302 - Serial-ATA:more-diagnostic-items, r=manishearth
Dylan-DPC Apr 28, 2022
ef079b8
Rollup merge of #96393 - joboet:pthread_parker, r=thomcc
Dylan-DPC Apr 28, 2022
16d029b
Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco
Dylan-DPC Apr 28, 2022
021a4ff
Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime…
Dylan-DPC Apr 28, 2022
439d24e
Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC
Dylan-DPC Apr 28, 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
use ParseSess instead of Session in into_diagnostic
  • Loading branch information
pvdrz committed Apr 25, 2022
commit eb55cdce4bc1c03e1ce805af633dac611a948d43
6 changes: 4 additions & 2 deletions compiler/rustc_macros/src/session_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ fn span_err(span: impl proc_macro::MultiSpan, msg: &str) -> proc_macro::Diagnost
/// Emit a diagnostic on span `$span` with msg `$msg` (optionally performing additional decoration
/// using the `FnOnce` passed in `diag`) and return `Err(ErrorHandled)`.
macro_rules! throw_span_err {
($span:expr, $msg:expr) => {{ throw_span_err!($span, $msg, |diag| diag) }};
($span:expr, $msg:expr) => {{
throw_span_err!($span, $msg, |diag| diag)
}};
($span:expr, $msg:expr, $f:expr) => {{
return Err(_throw_span_err($span, $msg, $f));
}};
Expand Down Expand Up @@ -308,7 +310,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
{
fn into_diagnostic(
self,
#sess: &'__session_diagnostic_sess rustc_session::Session
#sess: &'__session_diagnostic_sess rustc_session::parse::ParseSess
) -> rustc_errors::DiagnosticBuilder<'__session_diagnostic_sess, #param_ty> {
use rustc_errors::IntoDiagnosticArg;
#implementation
Expand Down
18 changes: 17 additions & 1 deletion compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

use crate::config::CheckCfg;
use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId};
use crate::SessionDiagnostic;
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{
error_code, fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, MultiSpan,
DiagnosticMessage, ErrorGuaranteed, MultiSpan,
};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -287,4 +288,19 @@ impl ParseSess {
pub fn proc_macro_quoted_spans(&self) -> Vec<Span> {
self.proc_macro_quoted_spans.lock().clone()
}

pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit()
}

pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
warning.into_diagnostic(self).emit()
}

pub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.span_diagnostic.struct_err(msg)
}
}
14 changes: 9 additions & 5 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub struct PerfStats {
pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
/// Write out as a diagnostic out of `sess`.
#[must_use]
fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, T>;
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, T>;
}

impl Session {
Expand Down Expand Up @@ -334,7 +334,7 @@ impl Session {
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err(msg)
self.parse_sess.struct_err(msg)
}
pub fn struct_err_with_code(
&self,
Expand Down Expand Up @@ -414,10 +414,10 @@ impl Session {
self.diagnostic().err(msg)
}
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit()
self.parse_sess.emit_err(err)
}
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
warning.into_diagnostic(self).emit()
self.parse_sess.emit_warning(warning)
}
#[inline]
pub fn err_count(&self) -> usize {
Expand Down Expand Up @@ -783,7 +783,11 @@ impl Session {
Path::new(&rustlib_path),
Path::new("bin"),
]);
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
if self_contained {
vec![p.clone(), p.join("self-contained")]
} else {
vec![p]
}
}

pub fn init_incr_comp_session(
Expand Down