Skip to content

Commit 7b4bfd6

Browse files
authored
Rollup merge of #114203 - fee1-dead-contrib:effects/pp-no-host, r=oli-obk
Effects: don't print `host` param in diagnostics r? ``@oli-obk``
2 parents b97da75 + df3f9fd commit 7b4bfd6

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_hir::LangItem;
1717
use rustc_session::config::TrimmedDefPaths;
1818
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
1919
use rustc_session::Limit;
20+
use rustc_span::sym;
2021
use rustc_span::symbol::{kw, Ident, Symbol};
2122
use rustc_span::FileNameDisplayPreference;
2223
use rustc_target::abi::Size;
@@ -2017,11 +2018,37 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
20172018
) -> Result<Self::Path, Self::Error> {
20182019
self = print_prefix(self)?;
20192020

2020-
if args.first().is_some() {
2021+
let tcx = self.tcx;
2022+
2023+
let args = args.iter().copied();
2024+
2025+
let args: Vec<_> = if !tcx.sess.verbose() {
2026+
// skip host param as those are printed as `~const`
2027+
args.filter(|arg| match arg.unpack() {
2028+
// FIXME(effects) there should be a better way than just matching the name
2029+
GenericArgKind::Const(c)
2030+
if tcx.features().effects
2031+
&& matches!(
2032+
c.kind(),
2033+
ty::ConstKind::Param(ty::ParamConst { name: sym::host, .. })
2034+
) =>
2035+
{
2036+
false
2037+
}
2038+
_ => true,
2039+
})
2040+
.collect()
2041+
} else {
2042+
// If -Zverbose is passed, we should print the host parameter instead
2043+
// of eating it.
2044+
args.collect()
2045+
};
2046+
2047+
if !args.is_empty() {
20212048
if self.in_value {
20222049
write!(self, "::")?;
20232050
}
2024-
self.generic_delimiters(|cx| cx.comma_sep(args.iter().cloned()))
2051+
self.generic_delimiters(|cx| cx.comma_sep(args.into_iter()))
20252052
} else {
20262053
Ok(self)
20272054
}

tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// known-bug: #110395
2-
#![feature(const_trait_impl)]
1+
#![feature(const_trait_impl, effects)]
32

43
#[const_trait]
54
pub trait Tr {
65
fn a(&self) {}
76

87
fn b(&self) {
98
().a()
10-
//FIXME ~^ ERROR the trait bound
9+
//~^ ERROR the trait bound
1110
}
1211
}
1312

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0015]: cannot call non-const fn `<() as Tr>::a` in constant functions
2-
--> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12
1+
error[E0277]: the trait bound `(): ~const Tr` is not satisfied
2+
--> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12
33
|
44
LL | ().a()
5-
| ^^^
5+
| ^ the trait `~const Tr` is not implemented for `()`
66
|
7-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
7+
= help: the trait `Tr` is implemented for `()`
88

99
error: aborting due to previous error
1010

11-
For more information about this error, try `rustc --explain E0015`.
11+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)