Skip to content

Commit b5d1aac

Browse files
committed
Add tests for program_clauses_for_env
1 parent a1931d3 commit b5d1aac

File tree

6 files changed

+103
-8
lines changed

6 files changed

+103
-8
lines changed

src/librustc_traits/lowering/environment.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,15 @@ crate fn environment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> En
231231
input_tys.extend(trait_ref.self_ty().walk());
232232
}
233233

234-
// In an fn, we assume that the arguments and all their constitutents are
234+
// In an fn, we assume that the arguments and all their constituents are
235235
// well-formed.
236236
if is_fn {
237-
let fn_sig = tcx.fn_sig(def_id)
238-
.no_late_bound_regions()
239-
.expect("only early bound regions");
237+
let fn_sig = tcx.fn_sig(def_id);
240238
input_tys.extend(
241-
fn_sig.inputs().iter().flat_map(|ty| ty.walk())
239+
// FIXME: `skip_binder` seems ok for now? In a real setting,
240+
// the late bound regions would next be instantiated with things
241+
// in the inference table.
242+
fn_sig.skip_binder().inputs().iter().flat_map(|ty| ty.walk())
242243
);
243244
}
244245

src/test/ui/chalkify/lower_env1.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
1818
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
1919
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
2020
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
21-
= note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo).
22-
= note: WellFormed(Self: Foo) :- Implemented(Self: Foo).
23-
= note: WellFormed(Self: std::marker::Sized) :- Implemented(Self: std::marker::Sized).
2421

2522
error: aborting due to 2 previous errors
2623

src/test/ui/chalkify/lower_env2.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(dead_code)]
13+
14+
trait Foo { }
15+
16+
#[rustc_dump_program_clauses] //~ ERROR program clause dump
17+
struct S<'a, T> where T: Foo {
18+
data: &'a T,
19+
}
20+
21+
#[rustc_dump_env_program_clauses] //~ ERROR program clause dump
22+
fn bar<'a, T: Foo>(x: S<T>) {
23+
}
24+
25+
fn main() {
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: program clause dump
2+
--> $DIR/lower_env2.rs:16:1
3+
|
4+
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: FromEnv(T: Foo) :- FromEnv(S<'a, T>).
8+
= note: FromEnv(T: std::marker::Sized) :- FromEnv(S<'a, T>).
9+
= note: TypeOutlives(T : 'a) :- FromEnv(S<'a, T>).
10+
= note: WellFormed(S<'a, T>) :- Implemented(T: std::marker::Sized), Implemented(T: Foo), TypeOutlives(T : 'a).
11+
12+
error: program clause dump
13+
--> $DIR/lower_env2.rs:21:1
14+
|
15+
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= note: FromEnv(T: Foo) :- FromEnv(S<'a, T>).
19+
= note: FromEnv(T: std::marker::Sized) :- FromEnv(S<'a, T>).
20+
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
21+
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
22+
= note: TypeOutlives(T : 'a) :- FromEnv(S<'a, T>).
23+
24+
error: aborting due to 2 previous errors
25+

src/test/ui/chalkify/lower_env3.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(dead_code)]
13+
14+
trait Foo {
15+
#[rustc_dump_env_program_clauses] //~ ERROR program clause dump
16+
fn foo(&self);
17+
}
18+
19+
impl<T> Foo for T where T: Clone {
20+
#[rustc_dump_env_program_clauses] //~ ERROR program clause dump
21+
fn foo(&self) {
22+
}
23+
}
24+
25+
fn main() {
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: program clause dump
2+
--> $DIR/lower_env3.rs:15:5
3+
|
4+
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
8+
9+
error: program clause dump
10+
--> $DIR/lower_env3.rs:20:5
11+
|
12+
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: FromEnv(Self: std::marker::Sized) :- FromEnv(Self: std::clone::Clone).
16+
= note: Implemented(Self: std::clone::Clone) :- FromEnv(Self: std::clone::Clone).
17+
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)