Skip to content

Rollup of 14 pull requests #126962

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 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a264bff
Mark assoc tys live only if the trait is live
mu001999 Jun 18, 2024
dd557d8
Add a test demonstrating that RPITITs cant use precise capturing
compiler-errors Jun 20, 2024
594fa01
not use offset when there is not ends with brace
bvanjoi Jun 23, 2024
8cfd4b1
Unify the precedence level for PREC_POSTFIX and PREC_PAREN
dtolnay Jun 24, 2024
273447c
Rename the 2 unambiguous precedence levels to PREC_UNAMBIGUOUS
dtolnay Jun 24, 2024
a2298a6
Do not ICE when suggesting dereferencing closure arg
estebank Jun 24, 2024
6521c39
Deny use<> for RPITITs
compiler-errors Jun 20, 2024
553a690
Specify target specific linker for riscv64gc-gnu job
Hoverbear Jun 24, 2024
26677eb
don't suggest awaiting type expr patterns
SparkyPotato Jun 24, 2024
8016940
Tweak a confusing comment in `create_match_candidates`
Zalathar Jun 24, 2024
050595a
core: VaArgSafe is an unsafe trait
workingjubilee Jun 25, 2024
c2f1072
Tweak `FlatPat::new` to avoid a temporarily-invalid state
Zalathar Jun 25, 2024
f2ade37
Add `input_file` method on `LlvmFileCheck`
GuillaumeGomez Jun 25, 2024
221dd30
Migrate `run-make/llvm-ident` to `rmake.rs`
GuillaumeGomez Jun 25, 2024
c7b579a
Add missing slash in const_eval_select doc comment
cyrgani Jun 25, 2024
2155c6c
#126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_p…
tnuha Jun 23, 2024
b08cd69
inner truncate methods for UEFI platforms
tnuha Jun 23, 2024
7e187e8
remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension`
tnuha Jun 23, 2024
aa46a33
`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platf…
tnuha Jun 25, 2024
d30d85f
Delegation: ast lowering refactor
Bryanskiy Jun 25, 2024
77f60a9
Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
workingjubilee Jun 25, 2024
e1a6e3b
Rollup merge of #126746 - compiler-errors:no-rpitit, r=oli-obk
workingjubilee Jun 25, 2024
5f03101
Rollup merge of #126868 - bvanjoi:fix-126764, r=davidtwco
workingjubilee Jun 25, 2024
c7dc441
Rollup merge of #126884 - estebank:issue-125634, r=Nadrieril
workingjubilee Jun 25, 2024
457cc4e
Rollup merge of #126885 - Borgerr:rm_internal_pathbuf_asmutvec, r=wor…
workingjubilee Jun 25, 2024
ad2eba4
Rollup merge of #126893 - dtolnay:prec, r=compiler-errors
workingjubilee Jun 25, 2024
a946c76
Rollup merge of #126915 - SparkyPotato:fix-126903, r=compiler-errors
workingjubilee Jun 25, 2024
fd17aaa
Rollup merge of #126916 - ferrocene:hoverbear/riscv64gc-gnu-specify-l…
workingjubilee Jun 25, 2024
ddc7d5b
Rollup merge of #126926 - Zalathar:candidate-per-arm, r=Nadrieril
workingjubilee Jun 25, 2024
2af6c9b
Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboet
workingjubilee Jun 25, 2024
8e2d069
Rollup merge of #126932 - Zalathar:flat-pat, r=Nadrieril
workingjubilee Jun 25, 2024
1626e24
Rollup merge of #126941 - GuillaumeGomez:migrate-run-make-llvm-ident,…
workingjubilee Jun 25, 2024
fdc973b
Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errors
workingjubilee Jun 25, 2024
c49f753
Rollup merge of #126947 - Bryanskiy:delegation-lowering-refactoring, …
workingjubilee Jun 25, 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
3 changes: 3 additions & 0 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ ast_lowering_never_pattern_with_guard =
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
ast_lowering_no_precise_captures_on_rpitit = `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
.note = currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
ast_lowering_previously_used_here = previously used here
ast_lowering_register1 = register `{$reg1_name}`
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,14 @@ pub(crate) struct NoPreciseCapturesOnApit {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_lowering_no_precise_captures_on_rpitit)]
#[note]
pub(crate) struct NoPreciseCapturesOnRpitit {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_lowering_yield_in_closure)]
pub(crate) struct YieldInClosure {
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,26 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
};
debug!(?captured_lifetimes_to_duplicate);

match fn_kind {
// Deny `use<>` on RPITIT in trait/trait-impl for now.
Some(FnDeclKind::Trait | FnDeclKind::Impl) => {
if let Some(span) = bounds.iter().find_map(|bound| match *bound {
ast::GenericBound::Use(_, span) => Some(span),
_ => None,
}) {
self.tcx.dcx().emit_err(errors::NoPreciseCapturesOnRpitit { span });
}
}
None
| Some(
FnDeclKind::Fn
| FnDeclKind::Inherent
| FnDeclKind::ExternFn
| FnDeclKind::Closure
| FnDeclKind::Pointer,
) => {}
}

self.lower_opaque_inner(
opaque_ty_node_id,
origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fn type_param<T>() -> impl Sized + use<> {}
trait Foo {
fn bar() -> impl Sized + use<>;
//~^ ERROR `impl Trait` must mention the `Self` type of the trait
//~| ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
--> $DIR/forgot-to-capture-type.rs:7:30
|
LL | fn bar() -> impl Sized + use<>;
| ^^^^^
|
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope

error: `impl Trait` must mention all type parameters in scope in `use<...>`
--> $DIR/forgot-to-capture-type.rs:3:23
|
Expand All @@ -18,5 +26,5 @@ LL | fn bar() -> impl Sized + use<>;
|
= note: currently, all type parameters are required to be mentioned in the precise captures list

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

20 changes: 20 additions & 0 deletions tests/ui/impl-trait/precise-capturing/redundant.normal.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
--> $DIR/redundant.rs:7:19
|
LL | fn hello<'a>() -> impl Sized + use<'a> {}
| ^^^^^^^^^^^^^-------
| |
| help: remove the `use<...>` syntax
|
= note: `#[warn(impl_trait_redundant_captures)]` on by default

warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
--> $DIR/redundant.rs:12:27
|
LL | fn inherent(&self) -> impl Sized + use<'_> {}
| ^^^^^^^^^^^^^-------
| |
| help: remove the `use<...>` syntax

warning: 2 warnings emitted

18 changes: 18 additions & 0 deletions tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
--> $DIR/redundant.rs:18:35
|
LL | fn in_trait() -> impl Sized + use<'a, Self>;
| ^^^^^^^^^^^^^
|
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope

error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
--> $DIR/redundant.rs:23:35
|
LL | fn in_trait() -> impl Sized + use<'a> {}
| ^^^^^^^
|
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope

error: aborting due to 2 previous errors

13 changes: 8 additions & 5 deletions tests/ui/impl-trait/precise-capturing/redundant.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
//@ compile-flags: -Zunstable-options --edition=2024
//@ check-pass
//@ revisions: normal rpitit
//@[normal] check-pass

#![feature(precise_capturing)]

fn hello<'a>() -> impl Sized + use<'a> {}
//~^ WARN all possible in-scope parameters are already captured
//[normal]~^ WARN all possible in-scope parameters are already captured

struct Inherent;
impl Inherent {
fn inherent(&self) -> impl Sized + use<'_> {}
//~^ WARN all possible in-scope parameters are already captured
//[normal]~^ WARN all possible in-scope parameters are already captured
}

#[cfg(rpitit)]
trait Test<'a> {
fn in_trait() -> impl Sized + use<'a, Self>;
//~^ WARN all possible in-scope parameters are already captured
//[rpitit]~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
}
#[cfg(rpitit)]
impl<'a> Test<'a> for () {
fn in_trait() -> impl Sized + use<'a> {}
//~^ WARN all possible in-scope parameters are already captured
//[rpitit]~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
}

fn main() {}
36 changes: 0 additions & 36 deletions tests/ui/impl-trait/precise-capturing/redundant.stderr

This file was deleted.

21 changes: 21 additions & 0 deletions tests/ui/impl-trait/precise-capturing/rpitit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ known-bug: unknown

// RPITITs don't have variances in their GATs, so they always relate invariantly
// and act as if they capture all their args.
// To fix this soundly, we need to make sure that all the trait header args
// remain captured, since they affect trait selection.

#![feature(precise_capturing)]

trait Foo<'a> {
fn hello() -> impl PartialEq + use<Self>;
}

fn test<'a, 'b, T: for<'r> Foo<'r>>() {
PartialEq::eq(
&<T as Foo<'a>>::hello(),
&<T as Foo<'b>>::hello(),
);
}

fn main() {}
50 changes: 50 additions & 0 deletions tests/ui/impl-trait/precise-capturing/rpitit.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
--> $DIR/rpitit.rs:11:36
|
LL | fn hello() -> impl PartialEq + use<Self>;
| ^^^^^^^^^
|
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope

error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
--> $DIR/rpitit.rs:11:19
|
LL | trait Foo<'a> {
| -- this lifetime parameter is captured
LL | fn hello() -> impl PartialEq + use<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait`

error: lifetime may not live long enough
--> $DIR/rpitit.rs:15:5
|
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | / PartialEq::eq(
LL | | &<T as Foo<'a>>::hello(),
LL | | &<T as Foo<'b>>::hello(),
LL | | );
| |_____^ argument requires that `'a` must outlive `'b`
|
= help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
--> $DIR/rpitit.rs:15:5
|
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | / PartialEq::eq(
LL | | &<T as Foo<'a>>::hello(),
LL | | &<T as Foo<'b>>::hello(),
LL | | );
| |_____^ argument requires that `'b` must outlive `'a`
|
= help: consider adding the following bound: `'b: 'a`

help: `'a` and `'b` must be the same: replace one with the other

error: aborting due to 4 previous errors

3 changes: 1 addition & 2 deletions tests/ui/impl-trait/precise-capturing/self-capture.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//@ check-pass

#![feature(precise_capturing)]

trait Foo {
fn bar<'a>() -> impl Sized + use<Self>;
//~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/impl-trait/precise-capturing/self-capture.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
--> $DIR/self-capture.rs:4:34
|
LL | fn bar<'a>() -> impl Sized + use<Self>;
| ^^^^^^^^^
|
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope

error: aborting due to 1 previous error