From d7d4d7c8d5620b7b120304cc5eecf25b499e394a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 8 Aug 2018 18:10:19 -0400 Subject: add a `user_substs` table and store the annotations in there --- src/libsyntax/feature_gate.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4ed96d26906..28d27836034 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -865,6 +865,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), + ("rustc_dump_user_substs", Whitelisted, Gated(Stability::Unstable, + "rustc_attrs", + "the `#[rustc_error]` attribute \ + is just used for rustc unit tests \ + and will never be stable", + cfg_fn!(rustc_attrs))), ("rustc_if_this_changed", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "the `#[rustc_if_this_changed]` attribute \ -- cgit 1.4.1-3-g733a5 From ed73a3267a648cffb92f60e50aa75a6547d9955d Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 23 Aug 2018 17:37:41 -0400 Subject: address pnkfelix nits --- src/librustc/ty/context.rs | 2 +- src/librustc_mir/build/matches/test.rs | 10 +++++- src/libsyntax/feature_gate.rs | 2 +- .../hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr | 38 +++++++++++++++------- .../hr-subtype.free_x_vs_free_y.nll.stderr | 22 +++++++------ src/test/ui/nll/user-annotations/dump-fn-method.rs | 5 +++ .../ui/nll/user-annotations/dump-fn-method.stderr | 8 ++--- 7 files changed, 59 insertions(+), 28 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 388c2455eb3..424139e7527 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -371,7 +371,7 @@ pub struct TypeckTables<'tcx> { /// other items. node_substs: ItemLocalMap<&'tcx Substs<'tcx>>, - /// Stores the substitutions that the user explicit gave (if any) + /// Stores the substitutions that the user explicitly gave (if any) /// attached to `id`. These will not include any inferred /// values. The canonical form is used to capture things like `_` /// or other unspecified values. diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 2baefc47f8e..4a0b4b0c885 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -344,7 +344,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { func: Operand::Constant(box Constant { span: test.span, ty: mty, - user_ty: None, // FIXME + + // FIXME(#47184): This constant comes from user + // input (a constant in a pattern). Are + // there forms where users can add type + // annotations here? For example, an + // associated constant? Need to + // experiment. + user_ty: None, + literal: method, }), args: vec![val, expect], diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 28d27836034..e2a22167b7e 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -867,7 +867,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG cfg_fn!(rustc_attrs))), ("rustc_dump_user_substs", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", - "the `#[rustc_error]` attribute \ + "this attribute \ is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr index 1999df909ed..bb4e922fdc0 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr @@ -18,17 +18,33 @@ LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |__________________________________________________- in this macro invocation -error: compilation successful - --> $DIR/hr-subtype.rs:110:1 +error: unsatisfied lifetime constraints + --> $DIR/hr-subtype.rs:43:13 | -LL | / fn main() { -LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful -LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful -LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful -LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful -LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful -LL | | } - | |_^ +LL | fn subtype<'x,'y:'x,'z:'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t2>(None::<$t1>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + +error: unsatisfied lifetime constraints + --> $DIR/hr-subtype.rs:49:13 + | +LL | fn supertype<'x,'y:'x,'z:'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr index f76b26b5191..c33e6fbfde7 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr @@ -8,17 +8,19 @@ LL | / check! { free_x_vs_free_y: (fn(&'x u32), LL | | fn(&'y u32)) } | |__________________________________________- in this macro invocation -error: compilation successful - --> $DIR/hr-subtype.rs:110:1 +error: unsatisfied lifetime constraints + --> $DIR/hr-subtype.rs:49:13 | -LL | / fn main() { -LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful -LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful -LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful -LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful -LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful -LL | | } - | |_^ +LL | fn supertype<'x,'y:'x,'z:'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |__________________________________________- in this macro invocation error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/dump-fn-method.rs b/src/test/ui/nll/user-annotations/dump-fn-method.rs index fa14009da5a..7f726d13a33 100644 --- a/src/test/ui/nll/user-annotations/dump-fn-method.rs +++ b/src/test/ui/nll/user-annotations/dump-fn-method.rs @@ -16,6 +16,7 @@ #![feature(nll)] #![feature(rustc_attrs)] +// Note: we reference the names T and U in the comments below. trait Bazoom { fn method(&self, arg: T, arg2: U) { } } @@ -36,6 +37,8 @@ fn main() { x(22); // Here: we only want the `T` to be given, the rest should be variables. + // + // (`T` refers to the declaration of `Bazoom`) let x = <_ as Bazoom>::method::<_>; //~ ERROR [?0, u32, ?1] x(&22, 44, 66); @@ -45,6 +48,8 @@ fn main() { // Here: we want in particular that *only* the method `U` // annotation is given, the rest are variables. + // + // (`U` refers to the declaration of `Bazoom`) let y = 22_u32; y.method::(44, 66); //~ ERROR [?0, ?1, u32] diff --git a/src/test/ui/nll/user-annotations/dump-fn-method.stderr b/src/test/ui/nll/user-annotations/dump-fn-method.stderr index 8f3a0498e24..6531f87dd98 100644 --- a/src/test/ui/nll/user-annotations/dump-fn-method.stderr +++ b/src/test/ui/nll/user-annotations/dump-fn-method.stderr @@ -1,23 +1,23 @@ error: user substs: Canonical { variables: [], value: [u32] } - --> $DIR/dump-fn-method.rs:35:13 + --> $DIR/dump-fn-method.rs:36:13 | LL | let x = foo::; //~ ERROR [u32] | ^^^^^^^^^^ error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, u32, ?1] } - --> $DIR/dump-fn-method.rs:39:13 + --> $DIR/dump-fn-method.rs:42:13 | LL | let x = <_ as Bazoom>::method::<_>; //~ ERROR [?0, u32, ?1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: user substs: Canonical { variables: [], value: [u8, u16, u32] } - --> $DIR/dump-fn-method.rs:43:13 + --> $DIR/dump-fn-method.rs:46:13 | LL | let x = >::method::; //~ ERROR [u8, u16, u32] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, ?1, u32] } - --> $DIR/dump-fn-method.rs:49:5 + --> $DIR/dump-fn-method.rs:54:5 | LL | y.method::(44, 66); //~ ERROR [?0, ?1, u32] | ^^^^^^^^^^^^^^^^^^^^^^^ -- cgit 1.4.1-3-g733a5