Skip to content

Commit b5f9436

Browse files
committed
Auto merge of rust-lang#120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes rust-lang#119717 Fixes rust-lang#123664 Fixes rust-lang#124857 Fixes rust-lang#126148
2 parents 4116552 + 2fcef6e commit b5f9436

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

tests/ui/missing_const_for_fn/could_be_const.fixed

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ fn main() {}
104104

105105
struct D;
106106

107+
/* FIXME(effects)
107108
impl const Drop for D {
108109
fn drop(&mut self) {
109110
todo!();
110111
}
111112
}
113+
*/
112114

113115
// Lint this, since it can be dropped in const contexts
114116
// FIXME(effects)
115-
fn d(this: D) {}
117+
const fn d(this: D) {}
118+
//~^ ERROR: this could be a `const fn`
116119

117120
mod msrv {
118121
struct Foo(*const u8, &'static u8);

tests/ui/missing_const_for_fn/could_be_const.rs

+3
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ fn main() {}
104104

105105
struct D;
106106

107+
/* FIXME(effects)
107108
impl const Drop for D {
108109
fn drop(&mut self) {
109110
todo!();
110111
}
111112
}
113+
*/
112114

113115
// Lint this, since it can be dropped in const contexts
114116
// FIXME(effects)
115117
fn d(this: D) {}
118+
//~^ ERROR: this could be a `const fn`
116119

117120
mod msrv {
118121
struct Foo(*const u8, &'static u8);

tests/ui/missing_const_for_fn/could_be_const.stderr

+18-7
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ LL | const fn msrv_1_46() -> i32 {
157157
| +++++
158158

159159
error: this could be a `const fn`
160-
--> tests/ui/missing_const_for_fn/could_be_const.rs:122:9
160+
--> tests/ui/missing_const_for_fn/could_be_const.rs:117:1
161+
|
162+
LL | fn d(this: D) {}
163+
| ^^^^^^^^^^^^^^^^
164+
|
165+
help: make the function `const`
166+
|
167+
LL | const fn d(this: D) {}
168+
| +++++
169+
170+
error: this could be a `const fn`
171+
--> tests/ui/missing_const_for_fn/could_be_const.rs:125:9
161172
|
162173
LL | / fn deref_ptr_can_be_const(self) -> usize {
163174
LL | |
@@ -171,7 +182,7 @@ LL | const fn deref_ptr_can_be_const(self) -> usize {
171182
| +++++
172183

173184
error: this could be a `const fn`
174-
--> tests/ui/missing_const_for_fn/could_be_const.rs:127:9
185+
--> tests/ui/missing_const_for_fn/could_be_const.rs:130:9
175186
|
176187
LL | / fn deref_copied_val(self) -> usize {
177188
LL | |
@@ -185,7 +196,7 @@ LL | const fn deref_copied_val(self) -> usize {
185196
| +++++
186197

187198
error: this could be a `const fn`
188-
--> tests/ui/missing_const_for_fn/could_be_const.rs:138:5
199+
--> tests/ui/missing_const_for_fn/could_be_const.rs:141:5
189200
|
190201
LL | / fn union_access_can_be_const() {
191202
LL | |
@@ -200,7 +211,7 @@ LL | const fn union_access_can_be_const() {
200211
| +++++
201212

202213
error: this could be a `const fn`
203-
--> tests/ui/missing_const_for_fn/could_be_const.rs:152:9
214+
--> tests/ui/missing_const_for_fn/could_be_const.rs:155:9
204215
|
205216
LL | / pub fn new(strings: Vec<String>) -> Self {
206217
LL | | Self { strings }
@@ -213,7 +224,7 @@ LL | pub const fn new(strings: Vec<String>) -> Self {
213224
| +++++
214225

215226
error: this could be a `const fn`
216-
--> tests/ui/missing_const_for_fn/could_be_const.rs:157:9
227+
--> tests/ui/missing_const_for_fn/could_be_const.rs:160:9
217228
|
218229
LL | / pub fn empty() -> Self {
219230
LL | | Self { strings: Vec::new() }
@@ -226,7 +237,7 @@ LL | pub const fn empty() -> Self {
226237
| +++++
227238

228239
error: this could be a `const fn`
229-
--> tests/ui/missing_const_for_fn/could_be_const.rs:168:9
240+
--> tests/ui/missing_const_for_fn/could_be_const.rs:171:9
230241
|
231242
LL | / pub fn new(text: String) -> Self {
232243
LL | | let vec = Vec::new();
@@ -239,5 +250,5 @@ help: make the function `const`
239250
LL | pub const fn new(text: String) -> Self {
240251
| +++++
241252

242-
error: aborting due to 17 previous errors
253+
error: aborting due to 18 previous errors
243254

0 commit comments

Comments
 (0)