Skip to content

Commit 74e7b5b

Browse files
committed
temporarily disable effects on specialization tests
1 parent 3637b15 commit 74e7b5b

File tree

8 files changed

+43
-50
lines changed

8 files changed

+43
-50
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ pub(super) fn check_specialization_validity<'tcx>(
879879
let result = opt_result.unwrap_or(Ok(()));
880880

881881
if let Err(parent_impl) = result {
882+
// FIXME(effects) the associated type from effects could be specialized
882883
if !tcx.is_impl_trait_in_trait(impl_item) && !tcx.is_effects_desugared_assoc_ty(impl_item) {
883884
report_forbidden_specialization(tcx, impl_item, parent_impl);
884885
} else {

compiler/rustc_ty_utils/src/assoc.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A
179179
/// If `def_id` is an impl, then synthesize the associated type according
180180
/// to the constness of the impl.
181181
fn associated_type_for_effects(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<DefId> {
182+
// don't synthesize the associated type even if the user has written `const_trait`
183+
// if the effects feature is disabled.
184+
if !tcx.features().effects {
185+
return None;
186+
}
182187
match tcx.def_kind(def_id) {
183188
DefKind::Trait => {
184189
let trait_def_id = def_id;
@@ -309,7 +314,7 @@ fn associated_type_for_effects(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<De
309314
}
310315
});
311316

312-
impl_assoc_ty.explicit_item_bounds(ty::EarlyBinder::bind(&[]));
317+
// impl_assoc_ty.explicit_item_bounds(ty::EarlyBinder::bind(&[]));
313318
impl_assoc_ty.explicit_item_super_predicates(ty::EarlyBinder::bind(&[]));
314319

315320
// There are no inferred outlives for the synthesized associated type.

tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
1+
#![feature(const_trait_impl)]
2+
// FIXME(effects) add effects
23
//@ edition: 2021
34

45
#[const_trait]
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
11
error: const trait bounds are not allowed in trait object types
2-
--> $DIR/const-trait-bounds-trait-objects.rs:8:17
2+
--> $DIR/const-trait-bounds-trait-objects.rs:9:17
33
|
44
LL | let _: &dyn const Trait;
55
| ^^^^^^^^^^^
66

77
error: `~const` is not allowed here
8-
--> $DIR/const-trait-bounds-trait-objects.rs:9:17
8+
--> $DIR/const-trait-bounds-trait-objects.rs:10:17
99
|
1010
LL | let _: &dyn ~const Trait;
1111
| ^^^^^^
1212
|
1313
= note: trait objects cannot have `~const` trait bounds
1414

1515
error: const trait bounds are not allowed in trait object types
16-
--> $DIR/const-trait-bounds-trait-objects.rs:14:25
16+
--> $DIR/const-trait-bounds-trait-objects.rs:15:25
1717
|
1818
LL | const fn handle(_: &dyn const NonConst) {}
1919
| ^^^^^^^^^^^^^^
2020

2121
error: `~const` is not allowed here
22-
--> $DIR/const-trait-bounds-trait-objects.rs:16:23
22+
--> $DIR/const-trait-bounds-trait-objects.rs:17:23
2323
|
2424
LL | const fn take(_: &dyn ~const NonConst) {}
2525
| ^^^^^^
2626
|
2727
= note: trait objects cannot have `~const` trait bounds
2828

29-
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
30-
--> $DIR/const-trait-bounds-trait-objects.rs:1:30
31-
|
32-
LL | #![feature(const_trait_impl, effects)]
33-
| ^^^^^^^
34-
|
35-
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
36-
= note: `#[warn(incomplete_features)]` on by default
37-
38-
error: aborting due to 4 previous errors; 1 warning emitted
29+
error: aborting due to 4 previous errors
3930

tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(const_trait_impl, effects, min_specialization, rustc_attrs)]
1+
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
22
//@ known-bug: #110395
33
#[rustc_specialization_trait]
44
#[const_trait]
Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/specializing-constness-2.rs:1:30
1+
error[E0049]: method `a` has 1 const parameter but its trait declaration has 0 const parameters
2+
--> $DIR/specializing-constness-2.rs:9:1
33
|
4-
LL | #![feature(const_trait_impl, effects, min_specialization, rustc_attrs)]
5-
| ^^^^^^^
6-
|
7-
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
4+
LL | #[const_trait]
5+
| ^^^^^^^^^^^^^^ found 1 const parameter
6+
LL | pub trait A {
7+
LL | fn a() -> u32;
8+
| - expected 0 const parameters
99

10-
error[E0119]: conflicting implementations of trait `A`
11-
--> $DIR/specializing-constness-2.rs:20:1
10+
error[E0049]: method `a` has 1 const parameter but its trait declaration has 0 const parameters
11+
--> $DIR/specializing-constness-2.rs:9:1
12+
|
13+
LL | #[const_trait]
14+
| ^^^^^^^^^^^^^^ found 1 const parameter
15+
LL | pub trait A {
16+
LL | fn a() -> u32;
17+
| - expected 0 const parameters
1218
|
13-
LL | impl<T: Default> A for T {
14-
| ------------------------ first implementation here
15-
...
16-
LL | impl<T: Default + ~const Sup> const A for T {
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
19+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1820

19-
error[E0308]: mismatched types
21+
error[E0015]: cannot call non-const fn `<T as A>::a` in constant functions
2022
--> $DIR/specializing-constness-2.rs:27:5
2123
|
2224
LL | <T as A>::a();
23-
| ^^^^^^^^^^^^^ expected `host`, found `true`
25+
| ^^^^^^^^^^^^^
26+
|
27+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
28+
help: add `#![feature(effects)]` to the crate attributes to enable
29+
|
30+
LL + #![feature(effects)]
2431
|
25-
= note: expected constant `host`
26-
found constant `true`
2732

28-
error: aborting due to 2 previous errors; 1 warning emitted
33+
error: aborting due to 3 previous errors
2934

30-
Some errors have detailed explanations: E0119, E0308.
31-
For more information about an error, try `rustc --explain E0119`.
35+
Some errors have detailed explanations: E0015, E0049.
36+
For more information about an error, try `rustc --explain E0015`.

tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//@ run-pass
22
//@ compile-flags: -Znext-solver
33

4-
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
4+
#![feature(const_trait_impl, effects)]
5+
#![allow(incomplete_features)]
56

67
#[const_trait]
78
trait Bar {

tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)