Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9395103
Give a better error when `x dist` fails for an optional tool
jyn514 Jul 11, 2022
40ae7b5
Parse closure binders
WaffleLapkin Jun 2, 2022
97fcead
--bless tests
WaffleLapkin Jun 2, 2022
f89ef3c
Comment out expr size check
WaffleLapkin Jul 12, 2022
c2dbd62
Lower closure binders to hir & properly check them
WaffleLapkin Jul 12, 2022
0c28484
make for<> in closures a possible place to suggest adding named lifetime
WaffleLapkin Jun 30, 2022
577f3c6
add test for implicit stuff in signatures of closures with `for<>`
WaffleLapkin Jun 24, 2022
3ebb852
Add `LifetimeBinderKind::Closure`
WaffleLapkin Jul 3, 2022
df4fee9
Add an indirection for closures in `hir::ExprKind`
WaffleLapkin Jul 11, 2022
d2923b4
Add back expr size checks
WaffleLapkin Jul 11, 2022
b504a18
implement rustfmt formatting for `for<>` closure binders
WaffleLapkin Jun 30, 2022
30a3673
Add rustfmt test for formatting `for<>` before closures
WaffleLapkin Jul 3, 2022
9aa142b
Fix clippy build
WaffleLapkin Jun 30, 2022
031b2c5
Always use CreateParameter mode for function definitions.
cjgillot Jun 19, 2022
c7ac816
Clippy fallout.
cjgillot Jun 4, 2022
3b1b38d
Bless ui-fulldeps tests.
cjgillot Jun 4, 2022
5a20834
Add feature gate.
cjgillot Jun 22, 2022
f94484f
reduce scope of allow(rustc::potential_query_instability) in rustc_span
NiklasJonsson Jul 10, 2022
d431338
Stabilize `core::ffi:c_*` and rexport in `std::ffi`
joshtriplett Jun 20, 2022
f5e9cb5
Rollup merge of #97720 - cjgillot:all-fresh, r=petrochenkov
Dylan-DPC Jul 14, 2022
103b860
Rollup merge of #98315 - joshtriplett:stabilize-core-ffi-c, r=Mark-Si…
Dylan-DPC Jul 14, 2022
e5a86d7
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Dylan-DPC Jul 14, 2022
85159a4
Rollup merge of #99126 - NiklasJonsson:84447/rustc_span, r=petrochenkov
Dylan-DPC Jul 14, 2022
c1b43ef
Rollup merge of #99139 - jyn514:dist-tool-help, r=Mark-Simulacrum
Dylan-DPC Jul 14, 2022
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
Always use CreateParameter mode for function definitions.
  • Loading branch information
cjgillot committed Jul 13, 2022
commit 031b2c53cd213c3730936e190df6fcc0296a7041
20 changes: 9 additions & 11 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
// We don't need to deal with patterns in parameters, because
// they are not possible for foreign or bodiless functions.
self.with_lifetime_rib(
LifetimeRibKind::AnonymousPassThrough(fn_id, false),
LifetimeRibKind::AnonymousCreateParameter {
binder: fn_id,
report_in_path: false,
},
|this| walk_list!(this, visit_param, &sig.decl.inputs),
);
self.with_lifetime_rib(
Expand Down Expand Up @@ -792,18 +795,13 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
// generic parameters. This is especially useful for `async fn`, where
// these fresh generic parameters can be applied to the opaque `impl Trait`
// return type.
let rib = if async_node_id.is_some() {
// Only emit a hard error for `async fn`, since this kind of
// elision has always been allowed in regular `fn`s.
this.with_lifetime_rib(
LifetimeRibKind::AnonymousCreateParameter {
binder: fn_id,
report_in_path: true,
}
} else {
LifetimeRibKind::AnonymousPassThrough(fn_id, false)
};
this.with_lifetime_rib(
rib,
// Only emit a hard error for `async fn`, since this kind of
// elision has always been allowed in regular `fn`s.
report_in_path: async_node_id.is_some(),
},
// Add each argument to the rib.
|this| this.resolve_params(&declaration.inputs),
);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-87748.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ error[E0478]: lifetime bound not satisfied
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the anonymous lifetime #2 defined here
note: lifetime parameter instantiated with the anonymous lifetime as defined here
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
note: but lifetime parameter must outlive the anonymous lifetime #1 defined here
note: but lifetime parameter must outlive the anonymous lifetime as defined here
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/generic-associated-types/issue-95305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ trait Foo {
fn foo(x: &impl Foo<Item<'_> = u32>) { }
//~^ ERROR `'_` cannot be used here [E0637]

// Ok: the anonymous lifetime is bound to the function.
fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
//~^ ERROR missing lifetime specifier

// Ok: the anonymous lifetime is bound to the function.
fn baz(x: &impl for<'a> Foo<Item<'a> = &u32>) { }

fn main() {}
16 changes: 2 additions & 14 deletions src/test/ui/generic-associated-types/issue-95305.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ error[E0637]: `'_` cannot be used here
LL | fn foo(x: &impl Foo<Item<'_> = u32>) { }
| ^^ `'_` is a reserved lifetime name

error[E0106]: missing lifetime specifier
--> $DIR/issue-95305.rs:14:41
|
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
| ^^ expected named lifetime parameter
|
help: consider using the `'a` lifetime
|
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'a u32>) { }
| ~~

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

Some errors have detailed explanations: E0106, E0637.
For more information about an error, try `rustc --explain E0106`.
For more information about this error, try `rustc --explain E0637`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-37884.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn next(&'a mut self) -> Option<Self::Item>
|
= note: expected fn pointer `fn(&mut RepeatMut<'a, T>) -> Option<_>`
found fn pointer `fn(&'a mut RepeatMut<'a, T>) -> Option<_>`
note: the anonymous lifetime #1 defined here...
note: the anonymous lifetime as defined here...
--> $DIR/issue-37884.rs:6:5
|
LL | fn next(&'a mut self) -> Option<Self::Item>
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
--> $DIR/impl-trait-captures.rs:11:5
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
| -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0)) T` captures the anonymous lifetime defined here
| -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_)) T` captures the anonymous lifetime defined here
LL | x
| ^
|
help: to declare that the `impl Trait` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0))` lifetime bound
help: to declare that the `impl Trait` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_))` lifetime bound
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0)) {
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_)) {
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to previous error

Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/suggestions/impl-trait-missing-lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
fn f(_: impl Iterator<Item = &'_ ()>) {} //~ ERROR missing lifetime specifier
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
fn f(_: impl Iterator<Item = &'_ ()>) {}

// But that lifetime does not participate in resolution.
fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
//~^ ERROR missing lifetime specifier

fn main() {}
13 changes: 7 additions & 6 deletions src/test/ui/suggestions/impl-trait-missing-lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime.rs:1:31
--> $DIR/impl-trait-missing-lifetime.rs:5:50
|
LL | fn f(_: impl Iterator<Item = &'_ ()>) {}
| ^^ expected named lifetime parameter
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
| ^^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
help: consider using the `'static` lifetime
|
LL | fn f<'a>(_: impl Iterator<Item = &'a ()>) {}
| ++++ ~~
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
| ~~~~~~~

error: aborting due to previous error

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ note: because this has an unmet lifetime requirement
|
LL | pub struct Wrapper<T: Trait>(T);
| ^^^^^ introduces a `'static` lifetime requirement
note: the anonymous lifetime #1 defined here...
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:5
note: the anonymous lifetime as defined here...
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:29
|
LL | pub fn repro(_: Wrapper<Ref>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^
note: ...does not necessarily outlive the static lifetime introduced by the compatible `impl`
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:1
|
Expand Down