]> git.lizzy.rs Git - rust.git/blob - src/librustdoc/test.rs
Remove rustc_llvm dependency from rustc_metadata
[rust.git] / src / librustdoc / test.rs
1 // Copyright 2013-2014 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 use std::collections::HashMap;
12 use std::env;
13 use std::ffi::OsString;
14 use std::io::prelude::*;
15 use std::io;
16 use std::path::{Path, PathBuf};
17 use std::panic::{self, AssertUnwindSafe};
18 use std::process::Command;
19 use std::rc::Rc;
20 use std::str;
21 use std::sync::{Arc, Mutex};
22
23 use testing;
24 use rustc_lint;
25 use rustc::dep_graph::DepGraph;
26 use rustc::hir;
27 use rustc::hir::intravisit;
28 use rustc::session::{self, config};
29 use rustc::session::config::{OutputType, OutputTypes, Externs};
30 use rustc::session::search_paths::{SearchPaths, PathKind};
31 use rustc_back::dynamic_lib::DynamicLibrary;
32 use rustc_back::tempdir::TempDir;
33 use rustc_driver::{self, driver, Compilation};
34 use rustc_driver::driver::phase_2_configure_and_expand;
35 use rustc_metadata::cstore::CStore;
36 use rustc_resolve::MakeGlobMap;
37 use rustc_trans;
38 use rustc_trans::back::link;
39 use syntax::ast;
40 use syntax::codemap::CodeMap;
41 use syntax::feature_gate::UnstableFeatures;
42 use syntax_pos::{BytePos, DUMMY_SP, Pos, Span};
43 use errors;
44 use errors::emitter::ColorConfig;
45
46 use clean::Attributes;
47 use html::markdown::{self, RenderType};
48
49 #[derive(Clone, Default)]
50 pub struct TestOptions {
51     pub no_crate_inject: bool,
52     pub attrs: Vec<String>,
53 }
54
55 pub fn run(input: &str,
56            cfgs: Vec<String>,
57            libs: SearchPaths,
58            externs: Externs,
59            mut test_args: Vec<String>,
60            crate_name: Option<String>,
61            maybe_sysroot: Option<PathBuf>,
62            render_type: RenderType,
63            display_warnings: bool)
64            -> isize {
65     let input_path = PathBuf::from(input);
66     let input = config::Input::File(input_path.clone());
67
68     let sessopts = config::Options {
69         maybe_sysroot: maybe_sysroot.clone().or_else(
70             || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
71         search_paths: libs.clone(),
72         crate_types: vec![config::CrateTypeDylib],
73         externs: externs.clone(),
74         unstable_features: UnstableFeatures::from_environment(),
75         actually_rustdoc: true,
76         ..config::basic_options().clone()
77     };
78
79     let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping()));
80     let handler =
81         errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone()));
82
83     let dep_graph = DepGraph::new(false);
84     let _ignore = dep_graph.in_ignore();
85     let cstore = Rc::new(CStore::new(&dep_graph, box rustc_trans::LlvmMetadataLoader));
86     let mut sess = session::build_session_(
87         sessopts, &dep_graph, Some(input_path.clone()), handler, codemap.clone(), cstore.clone(),
88     );
89     rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
90     sess.parse_sess.config =
91         config::build_configuration(&sess, config::parse_cfgspecs(cfgs.clone()));
92
93     let krate = panictry!(driver::phase_1_parse_input(&sess, &input));
94     let driver::ExpansionResult { defs, mut hir_forest, .. } = {
95         phase_2_configure_and_expand(
96             &sess, &cstore, krate, None, "rustdoc-test", None, MakeGlobMap::No, |_| Ok(())
97         ).expect("phase_2_configure_and_expand aborted in rustdoc!")
98     };
99
100     let crate_name = crate_name.unwrap_or_else(|| {
101         link::find_crate_name(None, &hir_forest.krate().attrs, &input)
102     });
103     let opts = scrape_test_config(hir_forest.krate());
104     let mut collector = Collector::new(crate_name,
105                                        cfgs,
106                                        libs,
107                                        externs,
108                                        false,
109                                        opts,
110                                        maybe_sysroot,
111                                        Some(codemap),
112                                        None,
113                                        render_type);
114
115     {
116         let dep_graph = DepGraph::new(false);
117         let _ignore = dep_graph.in_ignore();
118         let map = hir::map::map_crate(&mut hir_forest, defs);
119         let krate = map.krate();
120         let mut hir_collector = HirCollector {
121             collector: &mut collector,
122             map: &map
123         };
124         hir_collector.visit_testable("".to_string(), &krate.attrs, |this| {
125             intravisit::walk_crate(this, krate);
126         });
127     }
128
129     test_args.insert(0, "rustdoctest".to_string());
130
131     testing::test_main(&test_args,
132                        collector.tests.into_iter().collect(),
133                        testing::Options::new().display_output(display_warnings));
134     0
135 }
136
137 // Look for #![doc(test(no_crate_inject))], used by crates in the std facade
138 fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
139     use syntax::print::pprust;
140
141     let mut opts = TestOptions {
142         no_crate_inject: false,
143         attrs: Vec::new(),
144     };
145
146     let test_attrs: Vec<_> = krate.attrs.iter()
147         .filter(|a| a.check_name("doc"))
148         .flat_map(|a| a.meta_item_list().unwrap_or_else(Vec::new))
149         .filter(|a| a.check_name("test"))
150         .collect();
151     let attrs = test_attrs.iter().flat_map(|a| a.meta_item_list().unwrap_or(&[]));
152
153     for attr in attrs {
154         if attr.check_name("no_crate_inject") {
155             opts.no_crate_inject = true;
156         }
157         if attr.check_name("attr") {
158             if let Some(l) = attr.meta_item_list() {
159                 for item in l {
160                     opts.attrs.push(pprust::meta_list_item_to_string(item));
161                 }
162             }
163         }
164     }
165
166     opts
167 }
168
169 fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
170            externs: Externs,
171            should_panic: bool, no_run: bool, as_test_harness: bool,
172            compile_fail: bool, mut error_codes: Vec<String>, opts: &TestOptions,
173            maybe_sysroot: Option<PathBuf>) {
174     // the test harness wants its own `main` & top level functions, so
175     // never wrap the test in `fn main() { ... }`
176     let test = maketest(test, Some(cratename), as_test_harness, opts);
177     let input = config::Input::Str {
178         name: driver::anon_src(),
179         input: test.to_owned(),
180     };
181     let outputs = OutputTypes::new(&[(OutputType::Exe, None)]);
182
183     let sessopts = config::Options {
184         maybe_sysroot: maybe_sysroot.or_else(
185             || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
186         search_paths: libs,
187         crate_types: vec![config::CrateTypeExecutable],
188         output_types: outputs,
189         externs: externs,
190         cg: config::CodegenOptions {
191             prefer_dynamic: true,
192             .. config::basic_codegen_options()
193         },
194         test: as_test_harness,
195         unstable_features: UnstableFeatures::from_environment(),
196         ..config::basic_options().clone()
197     };
198
199     // Shuffle around a few input and output handles here. We're going to pass
200     // an explicit handle into rustc to collect output messages, but we also
201     // want to catch the error message that rustc prints when it fails.
202     //
203     // We take our thread-local stderr (likely set by the test runner) and replace
204     // it with a sink that is also passed to rustc itself. When this function
205     // returns the output of the sink is copied onto the output of our own thread.
206     //
207     // The basic idea is to not use a default Handler for rustc, and then also
208     // not print things by default to the actual stderr.
209     struct Sink(Arc<Mutex<Vec<u8>>>);
210     impl Write for Sink {
211         fn write(&mut self, data: &[u8]) -> io::Result<usize> {
212             Write::write(&mut *self.0.lock().unwrap(), data)
213         }
214         fn flush(&mut self) -> io::Result<()> { Ok(()) }
215     }
216     struct Bomb(Arc<Mutex<Vec<u8>>>, Box<Write+Send>);
217     impl Drop for Bomb {
218         fn drop(&mut self) {
219             let _ = self.1.write_all(&self.0.lock().unwrap());
220         }
221     }
222     let data = Arc::new(Mutex::new(Vec::new()));
223     let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping()));
224     let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
225                                                       Some(codemap.clone()));
226     let old = io::set_panic(Some(box Sink(data.clone())));
227     let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout()));
228
229     // Compile the code
230     let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
231
232     let dep_graph = DepGraph::new(false);
233     let cstore = Rc::new(CStore::new(&dep_graph, box rustc_trans::LlvmMetadataLoader));
234     let mut sess = session::build_session_(
235         sessopts, &dep_graph, None, diagnostic_handler, codemap, cstore.clone(),
236     );
237     rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
238
239     let outdir = Mutex::new(TempDir::new("rustdoctest").ok().expect("rustdoc needs a tempdir"));
240     let libdir = sess.target_filesearch(PathKind::All).get_lib_path();
241     let mut control = driver::CompileController::basic();
242     sess.parse_sess.config =
243         config::build_configuration(&sess, config::parse_cfgspecs(cfgs.clone()));
244     let out = Some(outdir.lock().unwrap().path().to_path_buf());
245
246     if no_run {
247         control.after_analysis.stop = Compilation::Stop;
248     }
249
250     let res = panic::catch_unwind(AssertUnwindSafe(|| {
251         driver::compile_input(&sess, &cstore, &input, &out, &None, None, &control)
252     }));
253
254     match res {
255         Ok(r) => {
256             match r {
257                 Err(count) => {
258                     if count > 0 && !compile_fail {
259                         sess.fatal("aborting due to previous error(s)")
260                     } else if count == 0 && compile_fail {
261                         panic!("test compiled while it wasn't supposed to")
262                     }
263                     if count > 0 && error_codes.len() > 0 {
264                         let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap();
265                         error_codes.retain(|err| !out.contains(err));
266                     }
267                 }
268                 Ok(()) if compile_fail => {
269                     panic!("test compiled while it wasn't supposed to")
270                 }
271                 _ => {}
272             }
273         }
274         Err(_) => {
275             if !compile_fail {
276                 panic!("couldn't compile the test");
277             }
278             if error_codes.len() > 0 {
279                 let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap();
280                 error_codes.retain(|err| !out.contains(err));
281             }
282         }
283     }
284
285     if error_codes.len() > 0 {
286         panic!("Some expected error codes were not found: {:?}", error_codes);
287     }
288
289     if no_run { return }
290
291     // Run the code!
292     //
293     // We're careful to prepend the *target* dylib search path to the child's
294     // environment to ensure that the target loads the right libraries at
295     // runtime. It would be a sad day if the *host* libraries were loaded as a
296     // mistake.
297     let mut cmd = Command::new(&outdir.lock().unwrap().path().join("rust_out"));
298     let var = DynamicLibrary::envvar();
299     let newpath = {
300         let path = env::var_os(var).unwrap_or(OsString::new());
301         let mut path = env::split_paths(&path).collect::<Vec<_>>();
302         path.insert(0, libdir.clone());
303         env::join_paths(path).unwrap()
304     };
305     cmd.env(var, &newpath);
306
307     match cmd.output() {
308         Err(e) => panic!("couldn't run the test: {}{}", e,
309                         if e.kind() == io::ErrorKind::PermissionDenied {
310                             " - maybe your tempdir is mounted with noexec?"
311                         } else { "" }),
312         Ok(out) => {
313             if should_panic && out.status.success() {
314                 panic!("test executable succeeded when it should have failed");
315             } else if !should_panic && !out.status.success() {
316                 panic!("test executable failed:\n{}\n{}\n",
317                        str::from_utf8(&out.stdout).unwrap_or(""),
318                        str::from_utf8(&out.stderr).unwrap_or(""));
319             }
320         }
321     }
322 }
323
324 pub fn maketest(s: &str, cratename: Option<&str>, dont_insert_main: bool,
325                 opts: &TestOptions) -> String {
326     let (crate_attrs, everything_else) = partition_source(s);
327
328     let mut prog = String::new();
329
330     // First push any outer attributes from the example, assuming they
331     // are intended to be crate attributes.
332     prog.push_str(&crate_attrs);
333
334     // Next, any attributes for other aspects such as lints.
335     for attr in &opts.attrs {
336         prog.push_str(&format!("#![{}]\n", attr));
337     }
338
339     // Don't inject `extern crate std` because it's already injected by the
340     // compiler.
341     if !s.contains("extern crate") && !opts.no_crate_inject && cratename != Some("std") {
342         if let Some(cratename) = cratename {
343             if s.contains(cratename) {
344                 prog.push_str(&format!("extern crate {};\n", cratename));
345             }
346         }
347     }
348     if dont_insert_main || s.contains("fn main") {
349         prog.push_str(&everything_else);
350     } else {
351         prog.push_str("fn main() {\n");
352         prog.push_str(&everything_else);
353         prog = prog.trim().into();
354         prog.push_str("\n}");
355     }
356
357     info!("final test program: {}", prog);
358
359     prog
360 }
361
362 // FIXME(aburka): use a real parser to deal with multiline attributes
363 fn partition_source(s: &str) -> (String, String) {
364     use std_unicode::str::UnicodeStr;
365
366     let mut after_header = false;
367     let mut before = String::new();
368     let mut after = String::new();
369
370     for line in s.lines() {
371         let trimline = line.trim();
372         let header = trimline.is_whitespace() ||
373             trimline.starts_with("#![");
374         if !header || after_header {
375             after_header = true;
376             after.push_str(line);
377             after.push_str("\n");
378         } else {
379             before.push_str(line);
380             before.push_str("\n");
381         }
382     }
383
384     (before, after)
385 }
386
387 pub struct Collector {
388     pub tests: Vec<testing::TestDescAndFn>,
389     // to be removed when hoedown will be definitely gone
390     pub old_tests: HashMap<String, Vec<String>>,
391     names: Vec<String>,
392     cfgs: Vec<String>,
393     libs: SearchPaths,
394     externs: Externs,
395     cnt: usize,
396     use_headers: bool,
397     current_header: Option<String>,
398     cratename: String,
399     opts: TestOptions,
400     maybe_sysroot: Option<PathBuf>,
401     position: Span,
402     codemap: Option<Rc<CodeMap>>,
403     filename: Option<String>,
404     // to be removed when hoedown will be removed as well
405     pub render_type: RenderType,
406 }
407
408 impl Collector {
409     pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
410                use_headers: bool, opts: TestOptions, maybe_sysroot: Option<PathBuf>,
411                codemap: Option<Rc<CodeMap>>, filename: Option<String>,
412                render_type: RenderType) -> Collector {
413         Collector {
414             tests: Vec::new(),
415             old_tests: HashMap::new(),
416             names: Vec::new(),
417             cfgs: cfgs,
418             libs: libs,
419             externs: externs,
420             cnt: 0,
421             use_headers: use_headers,
422             current_header: None,
423             cratename: cratename,
424             opts: opts,
425             maybe_sysroot: maybe_sysroot,
426             position: DUMMY_SP,
427             codemap: codemap,
428             filename: filename,
429             render_type: render_type,
430         }
431     }
432
433     fn generate_name(&self, line: usize, filename: &str) -> String {
434         if self.use_headers {
435             if let Some(ref header) = self.current_header {
436                 format!("{} - {} (line {})", filename, header, line)
437             } else {
438                 format!("{} - (line {})", filename, line)
439             }
440         } else {
441             format!("{} - {} (line {})", filename, self.names.join("::"), line)
442         }
443     }
444
445     // to be removed once hoedown is gone
446     fn generate_name_beginning(&self, filename: &str) -> String {
447         if self.use_headers {
448             if let Some(ref header) = self.current_header {
449                 format!("{} - {} (line", filename, header)
450             } else {
451                 format!("{} - (line", filename)
452             }
453         } else {
454             format!("{} - {} (line", filename, self.names.join("::"))
455         }
456     }
457
458     pub fn add_old_test(&mut self, test: String, filename: String) {
459         let name_beg = self.generate_name_beginning(&filename);
460         let entry = self.old_tests.entry(name_beg)
461                                   .or_insert(Vec::new());
462         entry.push(test.trim().to_owned());
463     }
464
465     pub fn add_test(&mut self, test: String,
466                     should_panic: bool, no_run: bool, should_ignore: bool,
467                     as_test_harness: bool, compile_fail: bool, error_codes: Vec<String>,
468                     line: usize, filename: String) {
469         let name = self.generate_name(line, &filename);
470         // to be removed when hoedown is removed
471         if self.render_type == RenderType::Pulldown {
472             let name_beg = self.generate_name_beginning(&filename);
473             let mut found = false;
474             let test = test.trim().to_owned();
475             if let Some(entry) = self.old_tests.get_mut(&name_beg) {
476                 found = entry.remove_item(&test).is_some();
477             }
478             if !found {
479                 let _ = writeln!(&mut io::stderr(),
480                                  "WARNING: {} Code block is not currently run as a test, but will \
481                                   in future versions of rustdoc. Please ensure this code block is \
482                                   a runnable test, or use the `ignore` directive.",
483                                  name);
484                 return
485             }
486         }
487         let cfgs = self.cfgs.clone();
488         let libs = self.libs.clone();
489         let externs = self.externs.clone();
490         let cratename = self.cratename.to_string();
491         let opts = self.opts.clone();
492         let maybe_sysroot = self.maybe_sysroot.clone();
493         debug!("Creating test {}: {}", name, test);
494         self.tests.push(testing::TestDescAndFn {
495             desc: testing::TestDesc {
496                 name: testing::DynTestName(name),
497                 ignore: should_ignore,
498                 // compiler failures are test failures
499                 should_panic: testing::ShouldPanic::No,
500             },
501             testfn: testing::DynTestFn(box move |()| {
502                 let panic = io::set_panic(None);
503                 let print = io::set_print(None);
504                 match {
505                     rustc_driver::in_rustc_thread(move || {
506                         io::set_panic(panic);
507                         io::set_print(print);
508                         runtest(&test,
509                                 &cratename,
510                                 cfgs,
511                                 libs,
512                                 externs,
513                                 should_panic,
514                                 no_run,
515                                 as_test_harness,
516                                 compile_fail,
517                                 error_codes,
518                                 &opts,
519                                 maybe_sysroot)
520                     })
521                 } {
522                     Ok(()) => (),
523                     Err(err) => panic::resume_unwind(err),
524                 }
525             }),
526         });
527     }
528
529     pub fn get_line(&self) -> usize {
530         if let Some(ref codemap) = self.codemap {
531             let line = self.position.lo.to_usize();
532             let line = codemap.lookup_char_pos(BytePos(line as u32)).line;
533             if line > 0 { line - 1 } else { line }
534         } else {
535             0
536         }
537     }
538
539     pub fn set_position(&mut self, position: Span) {
540         self.position = position;
541     }
542
543     pub fn get_filename(&self) -> String {
544         if let Some(ref codemap) = self.codemap {
545             let filename = codemap.span_to_filename(self.position);
546             if let Ok(cur_dir) = env::current_dir() {
547                 if let Ok(path) = Path::new(&filename).strip_prefix(&cur_dir) {
548                     if let Some(path) = path.to_str() {
549                         return path.to_owned();
550                     }
551                 }
552             }
553             filename
554         } else if let Some(ref filename) = self.filename {
555             filename.clone()
556         } else {
557             "<input>".to_owned()
558         }
559     }
560
561     pub fn register_header(&mut self, name: &str, level: u32) {
562         if self.use_headers && level == 1 {
563             // we use these headings as test names, so it's good if
564             // they're valid identifiers.
565             let name = name.chars().enumerate().map(|(i, c)| {
566                     if (i == 0 && c.is_xid_start()) ||
567                         (i != 0 && c.is_xid_continue()) {
568                         c
569                     } else {
570                         '_'
571                     }
572                 }).collect::<String>();
573
574             // new header => reset count.
575             self.cnt = 0;
576             self.current_header = Some(name);
577         }
578     }
579 }
580
581 struct HirCollector<'a, 'hir: 'a> {
582     collector: &'a mut Collector,
583     map: &'a hir::map::Map<'hir>
584 }
585
586 impl<'a, 'hir> HirCollector<'a, 'hir> {
587     fn visit_testable<F: FnOnce(&mut Self)>(&mut self,
588                                             name: String,
589                                             attrs: &[ast::Attribute],
590                                             nested: F) {
591         let has_name = !name.is_empty();
592         if has_name {
593             self.collector.names.push(name);
594         }
595
596         let mut attrs = Attributes::from_ast(attrs);
597         attrs.collapse_doc_comments();
598         attrs.unindent_doc_comments();
599         if let Some(doc) = attrs.doc_value() {
600             self.collector.cnt = 0;
601             if self.collector.render_type == RenderType::Pulldown {
602                 markdown::old_find_testable_code(doc, self.collector,
603                                                  attrs.span.unwrap_or(DUMMY_SP));
604                 markdown::find_testable_code(doc, self.collector,
605                                              attrs.span.unwrap_or(DUMMY_SP));
606             } else {
607                 markdown::old_find_testable_code(doc, self.collector,
608                                                  attrs.span.unwrap_or(DUMMY_SP));
609             }
610         }
611
612         nested(self);
613
614         if has_name {
615             self.collector.names.pop();
616         }
617     }
618 }
619
620 impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
621     fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'hir> {
622         intravisit::NestedVisitorMap::All(&self.map)
623     }
624
625     fn visit_item(&mut self, item: &'hir hir::Item) {
626         let name = if let hir::ItemImpl(.., ref ty, _) = item.node {
627             self.map.node_to_pretty_string(ty.id)
628         } else {
629             item.name.to_string()
630         };
631
632         self.visit_testable(name, &item.attrs, |this| {
633             intravisit::walk_item(this, item);
634         });
635     }
636
637     fn visit_trait_item(&mut self, item: &'hir hir::TraitItem) {
638         self.visit_testable(item.name.to_string(), &item.attrs, |this| {
639             intravisit::walk_trait_item(this, item);
640         });
641     }
642
643     fn visit_impl_item(&mut self, item: &'hir hir::ImplItem) {
644         self.visit_testable(item.name.to_string(), &item.attrs, |this| {
645             intravisit::walk_impl_item(this, item);
646         });
647     }
648
649     fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem) {
650         self.visit_testable(item.name.to_string(), &item.attrs, |this| {
651             intravisit::walk_foreign_item(this, item);
652         });
653     }
654
655     fn visit_variant(&mut self,
656                      v: &'hir hir::Variant,
657                      g: &'hir hir::Generics,
658                      item_id: ast::NodeId) {
659         self.visit_testable(v.node.name.to_string(), &v.node.attrs, |this| {
660             intravisit::walk_variant(this, v, g, item_id);
661         });
662     }
663
664     fn visit_struct_field(&mut self, f: &'hir hir::StructField) {
665         self.visit_testable(f.name.to_string(), &f.attrs, |this| {
666             intravisit::walk_struct_field(this, f);
667         });
668     }
669
670     fn visit_macro_def(&mut self, macro_def: &'hir hir::MacroDef) {
671         self.visit_testable(macro_def.name.to_string(), &macro_def.attrs, |_| ());
672     }
673 }