Skip to content

Rollup of 13 pull requests #119516

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 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2c23c06
rc: Take *const T in is_dangling
taiki-e Dec 30, 2023
07adee7
is_coroutine -> is_coroutine_or_closure
compiler-errors Dec 30, 2023
847cd6c
Use the right type for upvars
compiler-errors Dec 30, 2023
86bd81f
Update tracking issue of naked_functions
nbdd0121 Dec 31, 2023
d796ad4
rustdoc ui: adjust tooltip z-index to be above sidebar
Dec 31, 2023
f118c76
Remove two unused feature gates from rustc_query_impl
bjorn3 Dec 31, 2023
5cbe41a
Document that File does not buffer reads/writes, refer to BufReader/B…
chfogelman Dec 26, 2023
884cb41
Minor improvements in comment for
gurry Jan 1, 2024
01ac44a
Pretty-print always-const trait predicates correctly
fmease Dec 31, 2023
b1853eb
use css variable for z-index of the sidebar
Dec 31, 2023
440ba5f
Update books
rustbot Jan 1, 2024
82a5745
Update deadlinks of `strict_provenance` lints
ShE3py Jan 1, 2024
3d0297a
Deny defaults for higher-ranked generic parameters
fmease Jan 1, 2024
23924fe
Mark myself as back from leave
oli-obk Jan 2, 2024
ba86034
Don't synthesize host effect params for trait assoc fns marked const
fmease Jan 1, 2024
8f546aa
Turn a bug!() into a span_delay_bug()
fmease Jan 2, 2024
ae8e401
E0379: Make diagnostic more precise
fmease Jan 1, 2024
aa79904
E0379: Provide suggestions
fmease Jan 1, 2024
018f07b
Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472
fmease Jan 2, 2024
b0c969f
Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum
fmease Jan 2, 2024
2ba98dc
Rollup merge of #119444 - compiler-errors:closure-or-coroutine, r=oli…
fmease Jan 2, 2024
ebc5b92
Rollup merge of #119474 - nbdd0121:naked, r=Nilstrieb
fmease Jan 2, 2024
6240bc9
Rollup merge of #119476 - fmease:pp-always-const-trait-preds, r=compi…
fmease Jan 2, 2024
a9eaa02
Rollup merge of #119477 - lukas-code:tooltip-z-index, r=notriddle
fmease Jan 2, 2024
8b3a481
Rollup merge of #119479 - bjorn3:remove_unused_feature_gates, r=compi…
fmease Jan 2, 2024
14d6467
Rollup merge of #119487 - gurry:improve-freshner-comment, r=Nilstrieb
fmease Jan 2, 2024
58c2042
Rollup merge of #119492 - rustbot:docs-update, r=ehuss
fmease Jan 2, 2024
55dd7c5
Rollup merge of #119494 - fmease:deny-hr-param-defaults, r=compiler-e…
fmease Jan 2, 2024
8516118
Rollup merge of #119498 - ShE3py:provenance-lints-doc, r=Nilstrieb
fmease Jan 2, 2024
b2cf028
Rollup merge of #119505 - fmease:no-host-param-for-trait-fns, r=fee1-…
fmease Jan 2, 2024
f8baa9a
Rollup merge of #119512 - oli-obk:unleave, r=oli-obk
fmease Jan 2, 2024
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
Don't synthesize host effect params for trait assoc fns marked const
fmease committed Jan 2, 2024

Verified

This commit was signed with the committer’s verified signature.
fmease León Orell Valerian Liehr
commit ba860344e1656eb577b0e1484cd68b16b7735a59
10 changes: 6 additions & 4 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
@@ -1254,11 +1254,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
coroutine_kind: Option<CoroutineKind>,
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
let header = self.lower_fn_header(sig.header);
// Don't pass along the user-provided constness of trait associated functions; we don't want to
// synthesize a host effect param for them. We reject `const` on them during AST validation.
let constness = if kind == FnDeclKind::Inherent { sig.header.constness } else { Const::No };
let itctx = ImplTraitContext::Universal;
let (generics, decl) =
self.lower_generics(generics, sig.header.constness, id, &itctx, |this| {
this.lower_fn_decl(&sig.decl, id, sig.span, kind, coroutine_kind)
});
let (generics, decl) = self.lower_generics(generics, constness, id, &itctx, |this| {
this.lower_fn_decl(&sig.decl, id, sig.span, kind, coroutine_kind)
});
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
}

13 changes: 13 additions & 0 deletions tests/ui/rfcs/rfc-2632-const-trait-impl/effects/trait-fn-const.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Regression test for issue #113378.
#![feature(const_trait_impl, effects)]

#[const_trait]
trait Trait {
const fn fun(); //~ ERROR functions in traits cannot be declared const
}

impl const Trait for () {
const fn fun() {} //~ ERROR functions in traits cannot be declared const
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/trait-fn-const.rs:6:5
|
LL | const fn fun();
| ^^^^^ functions in traits cannot be const

error[E0379]: functions in traits cannot be declared const
--> $DIR/trait-fn-const.rs:10:5
|
LL | const fn fun() {}
| ^^^^^ functions in traits cannot be const

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0379`.