mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
Remove Session
methods that duplicate DiagCtxt
methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
This commit is contained in:
parent
870a5d957b
commit
620a1e4c2f
@ -636,11 +636,11 @@ impl Conf {
|
||||
match path {
|
||||
Ok((_, warnings)) => {
|
||||
for warning in warnings {
|
||||
sess.warn(warning.clone());
|
||||
sess.dcx().warn(warning.clone());
|
||||
}
|
||||
},
|
||||
Err(error) => {
|
||||
sess.err(format!("error finding Clippy's configuration file: {error}"));
|
||||
sess.dcx().err(format!("error finding Clippy's configuration file: {error}"));
|
||||
},
|
||||
}
|
||||
|
||||
@ -652,7 +652,7 @@ impl Conf {
|
||||
Ok((Some(path), _)) => match sess.source_map().load_file(path) {
|
||||
Ok(file) => deserialize(&file),
|
||||
Err(error) => {
|
||||
sess.err(format!("failed to read `{}`: {error}", path.display()));
|
||||
sess.dcx().err(format!("failed to read `{}`: {error}", path.display()));
|
||||
TryConf::default()
|
||||
},
|
||||
},
|
||||
@ -663,14 +663,14 @@ impl Conf {
|
||||
|
||||
// all conf errors are non-fatal, we just use the default conf in case of error
|
||||
for error in errors {
|
||||
sess.span_err(
|
||||
sess.dcx().span_err(
|
||||
error.span,
|
||||
format!("error reading Clippy's configuration file: {}", error.message),
|
||||
);
|
||||
}
|
||||
|
||||
for warning in warnings {
|
||||
sess.span_warn(
|
||||
sess.dcx().span_warn(
|
||||
warning.span,
|
||||
format!("error reading Clippy's configuration file: {}", warning.message),
|
||||
);
|
||||
|
@ -83,7 +83,7 @@ impl Msrv {
|
||||
(None, Some(cargo_msrv)) => self.stack = vec![cargo_msrv],
|
||||
(Some(clippy_msrv), Some(cargo_msrv)) => {
|
||||
if clippy_msrv != cargo_msrv {
|
||||
sess.warn(format!(
|
||||
sess.dcx().warn(format!(
|
||||
"the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{clippy_msrv}` from `clippy.toml`"
|
||||
));
|
||||
}
|
||||
@ -106,7 +106,7 @@ impl Msrv {
|
||||
|
||||
if let Some(msrv_attr) = msrv_attrs.next() {
|
||||
if let Some(duplicate) = msrv_attrs.last() {
|
||||
sess.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
|
||||
sess.dcx().struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
|
||||
.span_note(msrv_attr.span, "first definition found here")
|
||||
.emit();
|
||||
}
|
||||
@ -116,9 +116,9 @@ impl Msrv {
|
||||
return Some(version);
|
||||
}
|
||||
|
||||
sess.span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
|
||||
sess.dcx().span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
|
||||
} else {
|
||||
sess.span_err(msrv_attr.span, "bad clippy attribute");
|
||||
sess.dcx().span_err(msrv_attr.span, "bad clippy attribute");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
|
||||
|
||||
if let Err((span, err)) = is_min_const_fn(cx.tcx, mir, &self.msrv) {
|
||||
if cx.tcx.is_const_fn_raw(def_id.to_def_id()) {
|
||||
cx.tcx.sess.span_err(span, err);
|
||||
cx.tcx.dcx().span_err(span, err);
|
||||
}
|
||||
} else {
|
||||
span_lint(cx, MISSING_CONST_FOR_FN, span, "this could be a `const fn`");
|
||||
|
@ -76,12 +76,12 @@ pub fn get_attr<'a>(
|
||||
})
|
||||
.map_or_else(
|
||||
|| {
|
||||
sess.span_err(attr_segments[1].ident.span, "usage of unknown attribute");
|
||||
sess.dcx().span_err(attr_segments[1].ident.span, "usage of unknown attribute");
|
||||
false
|
||||
},
|
||||
|deprecation_status| {
|
||||
let mut diag =
|
||||
sess.struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
|
||||
sess.dcx().struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
|
||||
match *deprecation_status {
|
||||
DeprecationStatus::Deprecated => {
|
||||
diag.emit();
|
||||
@ -116,10 +116,10 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
||||
if let Ok(value) = FromStr::from_str(value.as_str()) {
|
||||
f(value);
|
||||
} else {
|
||||
sess.span_err(attr.span, "not a number");
|
||||
sess.dcx().span_err(attr.span, "not a number");
|
||||
}
|
||||
} else {
|
||||
sess.span_err(attr.span, "bad clippy attribute");
|
||||
sess.dcx().span_err(attr.span, "bad clippy attribute");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ pub fn get_unique_attr<'a>(
|
||||
let mut unique_attr: Option<&ast::Attribute> = None;
|
||||
for attr in get_attr(sess, attrs, name) {
|
||||
if let Some(duplicate) = unique_attr {
|
||||
sess.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
|
||||
sess.dcx().struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
|
||||
.span_note(duplicate.span, "first definition found here")
|
||||
.emit();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user