Skip to content

Commit 5591d34

Browse files
committed
auto merge of #5536 : sanxiyn/rust/doc-purity, r=brson
Fix #3804.
2 parents 7481524 + 585c572 commit 5591d34

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

src/librustdoc/tystr_pass.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
6969
match ctxt.ast_map.get(&fn_id) {
7070
ast_map::node_item(@ast::item {
7171
ident: ident,
72-
node: ast::item_fn(ref decl, _, ref tys, _), _
72+
node: ast::item_fn(ref decl, purity, ref tys, _), _
7373
}, _) |
7474
ast_map::node_foreign_item(@ast::foreign_item {
7575
ident: ident,
76-
node: ast::foreign_item_fn(ref decl, _, ref tys), _
76+
node: ast::foreign_item_fn(ref decl, purity, ref tys), _
7777
}, _, _, _) => {
78-
Some(pprust::fun_to_str(decl, ident, None, tys,
78+
Some(pprust::fun_to_str(decl, purity, ident, None, tys,
7979
extract::interner()))
8080
}
8181
_ => fail!(~"get_fn_sig: fn_id not bound to a fn item")
@@ -214,6 +214,7 @@ fn get_method_sig(
214214
ast::required(ty_m) => {
215215
Some(pprust::fun_to_str(
216216
&ty_m.decl,
217+
ty_m.purity,
217218
ty_m.ident,
218219
Some(ty_m.self_ty.node),
219220
&ty_m.generics,
@@ -223,6 +224,7 @@ fn get_method_sig(
223224
ast::provided(m) => {
224225
Some(pprust::fun_to_str(
225226
&m.decl,
227+
m.purity,
226228
m.ident,
227229
Some(m.self_ty.node),
228230
&m.generics,
@@ -243,6 +245,7 @@ fn get_method_sig(
243245
Some(method) => {
244246
Some(pprust::fun_to_str(
245247
&method.decl,
248+
method.purity,
246249
method.ident,
247250
Some(method.self_ty.node),
248251
&method.generics,

src/libsyntax/print/pprust.rs

+11-20
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ pub fn path_to_str(&&p: @ast::path, intr: @ident_interner) -> ~str {
180180
to_str(p, |a,b| print_path(a, b, false), intr)
181181
}
182182

183-
pub fn fun_to_str(decl: &ast::fn_decl, name: ast::ident,
183+
pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::ident,
184184
opt_self_ty: Option<ast::self_ty_>,
185185
generics: &ast::Generics, intr: @ident_interner) -> ~str {
186186
do io::with_str_writer |wr| {
187187
let s = rust_printer(wr, intr);
188-
print_fn(s, decl, None, name, generics, opt_self_ty, ast::inherited);
188+
print_fn(s, decl, purity, name, generics, opt_self_ty, ast::inherited);
189189
end(s); // Close the head box
190190
end(s); // Close the outer box
191191
eof(s.s);
@@ -441,7 +441,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
441441
print_outer_attributes(s, item.attrs);
442442
match item.node {
443443
ast::foreign_item_fn(ref decl, purity, ref generics) => {
444-
print_fn(s, decl, Some(purity), item.ident, generics, None,
444+
print_fn(s, decl, purity, item.ident, generics, None,
445445
ast::inherited);
446446
end(s); // end head-ibox
447447
word(s.s, ~";");
@@ -484,7 +484,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
484484
print_fn(
485485
s,
486486
decl,
487-
Some(purity),
487+
purity,
488488
item.ident,
489489
typarams,
490490
None,
@@ -815,7 +815,7 @@ pub fn print_method(s: @ps, meth: @ast::method) {
815815
hardbreak_if_not_bol(s);
816816
maybe_print_comment(s, meth.span.lo);
817817
print_outer_attributes(s, meth.attrs);
818-
print_fn(s, &meth.decl, Some(meth.purity),
818+
print_fn(s, &meth.decl, meth.purity,
819819
meth.ident, &meth.generics, Some(meth.self_ty.node),
820820
meth.vis);
821821
word(s.s, ~" ");
@@ -1663,7 +1663,7 @@ pub fn print_self_ty(s: @ps, self_ty: ast::self_ty_) -> bool {
16631663
16641664
pub fn print_fn(s: @ps,
16651665
decl: &ast::fn_decl,
1666-
purity: Option<ast::purity>,
1666+
purity: ast::purity,
16671667
name: ast::ident,
16681668
generics: &ast::Generics,
16691669
opt_self_ty: Option<ast::self_ty_>,
@@ -2158,16 +2158,6 @@ pub fn next_comment(s: @ps) -> Option<comments::cmnt> {
21582158
}
21592159
}
21602160

2161-
pub fn print_opt_purity(s: @ps, opt_purity: Option<ast::purity>) {
2162-
match opt_purity {
2163-
Some(ast::impure_fn) => { }
2164-
Some(purity) => {
2165-
word_nbsp(s, purity_to_str(purity));
2166-
}
2167-
None => {}
2168-
}
2169-
}
2170-
21712161
pub fn print_opt_abi(s: @ps, opt_abi: Option<ast::Abi>) {
21722162
match opt_abi {
21732163
Some(ast::RustAbi) => { word_nbsp(s, ~"extern"); }
@@ -2186,12 +2176,12 @@ pub fn print_opt_sigil(s: @ps, opt_sigil: Option<ast::Sigil>) {
21862176

21872177
pub fn print_fn_header_info(s: @ps,
21882178
opt_sty: Option<ast::self_ty_>,
2189-
opt_purity: Option<ast::purity>,
2179+
purity: ast::purity,
21902180
onceness: ast::Onceness,
21912181
opt_sigil: Option<ast::Sigil>,
21922182
vis: ast::visibility) {
21932183
word(s.s, visibility_qualified(vis, ~""));
2194-
print_opt_purity(s, opt_purity);
2184+
print_purity(s, purity);
21952185
print_onceness(s, onceness);
21962186
word(s.s, ~"fn");
21972187
print_opt_sigil(s, opt_sigil);
@@ -2264,8 +2254,9 @@ pub mod test {
22642254
cf: ast::return_val
22652255
};
22662256
let generics = ast_util::empty_generics();
2267-
assert_eq!(&fun_to_str(&decl, abba_ident, None, &generics, mock_interner),
2268-
&~"fn abba()");
2257+
assert_eq!(&fun_to_str(&decl, ast::impure_fn, abba_ident,
2258+
None, &generics, mock_interner),
2259+
&~"fn abba()");
22692260
}
22702261
22712262
#[test]

0 commit comments

Comments
 (0)