Skip to content

Commit 9d6555c

Browse files
committed
review comments
1 parent 4cc9397 commit 9d6555c

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

src/librustc/hir/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,9 +2751,8 @@ pub enum Node<'hir> {
27512751
Crate,
27522752
}
27532753

2754-
impl<'hir> Node<'hir> {
2754+
impl Node<'_> {
27552755
pub fn ident(&self) -> Option<Ident> {
2756-
27572756
match self {
27582757
Node::TraitItem(TraitItem { ident, .. }) |
27592758
Node::ImplItem(ImplItem { ident, .. }) |

src/librustc_typeck/check/mod.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,25 +4611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
46114611
// First, store the "user substs" for later.
46124612
self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty);
46134613

4614-
// Add all the obligations that are required, substituting and
4615-
// normalized appropriately.
4616-
let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs);
4617-
4618-
for (i, mut obligation) in traits::predicates_for_generics(
4619-
traits::ObligationCause::new(
4620-
span,
4621-
self.body_id,
4622-
traits::ItemObligation(def_id),
4623-
),
4624-
self.param_env,
4625-
&bounds,
4626-
).into_iter().enumerate() {
4627-
// This makes the error point at the bound, but we want to point at the argument
4628-
if let Some(span) = spans.get(i) {
4629-
obligation.cause.code = traits::BindingObligation(def_id, *span);
4630-
}
4631-
self.register_predicate(obligation);
4632-
}
4614+
self.add_required_obligations(span, def_id, &substs);
46334615

46344616
// Substitute the values for the type parameters into the type of
46354617
// the referenced item.
@@ -4666,6 +4648,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
46664648
(ty_substituted, res)
46674649
}
46684650

4651+
/// Add all the obligations that are required, substituting and normalized appropriately.
4652+
fn add_required_obligations(&self, span: Span, def_id: DefId, substs: &SubstsRef<'tcx>) {
4653+
let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs);
4654+
4655+
for (i, mut obligation) in traits::predicates_for_generics(
4656+
traits::ObligationCause::new(
4657+
span,
4658+
self.body_id,
4659+
traits::ItemObligation(def_id),
4660+
),
4661+
self.param_env,
4662+
&bounds,
4663+
).into_iter().enumerate() {
4664+
// This makes the error point at the bound, but we want to point at the argument
4665+
if let Some(span) = spans.get(i) {
4666+
obligation.cause.code = traits::BindingObligation(def_id, *span);
4667+
}
4668+
self.register_predicate(obligation);
4669+
}
4670+
}
4671+
46694672
fn check_rustc_args_require_const(&self,
46704673
def_id: DefId,
46714674
hir_id: hir::HirId,

src/libsyntax/parse/parser/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'a> Parser<'a> {
197197
let (args, constraints) =
198198
self.parse_generic_args_with_leaning_angle_bracket_recovery(style, lo)?;
199199
self.expect_gt()?;
200-
let span = ident.span.to(self.prev_span);
200+
let span = lo.to(self.prev_span);
201201
AngleBracketedArgs { args, constraints, span }.into()
202202
} else {
203203
// `(T, U) -> R`

src/test/ui/parser/type-parameters-in-field-exprs.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error: field expressions may not have generic arguments
2-
--> $DIR/type-parameters-in-field-exprs.rs:13:7
2+
--> $DIR/type-parameters-in-field-exprs.rs:13:10
33
|
44
LL | f.x::<isize>;
5-
| ^^^^^^^^^^
5+
| ^^^^^^^
66

77
error: field expressions may not have generic arguments
8-
--> $DIR/type-parameters-in-field-exprs.rs:15:7
8+
--> $DIR/type-parameters-in-field-exprs.rs:15:10
99
|
1010
LL | f.x::<>;
11-
| ^^^^^
11+
| ^^
1212

1313
error: field expressions may not have generic arguments
1414
--> $DIR/type-parameters-in-field-exprs.rs:17:7
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error: generic arguments in macro path
2-
--> $DIR/macro-ty-params.rs:10:5
2+
--> $DIR/macro-ty-params.rs:10:10
33
|
44
LL | foo::<T>!();
5-
| ^^^^^^^^
5+
| ^^^
66

77
error: generic arguments in macro path
8-
--> $DIR/macro-ty-params.rs:11:5
8+
--> $DIR/macro-ty-params.rs:11:10
99
|
1010
LL | foo::<>!();
11-
| ^^^^^^^
11+
| ^^
1212

1313
error: unexpected generic arguments in path
1414
--> $DIR/macro-ty-params.rs:12:8
@@ -17,10 +17,10 @@ LL | m!(Default<>);
1717
| ^^^^^^^^^
1818

1919
error: generic arguments in macro path
20-
--> $DIR/macro-ty-params.rs:12:8
20+
--> $DIR/macro-ty-params.rs:12:15
2121
|
2222
LL | m!(Default<>);
23-
| ^^^^^^^^^
23+
| ^^
2424

2525
error: aborting due to 4 previous errors
2626

0 commit comments

Comments
 (0)