Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass attributes to hir::TyParam #49242

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_attrs(&mut self, attrs: &Vec<Attribute>) -> hir::HirVec<Attribute> {
fn lower_attrs(&mut self, attrs: &[Attribute]) -> hir::HirVec<Attribute> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause tp.attrs below is ThinVec.

attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>().into()
}

Expand Down Expand Up @@ -1019,6 +1019,7 @@ impl<'a> LoweringContext<'a> {
span,
pure_wrt_drop: false,
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
attrs: P::new(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what I should put here.

});

hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
Expand Down Expand Up @@ -1585,6 +1586,7 @@ impl<'a> LoweringContext<'a> {
.filter(|attr| attr.check_name("rustc_synthetic"))
.map(|_| hir::SyntheticTyParamKind::ImplTrait)
.nth(0),
attrs: self.lower_attrs(&tp.attrs),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ impl<'hir> Map<'hir> {
Some(NodeField(ref f)) => Some(&f.attrs[..]),
Some(NodeExpr(ref e)) => Some(&*e.attrs),
Some(NodeStmt(ref s)) => Some(s.node.attrs()),
Some(NodeTyParam(tp)) => Some(&tp.attrs[..]),
// unit/tuple structs take the attributes straight from
// the struct definition.
Some(NodeStructCtor(_)) => {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ pub struct TyParam {
pub span: Span,
pub pure_wrt_drop: bool,
pub synthetic: Option<SyntheticTyParamKind>,
pub attrs: HirVec<Attribute>,
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ impl_stable_hash_for!(struct hir::TyParam {
default,
span,
pure_wrt_drop,
synthetic
synthetic,
attrs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add trailing comma

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside macro which requires no trailing comma. Otherwise it fails to compile with:

error: no rules expected the token `}`
   --> librustc\ich\impls_hir.rs:208:1
    |
208 | });
    | ^

error: aborting due to previous error

error: Could not compile `rustc`.

You can look around this place in code - other calls to this macro don't have trailing commas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt notice it was in a macro.

});

impl_stable_hash_for!(enum hir::GenericParam {
Expand Down