Effects: don't print host
param in diagnostics
This commit is contained in:
parent
2dc661037d
commit
df3f9fdf5a
3 changed files with 36 additions and 10 deletions
|
@ -17,6 +17,7 @@ use rustc_hir::LangItem;
|
||||||
use rustc_session::config::TrimmedDefPaths;
|
use rustc_session::config::TrimmedDefPaths;
|
||||||
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
|
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
|
use rustc_span::sym;
|
||||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||||
use rustc_span::FileNameDisplayPreference;
|
use rustc_span::FileNameDisplayPreference;
|
||||||
use rustc_target::abi::Size;
|
use rustc_target::abi::Size;
|
||||||
|
@ -2017,11 +2018,37 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
) -> Result<Self::Path, Self::Error> {
|
) -> Result<Self::Path, Self::Error> {
|
||||||
self = print_prefix(self)?;
|
self = print_prefix(self)?;
|
||||||
|
|
||||||
if args.first().is_some() {
|
let tcx = self.tcx;
|
||||||
|
|
||||||
|
let args = args.iter().copied();
|
||||||
|
|
||||||
|
let args: Vec<_> = if !tcx.sess.verbose() {
|
||||||
|
// skip host param as those are printed as `~const`
|
||||||
|
args.filter(|arg| match arg.unpack() {
|
||||||
|
// FIXME(effects) there should be a better way than just matching the name
|
||||||
|
GenericArgKind::Const(c)
|
||||||
|
if tcx.features().effects
|
||||||
|
&& matches!(
|
||||||
|
c.kind(),
|
||||||
|
ty::ConstKind::Param(ty::ParamConst { name: sym::host, .. })
|
||||||
|
) =>
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
_ => true,
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
} else {
|
||||||
|
// If -Zverbose is passed, we should print the host parameter instead
|
||||||
|
// of eating it.
|
||||||
|
args.collect()
|
||||||
|
};
|
||||||
|
|
||||||
|
if !args.is_empty() {
|
||||||
if self.in_value {
|
if self.in_value {
|
||||||
write!(self, "::")?;
|
write!(self, "::")?;
|
||||||
}
|
}
|
||||||
self.generic_delimiters(|cx| cx.comma_sep(args.iter().cloned()))
|
self.generic_delimiters(|cx| cx.comma_sep(args.into_iter()))
|
||||||
} else {
|
} else {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// known-bug: #110395
|
#![feature(const_trait_impl, effects)]
|
||||||
#![feature(const_trait_impl)]
|
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
pub trait Tr {
|
pub trait Tr {
|
||||||
|
@ -7,7 +6,7 @@ pub trait Tr {
|
||||||
|
|
||||||
fn b(&self) {
|
fn b(&self) {
|
||||||
().a()
|
().a()
|
||||||
//FIXME ~^ ERROR the trait bound
|
//~^ ERROR the trait bound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error[E0015]: cannot call non-const fn `<() as Tr>::a` in constant functions
|
error[E0277]: the trait bound `(): ~const Tr` is not satisfied
|
||||||
--> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12
|
--> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12
|
||||||
|
|
|
|
||||||
LL | ().a()
|
LL | ().a()
|
||||||
| ^^^
|
| ^ the trait `~const Tr` is not implemented for `()`
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= help: the trait `Tr` is implemented for `()`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0015`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
|
Loading…
Add table
Reference in a new issue